Skip to content

Commit

Permalink
Throw together temporary version of unsubscribe page
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Mar 5, 2024
1 parent 5358b21 commit 3c381e3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/views/_tailwind/alerts/unsubscribe.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
<p class="mt-8 text-2xl text-navy">
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) %>).
</p>
<p class="mt-8 text-2xl text-navy">
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) %>
</p>
<% else %>
<p class="mt-8 text-2xl text-navy">
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 %>
</p>
<% end %>
38 changes: 38 additions & 0 deletions spec/features/manage_alerts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,44 @@
user: User.find_by(email: "[email protected]"))).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: "[email protected]"),
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: "[email protected]")
alert = create(:alert,
Expand Down

0 comments on commit 3c381e3

Please sign in to comment.