diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 6d12236568..b785f314af 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -17,11 +17,4 @@ class ApplicationPolicy < ActionPolicy::Base # record.user_id == user.id # end # - - # attr_accessor :details - - # def initialize(record = nil, **params) - # super - # @details ||= {} - # end end diff --git a/test/policies/graphql_policy_test.rb b/test/policies/graphql_policy_test.rb index 3105890ae3..633615ee91 100644 --- a/test/policies/graphql_policy_test.rb +++ b/test/policies/graphql_policy_test.rb @@ -13,26 +13,26 @@ def setup end test '#query? when token has api scope' do - assert @policy_with_api_scope_token.query? + assert @policy_with_api_scope_token.apply(:query?) end test '#mutate? when token has api scope' do - assert @policy_with_api_scope_token.mutate? + assert @policy_with_api_scope_token.apply(:mutate?) end test '#query? when token has read api scope' do - assert @policy_with_read_api_scope_token.query? + assert @policy_with_read_api_scope_token.apply(:query?) end test '#mutate? when token has read api scope' do - assert_not @policy_with_read_api_scope_token.mutate? + assert_not @policy_with_read_api_scope_token.apply(:mutate?) end test '#query? when nil token' do - assert @policy_without_token.query? + assert @policy_without_token.apply(:query?) end test '#mutate? when nil token' do - assert @policy_without_token.mutate? + assert @policy_without_token.apply(:mutate?) end end diff --git a/test/policies/group_policy_test.rb b/test/policies/group_policy_test.rb index 0fa606d16a..e59b5d1eef 100644 --- a/test/policies/group_policy_test.rb +++ b/test/policies/group_policy_test.rb @@ -10,91 +10,91 @@ def setup end test '#read?' do - assert @policy.read? + assert @policy.apply(:read?) end test '#new?' do - assert @policy.new? + assert @policy.apply(:new?) end test '#edit?' do - assert @policy.edit? + assert @policy.apply(:edit?) end test '#create?' do - assert @policy.create? + assert @policy.apply(:create?) end test '#update?' do - assert @policy.update? + assert @policy.apply(:update?) end test '#destroy?' do - assert @policy.destroy? + assert @policy.apply(:destroy?) end test '#create_subgroup?' do - assert @policy.create_subgroup? + assert @policy.apply(:create_subgroup?) end test '#transfer?' do - assert @policy.transfer? + assert @policy.apply(:transfer?) end test '#transfer_into_namespace?' do - assert @policy.transfer_into_namespace? + assert @policy.apply(:transfer_into_namespace?) end test '#create_member?' do - assert @policy.create_member? + assert @policy.apply(:create_member?) end test '#update_member?' do - assert @policy.update_member? + assert @policy.apply(:update_member?) end test '#destroy_member?' do - assert @policy.destroy_member? + assert @policy.apply(:destroy_member?) end test '#member_listing?' do - assert @policy.member_listing? + assert @policy.apply(:member_listing?) end test '#sample_listing?' do - assert @policy.sample_listing? + assert @policy.apply(:sample_listing?) end test '#link_namespace_with_group?' do - assert @policy.link_namespace_with_group? + assert @policy.apply(:link_namespace_with_group?) end test '#unlink_namespace_with_group?' do - assert @policy.unlink_namespace_with_group? + assert @policy.apply(:unlink_namespace_with_group?) end test '#update_namespace_with_group_link?' do - assert @policy.update_namespace_with_group_link? + assert @policy.apply(:update_namespace_with_group_link?) end test '#submit_workflow?' do - assert @policy.submit_workflow? + assert @policy.apply(:submit_workflow?) end test '#update_sample_metadata?' do - assert @policy.update_sample_metadata? + assert @policy.apply(:update_sample_metadata?) end test '#view_attachments?' do - assert @policy.view_attachments? + assert @policy.apply(:view_attachments?) end test '#create_attachment?' do - assert @policy.create_attachment? + assert @policy.apply(:create_attachment?) end test '#destroy_attachment?' do - assert @policy.destroy_attachment? + assert @policy.apply(:destroy_attachment?) end test 'scope' do diff --git a/test/policies/namespaces/project_namespace_policy_test.rb b/test/policies/namespaces/project_namespace_policy_test.rb index e95886f814..5ce6036234 100644 --- a/test/policies/namespaces/project_namespace_policy_test.rb +++ b/test/policies/namespaces/project_namespace_policy_test.rb @@ -11,59 +11,59 @@ def setup end test '#update?' do - assert @policy.update? + assert @policy.apply(:update?) end test '#create_member?' do - assert @policy.create_member? + assert @policy.apply(:create_member?) end test '#update_member?' do - assert @policy.update_member? + assert @policy.apply(:update_member?) end test '#destroy_member?' do - assert @policy.destroy_member? + assert @policy.apply(:destroy_member?) end test '#member_listing?' do - assert @policy.member_listing? + assert @policy.apply(:member_listing?) end test '#link_namespace_with_group?' do - assert @policy.link_namespace_with_group? + assert @policy.apply(:link_namespace_with_group?) end test '#unlink_namespace_with_group?' do - assert @policy.unlink_namespace_with_group? + assert @policy.apply(:unlink_namespace_with_group?) end test '#update_namespace_with_group_link?' do - assert @policy.update_namespace_with_group_link? + assert @policy.apply(:update_namespace_with_group_link?) end test '#create_automated_workflow_executions?' do - assert @policy.create_automated_workflow_executions? + assert @policy.apply(:create_automated_workflow_executions?) end test '#destroy_automated_workflow_executions?' do - assert @policy.destroy_automated_workflow_executions? + assert @policy.apply(:destroy_automated_workflow_executions?) end test '#update_automated_workflow_executions?' do - assert @policy.update_automated_workflow_executions? + assert @policy.apply(:update_automated_workflow_executions?) end test '#view_automated_workflow_executions?' do - assert @policy.view_automated_workflow_executions? + assert @policy.apply(:view_automated_workflow_executions?) end test '#view_workflow_executions?' do - assert @policy.view_automated_workflow_executions? + assert @policy.apply(:view_automated_workflow_executions?) end test '#update_sample_metadata?' do - assert @policy.update_sample_metadata? + assert @policy.apply(:update_sample_metadata?) end end end diff --git a/test/policies/namespaces/user_namespace_policy_test.rb b/test/policies/namespaces/user_namespace_policy_test.rb index 7e3613334b..d23cdf6881 100644 --- a/test/policies/namespaces/user_namespace_policy_test.rb +++ b/test/policies/namespaces/user_namespace_policy_test.rb @@ -11,11 +11,11 @@ def setup end test '#create?' do - assert @policy.create? + assert @policy.apply(:create?) end test '#transfer_into_namespace?' do - assert @policy.transfer_into_namespace? + assert @policy.apply(:transfer_into_namespace?) end end end diff --git a/test/policies/project_policy_test.rb b/test/policies/project_policy_test.rb index 7f09e03ab7..8cdcb2d75b 100644 --- a/test/policies/project_policy_test.rb +++ b/test/policies/project_policy_test.rb @@ -11,86 +11,86 @@ def setup end test '#read?' do - assert @policy.read? + assert @policy.apply(:read?) end test '#edit?' do - assert @policy.edit? + assert @policy.apply(:edit?) end test '#new?' do - assert @policy.new? + assert @policy.apply(:new?) end test '#update?' do - assert @policy.update? + assert @policy.apply(:update?) end test '#activity?' do - assert @policy.activity? + assert @policy.apply(:activity?) end test '#destroy?' do - assert @policy.destroy? + assert @policy.apply(:destroy?) end test '#transfer?' do - assert @policy.transfer? + assert @policy.apply(:transfer?) end test '#sample_listing?' do - assert @policy.sample_listing? + assert @policy.apply(:sample_listing?) end test '#create_sample?' do - assert @policy.create_sample? + assert @policy.apply(:create_sample?) end test '#update_sample?' do - assert @policy.update_sample? + assert @policy.apply(:update_sample?) end test '#transfer_sample?' do - assert @policy.transfer_sample? + assert @policy.apply(:transfer_sample?) end test '#destroy_sample?' do - assert @policy.destroy_sample? + assert @policy.apply(:destroy_sample?) end test '#read_sample?' do - assert @policy.destroy_sample? + assert @policy.apply(:read_sample?) end test '#transfer_sample_into_project?' do - assert @policy.transfer_sample_into_project? + assert @policy.apply(:transfer_sample_into_project?) end test '#clone_sample?' do - assert @policy.clone_sample? + assert @policy.apply(:clone_sample?) end test '#clone_sample_into_project?' do - assert @policy.clone_sample_into_project? + assert @policy.apply(:clone_sample_into_project?) end test '#export_data?' do - assert @policy.export_data? + assert @policy.apply(:export_data?) end test '#submit_workflow?' do - assert @policy.submit_workflow? + assert @policy.apply(:submit_workflow?) end test '#view_attachments?' do - assert @policy.view_attachments? + assert @policy.apply(:view_attachments?) end test '#create_attachment?' do - assert @policy.create_attachment? + assert @policy.apply(:create_attachment?) end test '#destroy_attachment?' do - assert @policy.destroy_attachment? + assert @policy.apply(:destroy_attachment?) end test 'scope' do diff --git a/test/policies/sample_policy_test.rb b/test/policies/sample_policy_test.rb index 3c8ed551eb..d9bf28aa88 100644 --- a/test/policies/sample_policy_test.rb +++ b/test/policies/sample_policy_test.rb @@ -10,7 +10,7 @@ def setup end test '#destroy_attachment?' do - assert @policy.destroy_attachment? + assert @policy.apply(:destroy_attachment?) end test 'scope' do diff --git a/test/policies/user_policy_test.rb b/test/policies/user_policy_test.rb index 916f88c3c8..044f7ec681 100644 --- a/test/policies/user_policy_test.rb +++ b/test/policies/user_policy_test.rb @@ -9,34 +9,34 @@ def setup end test '#update?' do - assert @policy.update? + assert @policy.apply(:update?) end test '#edit?' do - assert @policy.edit? + assert @policy.apply(:edit?) end test '#destroy?' do - assert @policy.destroy? + assert @policy.apply(:destroy?) end test '#revoke?' do - assert @policy.revoke? + assert @policy.apply(:revoke?) end test '#read?' do - assert @policy.read? + assert @policy.apply(:read?) end test '#index?' do - assert @policy.index? + assert @policy.apply(:index?) end test '#new?' do - assert @policy.new? + assert @policy.apply(:new?) end test '#create?' do - assert @policy.create? + assert @policy.apply(:create?) end end diff --git a/test/policies/workflow_execution_policy_test.rb b/test/policies/workflow_execution_policy_test.rb index 1c9c51583d..34c300f145 100644 --- a/test/policies/workflow_execution_policy_test.rb +++ b/test/policies/workflow_execution_policy_test.rb @@ -4,85 +4,84 @@ class WorkflowExecutionPolicyTest < ActiveSupport::TestCase def setup + @details = {} @user = users(:john_doe) @automation_bot_user = users(:project1_automation_bot) @workflow_execution = workflow_executions(:irida_next_example_prepared) @policy = WorkflowExecutionPolicy.new(@workflow_execution, user: @user) - - @details = {} end test '#read?' do - assert @policy.read? + assert @policy.apply(:read?) user = users(:ryan_doe) policy = WorkflowExecutionPolicy.new(@workflow_execution, user:) - assert policy.read? + assert policy.apply(:read?) user = users(:project1_automation_bot) user_incorrect_permissions = users(:micha_doe) workflow_execution = workflow_executions(:automated_workflow_execution) policy = WorkflowExecutionPolicy.new(workflow_execution, user:) - assert policy.read? + assert policy.apply(:read?) policy = WorkflowExecutionPolicy.new(workflow_execution, user: @user) - assert policy.read? + assert policy.apply(:read?) policy = WorkflowExecutionPolicy.new(workflow_execution, user: user_incorrect_permissions) - assert_not policy.read? + assert_not policy.apply(:read?) end test '#create?' do - assert @policy.create? + assert @policy.apply(:create?) user_incorrect_permissions = users(:ryan_doe) workflow_execution = workflow_executions(:automated_workflow_execution) policy = WorkflowExecutionPolicy.new(workflow_execution, user: user_incorrect_permissions) - assert_not policy.create? + assert_not policy.apply(:create?) end test '#cancel?' do - assert @policy.cancel? + assert @policy.apply(:cancel?) user = users(:project1_automation_bot) workflow_execution = workflow_executions(:automated_workflow_execution) policy = WorkflowExecutionPolicy.new(workflow_execution, user:) - assert policy.cancel? + assert policy.apply(:cancel?) automated_workflow_execution = workflow_executions(:automated_workflow_execution) policy = WorkflowExecutionPolicy.new(automated_workflow_execution, user: @user) - assert policy.cancel? + assert policy.apply(:cancel?) user_incorrect_permissions = users(:ryan_doe) policy = WorkflowExecutionPolicy.new(workflow_execution, user: user_incorrect_permissions) - assert_not policy.cancel? + assert_not policy.apply(:cancel?) end test '#destroy?' do - assert @policy.destroy? + assert @policy.apply(:destroy?) user = users(:project1_automation_bot) user_incorrect_permissions = users(:ryan_doe) workflow_execution = workflow_executions(:automated_workflow_execution) policy = WorkflowExecutionPolicy.new(workflow_execution, user:) - assert policy.destroy? + assert policy.apply(:destroy?) policy = WorkflowExecutionPolicy.new(workflow_execution, user: @user) - assert policy.destroy? + assert policy.apply(:destroy?) policy = WorkflowExecutionPolicy.new(workflow_execution, user: user_incorrect_permissions) - assert_not policy.destroy? + assert_not policy.apply(:destroy?) end test 'automated scope' do