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

Require a note after further information requests #2289

Merged
merged 1 commit into from
Jul 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class AssessorInterface::AssessmentDeclarationDeclineForm
attribute :recommendation_assessor_note, :string

validates :declaration, presence: true
validates :recommendation_assessor_note,
presence: true,
if: -> { assessment.selected_failure_reasons_empty? }
validates :recommendation_assessor_note, presence: true, if: :note_required?

def save
return false unless valid?
Expand All @@ -24,4 +22,9 @@ def save

true
end

def note_required?
assessment.sections.all? { _1.selected_failure_reasons.empty? } ||
assessment.further_information_requests.exists?(review_passed: false)
end
end
4 changes: 0 additions & 4 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,6 @@ def available_recommendations
end
end

def selected_failure_reasons_empty?
sections.all? { |section| section.selected_failure_reasons.empty? }
end

def all_preliminary_sections_passed?
sections.preliminary.all?(&:passed?)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
)
end
end

context "when further information failed" do
before do
create(:further_information_request, :review_failed, assessment:)
end

it { is_expected.to validate_presence_of(:recommendation_assessor_note) }
end
end

describe "#save" do
Expand Down
18 changes: 0 additions & 18 deletions spec/models/assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,4 @@
it { is_expected.to include("request_further_information") }
end
end

describe "#selected_failure_reasons_empty?" do
subject(:selected_failure_reasons_empty?) do
assessment.selected_failure_reasons_empty?
end

context "with no failure reasons" do
it { is_expected.to be true }
end

context "with failure reasons" do
before do
create(:assessment_section, :declines_with_already_qts, assessment:)
end

it { is_expected.to be false }
end
end
end
Loading