Skip to content

Commit

Permalink
Merge branch '4160-duplicate-requests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Nov 12, 2024
2 parents ed8e9fa + 2fb1d1b commit 0319900
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/info_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def self._extract_id_hash_from_email(incoming_email)
# TODO: this *should* also check outgoing message joined to is an initial
# request (rather than follow up)
def self.find_existing(title, public_body_id, body)
conditions = { title: title&.strip, public_body_id: public_body_id }
conditions = { title: title&.squish, public_body_id: public_body_id }

InfoRequest.
includes(:outgoing_messages).
Expand Down
16 changes: 16 additions & 0 deletions spec/models/info_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,22 @@
"Some information please")).
to eq(info_request)
end

it 'compress whitespace within the title when considering duplicates' do
info_request = FactoryBot.create(:info_request, title: 'Foo bar')
expect(InfoRequest.find_existing('Foo bar',
info_request.public_body_id,
'Some information please')).
to eq(info_request)
end

it 'compress newlines within the title when considering duplicates' do
info_request = FactoryBot.create(:info_request, title: 'Foo bar')
expect(InfoRequest.find_existing("Foo\r\nbar",
info_request.public_body_id,
'Some information please')).
to eq(info_request)
end
end

describe '#find_existing_outgoing_message' do
Expand Down

0 comments on commit 0319900

Please sign in to comment.