diff --git a/app/controllers/assessor_interface/professional_standing_requests_controller.rb b/app/controllers/assessor_interface/professional_standing_requests_controller.rb index 18554b9e74..3346576e54 100644 --- a/app/controllers/assessor_interface/professional_standing_requests_controller.rb +++ b/app/controllers/assessor_interface/professional_standing_requests_controller.rb @@ -5,7 +5,7 @@ class ProfessionalStandingRequestsController < BaseController before_action :set_variables def edit_location - authorize [:assessor_interface, professional_standing_request] + authorize [:assessor_interface, professional_standing_request], :show? @form = ProfessionalStandingRequestLocationForm.new( @@ -18,7 +18,7 @@ def edit_location end def update_location - authorize [:assessor_interface, professional_standing_request] + authorize [:assessor_interface, professional_standing_request], :show? @form = ProfessionalStandingRequestLocationForm.new( diff --git a/app/policies/assessor_interface/professional_standing_request_policy.rb b/app/policies/assessor_interface/professional_standing_request_policy.rb index 8ac8ca37df..8d432bba50 100644 --- a/app/policies/assessor_interface/professional_standing_request_policy.rb +++ b/app/policies/assessor_interface/professional_standing_request_policy.rb @@ -1,11 +1,21 @@ # frozen_string_literal: true class AssessorInterface::ProfessionalStandingRequestPolicy < ApplicationPolicy - def update_location? + def show? true end - alias_method :edit_location?, :update_location? + def update_request? + user.verify_permission + end + + alias_method :edit_request?, :update_request? + + def update_verify? + user.verify_permission + end + + alias_method :edit_verify?, :update_verify? def update_review? user.award_decline_permission diff --git a/spec/factories/staff.rb b/spec/factories/staff.rb index 8d6feea803..b663b885e4 100644 --- a/spec/factories/staff.rb +++ b/spec/factories/staff.rb @@ -80,7 +80,7 @@ support_console_permission { true } end - trait :with_verification_permission do + trait :with_verify_permission do verify_permission { true } end diff --git a/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb b/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb index a8e67ab6da..4f987d815b 100644 --- a/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb +++ b/spec/policies/assessor_interface/professional_standing_request_policy_spec.rb @@ -21,7 +21,7 @@ subject(:show?) { policy.show? } let(:user) { create(:staff, :confirmed) } - it { is_expected.to be false } + it { is_expected.to be true } end describe "#create?" do @@ -52,18 +52,24 @@ it { is_expected.to be false } end - describe "#update_location?" do - subject(:update_location?) { policy.update_location? } + describe "#update_request?" do + subject(:update_request?) { policy.update_request? } + it_behaves_like "a policy method requiring the verify permission" + end - let(:user) { create(:staff, :confirmed) } - it { is_expected.to be true } + describe "#edit_request?" do + subject(:edit_request?) { policy.edit_request? } + it_behaves_like "a policy method requiring the verify permission" end - describe "#edit_review?" do - subject(:edit_location?) { policy.edit_location? } + describe "#update_verify?" do + subject(:update_review?) { policy.update_verify? } + it_behaves_like "a policy method requiring the verify permission" + end - let(:user) { create(:staff, :confirmed) } - it { is_expected.to be true } + describe "#edit_verify?" do + subject(:edit_review?) { policy.edit_verify? } + it_behaves_like "a policy method requiring the verify permission" end describe "#update_review?" do diff --git a/spec/support/shared_examples/policy.rb b/spec/support/shared_examples/policy.rb index c1872f4e67..393cec6722 100644 --- a/spec/support/shared_examples/policy.rb +++ b/spec/support/shared_examples/policy.rb @@ -64,26 +64,38 @@ end end -RSpec.shared_examples "a policy method requiring the withdraw permission" do +RSpec.shared_examples "a policy method requiring the support console permission" do context "without permission" do let(:user) { create(:staff) } it { is_expected.to be false } end context "with permission" do - let(:user) { create(:staff, :with_withdraw_permission) } + let(:user) { create(:staff, :with_support_console_permission) } it { is_expected.to be true } end end -RSpec.shared_examples "a policy method requiring the support console permission" do +RSpec.shared_examples "a policy method requiring the verify permission" do context "without permission" do let(:user) { create(:staff) } it { is_expected.to be false } end context "with permission" do - let(:user) { create(:staff, :with_support_console_permission) } + let(:user) { create(:staff, :with_verify_permission) } + it { is_expected.to be true } + end +end + +RSpec.shared_examples "a policy method requiring the withdraw permission" do + context "without permission" do + let(:user) { create(:staff) } + it { is_expected.to be false } + end + + context "with permission" do + let(:user) { create(:staff, :with_withdraw_permission) } it { is_expected.to be true } end end