Skip to content

Commit

Permalink
Merge 8ea7aea into 02a812d
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbeedle committed Jun 21, 2015
2 parents 02a812d + 8ea7aea commit 73e17d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/capsule_crm/serializer.rb
Expand Up @@ -84,7 +84,7 @@ def attributes
attrs.each do |key, value|
attrs[key] = value.to_s(:db) if value.is_a?(Date)
if value.is_a?(DateTime)
attrs[key] = value.strftime("%Y-%m-%dT%H:%M:%SZ")
attrs[key] = value.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
end
end
additional_methods.each do |method|
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/capsule_crm/history_spec.rb
Expand Up @@ -301,7 +301,7 @@

it 'has the correct history item entry date' do
expect(subject['historyItem']['entryDate']).
to eql(history.entry_date.strftime("%Y-%m-%dT%H:%M:%SZ"))
to eql(history.entry_date.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
end

it 'has the correct history item creator' do
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/capsule_crm/serializer_spec.rb
Expand Up @@ -8,6 +8,7 @@ class SerializableTest
attribute :name
attribute :description
attribute :something, Date
attribute :a_timestamp, DateTime
end

class SerializableInverse
Expand Down Expand Up @@ -130,5 +131,16 @@ class SerializableInverse
to eql(Date.today.to_s(:db))
end
end

context 'when there are datetimes' do
let(:time) { Time.now }

before { object.a_timestamp = time }

it 'uses the UTC time' do
expect(subject['serializabletest']['aTimestamp'])
.to eql(time.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
end
end
end
end

0 comments on commit 73e17d2

Please sign in to comment.