Skip to content

Commit

Permalink
Use shared displayable_address method for displaying addresses
Browse files Browse the repository at this point in the history
The `address_lines` method is another example of duplication which can now be replaced by the method added in DEFRA/waste-carriers-engine#281
  • Loading branch information
irisfaraway committed Oct 10, 2018
1 parent 908ff26 commit 0a68d3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
14 changes: 2 additions & 12 deletions app/helpers/transient_registrations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,11 @@ def display_current_workflow_state
end

def display_registered_address
address_lines(@transient_registration.registered_address)
displayable_address(@transient_registration.registered_address)
end

def display_contact_address
address_lines(@transient_registration.contact_address)
end

def address_lines(address)
[address.address_line_1,
address.address_line_2,
address.address_line_3,
address.address_line_4,
address.town_city,
address.postcode,
address.country].compact
displayable_address(@transient_registration.contact_address)
end

def key_people_with_conviction_search_results?
Expand Down
6 changes: 4 additions & 2 deletions spec/helpers/transient_registrations_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
end

it "returns the required values in an array" do
array = ["Foo Gardens",
array = ["42",
"Foo Gardens",
"Baz City",
"FA1 1KE"]
expect(helper.display_registered_address).to eq(array)
Expand All @@ -71,7 +72,8 @@
end

it "returns the required values in an array" do
array = ["Foo Gardens",
array = ["42",
"Foo Gardens",
"Baz City",
"FA1 1KE"]
expect(helper.display_contact_address).to eq(array)
Expand Down

0 comments on commit 0a68d3c

Please sign in to comment.