ban fixes
This commit is contained in:
@@ -3,10 +3,11 @@ require 'test_helper'
|
||||
class BansControllerTest < ActionController::TestCase
|
||||
context "A bans controller" do
|
||||
setup do
|
||||
CurrentUser.user = Factory.create(:user)
|
||||
@mod = Factory.create(:moderator_user)
|
||||
CurrentUser.user = @mod
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@ban = Factory.create(:ban)
|
||||
@user = Factory.create(:moderator_user)
|
||||
@user = Factory.create(:user)
|
||||
@ban = Factory.create(:ban, :user_id => @user.id)
|
||||
end
|
||||
|
||||
teardown do
|
||||
@@ -15,12 +16,12 @@ class BansControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "get the new page" do
|
||||
get :new, {}, {:user_id => @user.id}
|
||||
get :new, {}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "get the edit page" do
|
||||
get :edit, {:id => @ban.id}, {:user_id => @user.id}
|
||||
get :edit, {:id => @ban.id}, {:user_id => @mod.id}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -36,22 +37,22 @@ class BansControllerTest < ActionController::TestCase
|
||||
|
||||
should "create a ban" do
|
||||
assert_difference("Ban.count", 1) do
|
||||
post :create, {:ban => Factory.attributes_for(:ban)}, {:user_id => @user.id}
|
||||
post :create, {:ban => {:duration => 60, :reason => "xxx", :user_id => @user.id}}, {:user_id => @mod.id}
|
||||
end
|
||||
ban = Ban.last
|
||||
assert_redirected_to(ban_path(ban))
|
||||
end
|
||||
|
||||
should "update a ban" do
|
||||
post :update, {:id => @ban.id, :ban => {:reason => "xxx"}}, {:user_id => @user.id}
|
||||
ban = Ban.last
|
||||
assert_equal("xxx", ban.reason)
|
||||
assert_redirected_to(ban_path(ban))
|
||||
post :update, {:id => @ban.id, :ban => {:reason => "xxx", :duration => 60}}, {:user_id => @mod.id}
|
||||
@ban.reload
|
||||
assert_equal("xxx", @ban.reason)
|
||||
assert_redirected_to(ban_path(@ban))
|
||||
end
|
||||
|
||||
should "destroy a ban" do
|
||||
assert_difference("Ban.count", -1) do
|
||||
post :destroy, {:id => @ban.id}, {:user_id => @user.id}
|
||||
post :destroy, {:id => @ban.id}, {:user_id => @mod.id}
|
||||
end
|
||||
assert_redirected_to(bans_path)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user