Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename build_text_field to build_field #66

Merged
merged 1 commit into from
Jan 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/inputs/multi_value_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def input(wrapper_options)
collection.each_with_index do |value, index|
markup << <<-HTML
<li class="field-wrapper">
#{build_text_field(value, index)}
#{build_field(value, index)}
</li>
HTML
end
Expand All @@ -28,7 +28,7 @@ def input(wrapper_options)
# Although the 'index' parameter is not used in this implementation it is useful in an
# an overridden version of this method, especially when the field is a complex object and
# the override defines nested fields.
def build_text_field(value, index)
def build_field(value, index)
options = input_html_options.dup

options[:value] = value
Expand Down
8 changes: 4 additions & 4 deletions spec/inputs/multi_value_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ def [](val)
end
end

describe '#build_text_field' do
describe '#build_field' do
let(:foo) { Foo.new }
before { foo.bar = ['bar1', 'bar2'] }
let(:builder) { double("builder", object: foo, object_name: 'foo') }

subject { MultiValueInput.new(builder, :bar, nil, :multi_value, {}) }

it 'renders multi-value' do
expect(subject).to receive(:build_text_field).with('bar1', 0)
expect(subject).to receive(:build_text_field).with('bar2', 1)
expect(subject).to receive(:build_text_field).with('', 2)
expect(subject).to receive(:build_field).with('bar1', 0)
expect(subject).to receive(:build_field).with('bar2', 1)
expect(subject).to receive(:build_field).with('', 2)
subject.input({})
end
end
Expand Down