Skip to content

Commit

Permalink
Don't import revoked_reason to transient_registrations (#251)
Browse files Browse the repository at this point in the history
This attribute is used to store reasons for approving or rejecting a registration if it was flagged with possible conviction matches. Because these convictions would be three years old at least, they are no longer relevant to the renewal, so we should not import the old revoked_reason as it's not related.
  • Loading branch information
irisfaraway committed Aug 29, 2018
1 parent ad6efb6 commit 444f096
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/waste_carriers_engine/transient_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,20 @@ def copy_data_from_registration
end

def remove_invalid_attributes
remove_invalid_phone_numbers
remove_revoked_reason
end

def remove_invalid_phone_numbers
validator = PhoneNumberValidator.new(attributes: :phone_number)
return if validator.validate_each(self, :phone_number, phone_number)
self.phone_number = nil
end

def remove_revoked_reason
metaData.revoked_reason = nil
end

# Check if a transient renewal already exists for this registration so we don't have
# multiple renewals in progress at once
def no_renewal_in_progress?
Expand Down
13 changes: 13 additions & 0 deletions spec/models/waste_carriers_engine/transient_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ module WasteCarriersEngine
expect(transient_registration.phone_number).to eq(nil)
end
end

context "when the source registration has a revoked_reason" do
let(:registration) do
create(:registration,
:has_required_data,
metaData: build(:metaData, revoked_reason: "foo"))
end

it "does not import it" do
transient_registration = TransientRegistration.new(reg_identifier: registration.reg_identifier)
expect(transient_registration.metaData.revoked_reason).to eq(nil)
end
end
end

describe "#reg_identifier" do
Expand Down

0 comments on commit 444f096

Please sign in to comment.