Skip to content

Send account validation email when pipeline fails

Eugie Limpin requested to merge account-verification-email-experiment into master

What does this MR do and why?

This MR is part of #346233 (closed).

It implements sending of Account Validation email (introduced in !75080 (merged)) when a pipeline fails due to an unverified account (of the pipeline creator).

Why are we sending this email?

We want to check if sending this email increases initial verify usage (see #346233 (closed)).

Note: tracking will be implemented in a separate MR.

Screenshots or screen recordings

  1. Create a project
    GIF 1
  2. Start a pipeline by adding a .gitlab-ci.yml to the project
    GIF 2
  3. Pipeline fails because user's account is not verified
    GIF 3
  4. Account Validation email is sent
    GIF 4

How to set up and validate locally

Set up

  1. Ensure your GDK instance is EE (you might have to upload a License)

  2. Ensure the following feature flags are enabled:

    1. account_validation_email
    2. ci_require_credit_card_on_trial_plan
    # In Rails console (run `bin/rails c` in `/path/to/gitlab-development-kit/gitlab`)
    > Feature.enable(:account_validation_email)
    > Feature.enable(:ci_require_credit_card_on_trial_plan)
  3. Create a test user and group

    # In Rails console
    > user = FactoryBot.create(:user, username: 'user_dec1_1', email: 'user_dec1_1@example.org', password: '12345678')
    # Create a new Group & assign the new user as its owner
    > group = FactoryBot.create(:group)
    > group.add_owner(user)
  4. Create a trial subscription for the group

    # In Rails console
    # Turn on billing features in the app
    > ApplicationSetting.first.update(check_namespace_plan: true)
    # Find or create the Ultimate plan
    > plan = Plan.create_with(title: 'Ultimate (Formerly Gold)').find_or_create_by(name: :ultimate)
    # Create a new trial subscription for the Group
    > GitlabSubscription.create(namespace: group, hosted_plan: plan, seats: 10, start_date: Date.current, end_date: Date.current.advance(years: 1), trial: true, trial_starts_on: Date.current, trial_ends_on: Date.current.advance(days: 30))
  5. Ensure that your test user is opted-in to receive marketing emails Go to http://localhost:3000/-/profile/notifications and check Receive product marketing emails checkbox

    Screenshot Screen_Shot_2021-12-01_at_5.33.28_PM

Validate

  1. Login with your test user

  2. Navigate to the test group

    Group with trial subscription Screen_Shot_2021-12-01_at_8.56.42_PM
  3. Create a project

  4. Add a .gitlab-ci.yml to the project to start a pipeline

    GIF 2
  5. Validate that the pipeline for the commit fails with the reason Pipeline failed due to the user not being verified

    Screenshot Screen_Shot_2021-12-01_at_9.00.08_PM
  6. Go to letter opener (http://127.0.0.1:3000/rails/letter_opener/) and validate that the email has been sent

    Screenshot of the email you should have received Screen_Shot_2021-12-01_at_8.49.21_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports