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

P20-851: Fix LTI Confirmation mail #57956

Merged
merged 1 commit into from
Apr 11, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dashboard/app/mailers/lti_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class LtiMailer < ApplicationMailer
default from: 'Code.org <noreply@code.org>'
@catalog_url = CDO.studio_url('/catalog')

# Email an LMS admin after they create an LTI integration
def lti_integration_confirmation(admin_email)
@catalog_url = CDO.studio_url('/catalog')
mail to: admin_email, subject: I18n.t('lti.integration.mailer_confirmation_subject')
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%p
!= I18n.t('lti.integration.mailer_confirmation_body', lms_guides: SharedConstants::LMS_LINKS.INTEGRATION_GUIDE_URL, catalog_url: @catalog_url, markdown: true)
!= I18n.t('lti.integration.mailer_confirmation_body', integration_guide_url: SharedConstants::LMS_LINKS.INTEGRATION_GUIDE_URL, course_offering_url: @catalog_url, markdown: true)
%br
%p
= t('lti.integration.mailer_confirmation_signature')
Expand Down
39 changes: 33 additions & 6 deletions dashboard/test/mailers/lti_mailer_test.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
require 'test_helper'

class LtiMailerTest < ActionMailer::TestCase
test 'lti integration confirmation' do
admin_email = 'admin@test.com'
mail = LtiMailer.lti_integration_confirmation(admin_email)
class IntegrationConfirmationTest < ActionMailer::TestCase
setup do
@admin_email = 'admin@test.com'
@mail = LtiMailer.lti_integration_confirmation(@admin_email)
end

assert_equal I18n.t('lti.integration.mailer_confirmation_subject'), mail.subject
assert_equal [admin_email], mail.to
assert_equal ['noreply@code.org'], mail.from
test 'lti_integration_confirmation - should have correct subject' do
assert_equal 'Code.org has completed your LMS registration request', @mail.subject
end

test 'lti_integration_confirmation - should have correct recipient' do
assert_equal [@admin_email], @mail.to
end

test 'lti_integration_confirmation - should have correct sender' do
assert_equal '"Code.org" <noreply@code.org>', @mail[:from].decoded
assert_equal ['noreply@code.org'], @mail.from
end

test 'lti_integration_confirmation - should contain "LMS integration guides" link' do
expected_link = <<~HTML.strip
<a href="https://support.code.org/hc/en-us/articles/23120014459405-Learning-Management-System-LMS-and-Single-Sign-On-SSO-Integrations-and-Support-for-Code-org">LMS integration guides</a>
HTML

assert_includes @mail.body, expected_link
end

test 'lti_integration_confirmation - should contain "course offerings" link' do
expected_link = <<~HTML.strip
<a href="//test-studio.code.org/catalog">course offerings</a>
HTML

assert_includes @mail.body, expected_link
end
end
end