Skip to content

Commit

Permalink
Update method name
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyoseni committed Jul 29, 2019
1 parent a4e2658 commit 4783aab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/helpers/mushrooms_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def mushroom_attributes_values(key)
MUSHROOM_ATTRIBUTES[key].values
end

def filter_selected?(key, value)
def selected_filter(key, value)
if params[:filter].blank?
''
elsif params[:filter][key]&.include?(value)
Expand Down
2 changes: 1 addition & 1 deletion app/views/mushrooms/_filter_option.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<select name='filter[<%= field.to_s %>][]' id=<%= field.to_s %> multiple>
<option value='' class='placeholder' disabled><%= placeholder %></option>
<% mushroom_attributes_values(field).each do |value| %>
<option <%= filter_selected?(field, value) %> value=<%= value %>>
<option <%= selected_filter(field, value) %> value=<%= value %>>
<%= value %>
</option>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions spec/helpers/mushrooms_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@
end
end

describe '#filter_selected?' do
describe '#selected_filter' do
context 'when filter params is present' do
it "returns 'selected'" do
params[:filter] = { odor: 'fishy' }

expect(filter_selected?(:odor, 'fishy')).to eq('selected')
expect(selected_filter(:odor, 'fishy')).to eq('selected')
end
end

context 'when filter params is NOT present' do
it 'returns an empty string' do
expect(filter_selected?(:odor, 'fishy')).to eq('')
expect(selected_filter(:odor, 'fishy')).to eq('')
end
end
end
Expand Down

0 comments on commit 4783aab

Please sign in to comment.