Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename award/decline permission #1751

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/staff/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def configure_permitted_parameters
:invite,
keys: %i[
name
award_decline_permission
assess_permission
change_name_permission
change_work_history_permission
reverse_decision_permission
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/support_interface/staff_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def load_staff

def staff_params
params.require(:staff).permit(
:award_decline_permission,
:assess_permission,
:change_name_permission,
:change_work_history_permission,
:reverse_decision_permission,
Expand Down
4 changes: 2 additions & 2 deletions app/models/staff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Table name: staff
#
# id :bigint not null, primary key
# award_decline_permission :boolean default(FALSE)
# assess_permission :boolean default(FALSE)
# azure_ad_uid :string
# change_name_permission :boolean default(FALSE), not null
# change_work_history_permission :boolean default(FALSE), not null
Expand Down Expand Up @@ -69,7 +69,7 @@ class Staff < ApplicationRecord

validates :name, presence: true

scope :assessors, -> { where(award_decline_permission: true) }
scope :assessors, -> { where(assess_permission: true) }

def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
Expand Down
2 changes: 1 addition & 1 deletion app/policies/assessor_interface/assessment_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class AssessorInterface::AssessmentPolicy < ApplicationPolicy
def update?
user.award_decline_permission
user.assess_permission
end

def destroy?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class AssessorInterface::AssessmentRecommendationPolicy < ApplicationPolicy
def update?
user.award_decline_permission || user.verify_permission
user.assess_permission || user.verify_permission
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def update_verify?
alias_method :edit_verify?, :update_verify?

def update_review?
user.award_decline_permission
user.assess_permission
end

alias_method :edit_review?, :update_review?
Expand Down
6 changes: 3 additions & 3 deletions app/policies/assessor_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def show?
end

def create?
user.award_decline_permission?
user.assess_permission
end

def update?
user.award_decline_permission?
user.assess_permission
end

def destroy?
user.award_decline_permission?
user.assess_permission
end
end
4 changes: 2 additions & 2 deletions app/views/personas/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

head.with_row do |row|
row.with_cell(header: true, text: "Email")
row.with_cell(header: true, text: "Award/decline")
row.with_cell(header: true, text: "Assess applicants")
row.with_cell(header: true, text: "Change names")
row.with_cell(header: true, text: "Change work history")
row.with_cell(header: true, text: "Reverse decisions")
Expand All @@ -40,7 +40,7 @@
body.with_row do |row|
row.with_cell(text: staff.email)

row.with_cell { govuk_boolean_tag(staff.award_decline_permission) }
row.with_cell { govuk_boolean_tag(staff.assess_permission) }
row.with_cell { govuk_boolean_tag(staff.change_name_permission) }
row.with_cell { govuk_boolean_tag(staff.change_work_history_permission) }
row.with_cell { govuk_boolean_tag(staff.reverse_decision_permission) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= f.govuk_check_boxes_fieldset :permissions do %>
<%= f.govuk_check_box :award_decline_permission, 1, 0, multiple: false,
label: { text: t("activerecord.attributes.staff.award_decline_permission") } %>
<%= f.govuk_check_box :assess_permission, 1, 0, multiple: false,
label: { text: t("activerecord.attributes.staff.assess_permission") } %>

<%= f.govuk_check_box :change_name_permission, 1, 0, multiple: false,
label: { text: t("activerecord.attributes.staff.change_name_permission") } %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/support_interface/staff/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
end

summary_list.with_row do |row|
row.with_key { t("activerecord.attributes.staff.award_decline_permission") }
row.with_value { govuk_boolean_tag(staff.award_decline_permission) }
row.with_key { t("activerecord.attributes.staff.assess_permission") }
row.with_value { govuk_boolean_tag(staff.assess_permission) }
row.with_action(
href: edit_support_interface_staff_path(staff),
visually_hidden_text: t("activerecord.attributes.staff.award_decline_permission")
visually_hidden_text: t("activerecord.attributes.staff.assess_permission")
)
end

Expand Down
2 changes: 1 addition & 1 deletion config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
- work_history_id
- selected_failure_reason_id
:staff:
- award_decline_permission
- assess_permission
- azure_ad_uid
- change_name_permission
- change_work_history_permission
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ en:
activerecord:
attributes:
staff:
award_decline_permission: Award/decline (assessor)
assess_permission: Assess applicants
change_name_permission: Change applicant’s name
change_work_history_permission: Change work history references
reverse_decision_permission: Reverse decisions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RenameStaffAwardDeclinePermission < ActiveRecord::Migration[7.1]
def change
rename_column :staff, :award_decline_permission, :assess_permission
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions lib/tasks/example_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def staff_members
{
name: "Dave Assessor",
email: "[email protected]",
award_decline_permission: true,
assess_permission: true,
change_name_permission: false,
change_work_history_permission: false,
reverse_decision_permission: false,
Expand All @@ -66,7 +66,7 @@ def staff_members
{
name: "Beryl Assessor",
email: "[email protected]",
award_decline_permission: true,
assess_permission: true,
change_name_permission: false,
change_work_history_permission: false,
reverse_decision_permission: false,
Expand All @@ -77,7 +77,7 @@ def staff_members
{
name: "Sally Manager",
email: "[email protected]",
award_decline_permission: false,
assess_permission: false,
change_name_permission: true,
change_work_history_permission: true,
reverse_decision_permission: true,
Expand All @@ -88,7 +88,7 @@ def staff_members
{
name: "Antonio Helpdesk",
email: "[email protected]",
award_decline_permission: false,
assess_permission: false,
change_name_permission: false,
change_work_history_permission: false,
reverse_decision_permission: false,
Expand All @@ -99,7 +99,7 @@ def staff_members
{
name: "Victarion Verifier",
email: "[email protected]",
award_decline_permission: false,
assess_permission: false,
change_name_permission: false,
change_work_history_permission: false,
reverse_decision_permission: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe AssessorInterface::UploadsController, type: :controller do
before { FeatureFlags::FeatureFlag.activate(:service_open) }

let(:staff) { create(:staff, :with_award_decline_permission, :confirmed) }
let(:staff) { create(:staff, :with_assess_permission, :confirmed) }
let(:application_form) { create(:application_form) }

before { sign_in staff, scope: :staff }
Expand Down
6 changes: 3 additions & 3 deletions spec/factories/staff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Table name: staff
#
# id :bigint not null, primary key
# award_decline_permission :boolean default(FALSE)
# assess_permission :boolean default(FALSE)
# azure_ad_uid :string
# change_name_permission :boolean default(FALSE), not null
# change_work_history_permission :boolean default(FALSE), not null
Expand Down Expand Up @@ -60,8 +60,8 @@
confirmed_at { Time.zone.now }
end

trait :with_award_decline_permission do
award_decline_permission { true }
trait :with_assess_permission do
assess_permission { true }
end

trait :with_change_name_permission do
Expand Down
12 changes: 5 additions & 7 deletions spec/models/staff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Table name: staff
#
# id :bigint not null, primary key
# award_decline_permission :boolean default(FALSE)
# assess_permission :boolean default(FALSE)
# azure_ad_uid :string
# change_name_permission :boolean default(FALSE), not null
# change_work_history_permission :boolean default(FALSE), not null
Expand Down Expand Up @@ -72,15 +72,13 @@
describe ".assessors" do
subject { described_class.assessors }

context "when award_decline_permission == true" do
let(:with_award_decline_permission) do
create(:staff, :with_award_decline_permission)
end
context "when assess_permission == true" do
let(:with_assess_permission) { create(:staff, :with_assess_permission) }

it { is_expected.to include(with_award_decline_permission) }
it { is_expected.to include(with_assess_permission) }
end

context "when with_award_decline_permission == false" do
context "when with_assess_permission == false" do
let(:non_assessor) { create(:staff) }

it { is_expected.not_to include(non_assessor) }
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

context "with permission" do
let(:user) { create(:staff, :with_award_decline_permission) }
let(:user) { create(:staff, :with_assess_permission) }
it { is_expected.to be true }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/system_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def given_i_am_authorized_as_an_assessor_user
user =
create(
:staff,
:with_award_decline_permission,
:with_assess_permission,
:confirmed,
name: "Authorized User",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def application_form
alias_method :application_id, :application_form_id

def assessor
create(:staff, :confirmed, :with_award_decline_permission)
create(:staff, :confirmed, :with_assess_permission)
end

def manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def reference_request
end

def assessor
create(:staff, :confirmed, :with_award_decline_permission)
create(:staff, :confirmed, :with_assess_permission)
end

def manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def application_forms

def assessors
@assessors ||= [
create(:staff, :with_award_decline_permission, name: "Fal Staff"),
create(:staff, :with_award_decline_permission, name: "Wag Staff"),
create(:staff, :with_assess_permission, name: "Fal Staff"),
create(:staff, :with_assess_permission, name: "Wag Staff"),
]
end
end
2 changes: 1 addition & 1 deletion spec/system/assessor_interface/reverse_decision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def assessment
delegate :id, to: :assessment, prefix: true

def assessor
create(:staff, :confirmed, :with_award_decline_permission)
create(:staff, :confirmed, :with_assess_permission)
end

def manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def assessment
delegate :id, to: :assessment, prefix: true

def assessor
create(:staff, :confirmed, :with_award_decline_permission)
create(:staff, :confirmed, :with_assess_permission)
end

def manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
end

context "with an assessor user" do
let!(:staff) { create(:staff, :with_award_decline_permission) }
let!(:staff) { create(:staff, :with_assess_permission) }

it { is_expected.to include(staff) }
end
Expand Down
Loading