Skip to content

Commit

Permalink
Move policy to SAR
Browse files Browse the repository at this point in the history
  • Loading branch information
vertism committed Jan 23, 2025
1 parent 4a17f59 commit 907b2c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
5 changes: 0 additions & 5 deletions app/policies/case/ico/base_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ def can_respond?
clear_failed_checks
check_can_trigger_event(:respond)
end

def can_set_outcome?
clear_failed_checks
user.in?(self.case.approving_team_users)
end
end
5 changes: 5 additions & 0 deletions app/policies/case/ico/sar_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ def resolve
def show?
defer_to_existing_policy(Case::SARPolicy, :show?)
end

def can_set_outcome?
clear_failed_checks
user.in?(self.case.approving_team_users)
end
end
20 changes: 20 additions & 0 deletions spec/policies/case/ico/sar_policy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "rails_helper"

RSpec.describe Case::ICO::SARPolicy do
subject { described_class }

let(:manager) { create :manager }

describe Case::ICO::SARPolicy::Scope do
Expand Down Expand Up @@ -33,4 +35,22 @@
Pundit.policy(manager, Case::ICO::SAR).show?
end
end

permissions :can_set_outcome? do
let(:case_with_response) { create :case_with_response }
let(:dacu_disclosure) { find_or_create :team_dacu_disclosure }
let(:approver) { dacu_disclosure.approvers.first }
let(:managing_team) { find_or_create :team_dacu }
let(:manager) { managing_team.managers.first }
let(:responding_team) { find_or_create :foi_responding_team }
let(:responder) { responding_team.responders.first }

before do
case_with_response.approving_teams << dacu_disclosure
end

it { is_expected.not_to permit(manager, case_with_response) }
it { is_expected.not_to permit(responder, case_with_response) }
it { is_expected.to permit(approver, case_with_response) }
end
end

0 comments on commit 907b2c4

Please sign in to comment.