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

[#4160] Update InfoRequest.find_existing #8452

Merged
merged 1 commit into from
Nov 12, 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
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
Loading