Skip to content

Commit 8135e63

Browse files
committed
Update content for opt in page and add additional testing for user research contact preference
This commit adds the updated content for the contact for research page, as well as addidng tests for the contact for research controller It also adds a feature test to test the functionality of add a user research contact preference
1 parent 7fc70e3 commit 8135e63

6 files changed

Lines changed: 92 additions & 25 deletions

File tree

app/controllers/account/contact_for_research_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module Account
2-
class ContactForResearchController < ApplicationController
2+
class ContactForResearchController < WebController
33
include AfterSignInPathHelper
44

5-
# before_action :redirect_contact_for_research_set
65
skip_before_action :redirect_if_account_not_completed
76

87
def edit

app/views/account/contact_for_research/edit.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
<%=t("page_titles.account_contact_for_research")%>
1010
</h1>
1111

12-
<%= t(".content_html") %>
13-
14-
<%= f.govuk_collection_radio_buttons :research_contact_status, @contact_for_research_input.values, :itself, nil %>
12+
<%= f.govuk_collection_radio_buttons :research_contact_status, @contact_for_research_input.values, :itself, legend: nil, hint:{ text: @hint } %>
1513

1614
<%= f.govuk_submit t('continue') %>
1715
<% end %>

config/locales/en.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
---
22
en:
33
account:
4-
contact_for_research:
5-
edit:
6-
content_html: |
7-
<p>GOV.UK Forms needs your help to improve and to make sure our platform works well for the people who use it. You can help by agreeing to take part in user research.</p>
8-
<p>If you select yes, you will get a confirmation email with a link to our sign up form. When you’ve completed the form, your name will be added to a list that we’ll use to recruit research participants. Your details will be stored in compliance with GDPR.</p>
9-
<p>We’ll only contact you about upcoming research or to verify that your details are up to date.</p>
10-
<p>We might invite you to:</p>
11-
12-
<ul class="govuk-list govuk-list--bullet">
13-
<li>try out new things we are working on</li>
14-
<li>answer questions by survey or email</li>
15-
<li>talk to us about how you work with forms</li>
16-
</ul>
17-
18-
<p>You can always say no to an invite and you can ask to be taken off our list at any time.</p>
194
organisation_details_summary: If your organisation is not listed
205
organisation_text_html: |
216
<p>If you’re from a central government organisation that publishes content on the GOV.UK website but your organisation is not listed, please %{contact_link}.</p>
@@ -1169,7 +1154,7 @@ en:
11691154
length: Length
11701155
page_titles:
11711156
access_denied: You do not have permission to access GOV.UK Forms
1172-
account_contact_for_research: Choose to take part in user research
1157+
account_contact_for_research: Can we send you an email with information about taking part in user research to improve GOV.UK Forms?
11731158
account_name: Enter your name
11741159
account_organisation: Select your organisation
11751160
account_terms_of_use: Terms of use

config/locales/input_objects/contact_for_research.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ en:
66
account/contact_for_research_input:
77
attributes:
88
research_contact_status:
9-
blank: Choose if you want to sign up to take part in research
9+
blank: Select ‘Yes’ if you’re happy for us to send you an email with information about taking part in user research
1010
helpers:
11+
hint:
12+
account_contact_for_research_input:
13+
research_contact_status: This is not a commitment to take part. If you say ‘yes’ we’ll send you an email with more details about what’s involved and how to sign up.
1114
label:
1215
account_contact_for_research_input:
1316
research_contact_status_options:
1417
consented: 'Yes'
1518
declined: 'No'
16-
legend:
17-
account_contact_for_research_input:
18-
research_contact_status: Do you want to sign up to take part in user research?
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require "rails_helper"
2+
3+
feature "Add user research contact preference", type: :feature do
4+
let(:user) { create(:user, name: "Test name", research_contact_status: "to_be_asked") }
5+
6+
before do
7+
login_as user
8+
end
9+
10+
describe "user adds their user research content preference" do
11+
scenario "user can update their preference" do
12+
when_i_visit_the_edit_page
13+
when_i_choose_yes
14+
then_i_should_be_redirecteed_to_the_groups_page
15+
end
16+
end
17+
18+
def when_i_visit_the_edit_page
19+
visit edit_account_contact_for_research_path
20+
end
21+
22+
def when_i_choose_yes
23+
choose "Yes"
24+
click_button "Continue"
25+
end
26+
27+
def then_i_should_be_redirecteed_to_the_groups_page
28+
expect(page.find("h1")).to have_text "Your groups"
29+
end
30+
end
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
require "rails_helper"
2+
3+
describe Account::ContactForResearchController do
4+
let(:user) { create(:user, name: nil, research_contact_status: "to_be_asked") }
5+
6+
before do
7+
login_as user
8+
end
9+
10+
describe "GET #edit" do
11+
context "when user adds a research contact status" do
12+
it "assigns a new ContactForResearchInput to @contact_for_research_input" do
13+
get edit_account_contact_for_research_path
14+
expect(assigns(:contact_for_research_input)).to be_a(Account::ContactForResearchInput)
15+
end
16+
end
17+
end
18+
19+
describe "PUT #update" do
20+
context "with valid params" do
21+
let(:valid_params) { { account_contact_for_research_input: { research_contact_status: "consented" } } }
22+
23+
before do
24+
# rubocop:disable RSpec/AnyInstance
25+
allow_any_instance_of(AfterSignInPathHelper).to receive(:after_sign_in_next_path).and_return("/next-path")
26+
# rubocop:enable RSpec/AnyInstance
27+
end
28+
29+
it "updates the user's research contact status" do
30+
put account_contact_for_research_path, params: valid_params
31+
expect(user.reload.research_contact_status).to eq("consented")
32+
end
33+
34+
it "redirects to the root path" do
35+
put account_contact_for_research_path, params: valid_params
36+
expect(response).to redirect_to("/next-path")
37+
end
38+
end
39+
40+
context "with invalid params" do
41+
let(:invalid_params) { { account_contact_for_research_input: { research_contact_status: "" } } }
42+
43+
it "does not update the user's research contact status" do
44+
put account_contact_for_research_path, params: invalid_params
45+
expect(user.reload.research_contact_status).to eq("to_be_asked")
46+
end
47+
48+
it "renders the edit template" do
49+
put account_contact_for_research_path, params: invalid_params
50+
expect(response).to have_http_status(:unprocessable_content)
51+
expect(response).to render_template(:edit)
52+
end
53+
end
54+
end
55+
end

0 commit comments

Comments
 (0)