fixed tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
Factory.define(:unapproval) do |f|
|
||||
f.post {|x| x.association(:post)}
|
||||
f.reason "xxx"
|
||||
end
|
||||
|
||||
@@ -6,7 +6,8 @@ class PostsControllerTest < ActionController::TestCase
|
||||
@user = Factory.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = Factory.create(:post, :uploader_id => @user.id, :tag_string => "aaa")
|
||||
@post = Factory.create(:post, :uploader_id => @user.id, :tag_string => "aaaa")
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
@@ -22,7 +23,7 @@ class PostsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with a search" do
|
||||
should "render" do
|
||||
get :index, {:tags => "aaa"}
|
||||
get :index, {:tags => "aaaa"}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
@@ -52,11 +53,11 @@ class PostsControllerTest < ActionController::TestCase
|
||||
|
||||
should "work" do
|
||||
@version = @post.versions(true).first
|
||||
assert_equal("aaa", @version.add_tags)
|
||||
assert_equal("aaaa", @version.add_tags)
|
||||
post :revert, {:id => @post.id, :version_id => @version.id}, {:user_id => @user.id}
|
||||
assert_redirected_to post_path(@post)
|
||||
@post.reload
|
||||
assert_equal("aaa", @post.tag_string)
|
||||
assert_equal("aaaa", @post.tag_string)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,9 @@ class UnapprovalsControllerTest < ActionController::TestCase
|
||||
|
||||
should "create a new unapproval" do
|
||||
assert_difference("Unapproval.count", 1) do
|
||||
post :create, {:post_id => @post.id, :reason => "xxx"}, {:user_id => @user.id}
|
||||
post :create, {:unapproval => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id}
|
||||
assert_not_nil(assigns(:unapproval))
|
||||
assert_equal([], assigns(:unapproval).errors.full_messages)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,7 +80,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "revert to a previous version" do
|
||||
version = @wiki_page.versions(true).last
|
||||
version = @wiki_page.versions(true).first
|
||||
assert_equal("1", version.body)
|
||||
post :revert, {:id => @wiki_page.id, :version_id => version.id}
|
||||
@wiki_page.reload
|
||||
|
||||
@@ -2,7 +2,7 @@ require_relative '../test_helper'
|
||||
|
||||
class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
user = Factory.create(:owner)
|
||||
user = Factory.create(:user)
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
@@ -16,7 +16,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
context "A tag subscription" do
|
||||
should "find the union of all posts for each tag in its tag query" do
|
||||
posts = []
|
||||
user = Factory.create(:owner)
|
||||
user = Factory.create(:user)
|
||||
posts << Factory.create(:post, :tag_string => "aaa")
|
||||
posts << Factory.create(:post, :tag_string => "bbb")
|
||||
posts << Factory.create(:post, :tag_string => "ccc")
|
||||
@@ -29,7 +29,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
|
||||
should "cache its tag query results" do
|
||||
posts = []
|
||||
user = Factory.create(:owner)
|
||||
user = Factory.create(:user)
|
||||
posts << Factory.create(:post, :tag_string => "aaa")
|
||||
posts << Factory.create(:post, :tag_string => "bbb")
|
||||
posts << Factory.create(:post, :tag_string => "ccc")
|
||||
@@ -38,7 +38,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
should "find posts based on its cached post ids" do
|
||||
user = Factory.create(:owner)
|
||||
user = Factory.create(:user)
|
||||
subs = []
|
||||
subs << Factory.create(:tag_subscription, :tag_query => "aaa", :owner => user, :name => "zzz")
|
||||
subs << Factory.create(:tag_subscription, :tag_query => "bbb", :owner => user, :name => "yyy")
|
||||
@@ -59,8 +59,8 @@ class TagSubscriptionTest < ActiveSupport::TestCase
|
||||
context "A tag subscription manager" do
|
||||
should "process all active tag subscriptions" do
|
||||
users = []
|
||||
users << Factory.create(:owner)
|
||||
users << Factory.create(:owner)
|
||||
users << Factory.create(:user)
|
||||
users << Factory.create(:user)
|
||||
posts = []
|
||||
posts << Factory.create(:post, :tag_string => "aaa")
|
||||
posts << Factory.create(:post, :tag_string => "bbb")
|
||||
|
||||
Reference in New Issue
Block a user