Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Er 506 registration journey #368

Merged
merged 13 commits into from
Nov 11, 2022
2 changes: 1 addition & 1 deletion app/assets/stylesheets/autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
.autocomplete__option:hover {
background-color: govuk-colour('blue');
border-color: govuk-colour('blue');
color: govuk-color('white');
color: govuk-colour('white');
outline: 0
}

Expand Down
7 changes: 6 additions & 1 deletion app/controllers/registration/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ def next_action
def complete_registration
track('user_registration', success: true)
current_user.update! registration_complete: true
redirect_to my_modules_path, notice: t('.complete')
if current_user.display_whats_new?
current_user.update! display_whats_new: false
redirect_to static_path('whats-new'), notice: t('.complete')
else
redirect_to my_modules_path, notice: t('.complete')
end
end

# @see Auditing
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ class Users::SessionsController < Devise::SessionsController

def after_sign_in_path_for(resource)
if resource.registration_complete?
if resource.display_whats_new
if resource.display_whats_new?
resource.display_whats_new = false
resource.save!
static_path('whats-new')
else
my_modules_path
end
elsif resource.private_beta_registration_complete?
static_path('new_registration')
static_path('new-registration')
else
edit_registration_name_path
end
Expand Down
4 changes: 2 additions & 2 deletions app/forms/users/setting_type_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def save
setting_type_id: setting_type_id,
setting_type: object.name,
}
update_attributes[:local_authority] = nil unless setting_type.local_authority_next?
update_attributes[:role_type] = nil unless setting_type.role_type_next?
update_attributes[:local_authority] = 'Not applicable' unless setting_type.local_authority_next?
update_attributes[:role_type] = 'Not applicable' unless setting_type.role_type_next?
user.update(update_attributes)
user.save(validate: false)
end
Expand Down
3 changes: 0 additions & 3 deletions app/views/static/new_registration.html.slim
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.govuk-grid-row
.govuk-grid-column-two-thirds-from-desktop
= govuk_back_link href: root_path

h1= t('.heading')

.content.gem-c-govspeak
= translate_markdown t('.content')

Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ en:
heading: Where do you work?
body: Enter the type of setting or organisation where you work.
button: Continue
update:
complete: Thank you for creating a child development training account. You can now start the first module.
local_authorities:
edit:
heading: What local authority area do you work in?
Expand Down Expand Up @@ -449,3 +451,4 @@ en:
terms-and-conditions: Terms and conditions
whats-new: What's new
sitemap: Sitemap
new-registration: Update your registration details
15 changes: 13 additions & 2 deletions config/locales/static/new_registration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
en:
static:
new_registration:
heading: Please update your registration
heading: Update your registration details
content: |
We've updated our registration process.
You need to update your registration details to access the Early Years Child Development Training course.

We've changed the information we are asking for you to give to register for and account.
Our <a class='govuk-link' href='/privacy-policy'>privacy policy</a> explains how we will use this information.

We are no longer collecting the Ofsted number or postcode for your setting. If you previously gave this information, we have deleted it from our records.

We will now ask you to tell us:

* the type of setting you work in - we have added more options for you to choose from
* your local authority
* your job role
15 changes: 15 additions & 0 deletions db/migrate/20221110104509_remove_attributes_from_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class RemoveAttributesFromUsers < ActiveRecord::Migration[7.0]
def up
change_table :users, bulk: true do |t|
t.remove :postcode
t.remove :ofsted_number
end
end

def down
change_table :users, bulk: true do |t|
t.string :postcode
t.string :ofsted_number
end
end
end
4 changes: 1 addition & 3 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions db/seeds/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@ completed@example.com:
role_type: <%= RoleType.first.name %>
# optional
local_authority: local authority

private-beta-completed@example.com:
password: <%= ENV.fetch('USER_PASSWORD', 'StrongPassword') %>
confirmed_at: <%= 1.year.ago %>
terms_and_conditions_agreed_at: <%= 1.year.ago %>
private_beta_registration_complete: true
# mandatory if "registration_complete"
first_name: Private beta Demo
last_name: DemoUser
setting_type: 'school'
# optional

whats-new-private-beta-completed@example.com:
password: <%= ENV.fetch('USER_PASSWORD', 'StrongPassword') %>
confirmed_at: <%= 1.year.ago %>
display_whats_new: true
terms_and_conditions_agreed_at: <%= 1.year.ago %>
private_beta_registration_complete: true
# mandatory if "registration_complete"
first_name: Private beta Demo
last_name: DemoUser
setting_type: 'school'
# optional
23 changes: 23 additions & 0 deletions spec/controllers/users/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rails_helper'

RSpec.describe Users::SessionsController, type: :controller do
before { request.env['devise.mapping'] = Devise.mappings[:user] }

it 'redirects to my modules for registered user' do
user = create :user, :registered
post :create, params: { user: { email: user.email, password: 'StrongPassword123' } }
expect(response).to redirect_to(my_modules_path)
end

it 'redirects to whats new for registered user with flag turned on' do
user = create :user, :registered, display_whats_new: true
post :create, params: { user: { email: user.email, password: 'StrongPassword123' } }
expect(response).to redirect_to(static_path('whats-new'))
end

it 'redirects to new registration if previously registered' do
user = create :user, :registered, registration_complete: false, private_beta_registration_complete: true
post :create, params: { user: { email: user.email, password: 'StrongPassword123' } }
expect(response).to redirect_to(static_path('new-registration'))
end
end
5 changes: 0 additions & 5 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
terms_and_conditions_agreed_at { Date.new(2000, 0o1, 0o1) }
end

trait :completed do
registered
ofsted_number { 'EY123456' }
end

trait :name do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
Expand Down
4 changes: 2 additions & 2 deletions spec/forms/users/setting_type_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

form.save
expect(user.setting_type).to eq('Department for Education')
expect(user.local_authority).to eq(nil)
expect(user.role_type).to eq(nil)
expect(user.local_authority).to eq('Not applicable')
expect(user.role_type).to eq('Not applicable')
end
# rubocop:enable Rails/SaveBang
end
Expand Down
6 changes: 3 additions & 3 deletions spec/support/shared/with_events.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RSpec.shared_context 'with events' do
let(:user) { create(:user, :completed) }
let(:user1) { create(:user, :completed) }
let(:user2) { create(:user, :completed) }
let(:user) { create(:user, :registered) }
let(:user1) { create(:user, :registered) }
let(:user2) { create(:user, :registered) }

let(:events) do
Ahoy::Event.where(user_id: user.id).where_properties(training_module_id: module_name)
Expand Down
1 change: 1 addition & 0 deletions spec/system/page_title_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
it { expect(static_path('privacy-policy')).to have_page_title 'Privacy policy' }
it { expect(static_path('terms-and-conditions')).to have_page_title 'Terms and conditions' }
it { expect(static_path('whats-new')).to have_page_title "What's new" }
it { expect(static_path('new-registration')).to have_page_title 'Update your registration details' }

context 'and is confirmed' do
let(:user) { create(:user, :confirmed) }
Expand Down
4 changes: 2 additions & 2 deletions spec/system/whats_new_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include_context 'with user'

context 'when existing user' do
let(:user) { create :user, :completed, :display_whats_new }
let(:user) { create :user, :registered, :display_whats_new }

context "and 'whats new' page has not been viewed" do
it "visits what's new page after sign in" do
Expand All @@ -13,7 +13,7 @@
end

context "and 'whats new' page has been viewed" do
let(:user) { create :user, :completed, :display_whats_new }
let(:user) { create :user, :registered, :display_whats_new }

it "does not visit what's new page after sign in" do
click_on 'Sign out'
Expand Down