first attempt to fix the broken tests in Travis

did committed Dec 28, 2015
commit 1cd5197048af886ecd27caac7f90101daf58383a
Showing 5 changed files with 20 additions and 6 deletions
.travis.yml +5 -1
@@ @@ -1,3 +1,7 @@
language: ruby
rvm:
- - 2.1.1
\ No newline at end of file
+ - 2.1.1
+ before_install:
+ - export TZ=Paris
+ - date
+
Gemfile +1 -1
@@ @@ -8,7 +8,7 @@ gem 'rb-fsevent', '~> 0.9.1'
gem 'therubyracer'
# Development
- gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '99baa3e', require: false
+ gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '7825b47', require: false
# gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: '32b2844', require: false
# gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '3046b79893', require: false
locomotive/wagon/decorators/content_entry_decorator.rb b/lib/locomotive/wagon/decorators/content_entry_decorator.rb +4 -1
@@ @@ -45,11 +45,14 @@ module Locomotive
end
def decorate_date_time_field(value)
+ value.utc.try(:iso8601)
+ end
+
+ def decorate_date_field(value)
value.try(:iso8601)
end
alias :decorate_time_field :decorate_date_time_field
- alias :decorate_date_field :decorate_date_time_field
def to_hash
if (hash = super).keys == [:_slug]
spec/support/chronic.rb +6 -0
@@ @@ -0,0 +1,6 @@
+ require 'active_support'
+ require 'active_support/core_ext'
+ require 'chronic'
+
+ Time.zone = 'Europe/Paris'
+ Chronic.time_class = Time.zone
spec/unit/decorators/content_entry_decorator_spec.rb +4 -3
@@ @@ -2,7 +2,6 @@
require 'spec_helper'
- require 'chronic'
require 'locomotive/steam'
require 'locomotive/wagon/decorators/concerns/to_hash_concern'
require 'locomotive/wagon/decorators/concerns/persist_assets_concern'
@@ @@ -14,6 +13,8 @@ describe Locomotive::Wagon::ContentEntryDecorator do
let(:entry) { instance_double('ContentEntry', attributes.merge(content_type: content_type, localized_attributes: [])) }
let(:decorator) { described_class.new(entry, 'en', '.') }
+ before { Chronic.time_class = Time.zone }
+
before { allow(decorator).to receive(:_slug).and_return('sample') }
describe '#to_hash' do
@@ @@ -57,11 +58,11 @@ describe Locomotive::Wagon::ContentEntryDecorator 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 } }
+ let(:attributes) { { posted_at: Chronic.parse('2015-11-11 18:00:00').to_datetime } }
subject { decorator.to_hash }
- it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-11-11T18:00:00+01:00' }) }
+ it { is_expected.to eq({ _slug: 'sample', posted_at: '2015-11-11T17:00:00+00:00' }) }
end