From 3c381e35325f1da3a14968075d0e63388f69761a Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 5 Mar 2024 04:46:02 +0000 Subject: [PATCH] Throw together temporary version of unsubscribe page --- .../_tailwind/alerts/unsubscribe.html.erb | 24 ++++++++++++ spec/features/manage_alerts_spec.rb | 38 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 app/views/_tailwind/alerts/unsubscribe.html.erb diff --git a/app/views/_tailwind/alerts/unsubscribe.html.erb b/app/views/_tailwind/alerts/unsubscribe.html.erb new file mode 100644 index 000000000..07099f2f5 --- /dev/null +++ b/app/views/_tailwind/alerts/unsubscribe.html.erb @@ -0,0 +1,24 @@ +<% content_for :page_title, "Unsubscribed" %> + +<%# TODO: This page needs an actual proper design %> +<%# TODO: What shall we do if the user is actually logged in when they're on this page? %> +<%= render Tailwind::Heading.new(tag: :h1).with_content("You have been unsubscribed") %> + +<% if @alert %> +

+ You will no longer receive email alerts for any planning applications we find near + <%= @alert.address %> + (within <%= meters_in_words(@alert.radius_meters.to_f) %>). +

+

+ If this was a mistake + <%# TODO: The url below will get redirected. Send to correct path %> + <%= pa_link_to "you could always create a new alert for the same address", new_alert_path(address: @alert.address) %> +

+<% else %> +

+ If this was a mistake + <%# TODO: The url below will get redirected. Send to correct path %> + <%= pa_link_to "you could always create a new alert", new_alert_path %> +

+<% end %> diff --git a/spec/features/manage_alerts_spec.rb b/spec/features/manage_alerts_spec.rb index 62c711d8e..1c2a86f88 100644 --- a/spec/features/manage_alerts_spec.rb +++ b/spec/features/manage_alerts_spec.rb @@ -19,6 +19,44 @@ user: User.find_by(email: "example@example.com"))).to be_nil end + describe "Unsubscribe from an email alert in the new design" do + let(:user) { create(:confirmed_user, tailwind_theme: true, name: "Jane Ng") } + let(:alert) do + # Adding arbitrary coordinates so that geocoding is not carried out + create(:alert, + address: "24 Bruce Rd, Glenbrook", + user: create(:user, email: "example@example.com"), + radius_meters: Alert::DEFAULT_RADIUS, lat: 1.0, lng: 1.0) + end + + before do + sign_in user + visit unsubscribe_alert_path(confirm_id: alert.confirm_id) + end + + # rubocop:disable RSpec/NoExpectationExample + it "renders a snapshot for a visual diff", js: true do + page.percy_snapshot("Alert unsubscribe") + end + # rubocop:enable RSpec/NoExpectationExample + end + + describe "Unsubscribe from a non-existent email alert in the new design" do + let(:user) { create(:confirmed_user, tailwind_theme: true, name: "Jane Ng") } + + before do + sign_in user + # This is an invalid confirm_id + visit unsubscribe_alert_path(confirm_id: "abcd") + end + + # rubocop:disable RSpec/NoExpectationExample + it "renders a snapshot for a visual diff", js: true do + page.percy_snapshot("Alert unsubscribe invalid") + end + # rubocop:enable RSpec/NoExpectationExample + end + it "Change size of email alert" do user = create(:confirmed_user, email: "example@example.com") alert = create(:alert,