fix the bug preventing the group_by_<select name> method of the content entry liquid drop to work

did committed Mar 21, 2016
commit a3054f11cfbd75f6ced45ed96bc47f3bc738edc2
Showing 3 changed files with 4 additions and 4 deletions
locomotive/steam/liquid/drops/content_entry_collection.rb b/lib/locomotive/steam/liquid/drops/content_entry_collection.rb +1 -1
@@ @@ -40,7 +40,7 @@ module Locomotive
def before_method(meth)
if (meth.to_s =~ /^group_by_(.+)$/) == 0
- repository.group_by_select_option(@content_type, $1)
+ repository.group_by_select_option($1)
elsif (meth.to_s =~ /^(.+)_options$/) == 0
select_options($1)
else
locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb +2 -2
@@ @@ -102,7 +102,7 @@ module Locomotive
groups_to_array(name, _groups).tap do |groups|
# entries with a not existing select_option value?
unless _groups.blank?
- groups << { name: nil, entries: _groups.values.flatten }
+ groups << { name: nil, entries: _groups.values.flatten }.with_indifferent_access
end
end
end
@@ @@ -179,7 +179,7 @@ module Locomotive
def groups_to_array(name, groups)
content_type_repository.select_options(content_type, name).map do |option|
option_name = i18n_value_of(option, :name)
- { name: option_name, entries: groups.delete(option_name) || [] }
+ { 'name' => option_name, 'entries' => groups.delete(option_name) || [] }.with_indifferent_access
end
end
spec/unit/liquid/drops/content_entry_collection_spec.rb +1 -1
@@ @@ -88,7 +88,7 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntryCollection do
describe 'group entries by a select/belongs_to field' do
before do
- expect(services.repositories.content_entry).to receive(:group_by_select_option).with(content_type, 'category').and_return([['a', [1, 2]]])
+ expect(services.repositories.content_entry).to receive(:group_by_select_option).with('category').and_return([['a', [1, 2]]])
end
it { expect(drop.before_method(:group_by_category)).to eq [['a', [1, 2]]] }