* Fix typo * Add SMTP configs to Settings::General * Expand Settings's show page * Expand Settings::General's constants * Move smtp_enabled? logic to ApplicationMailer * Apply suggestions from code review Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> * Add missing descriptions and placeholders * Remove production guard clause * Change delivery_method to a callback * Create Settings::SMTP * Run migration * Move constants * Remove SMTP from Settings::General * Create SMTPSettingsController * Add back guard clause * Change which perform_deliveries configuration to use from * Update config/environments/production.rb * Rename migration to singular * Run migration again * Fix name * Alphabetize and add validation for authentication * Move settings and enabled? logic to Settings::SMTP * Change after_action to before_action * Fix broken spec * Fix broken spec * Create SMTP specs * Provide default for port * Create spec for ApplicationMailer * Fix broken spec * Move smtp_enabled? * Search and replace Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Admin Email Tools within User management", type: :system do
|
|
let(:admin) { create(:user, :super_admin) }
|
|
let(:user) { create(:user) }
|
|
let(:email_subject) { "Email subject" }
|
|
let(:email_body) { "Email body" }
|
|
|
|
context "when looking at a user with recorded emails in the admin panel" do
|
|
before do
|
|
allow(ForemInstance).to receive(:smtp_enabled?).and_return(true)
|
|
sign_in admin
|
|
visit admin_user_path(user)
|
|
|
|
# Send the test user an email using the built in form
|
|
within(:css, "#user-email-tools") do
|
|
fill_in("email_subject", with: email_subject)
|
|
fill_in("email_body", with: email_body)
|
|
click_on("Send Email")
|
|
end
|
|
|
|
visit admin_user_path(user)
|
|
end
|
|
|
|
it "shows the email sent to the user" do
|
|
email_tools_section = find("#user-email-tools")
|
|
expect(email_tools_section).to have_text(email_subject)
|
|
end
|
|
|
|
it "redirects and displays the email details" do
|
|
within(:css, "#user-email-tools") do
|
|
all("a.list-group-item-action").first.click
|
|
end
|
|
|
|
expect(page).to have_content(email_subject)
|
|
expect(page).to have_content(email_body)
|
|
expect(page).to have_content("NotifyMailer#user_contact_email")
|
|
expect(page).to have_content(user.email)
|
|
end
|
|
end
|
|
end
|