fix broken specs

did committed Feb 13, 2015
commit 2898ece76aecd35b17ae13b42581a6da4f9d8a1b
Showing 6 changed files with 17 additions and 39 deletions
locomotive/steam/liquid/drops/content_entry.rb b/lib/locomotive/steam/liquid/drops/content_entry.rb +0 -13
@@ @@ -51,15 +51,6 @@ module Locomotive
if not @@forbidden_attributes.include?(meth.to_s)
repository.value_for(meth, @_source, @context['with_scope'])
-
- # value = @_source.send(meth)
-
- # # check for an association (lazy loading)
- # if value.respond_to?(:all)
- # filter_association(value)
- # else
- # value
- # end
else
nil
end
@@ @@ -71,10 +62,6 @@ module Locomotive
@context.registers[:services].repositories.content_entry
end
- # def fetch_association(name)
- # repository.association(name, @_source, @context['with_scope'] || {})
- # end
-
end
end
end
spec/unit/decorators/i18n_decorator_spec.rb +2 -2
@@ @@ -65,8 +65,8 @@ describe Locomotive::Steam::Decorators::I18nDecorator do
let(:decorated) { Locomotive::Steam::Decorators::I18nDecorator.new(model, nil, locale, default_locale) }
it 'runs some basic tests' do
- expect(model.localized_attributes).to eq [:seo, :meta_description, :meta_keywords]
- expect(model.class.localized_attributes).to eq [:seo, :meta_description, :meta_keywords]
+ expect(model.localized_attributes).to eq [:seo_title, :meta_description, :meta_keywords]
+ expect(model.class.localized_attributes).to eq [:seo_title, :meta_description, :meta_keywords]
expect(decorated.name).to eq 'Acme'
expect(decorated.meta_description).to eq nil
end
spec/unit/liquid/drops/content_entry_spec.rb +3 -3
@@ @@ -29,11 +29,11 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntry do
describe 'relationship field' do
- let(:authors) { instance_double('Authors', all: ['john', 'jane']) }
+ let(:authors) { instance_double('Authors', all: ['john', 'jane'], association: true) }
let(:entry) { instance_double('Article', authors: authors) }
before do
- allow(services.repositories.content_entry).to receive(:filter).with(authors, {}).and_return(authors.all)
+ allow(services.repositories.content_entry).to receive(:association).and_return(authors.all)
end
it { expect(subject.before_method(:authors).first).to eq 'john' }
@@ @@ -89,7 +89,7 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntry do
context 'change the current locale of the context' do
- let(:context) { ::Liquid::Context.new(assigns, {}, { locale: 'fr', site: site }) }
+ let(:context) { ::Liquid::Context.new(assigns, {}, { services: services, locale: 'fr', site: site }) }
it { is_expected.to eq 'Bonjour monde' }
end
spec/unit/repositories/filesystem/content_type_spec.rb +1 -1
@@ @@ -2,7 +2,7 @@ require 'spec_helper'
describe Locomotive::Steam::Repositories::Filesystem::ContentType do
- let(:fields) { [{ title: { hint: 'Title of the article' } }, { author: { type: 'string', label: 'Fullname of the author' } }] }
+ let(:fields) { [{ title: { hint: 'Title of the article', type: 'string' } }, { author: { type: 'string', label: 'Fullname of the author' } }] }
let(:loader) { instance_double('Loader', list_of_attributes: [{ slug: 'articles', name: 'Articles', fields: fields }]) }
let(:site) { instance_double('Site', default_locale: :en, locales: [:en, :fr]) }
let(:locale) { :en }
spec/unit/repositories/filesystem/models/content_type_spec.rb +10 -19
@@ @@ -2,40 +2,31 @@ require 'spec_helper'
describe Locomotive::Steam::Repositories::Filesystem::Models::ContentType do
- let(:fields) { [instance_double('Field1', label: 'Title', name: 'title'), instance_double('Field2', label: 'Author', name: 'author')] }
+ let(:fields) { [instance_double('Field1', label: 'Title', name: :title, localized: false), instance_double('Field2', label: 'Author', name: :author, localized: true)] }
let(:content_type) do
Locomotive::Steam::Repositories::Filesystem::Models::ContentType.new(name: 'Articles').tap do |type|
type.fields = fields
end
end
- describe '#field_by_name' do
+ describe '#label_field_name' do
- let(:name) { nil }
- subject { content_type.field_by_name(name) }
+ subject { content_type.label_field_name }
+ it { is_expected.to eq :title }
- it { is_expected.to eq nil }
-
- context 'not nil name' do
+ context 'defined within the content type itself' do
- let(:name) { 'author' }
- it { expect(subject.label).to eq 'Author' }
+ before { allow(content_type.attributes).to receive(:[]).with(:label_field_name).and_return('author') }
+ it { is_expected.to eq :author }
end
end
- describe '#label_field' do
+ describe '#localized_fields_names' do
- subject { content_type.label_field.try(:label) }
- it { is_expected.to eq 'Title' }
-
- context 'defined within the content type itself' do
-
- before { allow(content_type.attributes).to receive(:[]).with(:label_field_name).and_return('author') }
- it { is_expected.to eq 'Author' }
-
- end
+ subject { content_type.localized_fields_names }
+ it { is_expected.to eq [:author] }
end
spec/unit/repositories/filesystem/yaml_loaders/content_entry_spec.rb +1 -1
@@ @@ -14,7 +14,7 @@ describe Locomotive::Steam::Repositories::Filesystem::YAMLLoaders::ContentEntry
it 'tests various stuff' do
expect(subject.size).to eq 3
expect(subject.first[:_label]).to eq 'Alice in Chains'
- expect(subject.first.content_type).to eq content_type
+ expect(subject.first[:content_type]).to eq content_type
end
end