pundit: convert tag aliases / implications to pundit.
This commit is contained in:
@@ -3,28 +3,34 @@ require 'test_helper'
|
||||
class TagAliasesControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The tag aliases controller" do
|
||||
setup do
|
||||
@user = create(:admin_user)
|
||||
@tag_alias = create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "list all tag alias" do
|
||||
get_auth tag_aliases_path, @user
|
||||
get tag_aliases_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "list all tag_alias (with search)" do
|
||||
get_auth tag_aliases_path, @user, params: {:search => {:antecedent_name => "aaa"}}
|
||||
get tag_aliases_path, params: {:search => {:antecedent_name => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "destroy action" do
|
||||
should "mark the alias as deleted" do
|
||||
assert_difference("TagAlias.count", 0) do
|
||||
delete_auth tag_alias_path(@tag_alias), @user
|
||||
assert_equal("deleted", @tag_alias.reload.status)
|
||||
end
|
||||
should "allow admins to delete aliases" do
|
||||
delete_auth tag_alias_path(@tag_alias), create(:admin_user)
|
||||
|
||||
assert_response :redirect
|
||||
assert_equal("deleted", @tag_alias.reload.status)
|
||||
end
|
||||
|
||||
should "not allow members to delete aliases" do
|
||||
delete_auth tag_alias_path(@tag_alias), create(:user)
|
||||
|
||||
assert_response 403
|
||||
assert_equal("active", @tag_alias.reload.status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,6 @@ require 'test_helper'
|
||||
class TagImplicationsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The tag implications controller" do
|
||||
setup do
|
||||
@user = create(:admin_user)
|
||||
@tag_implication = create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb")
|
||||
end
|
||||
|
||||
@@ -20,11 +19,18 @@ class TagImplicationsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
context "destroy action" do
|
||||
should "mark the implication as deleted" do
|
||||
assert_difference("TagImplication.count", 0) do
|
||||
delete_auth tag_implication_path(@tag_implication), @user
|
||||
assert_equal("deleted", @tag_implication.reload.status)
|
||||
end
|
||||
should "allow admins to delete implications" do
|
||||
delete_auth tag_implication_path(@tag_implication), create(:admin_user)
|
||||
|
||||
assert_response :redirect
|
||||
assert_equal("deleted", @tag_implication.reload.status)
|
||||
end
|
||||
|
||||
should "not allow members to delete aliases" do
|
||||
delete_auth tag_implication_path(@tag_implication), create(:user)
|
||||
|
||||
assert_response 403
|
||||
assert_equal("active", @tag_implication.reload.status)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user