Browse Source

Add banner

pull/1793/head
Kat 3 years ago
parent
commit
b91a47cee5
  1. 30
      app/controllers/form_controller.rb
  2. 4
      spec/features/lettings_log_spec.rb
  3. 4
      spec/features/sales_log_spec.rb

30
app/controllers/form_controller.rb

@ -161,18 +161,6 @@ private
params[@log.model_name.param_key]["interruption_page_referrer_type"].presence params[@log.model_name.param_key]["interruption_page_referrer_type"].presence
end end
def correcting_duplicate_logs_redirect_path
class_name = @log.class.name.underscore
original_log = current_user.send(class_name.pluralize).find_by(id: from_referrer_query("original_log_id"))
if current_user.send(class_name.pluralize).duplicate_logs(original_log).count.positive?
send("#{class_name}_duplicate_logs_path", original_log, original_log_id: original_log.id)
else
send("#{class_name}_duplicate_logs_path", "#{class_name}_id".to_sym => from_referrer_query("remaining_duplicate_id"), original_log_id: from_referrer_query("original_log_id"))
end
end
def successful_redirect_path def successful_redirect_path
if FeatureToggle.deduplication_flow_enabled? if FeatureToggle.deduplication_flow_enabled?
if is_referrer_type?("duplicate_logs") if is_referrer_type?("duplicate_logs")
@ -253,4 +241,22 @@ private
end end
CONFIRMATION_PAGE_IDS = %w[uprn_confirmation].freeze CONFIRMATION_PAGE_IDS = %w[uprn_confirmation].freeze
def correcting_duplicate_logs_redirect_path
class_name = @log.class.name.underscore
original_log = current_user.send(class_name.pluralize).find_by(id: from_referrer_query("original_log_id"))
if current_user.send(class_name.pluralize).duplicate_logs(original_log).count.positive?
flash[:notice] = deduplication_success_banner unless current_user.send(class_name.pluralize).duplicate_logs(@log).count.positive?
send("#{class_name}_duplicate_logs_path", original_log, original_log_id: original_log.id)
else
flash[:notice] = deduplication_success_banner
send("#{class_name}_duplicate_logs_path", "#{class_name}_id".to_sym => from_referrer_query("remaining_duplicate_id"), original_log_id: from_referrer_query("original_log_id"))
end
end
def deduplication_success_banner
"<a class=\"govuk-notification-banner__link govuk-!-font-weight-bold\" href=\"#{send("#{@log.class.name.underscore}_path", @log)}\">Log #{@log.id}</a> is no longer a duplicate and has been removed from the list".html_safe
end
end end

4
spec/features/lettings_log_spec.rb

@ -513,6 +513,8 @@ RSpec.describe "Lettings Log Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}") expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}")
expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}") expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_content("Log #{duplicate_log.id} is no longer a duplicate and has been removed from the list")
end end
it "allows deduplicating logs by changing the answers on the original log" do it "allows deduplicating logs by changing the answers on the original log" do
@ -521,6 +523,8 @@ RSpec.describe "Lettings Log Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/lettings-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}") expect(page).to have_current_path("/lettings-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}")
expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}") expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_content("Log #{lettings_log.id} is no longer a duplicate and has been removed from the list")
end end
end end
end end

4
spec/features/sales_log_spec.rb

@ -252,6 +252,8 @@ RSpec.describe "Sales Log Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}")
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_content("Log #{duplicate_log.id} is no longer a duplicate and has been removed from the list")
end end
it "allows deduplicating logs by changing the answers on the original log" do it "allows deduplicating logs by changing the answers on the original log" do
@ -260,6 +262,8 @@ RSpec.describe "Sales Log Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/sales-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") expect(page).to have_current_path("/sales-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{sales_log.id}")
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success")
expect(page).to have_content("Log #{sales_log.id} is no longer a duplicate and has been removed from the list")
end end
end end
end end

Loading…
Cancel
Save