fixes #1396, fix tests

This commit is contained in:
r888888888
2013-05-03 17:29:41 -07:00
parent c0dac889b2
commit ce10a72bb6
6 changed files with 36 additions and 27 deletions

View File

@@ -40,8 +40,8 @@ class ArtistUrlTest < ActiveSupport::TestCase
end
should "normalize pixiv urls" do
url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/monet")
assert_equal("http://img55.pixiv.net/monet", url.url)
url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/img/monet")
assert_equal("http://img55.pixiv.net/img/monet", url.url)
assert_equal("http://img.pixiv.net/monet/", url.normalized_url)
end
end

View File

@@ -34,7 +34,13 @@ class NoteTest < ActiveSupport::TestCase
context "creating a note" do
setup do
@post = FactoryGirl.create(:post)
@post = FactoryGirl.create(:post, :image_width => 1000, :image_height => 1000)
end
should "not validate if the note is outside the image" do
@note = FactoryGirl.build(:note, :x => 1001, :y => 500, :post => @post)
@note.save
assert_equal(["Coordinates must be inside the image"], @note.errors.full_messages)
end
should "create a version" do
@@ -72,7 +78,7 @@ class NoteTest < ActiveSupport::TestCase
context "updating a note" do
setup do
@post = FactoryGirl.create(:post)
@post = FactoryGirl.create(:post, :image_width => 1000, :image_height => 1000)
@note = FactoryGirl.create(:note, :post => @post)
end
@@ -84,7 +90,7 @@ class NoteTest < ActiveSupport::TestCase
should "update the post's last_noted_at field" do
assert_nil(@post.last_noted_at)
@note.update_attributes(:x => 1000)
@note.update_attributes(:x => 500)
@post.reload
assert_equal(@post.last_noted_at.to_i, @note.updated_at.to_i)
end
@@ -105,7 +111,7 @@ class NoteTest < ActiveSupport::TestCase
end
should "fail" do
@note.update_attributes(:x => 1000)
@note.update_attributes(:x => 500)
assert_equal(["Post is note locked"], @note.errors.full_messages)
end
end