diff options
Diffstat (limited to 'app/mailers/previews/notify_preview.rb')
-rw-r--r-- | app/mailers/previews/notify_preview.rb | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index 7ed594bf571..d91f69cdd4b 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -60,6 +60,14 @@ class NotifyPreview < ActionMailer::Preview end end + def access_token_created_email + Notify.access_token_created_email(user, 'token_name').message + end + + def access_token_revoked_email + Notify.access_token_revoked_email(user, 'token_name').message + end + def new_mention_in_merge_request_email Notify.new_mention_in_merge_request_email(user.id, merge_request.id, user.id).message end @@ -84,6 +92,10 @@ class NotifyPreview < ActionMailer::Preview Notify.import_issues_csv_email(user.id, project.id, { success: 3, errors: [5, 6, 7], valid_file: true }) end + def import_work_items_csv_email + Notify.import_work_items_csv_email(user.id, project.id, { success: 4, error_lines: [2, 3, 4], parse_error: false }) + end + def issues_csv_email Notify.issues_csv_email(user, project, '1997,Ford,E350', { truncated: false, rows_expected: 3, rows_written: 3 }).message end @@ -201,6 +213,52 @@ class NotifyPreview < ActionMailer::Preview Notify.service_desk_thank_you_email(issue.id).message end + def service_desk_custom_email_verification_email + cleanup do + setup_service_desk_custom_email_objects + + Notify.service_desk_custom_email_verification_email(service_desk_setting).message + end + end + + def service_desk_verification_triggered_email + cleanup do + setup_service_desk_custom_email_objects + + Notify.service_desk_verification_triggered_email(service_desk_setting, 'owner@example.com').message + end + end + + def service_desk_verification_result_email_for_verified_state + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.mark_as_finished! + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + + def service_desk_verification_result_email_for_incorrect_token_error + service_desk_verification_result_email_for_error_state(error: :incorrect_token) + end + + def service_desk_verification_result_email_for_incorrect_from_error + service_desk_verification_result_email_for_error_state(error: :incorrect_from) + end + + def service_desk_verification_result_email_for_mail_not_received_within_timeframe_error + service_desk_verification_result_email_for_error_state(error: :mail_not_received_within_timeframe) + end + + def service_desk_verification_result_email_for_invalid_credentials_error + service_desk_verification_result_email_for_error_state(error: :invalid_credentials) + end + + def service_desk_verification_result_email_for_smtp_host_issue_error + service_desk_verification_result_email_for_error_state(error: :smtp_host_issue) + end + def merge_when_pipeline_succeeds_email Notify.merge_when_pipeline_succeeds_email(user.id, merge_request.id, user.id).message end @@ -235,6 +293,53 @@ class NotifyPreview < ActionMailer::Preview @project ||= Project.first end + def service_desk_verification_result_email_for_error_state(error:) + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.mark_as_failed!(error) + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + + def setup_service_desk_custom_email_objects + # Call accessors to ensure objects have been created + custom_email_credential + custom_email_verification + + # Update associations in projects, because we access + # custom_email_credential and custom_email_verification via project + project.reset + end + + def custom_email_verification + @custom_email_verification ||= project.service_desk_custom_email_verification || ServiceDesk::CustomEmailVerification.create!( + project: project, + token: 'XXXXXXXXXXXX', + triggerer: user, + triggered_at: Time.current, + state: 'started' + ) + end + + def custom_email_credential + @custom_email_credential ||= project.service_desk_custom_email_credential || ServiceDesk::CustomEmailCredential.create!( + project: project, + smtp_address: 'smtp.gmail.com', # Use gmail, because Gitlab::UrlBlocker resolves DNS + smtp_port: 587, + smtp_username: 'user@gmail.com', + smtp_password: 'supersecret' + ) + end + + def service_desk_setting + @service_desk_setting ||= project.service_desk_setting || ServiceDeskSetting.create!( + project: project, + custom_email: 'user@gmail.com' + ) + end + def issue @issue ||= project.issues.first end |