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

Fix/ruby 2860 conviction search results #1508

Merged
merged 2 commits into from
Feb 26, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ConvictionSearchResult
embedded_in :past_registration, class_name: "WasteCarriersEngine::PastRegistration"
embedded_in :key_person, class_name: "WasteCarriersEngine::KeyPerson"

field :match_result, type: String
field :match_result, type: String, default: "NO"
field :matching_system, type: String
field :reference, type: String
field :matched_name, type: String
Expand Down
6 changes: 3 additions & 3 deletions app/services/waste_carriers_engine/conviction_data_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def run(transient_registration)
@transient_registration = transient_registration

check_for_matches
add_conviction_sign_off if transient_registration.declared_convictions? || matching_or_unknown_convictions?
add_conviction_sign_off(transient_registration.declared_convictions? || matching_or_unknown_convictions?)
end

private
Expand All @@ -15,9 +15,9 @@ def check_for_matches
WasteCarriersEngine::EntityMatchingService.run(@transient_registration)
end

def add_conviction_sign_off
def add_conviction_sign_off(convictions_present)
conviction_sign_off = ConvictionSignOff.new
conviction_sign_off.confirmed = "no"
conviction_sign_off.confirmed = "no" if convictions_present

@transient_registration.conviction_sign_offs = [conviction_sign_off]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def copy_data_from_transient_registration
renewal_attributes = SafeCopyAttributesService.run(
source_instance: transient_registration,
target_class: Registration,
embedded_documents: %w[addresses metaData financeDetails key_people],
embedded_documents: %w[addresses metaData financeDetails key_people conviction_search_result],
attributes_to_exclude: do_not_copy_attributes
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module WasteCarriersEngine
transient_registration.key_people = [build(:key_person, :unmatched_conviction_search_result)]
end

it "does not create a conviction_search_result" do
it "creates a conviction_search_result without a match" do
conviction_data_service
expect(transient_registration.reload.conviction_sign_offs).not_to exist
expect(transient_registration.reload.conviction_search_result.match_result).to eq "NO"
end
end

Expand All @@ -43,9 +43,9 @@ module WasteCarriersEngine
transient_registration.key_people = [build(:key_person, :unmatched_conviction_search_result)]
end

it "creates a conviction_search_result" do
it "creates a conviction_search_result with a match" do
conviction_data_service
expect(transient_registration.reload.conviction_sign_offs).to exist
expect(transient_registration.reload.conviction_search_result.match_result).to eq "YES"
end
end

Expand Down