Optimize: Remove per-language assertions for Mailer tests
I can't find any real reason they are needed at all and were taking a lot of time to run. Results for the test class Before: 56 seconds After: 23 seconds
This commit is contained in:
parent
84cc8ab215
commit
8100ce0ce5
|
@ -24,6 +24,7 @@ class MailerTest < ActiveSupport::TestCase
|
||||||
Setting.host_name = 'mydomain.foo'
|
Setting.host_name = 'mydomain.foo'
|
||||||
Setting.protocol = 'http'
|
Setting.protocol = 'http'
|
||||||
Setting.plain_text_mail = '0'
|
Setting.plain_text_mail = '0'
|
||||||
|
Setting.default_language = 'en'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generated_links_in_emails
|
def test_generated_links_in_emails
|
||||||
|
@ -212,38 +213,25 @@ class MailerTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# test mailer methods for each language
|
|
||||||
def test_issue_add
|
def test_issue_add
|
||||||
issue = Issue.find(1)
|
issue = Issue.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_issue_add(issue, 'dlopper@somenet.foo')
|
assert Mailer.deliver_issue_add(issue, 'dlopper@somenet.foo')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_issue_edit
|
def test_issue_edit
|
||||||
journal = Journal.find(1)
|
journal = Journal.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_issue_edit(journal, "jsmith@somenet.foo")
|
assert Mailer.deliver_issue_edit(journal, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_document_added
|
def test_document_added
|
||||||
document = Document.find(1)
|
document = Document.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_document_added(document, "jsmith@somenet.foo")
|
assert Mailer.deliver_document_added(document, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_attachments_added
|
def test_attachments_added
|
||||||
attachements = [ Attachment.find_by_container_type('Document') ]
|
attachements = [ Attachment.find_by_container_type('Document') ]
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_attachments_added(attachements, "jsmith@somenet.foo")
|
assert Mailer.deliver_attachments_added(attachements, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_version_file_added
|
def test_version_file_added
|
||||||
attachements = [ Attachment.find_by_container_type('Version') ]
|
attachements = [ Attachment.find_by_container_type('Version') ]
|
||||||
|
@ -259,88 +247,58 @@ class MailerTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_news_added
|
def test_news_added
|
||||||
news = News.find(:first)
|
news = News.find(:first)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_news_added(news, "jsmith@somenet.foo")
|
assert Mailer.deliver_news_added(news, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_news_comment_added
|
def test_news_comment_added
|
||||||
comment = Comment.find(2)
|
comment = Comment.find(2)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_news_comment_added(comment)
|
assert Mailer.deliver_news_comment_added(comment)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_message_posted
|
def test_message_posted
|
||||||
message = Message.find(:first)
|
message = Message.find(:first)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert Mailer.deliver_message_posted(message, "jsmith@somenet.foo")
|
assert Mailer.deliver_message_posted(message, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_wiki_content_added
|
def test_wiki_content_added
|
||||||
content = WikiContent.find(1)
|
content = WikiContent.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||||
assert Mailer.deliver_wiki_content_added(content, "jsmith@somenet.foo")
|
assert Mailer.deliver_wiki_content_added(content, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_wiki_content_updated
|
def test_wiki_content_updated
|
||||||
content = WikiContent.find(1)
|
content = WikiContent.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
Setting.default_language = lang.to_s
|
|
||||||
assert_difference 'ActionMailer::Base.deliveries.size' do
|
assert_difference 'ActionMailer::Base.deliveries.size' do
|
||||||
assert Mailer.deliver_wiki_content_updated(content, "jsmith@somenet.foo")
|
assert Mailer.deliver_wiki_content_updated(content, "jsmith@somenet.foo")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_account_information
|
def test_account_information
|
||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
valid_languages.each do |lang|
|
|
||||||
user.update_attribute :language, lang.to_s
|
|
||||||
user.reload
|
|
||||||
assert Mailer.deliver_account_information(user, 'pAsswORd')
|
assert Mailer.deliver_account_information(user, 'pAsswORd')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_lost_password
|
def test_lost_password
|
||||||
token = Token.find(2)
|
token = Token.find(2)
|
||||||
valid_languages.each do |lang|
|
|
||||||
token.user.update_attribute :language, lang.to_s
|
|
||||||
token.reload
|
|
||||||
assert Mailer.deliver_lost_password(token)
|
assert Mailer.deliver_lost_password(token)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_register
|
def test_register
|
||||||
token = Token.find(1)
|
token = Token.find(1)
|
||||||
Setting.host_name = 'redmine.foo'
|
Setting.host_name = 'redmine.foo'
|
||||||
Setting.protocol = 'https'
|
Setting.protocol = 'https'
|
||||||
|
|
||||||
valid_languages.each do |lang|
|
|
||||||
token.user.update_attribute :language, lang.to_s
|
|
||||||
token.reload
|
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
assert Mailer.deliver_register(token)
|
assert Mailer.deliver_register(token)
|
||||||
mail = ActionMailer::Base.deliveries.last
|
mail = ActionMailer::Base.deliveries.last
|
||||||
assert mail.body.include?("https://redmine.foo/account/activate?token=#{token.value}")
|
assert mail.body.include?("https://redmine.foo/account/activate?token=#{token.value}")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_test
|
def test_test
|
||||||
user = User.find(1)
|
user = User.find(1)
|
||||||
valid_languages.each do |lang|
|
|
||||||
user.update_attribute :language, lang.to_s
|
|
||||||
assert Mailer.deliver_test(user)
|
assert Mailer.deliver_test(user)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_reminders
|
def test_reminders
|
||||||
Mailer.reminders(:days => 42)
|
Mailer.reminders(:days => 42)
|
||||||
|
|
Loading…
Reference in New Issue