commentaries: merge versions (fix #3149).

This commit is contained in:
evazion
2017-06-13 14:29:11 -05:00
parent ca2adac3f0
commit 155faf8380
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(