fix tests

This commit is contained in:
r888888888
2017-04-04 12:25:03 -07:00
parent 347ffb5989
commit 0b8d4105aa
19 changed files with 111 additions and 162 deletions

View File

@@ -24,7 +24,7 @@ class PostArchiveTest < ActiveSupport::TestCase
@post.update_attributes(:tag_string => "2 3")
end
subject { @post.versions[1] }
subject { @post.versions.sort_by(&:id)[1] }
should "undo the changes" do
subject.undo!
@@ -61,7 +61,7 @@ class PostArchiveTest < ActiveSupport::TestCase
should "also create a version" do
assert_equal(1, @post.versions.size)
@version = @post.versions.last
@version = @post.versions.sort_by(&:id).last
assert_equal("aaa bbb ccc", @version.tags)
assert_equal(@post.rating, @version.rating)
assert_equal(@post.parent_id, @version.parent_id)
@@ -93,7 +93,7 @@ class PostArchiveTest < ActiveSupport::TestCase
@post.update_attributes(:tag_string => "bbb ccc xxx", :source => "")
assert_equal(2, @post.versions.size)
@version = @post.versions.last
@version = @post.versions.sort_by(&:id).last
assert_equal("bbb ccc xxx", @version.tags)
assert_equal("q", @version.rating)
assert_equal("", @version.source)
@@ -110,14 +110,14 @@ class PostArchiveTest < ActiveSupport::TestCase
should "should create a version if the rating changes" do
assert_difference("@post.versions.size", 1) do
@post.update(rating: "s")
assert_equal("s", @post.versions.last.rating)
assert_equal("s", @post.versions.sort_by(&:id).last.rating)
end
end
should "should create a version if the source changes" do
assert_difference("@post.versions.size", 1) do
@post.update(source: "blah")
assert_equal("blah", @post.versions.last.source)
assert_equal("blah", @post.versions.sort_by(&:id).last.source)
end
end
@@ -125,14 +125,14 @@ class PostArchiveTest < ActiveSupport::TestCase
assert_difference("@post.versions.size", 1) do
@parent = FactoryGirl.create(:post)
@post.update(parent_id: @parent.id)
assert_equal(@parent.id, @post.versions.last.parent_id)
assert_equal(@parent.id, @post.versions.sort_by(&:id).last.parent_id)
end
end
should "should create a version if the tags change" do
assert_difference("@post.versions.size", 1) do
@post.update(tag_string: "blah")
assert_equal("blah", @post.versions.last.tags)
assert_equal("blah", @post.versions.sort_by(&:id).last.tags)
end
end
end