Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 8 additions & 126 deletions app/services/analytics_events.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/services/form_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def success?

def to_h
hash = { success: success }
hash[:errors] = (!defined?(@error_details) && errors).presence if !serialize_error_details_only?
hash[:errors] = errors.presence if !defined?(@error_details) && !serialize_error_details_only?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

hash[:error_details] = flatten_details(error_details) if error_details.present?
hash.merge!(extra)
hash
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/add_user_email_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
it 'returns a successful result' do
expect(submit.to_h).to eq(
success: true,
errors: nil,
domain_name: 'example.com',
in_select_email_flow: false,
user_id: user.uuid,
Expand Down Expand Up @@ -109,7 +108,6 @@
it 'includes extra analytics in result for flow value' do
expect(submit.to_h).to eq(
success: true,
errors: nil,
domain_name: 'example.com',
in_select_email_flow: true,
user_id: user.uuid,
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/openid_connect_authorize_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
it 'is successful' do
expect(result.to_h).to eq(
success: true,
errors: nil,
client_id: client_id,
prompt: 'select_account',
allow_prompt_login: true,
Expand All @@ -66,7 +65,6 @@
it 'is unsuccessful and has error messages' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { response_type: { inclusion: true } },
client_id: client_id,
prompt: 'select_account',
Expand Down
3 changes: 0 additions & 3 deletions spec/forms/openid_connect_token_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@

expect(submission.to_h).to eq(
success: true,
errors: nil,
client_id: client_id,
user_id: user.uuid,
code_digest: Digest::SHA256.hexdigest(code),
Expand All @@ -396,7 +395,6 @@

expect(submission.to_h).to include(
success: false,
errors: nil,
error_details: hash_including(*form.errors.attribute_names),
client_id: nil,
user_id: nil,
Expand All @@ -413,7 +411,6 @@

expect(submission.to_h).to include(
success: false,
errors: nil,
error_details: hash_including(:grant_type),
client_id: client_id,
user_id: user.uuid,
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/otp_delivery_selection_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

expect(subject.submit(otp_delivery_preference: 'sms', resend: 'true').to_h).to eq(
success: true,
errors: nil,
**extra,
)
end
Expand All @@ -57,7 +56,6 @@

expect(subject.submit(otp_delivery_preference: 'foo').to_h).to include(
success: false,
errors: nil,
error_details: {
otp_delivery_preference: { inclusion: true },
phone: { blank: true },
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/password_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
let(:expected_response) do
{
success: true,
errors: nil,
user_id: user.uuid,
request_id_present: true,
}
Expand All @@ -134,7 +133,6 @@
let(:expected_response) do
{
success: true,
errors: nil,
user_id: user.uuid,
request_id_present: true,
}
Expand Down
4 changes: 0 additions & 4 deletions spec/forms/password_reset_email_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

expect(subject.submit.to_h).to eq(
success: true,
errors: nil,
user_id: user.uuid,
confirmed: true,
active_profile: false,
Expand All @@ -27,7 +26,6 @@
it 'returns hash with properties about the event and the nonexistent user' do
expect(subject.submit.to_h).to eq(
success: true,
errors: nil,
user_id: 'nonexistent-uuid',
confirmed: false,
active_profile: false,
Expand All @@ -41,7 +39,6 @@

expect(subject.submit.to_h).to include(
success: false,
errors: nil,
error_details: { email: { invalid: true } },
user_id: 'nonexistent-uuid',
confirmed: false,
Expand All @@ -54,7 +51,6 @@

expect(subject.submit.to_h).to include(
success: false,
errors: nil,
error_details: { email: { domain: true } },
user_id: 'nonexistent-uuid',
confirmed: false,
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/personal_key_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

expect(form.submit.to_h).to eq(
success: true,
errors: nil,
)
expect(user.reload.encrypted_recovery_code_digest).to eq old_code
end
Expand All @@ -26,7 +25,6 @@

expect(form.submit.to_h).to include(
success: false,
errors: nil,
error_details: { personal_key: { personal_key_incorrect: true } },
)
expect(user.encrypted_recovery_code_digest).to_not be_nil
Expand Down
12 changes: 1 addition & 11 deletions spec/forms/register_user_email_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
end

it 'sets success to true to prevent revealing account existence' do
expect(subject.submit(params).to_h).to eq(success: true, errors: nil, **extra_params)
expect(subject.submit(params).to_h).to eq(success: true, **extra_params)
expect(subject.email).to eq registered_email_address
expect_delivered_email_count(1)
expect_delivered_email(
Expand Down Expand Up @@ -168,7 +168,6 @@

expect(result).to eq(
success: true,
errors: nil,
**extra_params,
)
end
Expand Down Expand Up @@ -246,7 +245,6 @@

expect(submit_form.to_h).to eq(
success: true,
errors: nil,
**extra,
)
end
Expand Down Expand Up @@ -290,7 +288,6 @@

expect(subject.submit(email: invalid_email, terms_accepted: '1').to_h).to include(
success: false,
errors: nil,
error_details: { email: { invalid: true } },
**extra,
)
Expand All @@ -307,7 +304,6 @@

expect(subject.submit(email: 'test@çà.com', terms_accepted: '1').to_h).to include(
success: false,
errors: nil,
error_details: { email: { domain: true } },
**extra,
)
Expand All @@ -329,7 +325,6 @@

expect(subject.submit(email: blocked_email, terms_accepted: '1').to_h).to include(
success: false,
errors: nil,
error_details: { email: { t('valid_email.validations.email.invalid') => true } },
**extra,
)
Expand All @@ -344,7 +339,6 @@

expect(subject.submit(email: blocked_email, terms_accepted: '1').to_h).to include(
success: false,
errors: nil,
error_details: { email: { t('valid_email.validations.email.invalid') => true } },
email_already_exists: false,
rate_limited: false,
Expand All @@ -365,7 +359,6 @@

expect(result.to_h).to eq(
success: true,
errors: nil,
email_already_exists: false,
rate_limited: false,
user_id: User.find_with_email(email).uuid,
Expand All @@ -384,7 +377,6 @@

expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { terms_accepted: { terms: true } },
email_already_exists: false,
rate_limited: false,
Expand Down Expand Up @@ -437,7 +429,6 @@

expect(submit_form.to_h).to eq(
success: true,
errors: nil,
**extra,
)

Expand Down Expand Up @@ -465,7 +456,6 @@

expect(submit_form.to_h).to eq(
success: true,
errors: nil,
**extra,
)
end
Expand Down
10 changes: 0 additions & 10 deletions spec/forms/reset_password_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { reset_password_token: { token_expired: true } },
user_id: '123',
profile_deactivated: false,
Expand All @@ -53,7 +52,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: {
password: { too_short: true },
password_confirmation: { too_short: true },
Expand All @@ -76,7 +74,6 @@

expect(result.to_h).to eq(
success: true,
errors: nil,
user_id: '123',
profile_deactivated: false,
pending_profile_invalidated: false,
Expand All @@ -95,7 +92,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: {
password: { too_short: true },
password_confirmation: { too_short: true },
Expand All @@ -115,7 +111,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { reset_password_token: { invalid_token: true } },
user_id: nil,
profile_deactivated: false,
Expand Down Expand Up @@ -270,7 +265,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { reset_password_token: { token_expired: true } },
user_id: '123',
profile_deactivated: false,
Expand All @@ -290,7 +284,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: {
password: { too_short: true },
password_confirmation: { too_short: true },
Expand All @@ -313,7 +306,6 @@

expect(result.to_h).to eq(
success: true,
errors: nil,
user_id: '123',
profile_deactivated: false,
pending_profile_invalidated: false,
Expand All @@ -332,7 +324,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: {
password: { too_short: true },
password_confirmation: { too_short: true },
Expand All @@ -352,7 +343,6 @@
it 'returns a hash with errors' do
expect(result.to_h).to eq(
success: false,
errors: nil,
error_details: { reset_password_token: { invalid_token: true } },
user_id: nil,
profile_deactivated: false,
Expand Down
5 changes: 0 additions & 5 deletions spec/forms/totp_setup_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

expect(form.submit.to_h).to eq(
success: true,
errors: nil,
**extra,
)
expect(user.auth_app_configurations.any?).to eq true
Expand All @@ -45,7 +44,6 @@

expect(form.submit.to_h).to include(
success: false,
errors: nil,
**extra,
)
expect(user.auth_app_configurations.any?).to eq false
Expand All @@ -65,7 +63,6 @@

expect(form.submit.to_h).to include(
success: false,
errors: nil,
**extra,
)
expect(user.auth_app_configurations.any?).to eq false
Expand All @@ -80,7 +77,6 @@

expect(form.submit.to_h).to include(
success: false,
errors: nil,
error_details: { name: { blank: true } },
)
expect(user.auth_app_configurations.any?).to eq false
Expand All @@ -95,7 +91,6 @@

expect(form2.submit.to_h).to include(
success: false,
errors: nil,
error_details: { name: { unique_name: true } },
)
end
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/two_factor_login_options_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

expect(subject.submit(selection: 'sms').to_h).to eq(
success: true,
errors: nil,
**extra,
)
end
Expand All @@ -36,7 +35,6 @@

expect(subject.submit(selection: 'foo').to_h).to include(
success: false,
errors: nil,
error_details: { selection: { inclusion: true } },
**extra,
)
Expand Down
2 changes: 0 additions & 2 deletions spec/forms/update_user_password_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

expect(result).to include(
success: false,
errors: nil,
error_details: hash_including(:password, :password_confirmation),
)
end
Expand All @@ -42,7 +41,6 @@
it 'returns FormResponse with success: true' do
expect(subject.submit(params).to_h).to eq(
success: true,
errors: nil,
active_profile_present: false,
pending_profile_present: false,
user_id: user.uuid,
Expand Down
Loading