fix tests

This commit is contained in:
r888888888
2017-04-04 12:25:03 -07:00
parent 347ffb5989
commit 0b8d4105aa
19 changed files with 111 additions and 162 deletions

View File

@@ -11,6 +11,11 @@ module Moderator
@post = FactoryGirl.create(:post)
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "confirm_delete action" do
should "render" do
get :confirm_delete, { id: @post.id }, { user_id: @admin.id }
@@ -49,7 +54,18 @@ module Moderator
end
context "move_favorites action" do
should "render" do
setup do
@admin = FactoryGirl.create(:admin_user)
CurrentUser.user = @admin
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "1234 render" do
parent = FactoryGirl.create(:post)
child = FactoryGirl.create(:post, parent: parent)
users = FactoryGirl.create_list(:user, 2)
@@ -57,6 +73,7 @@ module Moderator
put :move_favorites, { id: child.id, commit: "Submit" }, { user_id: @admin.id }
CurrentUser.user = @admin
assert_redirected_to(child)
assert_equal(users, parent.reload.favorited_users)
assert_equal([], child.reload.favorited_users)

View File

@@ -14,6 +14,7 @@ class PoolsControllerTest < ActionController::TestCase
CurrentUser.ip_addr = "127.0.0.1"
@post = FactoryGirl.create(:post)
mock_pool_archive_service!
PoolArchive.sqs_service.stubs(:merge?).returns(false)
start_pool_archive_transaction
end

View File

@@ -1,18 +1,23 @@
require 'test_helper'
require 'helpers/post_archive_test_helper'
class PostVersionsControllerTest < ActionController::TestCase
include PostArchiveTestHelper
def setup
super
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
def teardown
super
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "The post versions controller" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "index action" do
setup do
@post = FactoryGirl.create(:post)
@@ -21,13 +26,13 @@ class PostVersionsControllerTest < ActionController::TestCase
end
should "list all versions" do
get :index
get :index, {}, {:user_id => @user.id}
assert_response :success
assert_not_nil(assigns(:post_versions))
end
should "list all versions that match the search criteria" do
get :index, {:search => {:post_id => @post.id}}
get :index, {:search => {:post_id => @post.id}}, {:user_id => @user.id}
assert_response :success
assert_not_nil(assigns(:post_versions))
end

View File

@@ -1,7 +1,12 @@
require 'test_helper'
require 'helpers/post_archive_test_helper'
class ReportsControllerTest < ActionController::TestCase
setup do
include PostArchiveTestHelper
def setup
super
CurrentUser.user = FactoryGirl.create(:mod_user)
CurrentUser.ip_addr = "127.0.0.1"
session[:user_id] = CurrentUser.user.id
@@ -10,34 +15,15 @@ class ReportsControllerTest < ActionController::TestCase
@posts = @users.map { |u| FactoryGirl.create(:post, uploader: u) }
end
teardown do
def teardown
super
CurrentUser.user = nil
CurrentUser.ip_addr = nil
session[:user_id] = nil
end
context "The reports controller" do
context "user_promotions action" do
should "render" do
get :user_promotions
assert_response :success
end
end
context "janitor_trials action" do
should "render" do
get :janitor_trials
assert_response :success
end
end
context "contributors action" do
should "render" do
get :contributors
assert_response :success
end
end
context "uploads action" do
should "render" do
get :uploads
@@ -58,12 +44,5 @@ class ReportsControllerTest < ActionController::TestCase
assert_response :success
end
end
context "post_versions_create action" do
should "render" do
#post :post_versions_create, { tag: "touhou", type: "added" }
#assert_response :success
end
end
end
end