close #365; VersionConcern#version_at should return nil if timestamp argument received is after the object was destroyed
This commit is contained in:
parent
8172c16c9c
commit
3323f21679
|
@ -4,6 +4,8 @@
|
||||||
- [#383](https://github.com/airblade/paper_trail/pull/383) - Make gem compatible with `ActiveRecord::Enum` (available in `ActiveRecord` 4.1+).
|
- [#383](https://github.com/airblade/paper_trail/pull/383) - Make gem compatible with `ActiveRecord::Enum` (available in `ActiveRecord` 4.1+).
|
||||||
- [#373](https://github.com/airblade/paper_trail/pull/373) - Fix default sort order for the `versions` association in `ActiveRecord` 4.1.
|
- [#373](https://github.com/airblade/paper_trail/pull/373) - Fix default sort order for the `versions` association in `ActiveRecord` 4.1.
|
||||||
- [#372](https://github.com/airblade/paper_trail/pull/372) - Use [Arel](https://github.com/rails/arel) for SQL construction.
|
- [#372](https://github.com/airblade/paper_trail/pull/372) - Use [Arel](https://github.com/rails/arel) for SQL construction.
|
||||||
|
- [#365](https://github.com/airblade/paper_trail/issues/365) - `VersionConcern#version_at` should return `nil` when receiving a timestamp
|
||||||
|
that occured after the object was destroyed.
|
||||||
- [#347](https://github.com/airblade/paper_trail/pull/347) - Autoload `ActiveRecord` models in via a `Rails::Engine` when
|
- [#347](https://github.com/airblade/paper_trail/pull/347) - Autoload `ActiveRecord` models in via a `Rails::Engine` when
|
||||||
the gem is used with `Rails`.
|
the gem is used with `Rails`.
|
||||||
- Expand `PaperTrail::VERSION` into a module, mimicking the form used by Rails to give it some additional modularity & versatility.
|
- Expand `PaperTrail::VERSION` into a module, mimicking the form used by Rails to give it some additional modularity & versatility.
|
||||||
|
|
|
@ -182,7 +182,8 @@ module PaperTrail
|
||||||
# Because a version stores how its object looked *before* the change,
|
# Because a version stores how its object looked *before* the change,
|
||||||
# we need to look for the first version created *after* the timestamp.
|
# we need to look for the first version created *after* the timestamp.
|
||||||
v = send(self.class.versions_association_name).subsequent(timestamp, true).first
|
v = send(self.class.versions_association_name).subsequent(timestamp, true).first
|
||||||
v ? v.reify(reify_options) : self
|
return v.reify(reify_options) if v
|
||||||
|
self unless self.destroyed?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the objects (not Versions) as they were between the given times.
|
# Returns the objects (not Versions) as they were between the given times.
|
||||||
|
|
|
@ -105,6 +105,21 @@ describe Widget do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe :version_at do
|
||||||
|
it { should respond_to(:version_at) }
|
||||||
|
|
||||||
|
context "Timestamp argument is AFTER object has been destroyed" do
|
||||||
|
before do
|
||||||
|
widget.update_attribute(:name, 'foobar')
|
||||||
|
widget.destroy
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return `nil`" do
|
||||||
|
widget.version_at(Time.now).should be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe :whodunnit do
|
describe :whodunnit do
|
||||||
it { should respond_to(:whodunnit) }
|
it { should respond_to(:whodunnit) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue