fix the specs for the content_entry liquid drop

did committed Mar 09, 2015
commit 170c3f86a5e9bc8e078be0b783ac04aeb9131a84
Showing 2 changed files with 6 additions and 11 deletions
locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb +1 -1
@@ @@ -67,7 +67,7 @@ module Locomotive
# a safe copy of the proxy repository is needed here
value = value.dup
# like this, we do not modify the original local conditions
- value.local_conditions.merge!(conditions)
+ value.local_conditions.merge!(conditions) if conditions
end
value
spec/unit/liquid/drops/content_entry_spec.rb +5 -10
@@ @@ -30,18 +30,13 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntry do
describe 'relationship field' do
- let(:authors) { instance_double(Locomotive::Steam::ContentEntryRepository, all: ['john', 'jane']) }
+ let(:authors) { instance_double('AuthorsRepository', first: 'john', local_conditions: {}) }
let(:type) { instance_double('Type', fields_by_name: { authors: instance_double('Field', type: :has_many ) }) }
let(:entry) { instance_double('Article', content_type: type, authors: authors) }
- # before do
- # allow(services.repositories.content_entry).to receive(:association).and_return(authors.all)
- # end
+ before { allow(authors).to receive(:dup).and_return(authors) }
- it do
- allow(subject.before_method(:authors)).to receive(:local_conditions).and_return({})
- expect(subject.before_method(:authors).first).to eq 'john'
- end
+ it { expect(subject.before_method(:authors).first).to eq 'john' }
end
@@ @@ -85,8 +80,8 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntry do
describe 'i18n' do
- let(:entry) { instance_double('Article', attributes: { title: { en: 'Hello world', fr: 'Bonjour monde' } }) }
- let(:drop) { Locomotive::Steam::Liquid::Drops::ContentEntry.new(entry, [:title]).tap { |d| d.context = context } }
+ let(:entry) { instance_double('Article', content_type: type, attributes: { title: { en: 'Hello world', fr: 'Bonjour monde' } }) }
+ let(:drop) { described_class.new(entry, [:title]).tap { |d| d.context = context } }
subject { drop.before_method(:title) }