mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Merge pull request #680 from airblade/fix_intermittent_cat_dog_test
Specify query order in STI test
This commit is contained in:
commit
402a78e3e5
1 changed files with 6 additions and 6 deletions
|
@ -1,7 +1,6 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class InheritanceColumnTest < ActiveSupport::TestCase
|
class InheritanceColumnTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
context 'STI models' do
|
context 'STI models' do
|
||||||
setup do
|
setup do
|
||||||
@animal = Animal.create :name => 'Animal'
|
@animal = Animal.create :name => 'Animal'
|
||||||
|
@ -28,16 +27,17 @@ class InheritanceColumnTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# For some reason `@dog.versions` doesn't include the final `destroy` version.
|
# For some reason `@dog.versions` doesn't include the final `destroy` version.
|
||||||
# Neither do `@dog.versions.scoped` nor `@dog.versions(true)` nor `@dog.versions.reload`.
|
# Neither do `@dog.versions.scoped` nor `@dog.versions(true)` nor `@dog.versions.reload`.
|
||||||
dog_versions = PaperTrail::Version.where(:item_id => @dog.id)
|
dog_versions = PaperTrail::Version.where(:item_id => @dog.id).
|
||||||
|
order(PaperTrail.timestamp_field)
|
||||||
assert_equal 4, dog_versions.count
|
assert_equal 4, dog_versions.count
|
||||||
assert_nil dog_versions.first.reify
|
assert_nil dog_versions.first.reify
|
||||||
dog_versions[1..-1].each { |v| assert_equal 'Dog', v.reify.class.name }
|
assert_equal %w[NilClass Dog Dog Dog], dog_versions.map { |v| v.reify.class.name }
|
||||||
|
|
||||||
cat_versions = PaperTrail::Version.where(:item_id => @cat.id)
|
cat_versions = PaperTrail::Version.where(:item_id => @cat.id).
|
||||||
|
order(PaperTrail.timestamp_field)
|
||||||
assert_equal 4, cat_versions.count
|
assert_equal 4, cat_versions.count
|
||||||
assert_nil cat_versions.first.reify
|
assert_nil cat_versions.first.reify
|
||||||
cat_versions[1..-1].each { |v| assert_equal 'Cat', v.reify.class.name }
|
assert_equal %w[NilClass Cat Cat Cat], cat_versions.map { |v| v.reify.class.name }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue