allow to get all the content entries even the not visible ones
did
committed Jun 12, 2017
commit 8809ae8e14b5c682ca9d245d23c3c06356583343
Showing 3
changed files with
23 additions
and 2 deletions
locomotive/steam/adapters/filesystem/sanitizers/content_entry.rb b/lib/locomotive/steam/adapters/filesystem/sanitizers/content_entry.rb
+1
-1
| @@ | @@ -83,7 +83,7 @@ module Locomotive::Steam |
| end | |
| def slugify(id, label, dataset, locale = nil) | |
| - | base, index = label.permalink(false), nil |
| + | base, index = label.to_s.permalink(false), nil |
| _slugify = -> (i) { [base, i].compact.join('-') } | |
| while !is_slug_unique?(id, _slugify.call(index), dataset, locale) | |
locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb
+9
-1
| @@ | @@ -137,7 +137,15 @@ module Locomotive |
| def prepare_conditions(*conditions) | |
| _conditions = Conditions.new(conditions.first, self.content_type.fields, simple_clone).prepare | |
| - | super({ _visible: true }, _conditions) |
| + | super(_conditions).tap do |final_conditions| |
| + | # skip the default visible condition (_visible: true) by just passing nil |
| + | skip_visible = final_conditions.stringify_keys.fetch('_visible', true).nil? |
| + | |
| + | # clean it |
| + | final_conditions.delete(:_visible) || final_conditions.delete('_visible') |
| + | |
| + | final_conditions[:_visible] = true unless skip_visible |
| + | end |
| end | |
| def simple_clone | |
spec/unit/repositories/content_entry_repository_spec.rb
+13
-0
| @@ | @@ -39,6 +39,19 @@ describe Locomotive::Steam::ContentEntryRepository do |
| end | |
| + | describe 'including also the not visible entries' do |
| + | |
| + | let(:entries) { [ |
| + | { content_type_id: 1, _position: 0, _label: 'Update #1', title: { fr: 'Mise a jour #1' }, text: { en: 'added some free stuff', fr: 'phrase FR' }, date: '2009/05/12', category: 'General' }, |
| + | { content_type_id: 1, _position: 1, _label: 'Update #2 [HIDDEN]', title: { fr: 'Mise a jour #1' }, text: { en: 'added some free stuff', fr: 'phrase FR' }, date: '2009/05/12', category: 'General', _visible: false } |
| + | ] } |
| + | |
| + | let(:conditions) { { _visible: nil } } |
| + | |
| + | it { expect(subject.size).to eq 2 } |
| + | |
| + | end |
| + | |
| end | |
| describe '#build' do | |