Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def deserialize(document)

# Set up common attributes
#
attribute :created_at, DateTime, default: lambda { |o,a| Time.now.utc }
attribute :updated_at, DateTime, default: lambda { |o,a| Time.now.utc }
attribute :created_at, Time, default: lambda { |o,a| Time.now.utc }
attribute :updated_at, Time, default: lambda { |o,a| Time.now.utc }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could revert this. I feel more strongly about ActiveSupport::TimeWithZone as in #395. The rest of this PR is more important.


attr_reader :hit
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def save(options={})
options.update index: self._index if self._index
options.update type: self._type if self._type

response = self.class.gateway.save(self, options)

self[:updated_at] = Time.now.utc

response = self.class.gateway.save(self, options)

@_id = response['_id']
@_index = response['_index']
@_type = response['_type']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ class ::Person
assert found.updated_at > updated_at, [found.updated_at, updated_at].inspect
end

should 'update the object timestamp on save' do
person = Person.create name: 'John Smith'
person.admin = true
sleep 1
person.save

Person.gateway.refresh_index!

found = Person.find(person.id)

# Compare without usec
assert_equal found.updated_at.to_i, person.updated_at.to_i
end

should "respect the version" do
person = Person.create name: 'John Smith'

Expand Down