-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented UI for Unsubscribing Candidates
- Loading branch information
1 parent
c2c147f
commit 26ee4ba
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
app/controllers/support_interface/candidates/bulk_unsubscribes_controller.rb
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,22 @@ | ||
class SupportInterface::Candidates::BulkUnsubscribesController < SupportInterface::SupportInterfaceController | ||
def new | ||
@bulk_unsubscribe_form = SupportInterface::Candidates::BulkUnsubscribeForm.new | ||
end | ||
|
||
def create | ||
@bulk_unsubscribe_form = SupportInterface::Candidates::BulkUnsubscribeForm.new(bulk_unsubscribe_params) | ||
|
||
if @bulk_unsubscribe_form.save | ||
flash[:success] = 'Candidates unsubscribed' | ||
redirect_to support_interface_path | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
private | ||
|
||
def bulk_unsubscribe_params | ||
params.expect(bulk_unsubscribe: [:email_addresses]) | ||
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
20 changes: 20 additions & 0 deletions
20
app/views/support_interface/candidates/bulk_unsubscribes/new.html.erb
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,20 @@ | ||
<% content_for :browser_title, "Bulk unsubscribe candidates" %> | ||
|
||
<%= render 'support_interface/candidates/candidates_navigation', title: 'Bulk unsubscribe candidates' %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with model: @bulk_unsubscribe_form, scope: :bulk_unsubscribe, url: support_interface_bulk_unsubscribe_path do |form| %> | ||
<%= form.govuk_error_summary %> | ||
|
||
<h1 class='govuk-heading-l'>Unsubscribe candidates</h1> | ||
|
||
<%= form.govuk_text_area :email_addresses, | ||
rows: 5, | ||
label: { text: 'Email addresses', size: 's' }, | ||
hint: { text: 'Enter email address to be unsubscribed, use a new line for each email address. You can also copy and paste directly from a spreadsheet.' } %> | ||
|
||
<%= form.govuk_submit 'Continue' %> | ||
<% 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
59 changes: 59 additions & 0 deletions
59
spec/system/support_interface/bulk_unsubscribe_candidates_spec.rb
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,59 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'bulk unsubscribe Candidates' do | ||
include DfESignInHelpers | ||
|
||
scenario 'bulk unsubscribe candidates', :with_audited do | ||
given_i_am_a_support_user | ||
and_there_are_candidates_in_the_system | ||
and_i_visit_the_bulk_unsubscribe_page | ||
|
||
when_i_click_continue | ||
then_i_see_bulk_unsubscribe_form_validation_error | ||
|
||
when_i_enter_the_email_addresses | ||
and_i_click_continue | ||
then_i_can_see_candidates_are_unsubscribed | ||
end | ||
|
||
private | ||
|
||
def given_i_am_a_support_user | ||
sign_in_as_support_user | ||
end | ||
|
||
def and_there_are_candidates_in_the_system | ||
@candidate_1 = create(:candidate, email_address: 'candidate_1@email.address') | ||
@candidate_2 = create(:candidate, email_address: 'candidate_2@email.address') | ||
@candidate_3 = create(:candidate, email_address: 'candidate_3@email.address') | ||
end | ||
|
||
def and_i_visit_the_bulk_unsubscribe_page | ||
visit support_interface_path | ||
click_on 'Bulk unsubscribe candidates' | ||
end | ||
|
||
def when_i_click_continue | ||
click_on 'Continue' | ||
end | ||
|
||
alias_method :and_i_click_continue, :when_i_click_continue | ||
|
||
def then_i_see_bulk_unsubscribe_form_validation_error | ||
expect(page).to have_content("can't be blank") | ||
end | ||
|
||
def when_i_enter_the_email_addresses | ||
fill_in 'Email addresses', with: ' | ||
candidate_1@email.address | ||
candidate_3@email.address | ||
' | ||
end | ||
|
||
def then_i_can_see_candidates_are_unsubscribed | ||
expect(page).to have_content('Candidates unsubscribed') | ||
expect(@candidate_1.reload).to be_unsubscribed_from_emails | ||
expect(@candidate_2.reload).not_to be_unsubscribed_from_emails | ||
expect(@candidate_3.reload).to be_unsubscribed_from_emails | ||
end | ||
end |