Skip to content

Commit

Permalink
Merge pull request #1971 from DFE-Digital/fix/dao-revocation-notes-sh…
Browse files Browse the repository at this point in the history
…owing-on-all-projects

Fix: DAO revocation notes on all projects
  • Loading branch information
mec authored Oct 22, 2024
2 parents e62dd4c + 4d8f859 commit 610a814
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- removed trust from the RPA radio button options text for conversions

### Fixed

- The note added during DAO revocation only appears on the associated project
notes, instead of all projects.

## [Release 92][release-92]

### Changed
Expand Down
4 changes: 1 addition & 3 deletions app/models/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class Note < ApplicationRecord
default_scope { order(created_at: "desc") }

scope :project_level_notes, ->(project) {
where(project: project)
.where(notable_type: nil).where(task_identifier: nil)
.or(where.not(notable_type: "SignificantDateHistoryReason"))
where(project: project).where(notable_type: [nil, "DaoRevocationReason"]).where(task_identifier: nil)
}

# When no value is provided, Rails will store an empty string. Instead, we want to ensure
Expand Down
7 changes: 7 additions & 0 deletions spec/models/note_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
end

describe "project_level_notes" do
let!(:other_project) { create(:conversion_project) }
let!(:project) { create(:conversion_project) }
let!(:project_level_note) { create(:note, project: project) }
let!(:task_level_note) { create(:note, task_identifier: "handover", project: project) }
Expand All @@ -57,6 +58,12 @@
expect(subject).to include project_level_note
expect(subject).to include dao_revocation_note
end

it "only include notes for the correct project" do
subject = Note.project_level_notes(other_project)

expect(subject).not_to include dao_revocation_note
end
end
end

Expand Down

0 comments on commit 610a814

Please sign in to comment.