use the last versions of Steam (1.0.0.rc9) and Coal (1.0.0.rc4)
did
committed Dec 16, 2015
commit 1d2c29e1d996aebf7e5021e07a00db009d209844
Showing 3
changed files with
73 additions
and 3 deletions
locomotive/wagon/decorators/content_entry_decorator.rb b/lib/locomotive/wagon/decorators/content_entry_decorator.rb
+1
-1
| @@ | @@ -95,7 +95,7 @@ module Locomotive |
| [nil] | |
| else | |
| entries.map { |entry| entry._slug.try(:[], __locale__) }.compact | |
| - | end.tap { |o| puts o.inspect } |
| + | end |
| end | |
| def decorate_has_many_field(value) | |
locomotivecms_wagon.gemspec
+2
-2
| @@ | @@ -27,8 +27,8 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'netrc', '~> 0.10.3' | |
| gem.add_dependency 'locomotivecms_common', '~> 0.0.5' | |
| - | gem.add_dependency 'locomotivecms_coal', '~> 1.0.0.rc3' |
| - | gem.add_dependency 'locomotivecms_steam', '~> 1.0.0.rc8' |
| + | gem.add_dependency 'locomotivecms_coal', '~> 1.0.0.rc4' |
| + | gem.add_dependency 'locomotivecms_steam', '~> 1.0.0.rc9' |
| gem.add_dependency 'listen', '~> 3.0.4' | |
| gem.add_dependency 'rack-livereload', '~> 0.3.16' | |
spec/unit/decorators/content_entry_decorator_spec.rb
+70
-0
| @@ | @@ -0,0 +1,70 @@ |
| + | # encoding: utf-8 |
| + | |
| + | require 'spec_helper' |
| + | |
| + | require 'chronic' |
| + | require 'locomotive/steam' |
| + | require 'locomotive/wagon/decorators/concerns/to_hash_concern' |
| + | require 'locomotive/wagon/decorators/concerns/persist_assets_concern' |
| + | require 'locomotive/wagon/decorators/content_entry_decorator' |
| + | |
| + | describe Locomotive::Wagon::ContentEntryDecorator do |
| + | |
| + | let(:content_type) { instance_double('ContentType', fields: fields) } |
| + | let(:entry) { instance_double('ContentEntry', attributes.merge(content_type: content_type, localized_attributes: [])) } |
| + | let(:decorator) { described_class.new(entry, 'en', '.') } |
| + | |
| + | before { allow(decorator).to receive(:_slug).and_return('sample') } |
| + | |
| + | describe '#to_hash' do |
| + | |
| + | describe 'no field' do |
| + | |
| + | let(:fields) { instance_double('Fields', by_name: nil, no_associations: []) } |
| + | let(:attributes) { {} } |
| + | |
| + | subject { decorator.to_hash } |
| + | |
| + | it { is_expected.to eq({}) } |
| + | |
| + | end |
| + | |
| + | describe 'string field' do |
| + | |
| + | let(:field) { instance_double('Field', name: 'title', type: 'string') } |
| + | let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) } |
| + | let(:attributes) { { title: 'Hello world' } } |
| + | |
| + | subject { decorator.to_hash } |
| + | |
| + | it { is_expected.to eq({ _slug: 'sample', title: 'Hello world' }) } |
| + | |
| + | end |
| + | |
| + | describe 'date field' do |
| + | |
| + | let(:field) { instance_double('Field', name: 'posted_at', type: 'date') } |
| + | let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) } |
| + | let(:attributes) { { posted_at: Chronic.parse('2015-09-26').to_date } } |
| + | |
| + | subject { decorator.to_hash } |
| + | |
| + | it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-09-26' }) } |
| + | |
| + | end |
| + | |
| + | describe 'date time field' do |
| + | |
| + | let(:field) { instance_double('Field', name: 'posted_at', type: 'date_time') } |
| + | let(:fields) { instance_double('Fields', by_name: field, no_associations: [field]) } |
| + | let(:attributes) { { posted_at: Chronic.parse('2015-11-11 18:00:00 +0100').to_datetime } } |
| + | |
| + | subject { decorator.to_hash } |
| + | |
| + | it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-11-11T18:00:00+01:00' }) } |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| + | end |