-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
182 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class UnsubscribeController < ApplicationController | ||
def show | ||
@form = Unsubscribe::ConfirmationForm.new(form_params) | ||
|
||
if @form.reminder.nil? | ||
render "subscription_not_found" | ||
end | ||
end | ||
|
||
def create | ||
@form = Unsubscribe::ConfirmationForm.new(form_params) | ||
|
||
if @form.reminder.nil? | ||
head :bad_request | ||
else | ||
@form.reminder.destroy | ||
end | ||
end | ||
|
||
private | ||
|
||
def form_params | ||
params.permit([:id]) | ||
end | ||
|
||
def current_journey_routing_name | ||
params[:journey] | ||
end | ||
helper_method :current_journey_routing_name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Unsubscribe | ||
class ConfirmationForm | ||
include ActiveModel::Model | ||
include ActiveModel::Attributes | ||
|
||
attribute :id, :string | ||
|
||
def reminder | ||
@reminder ||= Reminder.find_by(id:) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= content_for(:page_title) { "Unsubscribe" } %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= govuk_panel(title_text: "Unsubscribe complete") %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%= content_for(:page_title) { "Unsubscribe" } %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with model: @form, | ||
url: unsubscribe_index_path, | ||
scope: "", | ||
builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> | ||
|
||
<%= f.hidden_field :id %> | ||
|
||
<h1 class="govuk-heading-l"> | ||
Are you sure you wish to unsubscribe from your reminder? | ||
</h1> | ||
|
||
<%= f.govuk_submit "Unsubscribe" %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l"> | ||
Subscription not found | ||
</h1> | ||
|
||
<p class="govuk-body"> | ||
Your subscription could not be found. Either you have already unsubscribed or please ensure you have copied your unsubscribe link correctly. | ||
</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rails_helper" | ||
|
||
RSpec.feature "unsubscribe from reminders" do | ||
let(:reminder) do | ||
create( | ||
:reminder, | ||
journey_class: Journeys::FurtherEducationPayments.to_s | ||
) | ||
end | ||
|
||
scenario "happy path" do | ||
visit "/#{reminder.journey::ROUTING_NAME}/unsubscribe/reminders/#{reminder.id}" | ||
expect(page).to have_content "Are you sure you wish to unsub" | ||
|
||
expect { | ||
click_button("Unsubscribe") | ||
}.to change(Reminder, :count).by(-1) | ||
|
||
expect(page).to have_content "Unsubscribe complete" | ||
end | ||
|
||
scenario "when reminder does not exist" do | ||
visit "/#{reminder.journey::ROUTING_NAME}/unsubscribe/reminders/idonotexist" | ||
expect(page).to have_content "Subscription not found" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.