Skip to content

Commit

Permalink
remove second early years email preference
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-coggin committed Jul 7, 2023
1 parent 4c59374 commit 52686e4
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 187 deletions.
25 changes: 0 additions & 25 deletions app/controllers/registration/early_years_emails_controller.rb

This file was deleted.

6 changes: 5 additions & 1 deletion app/controllers/registration/training_emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ def update
@user_form = Users::TrainingEmailsForm.new(user_params.merge(user: current_user))

if @user_form.save
redirect_to edit_registration_early_years_emails_path
if current_user.registration_complete?
redirect_to my_modules_path, notice: t('.complete_update')
else
complete_registration
end
else
render :edit, status: :unprocessable_entity
end
Expand Down
19 changes: 0 additions & 19 deletions app/forms/users/early_years_emails_form.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def new_setting_type_role_required?

# @return [Boolean]
def email_preferences_complete?
!training_emails.nil? && !early_years_emails.nil?
!training_emails.nil?
end

# @return [Boolean]
Expand Down
14 changes: 0 additions & 14 deletions app/views/registration/early_years_emails/edit.html.slim

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/user/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
- row.with_key { 'Email updates about this training course' }
- row.with_value(text: @user.training_emails ? t('.training_emails_true') : t('.training_emails_false'), classes: ['data-hj-suppress'])
- row.with_action(text: t('links.change'), href: edit_registration_training_emails_path, visually_hidden_text: 'training_emails', html_attributes: { id: :edit_training_emails_registration })
- email_preferences.with_row do |row|
- row.with_key { 'Email updates about early years' }
- row.with_value(text: @user.early_years_emails ? t('.early_years_emails_true') : t('.early_years_emails_false'), classes: ['data-hj-suppress'])
- row.with_action(text: t('links.change'), href: edit_registration_early_years_emails_path, visually_hidden_text: 'early_years_emails', html_attributes: { id: :edit_early_years_emails_registration })


h2.govuk-heading-m Closing your account
Expand Down
4 changes: 0 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ en:
your_email_preferences_html: <h2 class='govuk-heading-m'>Your email preferences</h2>
training_emails_true: You have chosen to receive emails about this training course.
training_emails_false: You have chosen not to receive emails about this training course.
early_years_emails_true: You have chosen to receive early years email updates.
early_years_emails_false: You have chosen not to receive early years email updates.

activemodel:
errors:
Expand Down Expand Up @@ -43,8 +41,6 @@ en:
blank: Enter the local authority of the setting or organisation you work in most of the time.
training_emails:
blank: Choose an option.
early_years_emails:
blank: Choose an option.
activerecord:
errors:
models:
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
resource :role_type, only: %i[edit update], path: 'role-type'
resource :role_type_other, only: %i[edit update], path: 'role-type-other'
resource :training_emails, only: %i[edit update], path: 'training-emails'
resource :early_years_emails, only: %i[edit update], path: 'early-years-emails'
end

resource :user, controller: :user, only: %i[show], path: 'my-account' do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveEarlyYearsEmailPreferencesFromUsers < ActiveRecord::Migration[7.0]
def change
remove_column :users, :early_years_emails, :boolean
end
end
3 changes: 1 addition & 2 deletions db/schema.rb

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

5 changes: 1 addition & 4 deletions lib/update_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ def email_preferences_unsubscribe(emails)
if user.training_emails.nil?
user.training_emails = false
end
if user.early_years_emails.nil?
user.early_years_emails = false
end
user.save!
if user.training_emails.nil? || user.early_years_emails.nil?
if user.training_emails.nil?
puts "User update unsuccessful for #{user.email}"
end
end
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

context 'when confirmed user signed in' do
let(:confirmed_user) { create :user, :confirmed, :name, :emails_opt_in }
let(:confirmed_user) { create :user, :confirmed, :name, :setting_type, :role_type, :emails_opt_in }

before { sign_in confirmed_user }

Expand All @@ -32,7 +32,7 @@
describe 'POST #update' do
it 'succeeds' do
post :update, params: { user: { training_emails: 'true' } }
expect(response).to redirect_to edit_registration_early_years_emails_path
expect(response).to redirect_to my_modules_path
expect(confirmed_user.reload.training_emails).to eq true
end
end
Expand Down
2 changes: 0 additions & 2 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@

trait :emails_opt_in do
training_emails { true }
early_years_emails { true }
end

trait :emails_opt_out do
training_emails { false }
early_years_emails { false }
end
end
end
13 changes: 0 additions & 13 deletions spec/forms/users/early_years_emails_form_spec.rb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/lib/update_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
email_2 = '[email protected]'
update_user.email_preferences_unsubscribe([email_1, email_2])
expect(User.find_by(email: email_1).training_emails).to eq(false)
expect(User.find_by(email: email_1).early_years_emails).to eq(false)
expect(User.find_by(email: email_2).training_emails).to eq(false)
expect(User.find_by(email: email_2).early_years_emails).to eq(false)
end
end

Expand All @@ -37,7 +35,6 @@
email_3 = '[email protected]'
update_user.email_preferences_unsubscribe([email_3])
expect(User.find_by(email: email_3).training_emails).to eq(true)
expect(User.find_by(email: email_3).early_years_emails).to eq(true)
end
end
end
Expand Down
39 changes: 0 additions & 39 deletions spec/requests/registration/early_years_emails_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/requests/registration/training_emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

it 'redirects to my training email preference' do
update_user
expect(response).to redirect_to(edit_registration_early_years_emails_path)
expect(response).to redirect_to(my_modules_path)
end
end
end
Expand Down
11 changes: 0 additions & 11 deletions spec/system/confirmed_user/completing_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@

click_button 'Continue'

expect(page).to have_text('Do you want to get early years email updates from the Department for Education?')

click_button 'Continue'

expect(page).to have_text('There is a problem')
.and have_text('Choose an option.')

choose 'Send me early years email updates'

click_button 'Continue'

expect(page).to have_text('Thank you for creating an Early years child development training account. You can now start the first module.')
end
end

0 comments on commit 52686e4

Please sign in to comment.