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

Add ConsentMethodForm #2010

Merged
merged 1 commit into from
Feb 19, 2024
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
20 changes: 20 additions & 0 deletions app/forms/assessor_interface/consent_method_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class AssessorInterface::ConsentMethodForm
include ActiveModel::Model
include ActiveModel::Attributes

attr_accessor :qualification_request
validates :qualification_request, presence: true

attribute :consent_method
validates :consent_method,
presence: true,
inclusion: %w[signed_ecctis signed_institution unsigned]

def save
return false if invalid?
qualification_request.update!(consent_method:)
true
end
end
4 changes: 4 additions & 0 deletions config/locales/assessor_interface.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ en:
blank: Enter the maximum age
subject_1:
blank: Enter the subject
assessor_interface/consent_method_form:
attributes:
consent_method:
inclusion: Tell us which method of consent is required for this qualification
assessor_interface/create_note_form:
attributes:
text:
Expand Down
5 changes: 5 additions & 0 deletions config/locales/helpers.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ en:
subject_2: Subject 2 (optional)
subject_3: Subject 3 (optional)
subjects_note: '<strong class="govuk-!-font-weight-bold">Internal note:</strong> If you''ve edited the subjects please explain why (optional)'
assessor_interface_consent_method_form:
consent_method_options:
unsigned: Non-signed TRA consent document
signed_ecctis: Ecctis standard consent document with signature
signed_institution: Institution’s custom consent document
assessor_interface_create_note_form:
text: Add a note to this application
assessor_interface_filter_form:
Expand Down
32 changes: 32 additions & 0 deletions spec/forms/assessor_interface/consent_method_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe AssessorInterface::ConsentMethodForm, type: :model do
let(:qualification_request) { create(:qualification_request) }
let(:consent_method) { "unsigned" }

subject(:form) do
described_class.new(qualification_request:, consent_method:)
end

describe "validations" do
it { is_expected.to validate_presence_of(:qualification_request) }
it { is_expected.to validate_presence_of(:consent_method) }
it do
is_expected.to validate_inclusion_of(:consent_method).in_array(
%w[signed_ecctis signed_institution unsigned],
)
end
end

describe "#save" do
subject(:save) { form.save }

it "sets the consent method" do
expect { save }.to change(qualification_request, :consent_method).to(
"unsigned",
)
end
end
end
Loading