-
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from helpyio/dev/add-mail-settings
Dev/add mail settings
- Loading branch information
Showing
10 changed files
with
173 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
#class TopicMailer < MandrillMailer::MessageMailer | ||
class TopicMailer < ActionMailer::Base | ||
default from: "#{Settings.admin_email}" | ||
|
||
def new_ticket(topic) | ||
@topic = topic | ||
email_with_name = %("#{topic.user.name}" <#{topic.user.email}>) | ||
mail(to: email_with_name, subject: "[#{AppSettings['settings.site_name']}] ##{topic.id}-#{topic.name}") | ||
mail( | ||
to: email_with_name, | ||
from: %("#{AppSettings['settings.site_name']}" <#{AppSettings['email.admin_email']}>), | ||
subject: "[#{AppSettings['settings.site_name']}] ##{topic.id}-#{topic.name}" | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
class UserMailer < ActionMailer::Base | ||
|
||
default from: Settings.from_email | ||
|
||
def new_user(user, token) | ||
@user = user | ||
@token = token | ||
email_with_name = %("#{user.name}" <#{user.email}>) | ||
mail(to: email_with_name, subject: "Welcome to #{AppSettings['settings.site_name']}") | ||
mail( | ||
to: email_with_name, | ||
from: %("#{AppSettings['settings.site_name']}" <#{AppSettings['email.admin_email']}>), | ||
subject: "Welcome to #{AppSettings['settings.site_name']}" | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,4 +301,50 @@ class AdminControllerTest < ActionController::TestCase | |
assert_equal '1', AppSettings['widget.show_on_support_site'] | ||
end | ||
|
||
test 'an admin should be able to turn email delivery on and off' do | ||
put :update_settings, | ||
'email.send_email' => 'false' | ||
assert_no_difference 'ActionMailer::Base.deliveries.size' do | ||
xhr :post, :create_ticket, topic: { user: { name: 'a user', email: '[email protected]' }, name: 'some new private topic', body: 'some body text', forum_id: 1 }, post: { body: 'this is the body' } | ||
end | ||
end | ||
|
||
test 'an admin should be able to add mail settings' do | ||
put :update_settings, | ||
'email.admin_email' => '[email protected]', | ||
'email.from_email' => '[email protected]', | ||
'email.mail_service' => 'mailgun', | ||
'email.mail_smtp' => 'mail.test.com', | ||
'email.smtp_mail_username' => 'test-login', | ||
'email.smtp_mail_password' => '1234', | ||
'email.mail_port' => '587', | ||
'email.mail_domain' => 'something.com' | ||
assert_redirected_to :admin_settings | ||
|
||
assert_equal '[email protected]', AppSettings['email.admin_email'] | ||
assert_equal '[email protected]', AppSettings['email.from_email'] | ||
assert_equal 'mailgun', AppSettings['email.mail_service'] | ||
assert_equal 'mail.test.com', AppSettings['email.mail_smtp'] | ||
assert_equal 'test-login', AppSettings['email.smtp_mail_username'] | ||
assert_equal '1234', AppSettings['email.smtp_mail_password'] | ||
assert_equal '587', AppSettings['email.mail_port'] | ||
assert_equal 'something.com', AppSettings['email.mail_domain'] | ||
end | ||
|
||
test 'an admin should be able to add a cloudinary key' do | ||
put :update_settings, | ||
'cloudinary.cloud_name' => 'something', | ||
'cloudinary.api_key' => 'something', | ||
'cloudinary.api_secret' => 'something' | ||
assert_redirected_to :admin_settings | ||
|
||
assert_equal 'something', AppSettings['cloudinary.cloud_name'] | ||
assert_equal 'something', AppSettings['cloudinary.api_key'] | ||
assert_equal 'something', AppSettings['cloudinary.api_secret'] | ||
get :settings | ||
assert_equal 'something', Cloudinary.config.cloud_name | ||
assert_equal 'something', Cloudinary.config.api_key | ||
assert_equal 'something', Cloudinary.config.api_secret | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters