This commit is contained in:
albert
2013-03-10 16:31:39 -04:00
parent 1946fab809
commit e53d60d99b
22 changed files with 384 additions and 17 deletions

View File

@@ -0,0 +1,33 @@
require 'test_helper'
class TagAliasCorrectionsControllerTest < ActionController::TestCase
context "The tag alias correction controller" do
setup do
@admin = FactoryGirl.create(:admin_user)
CurrentUser.user = @admin
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Delayed::Worker.delay_jobs = false
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "show action" do
should "render" do
get :show, {:tag_alias_id => @tag_alias.id}, {:user => @admin.id}
assert_response :success
end
end
context "create action" do
should "render" do
post :create, {:tag_alias_id => @tag_alias.id, :commit => "Fix"}, {:user => @admin.id}
assert_redirected_to(tag_alias_correction_path(:tag_alias_id => @tag_alias.id))
end
end
end
end

View File

@@ -0,0 +1,34 @@
require 'test_helper'
class TagAliasRequestsControllerTest < ActionController::TestCase
context "The tag alias request controller" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Delayed::Worker.delay_jobs = false
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "new action" do
should "render" do
get :new, {}, {:user => @user.id}
assert_response :success
end
end
context "create action" do
should "render" do
assert_difference("ForumTopic.count", 1) do
post :create, {:tag_alias_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc"}}, {:user => @user.id}
end
assert_redirected_to(forum_topic_path(ForumTopic.last))
end
end
end
end

View File

@@ -0,0 +1,34 @@
require 'test_helper'
class TagImplicationRequestsControllerTest < ActionController::TestCase
context "The tag implication request controller" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Delayed::Worker.delay_jobs = false
end
teardown do
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
context "new action" do
should "render" do
get :new, {}, {:user => @user.id}
assert_response :success
end
end
context "create action" do
should "render" do
assert_difference("ForumTopic.count", 1) do
post :create, {:tag_implication_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc"}}, {:user => @user.id}
end
assert_redirected_to(forum_topic_path(ForumTopic.last))
end
end
end
end

View File

@@ -1,7 +1,7 @@
require 'test_helper'
class TagImplicationsControllerTest < ActionController::TestCase
context "The tag implicationes controller" do
context "The tag implications controller" do
setup do
@user = FactoryGirl.create(:admin_user)
CurrentUser.user = @user

View File

@@ -1,7 +1,7 @@
require 'test_helper'
class TagAliasTest < ActiveSupport::TestCase
context "A tag alias" do
class TagAliasCorrectionTest < ActiveSupport::TestCase
context "A tag alias correction" do
setup do
@mod = FactoryGirl.create(:moderator_user)
CurrentUser.user = @mod

View File

@@ -0,0 +1,44 @@
require 'test_helper'
class TagAliasRequestTest < ActiveSupport::TestCase
context "A tag alias request" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Delayed::Worker.delay_jobs = false
end
teardown do
MEMCACHE.flush_all
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "raise an exception if invalid" do
assert_raises(TagAliasRequest::ValidationError) do
TagAliasRequest.new("", "", "reason").create
end
end
should "create a tag alias" do
assert_difference("TagAlias.count", 1) do
TagAliasRequest.new("aaa", "bbb", "reason").create
end
assert_equal("pending", TagAlias.last.status)
end
should "create a forum topic" do
assert_difference("ForumTopic.count", 1) do
TagAliasRequest.new("aaa", "bbb", "reason").create
end
end
should "create a forum post" do
assert_difference("ForumPost.count", 1) do
TagAliasRequest.new("aaa", "bbb", "reason").create
end
end
end
end

View File

@@ -0,0 +1,44 @@
require 'test_helper'
class TagImplicationRequestTest < ActiveSupport::TestCase
context "A tag implication request" do
setup do
@user = FactoryGirl.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
Delayed::Worker.delay_jobs = false
end
teardown do
MEMCACHE.flush_all
CurrentUser.user = nil
CurrentUser.ip_addr = nil
end
should "raise an exception if invalid" do
assert_raises(TagImplicationRequest::ValidationError) do
TagImplicationRequest.new("", "", "reason").create
end
end
should "create a tag implication" do
assert_difference("TagImplication.count", 1) do
TagImplicationRequest.new("aaa", "bbb", "reason").create
end
assert_equal("pending", TagImplication.last.status)
end
should "create a forum topic" do
assert_difference("ForumTopic.count", 1) do
TagImplicationRequest.new("aaa", "bbb", "reason").create
end
end
should "create a forum post" do
assert_difference("ForumPost.count", 1) do
TagImplicationRequest.new("aaa", "bbb", "reason").create
end
end
end
end