-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new policy for verifying reference requests.
- Loading branch information
1 parent
9bd3520
commit c7cf492
Showing
5 changed files
with
84 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/policies/assessor_interface/reference_request_policy.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
class AssessorInterface::ReferenceRequestPolicy < ApplicationPolicy | ||
def index? | ||
user.assess_permission || user.verify_permission | ||
end | ||
|
||
def edit? | ||
user.assess_permission || user.verify_permission || | ||
user.change_work_history_permission | ||
end | ||
|
||
def update? | ||
user.assess_permission || user.verify_permission | ||
end | ||
end |
59 changes: 59 additions & 0 deletions
59
spec/policies/assessor_interface/reference_request_policy_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe AssessorInterface::ReferenceRequestPolicy do | ||
it_behaves_like "a policy" | ||
|
||
let(:user) { nil } | ||
let(:record) { nil } | ||
|
||
subject(:policy) { described_class.new(user, record) } | ||
|
||
describe "#index?" do | ||
subject(:index?) { policy.index? } | ||
it_behaves_like "a policy method requiring the assess permission" | ||
it_behaves_like "a policy method requiring the verify permission" | ||
end | ||
|
||
describe "#show?" do | ||
subject(:show?) { policy.show? } | ||
|
||
let(:user) { create(:staff, :confirmed) } | ||
it { is_expected.to be false } | ||
end | ||
|
||
describe "#create?" do | ||
subject(:create?) { policy.create? } | ||
|
||
let(:user) { create(:staff, :confirmed) } | ||
it { is_expected.to be false } | ||
end | ||
|
||
describe "#new?" do | ||
subject(:new?) { policy.new? } | ||
|
||
let(:user) { create(:staff, :confirmed) } | ||
it { is_expected.to be false } | ||
end | ||
|
||
describe "#update?" do | ||
subject(:update?) { policy.update? } | ||
it_behaves_like "a policy method requiring the assess permission" | ||
it_behaves_like "a policy method requiring the verify permission" | ||
end | ||
|
||
describe "#edit?" do | ||
subject(:edit?) { policy.edit? } | ||
it_behaves_like "a policy method requiring the assess permission" | ||
it_behaves_like "a policy method requiring the change work history permission" | ||
it_behaves_like "a policy method requiring the verify permission" | ||
end | ||
|
||
describe "#destroy?" do | ||
subject(:destroy?) { policy.destroy? } | ||
|
||
let(:user) { create(:staff, :confirmed) } | ||
it { is_expected.to be false } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters