fixes #2133
This commit is contained in:
@@ -15,8 +15,8 @@ class AdvertisementTest < ActiveSupport::TestCase
|
||||
assert_difference("AdvertisementHit.count") do
|
||||
@ad.hit!("0.0.0.0")
|
||||
end
|
||||
assert_equal("0.0.0.0", AdvertisementHit.first.ip_addr)
|
||||
assert_equal(1, AdvertisementHit.first.advertisement_id)
|
||||
assert_equal("0.0.0.0", AdvertisementHit.first.ip_addr.to_s)
|
||||
assert_equal(@ad.id, AdvertisementHit.first.advertisement_id)
|
||||
assert_equal(1, @ad.hit_sum(1.day.ago, 1.day.from_now))
|
||||
assert_equal(0, @ad.hit_sum(2.days.ago, 1.day.ago))
|
||||
end
|
||||
|
||||
@@ -2,31 +2,31 @@ require "test_helper"
|
||||
|
||||
module MetaSearches
|
||||
class TagTest < ActionMailer::TestCase
|
||||
context "The tag metasearcg" do
|
||||
context "The tag metasearch" do
|
||||
setup do
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
FactoryGirl.create(:tag, :name => "xxx")
|
||||
FactoryGirl.create(:post, :tag_string => "xxx")
|
||||
FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd")
|
||||
end
|
||||
|
||||
should "find the tag" do
|
||||
meta_search = Tag.new(:name => "xxx")
|
||||
meta_search = MetaSearches::Tag.new(:name => "xxx")
|
||||
meta_search.load_all
|
||||
assert_equal(1, meta_search.tags.size)
|
||||
assert_equal("xxx", meta_search.tags.first.name)
|
||||
end
|
||||
|
||||
should "find the alias" do
|
||||
meta_search = Tag.new(:name => "aaa")
|
||||
meta_search = MetaSearches::Tag.new(:name => "aaa")
|
||||
meta_search.load_all
|
||||
assert_equal(1, meta_search.tag_aliases.size)
|
||||
assert_equal("aaa", meta_search.tag_aliases.first.antecedent_name)
|
||||
end
|
||||
|
||||
should "find the implication" do
|
||||
meta_search = Tag.new(:name => "ccc")
|
||||
meta_search = MetaSearches::Tag.new(:name => "ccc")
|
||||
meta_search.load_all
|
||||
assert_equal(1, meta_search.tag_implications.size)
|
||||
assert_equal("ccc", meta_search.tag_implications.first.antecedent_name)
|
||||
|
||||
@@ -144,8 +144,15 @@ class NoteTest < ActiveSupport::TestCase
|
||||
|
||||
context "the act of undoing all changes by that user" do
|
||||
should "revert any affected notes" do
|
||||
Note.undo_changes_by_user(@vandal.id)
|
||||
assert_equal(2, NoteVersion.count)
|
||||
assert_equal([1, 2], @note.versions.map(&:version))
|
||||
assert_equal([@user.id, @vandal.id], @note.versions.map(&:updater_id))
|
||||
Timecop.travel(1.day.from_now) do
|
||||
Note.undo_changes_by_user(@vandal.id)
|
||||
end
|
||||
@note.reload
|
||||
assert_equal([1, 3], @note.versions.map(&:version))
|
||||
assert_equal([@user.id, @user.id], @note.versions.map(&:updater_id))
|
||||
assert_equal(5, @note.x)
|
||||
assert_equal(5, @note.y)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# encoding: utf-8
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class PoolTest < ActiveSupport::TestCase
|
||||
@@ -23,6 +25,16 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "A multibyte character name" do
|
||||
setup do
|
||||
@mb_pool = FactoryGirl.create(:pool, :name => "àáâãäå")
|
||||
end
|
||||
|
||||
should "be mapped to a pool id" do
|
||||
assert_equal(@mb_pool.id, Pool.name_to_id("àáâãäå"))
|
||||
end
|
||||
end
|
||||
|
||||
context "An id number" do
|
||||
setup do
|
||||
@pool = FactoryGirl.create(:pool)
|
||||
@@ -188,14 +200,24 @@ class PoolTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "create new versions for each distinct user" do
|
||||
assert_equal(1, @pool.versions(true).size)
|
||||
@pool.post_ids = "#{@p1.id}"
|
||||
CurrentUser.ip_addr = "1.2.3.4"
|
||||
@pool.save
|
||||
assert_equal(2, @pool.versions(true).size)
|
||||
@pool.post_ids = "#{@p1.id} #{@p2.id}"
|
||||
@pool.save
|
||||
assert_equal(2, @pool.versions(true).size)
|
||||
assert_equal(1, @pool.versions.size)
|
||||
user2 = FactoryGirl.create(:user)
|
||||
|
||||
CurrentUser.scoped(user2, "127.0.0.2") do
|
||||
@pool.post_ids = "#{@p1.id}"
|
||||
@pool.save
|
||||
end
|
||||
|
||||
@pool.reload
|
||||
assert_equal(2, @pool.versions.size)
|
||||
|
||||
CurrentUser.scoped(user2, "127.0.0.2") do
|
||||
@pool.post_ids = "#{@p1.id} #{@p2.id}"
|
||||
@pool.save
|
||||
end
|
||||
|
||||
@pool.reload
|
||||
assert_equal(2, @pool.versions.size)
|
||||
end
|
||||
|
||||
should "know what its post ids were previously" do
|
||||
|
||||
@@ -1169,7 +1169,7 @@ class PostTest < ActiveSupport::TestCase
|
||||
post3.add_pool!(pool2)
|
||||
relation = Post.tag_match("pool:test*")
|
||||
assert_equal(2, relation.count)
|
||||
assert_equal([post3.id, post1.id], relation.all.map!(&:id))
|
||||
assert_equal([post3.id, post1.id], relation.all.map(&:id))
|
||||
end
|
||||
|
||||
should "return posts for the <user> metatag" do
|
||||
|
||||
@@ -21,7 +21,7 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase
|
||||
context "with a bad cache and post counts" do
|
||||
setup do
|
||||
Cache.put("ta:aaa", "zzz")
|
||||
Tag.update_all("post_count = -3", "name = 'aaa'")
|
||||
Tag.where(:name => "aaa").update_all("post_count = -3")
|
||||
@correction = TagAliasCorrection.new(@tag_alias.id)
|
||||
end
|
||||
|
||||
|
||||
@@ -111,9 +111,7 @@ class TagTest < ActiveSupport::TestCase
|
||||
|
||||
should "not be lockable by a user" do
|
||||
@tag = FactoryGirl.create(:tag)
|
||||
assert_raises(ActiveModel::MassAssignmentSecurity::Error) do
|
||||
@tag.update_attributes({:is_locked => true}, :as => :member)
|
||||
end
|
||||
@tag.update_attributes({:is_locked => true}, :as => :member)
|
||||
@tag.reload
|
||||
assert_equal(false, @tag.is_locked?)
|
||||
end
|
||||
|
||||
@@ -196,7 +196,7 @@ class UploadTest < ActiveSupport::TestCase
|
||||
assert_equal("foo hoge lowres", post.tag_string)
|
||||
assert_equal("s", post.rating)
|
||||
assert_equal(@upload.uploader_id, post.uploader_id)
|
||||
assert_equal("127.0.0.1", post.uploader_ip_addr)
|
||||
assert_equal("127.0.0.1", post.uploader_ip_addr.to_s)
|
||||
assert_equal(@upload.md5, post.md5)
|
||||
assert_equal("gif", post.file_ext)
|
||||
assert_equal(276, post.image_width)
|
||||
@@ -223,7 +223,7 @@ class UploadTest < ActiveSupport::TestCase
|
||||
assert_equal("foo hoge lowres", post.tag_string)
|
||||
assert_equal("s", post.rating)
|
||||
assert_equal(@upload.uploader_id, post.uploader_id)
|
||||
assert_equal("127.0.0.1", post.uploader_ip_addr)
|
||||
assert_equal("127.0.0.1", post.uploader_ip_addr.to_s)
|
||||
assert_equal(@upload.md5, post.md5)
|
||||
assert_equal("jpg", post.file_ext)
|
||||
assert(File.exists?(post.file_path))
|
||||
|
||||
@@ -271,7 +271,7 @@ class UserTest < ActiveSupport::TestCase
|
||||
@user.password = "zugzug6"
|
||||
@user.password_confirmation = "zugzug5"
|
||||
@user.save
|
||||
assert_equal(["Password doesn't match confirmation"], @user.errors.full_messages)
|
||||
assert_equal(["Password confirmation doesn't match Password"], @user.errors.full_messages)
|
||||
end
|
||||
|
||||
should "not be too short" do
|
||||
|
||||
Reference in New Issue
Block a user