Skip to content

Commit

Permalink
Fix broken 'Finished' link on renewal end pages (#647)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/RUBY-859

We spotted that the 'Finished' button on the 'Renewal complete' and 'Renewal received' buttons was not behaving properly. For front office users, we now want to redirect straight to the front office dashboard; for back office users, we want to redirect to the new 'view details' page in the back office.

So we'll just provide a new default method in the engine and let the host apps override it as needed.
  • Loading branch information
irisfaraway committed Jan 24, 2020
1 parent a7ba0e7 commit 22da686
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module WasteCarriersEngine
class RenewalCompleteFormsController < FormsController
helper JourneyLinksHelper

def new
return unless super(RenewalCompleteForm, "renewal_complete_form")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module WasteCarriersEngine
class RenewalReceivedFormsController < FormsController
helper JourneyLinksHelper

def new
super(RenewalReceivedForm, "renewal_received_form")
end
Expand Down
9 changes: 0 additions & 9 deletions app/helpers/waste_carriers_engine/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ def display_pence_as_pounds(value_in_pence)
end
end

def dashboard_link(current_user)
return unless current_user.present?

id = current_user.id
root = Rails.configuration.wcrs_frontend_url
I18n.t("waste_carriers_engine.dashboard_link", root: root, id: id)
# "#{root}/user/#{id}/registrations"
end

def displayable_address(address)
return [] unless address.present?

Expand Down
10 changes: 10 additions & 0 deletions app/helpers/waste_carriers_engine/journey_links_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module WasteCarriersEngine
module JourneyLinksHelper
def renewal_finished_link(*)
# Designed to be overridden in host apps if needed
main_app.root_path
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<p><%= link_to(t(".survey_link_text"), t("layouts.application.feedback_url")) %> <%= t(".survey_link_hint") %></p>

<%= link_to t(".next_button"), dashboard_link(current_user), class: 'button' %>
<%= link_to t(".next_button"), renewal_finished_link(reg_identifier: @renewal_complete_form.reg_identifier), class: 'button' %>
<% end %>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<p><%= link_to(t(".survey_link_text"), t("layouts.application.feedback_url")) %> <%= t(".survey_link_hint") %></p>

<%= link_to t(".next_button"), dashboard_link(current_user), class: 'button' %>
<%= link_to t(".next_button"), renewal_finished_link(reg_identifier: @renewal_received_form.reg_identifier), class: 'button' %>
<% end %>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
en:
waste_carriers_engine:
dashboard_link: "%{root}/user/%{id}/registrations"
errors:
messages:
weak_password: Your password is not strong enough. It must include at least one lowercase letter, uppercase letter and number
Expand Down
12 changes: 0 additions & 12 deletions spec/helpers/waste_carriers_engine/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ module WasteCarriersEngine
end
end

describe "dashboard_link" do
before do
allow(Rails.configuration).to receive(:wcrs_frontend_url).and_return("http://www.example.com")
end

it "returns the correct value" do
user = build(:user)
expected_url = "http://www.example.com/user/#{user.id}/registrations"
expect(helper.dashboard_link(user)).to eq(expected_url)
end
end

describe "displayable_address" do
let(:address) do
build(:address,
Expand Down
13 changes: 13 additions & 0 deletions spec/helpers/waste_carriers_engine/journey_links_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "rails_helper"

module WasteCarriersEngine
RSpec.describe WasteCarriersEngine::JourneyLinksHelper, type: :helper do
describe "renewal_finished_link" do
it "returns the correct value" do
expect(helper.renewal_finished_link).to eq("/")
end
end
end
end

0 comments on commit 22da686

Please sign in to comment.