commentaries: trim whitespace from fields.

This commit is contained in:
evazion
2017-06-13 14:28:52 -05:00
parent 1aafdc3928
commit f8afabd51c
2 changed files with 31 additions and 0 deletions

View File

@@ -52,5 +52,28 @@ class ArtistCommentaryTest < ActiveSupport::TestCase
assert_equal("foo", @artcomm.versions.last.original_title)
end
end
context "when updated" do
setup do
@post = FactoryGirl.create(:post)
@artcomm = FactoryGirl.create(:artist_commentary, post_id: @post.id)
@artcomm.reload
end
should "trim whitespace from all fields" do
# \u00A0 - nonbreaking space.
@artcomm.update(
original_title: " foo\u00A0\t\n",
original_description: " foo\u00A0\t\n",
translated_title: " foo\u00A0\t\n",
translated_description: " foo\u00A0\n",
)
assert_equal("foo", @artcomm.original_title)
assert_equal("foo", @artcomm.original_description)
assert_equal("foo", @artcomm.translated_title)
assert_equal("foo", @artcomm.translated_description)
end
end
end
end