added unapproval+upload functional test

This commit is contained in:
albert
2011-01-31 18:01:48 -05:00
parent 28b42e791c
commit df20d9233b
13 changed files with 174 additions and 9 deletions

View File

@@ -1,8 +1,65 @@
require 'test_helper'
class UnapprovalsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
context "The unapprovals controller" do
setup do
@user = Factory.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "new action" do
should "render" do
get :new, {}, {:user_id => @user.id}
assert_response :success
end
end
context "index action" do
setup do
@unapproval = Factory.create(:unapproval)
end
should "render" do
get :index, {}, {:user_id => @user.id}
assert_response :success
end
context "with search parameters" do
should "render" do
get :index, {:search => {:post_id_equals => @unapproval.post_id}}, {:user_id => @user.id}
assert_response :success
end
end
end
context "create action" do
setup do
@post = Factory.create(:post)
end
should "create a new unapproval" do
assert_difference("Unapproval.count", 1) do
post :create, {:post_id => @post.id, :reason => "xxx"}, {:user_id => @user.id}
end
end
end
context "destroy action" do
setup do
@unapproval = Factory.create(:unapproval)
end
should "delete an unapproval" do
assert_difference "Unapproval.count", -1 do
post :destroy, {:id => @unapproval.id}, {:user_id => @user.id}
end
end
end
end
end