Skip to content

Commit

Permalink
Refactor WorkHistoryPolicy
Browse files Browse the repository at this point in the history
This uses the shared examples in the tests.
  • Loading branch information
thomasleese committed Dec 7, 2023
1 parent 088d057 commit aa64cc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module AssessorInterface
class WorkHistoriesController < BaseController
def edit
authorize [:assessor_interface, work_history]
before_action { authorize [:assessor_interface, work_history] }

def edit
@form =
WorkHistoryContactForm.new(
work_history:,
Expand All @@ -16,8 +16,6 @@ def edit
end

def update
authorize [:assessor_interface, work_history]

@form =
WorkHistoryContactForm.new(
form_params.merge(work_history:, user: current_staff),
Expand Down
20 changes: 5 additions & 15 deletions spec/policies/assessor_interface/work_history_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,22 @@

describe "#index?" do
subject(:index?) { policy.index? }

let(:user) { create(:staff, :confirmed) }
it { is_expected.to be false }
it_behaves_like "a policy method without permission"
end

describe "#show?" do
subject(:show?) { policy.show? }

let(:user) { create(:staff, :confirmed) }
it { is_expected.to be false }
it_behaves_like "a policy method without permission"
end

describe "#create?" do
subject(:create?) { policy.create? }

let(:user) { create(:staff, :confirmed) }
it { is_expected.to be false }
it_behaves_like "a policy method without permission"
end

describe "#new?" do
subject(:new?) { policy.new? }

let(:user) { create(:staff, :confirmed) }
it { is_expected.to be false }
it_behaves_like "a policy method without permission"
end

describe "#update?" do
Expand All @@ -50,8 +42,6 @@

describe "#destroy?" do
subject(:destroy?) { policy.destroy? }

let(:user) { create(:staff, :confirmed) }
it { is_expected.to be false }
it_behaves_like "a policy method without permission"
end
end

0 comments on commit aa64cc7

Please sign in to comment.