Merge pull request #3155 from evazion/fix-artcomm-version-merge

Fix #3149: Artist commentaries should merge versions
This commit is contained in:
Albert Yi
2017-06-14 12:26:46 -07:00
committed by GitHub
2 changed files with 76 additions and 28 deletions

View File

@@ -60,6 +60,28 @@ class ArtistCommentaryTest < ActiveSupport::TestCase
@artcomm.reload
end
should "not create new version if nothing changed" do
@artcomm.save
assert_equal(1, @post.artist_commentary.versions.size)
end
should "create a new version if outside merge window" do
travel_to(2.hours.from_now) do
@artcomm.update(original_title: "bar")
assert_equal(2, @post.artist_commentary.versions.size)
assert_equal("bar", @artcomm.versions.last.original_title)
end
end
should "merge with the previous version if inside merge window" do
@artcomm.update(original_title: "bar")
@artcomm.reload
assert_equal(1, @post.artist_commentary.versions.size)
assert_equal("bar", @artcomm.versions.last.original_title)
end
should "trim whitespace from all fields" do
# \u00A0 - nonbreaking space.
@artcomm.update(