code layout clean up test/unit/mail_handler_test.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8741 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
be9f1c592e
commit
65a1f54f71
|
@ -67,7 +67,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
|
||||
def test_add_issue_with_default_tracker
|
||||
# This email contains: 'Project: onlinestore'
|
||||
issue = submit_email('ticket_on_given_project.eml', :issue => {:tracker => 'Support request'})
|
||||
issue = submit_email(
|
||||
'ticket_on_given_project.eml',
|
||||
:issue => {:tracker => 'Support request'}
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -85,7 +88,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_add_issue_with_attributes_override
|
||||
issue = submit_email('ticket_with_attributes.eml', :allow_override => 'tracker,category,priority')
|
||||
issue = submit_email(
|
||||
'ticket_with_attributes.eml',
|
||||
:allow_override => 'tracker,category,priority'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -111,7 +117,11 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_add_issue_with_partial_attributes_override
|
||||
issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker'])
|
||||
issue = submit_email(
|
||||
'ticket_with_attributes.eml',
|
||||
:issue => {:priority => 'High'},
|
||||
:allow_override => ['tracker']
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -125,7 +135,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_add_issue_with_spaces_between_attribute_and_separator
|
||||
issue = submit_email('ticket_with_spaces_between_attribute_and_separator.eml', :allow_override => 'tracker,category,priority')
|
||||
issue = submit_email(
|
||||
'ticket_with_spaces_between_attribute_and_separator.eml',
|
||||
:allow_override => 'tracker,category,priority'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -160,7 +173,8 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert !issue.new_record?
|
||||
issue.reload
|
||||
assert_equal 'New ticket with custom field values', issue.subject
|
||||
assert_equal 'Value for a custom field', issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
||||
assert_equal 'Value for a custom field',
|
||||
issue.custom_value_for(CustomField.find_by_name('Searchable field')).value
|
||||
assert !issue.description.match(/^searchable field:/i)
|
||||
end
|
||||
|
||||
|
@ -175,14 +189,22 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
|
||||
def test_add_issue_by_unknown_user
|
||||
assert_no_difference 'User.count' do
|
||||
assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'})
|
||||
assert_equal false,
|
||||
submit_email(
|
||||
'ticket_by_unknown_user.eml',
|
||||
:issue => {:project => 'ecookbook'}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def test_add_issue_by_anonymous_user
|
||||
Role.anonymous.add_permission!(:add_issues)
|
||||
assert_no_difference 'User.count' do
|
||||
issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept')
|
||||
issue = submit_email(
|
||||
'ticket_by_unknown_user.eml',
|
||||
:issue => {:project => 'ecookbook'},
|
||||
:unknown_user => 'accept'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert issue.author.anonymous?
|
||||
end
|
||||
|
@ -191,7 +213,11 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
def test_add_issue_by_anonymous_user_with_no_from_address
|
||||
Role.anonymous.add_permission!(:add_issues)
|
||||
assert_no_difference 'User.count' do
|
||||
issue = submit_email('ticket_by_empty_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept')
|
||||
issue = submit_email(
|
||||
'ticket_by_empty_user.eml',
|
||||
:issue => {:project => 'ecookbook'},
|
||||
:unknown_user => 'accept'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert issue.author.anonymous?
|
||||
end
|
||||
|
@ -201,7 +227,12 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
Role.anonymous.add_permission!(:add_issues)
|
||||
assert_no_difference 'User.count' do
|
||||
assert_no_difference 'Issue.count' do
|
||||
assert_equal false, submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'onlinestore'}, :unknown_user => 'accept')
|
||||
assert_equal false,
|
||||
submit_email(
|
||||
'ticket_by_unknown_user.eml',
|
||||
:issue => {:project => 'onlinestore'},
|
||||
:unknown_user => 'accept'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -209,7 +240,12 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
def test_add_issue_by_anonymous_user_on_private_project_without_permission_check
|
||||
assert_no_difference 'User.count' do
|
||||
assert_difference 'Issue.count' do
|
||||
issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'onlinestore'}, :no_permission_check => '1', :unknown_user => 'accept')
|
||||
issue = submit_email(
|
||||
'ticket_by_unknown_user.eml',
|
||||
:issue => {:project => 'onlinestore'},
|
||||
:no_permission_check => '1',
|
||||
:unknown_user => 'accept'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert issue.author.anonymous?
|
||||
assert !issue.project.is_public?
|
||||
|
@ -221,7 +257,11 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
def test_add_issue_by_created_user
|
||||
Setting.default_language = 'en'
|
||||
assert_difference 'User.count' do
|
||||
issue = submit_email('ticket_by_unknown_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create')
|
||||
issue = submit_email(
|
||||
'ticket_by_unknown_user.eml',
|
||||
:issue => {:project => 'ecookbook'},
|
||||
:unknown_user => 'create'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert issue.author.active?
|
||||
assert_equal 'john.doe@somenet.foo', issue.author.mail
|
||||
|
@ -244,7 +284,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_add_issue_with_invalid_attributes
|
||||
issue = submit_email('ticket_with_invalid_attributes.eml', :allow_override => 'tracker,category,priority')
|
||||
issue = submit_email(
|
||||
'ticket_with_invalid_attributes.eml',
|
||||
:allow_override => 'tracker,category,priority'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -258,7 +301,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
|
||||
def test_add_issue_with_localized_attributes
|
||||
User.find_by_mail('jsmith@somenet.foo').update_attribute 'language', 'fr'
|
||||
issue = submit_email('ticket_with_localized_attributes.eml', :allow_override => 'tracker,category,priority')
|
||||
issue = submit_email(
|
||||
'ticket_with_localized_attributes.eml',
|
||||
:allow_override => 'tracker,category,priority'
|
||||
)
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
|
@ -276,13 +322,20 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
ja_dev.force_encoding('UTF-8') if ja_dev.respond_to?(:force_encoding)
|
||||
tracker = Tracker.create!(:name => ja_dev)
|
||||
Project.find(1).trackers << tracker
|
||||
issue = submit_email('japanese_keywords_iso_2022_jp.eml', :issue => {:project => 'ecookbook'}, :allow_override => 'tracker')
|
||||
issue = submit_email(
|
||||
'japanese_keywords_iso_2022_jp.eml',
|
||||
:issue => {:project => 'ecookbook'},
|
||||
:allow_override => 'tracker'
|
||||
)
|
||||
assert_kind_of Issue, issue
|
||||
assert_equal tracker, issue.tracker
|
||||
end
|
||||
|
||||
def test_add_issue_from_apple_mail
|
||||
issue = submit_email('apple_mail_with_attachment.eml', :issue => {:project => 'ecookbook'})
|
||||
issue = submit_email(
|
||||
'apple_mail_with_attachment.eml',
|
||||
:issue => {:project => 'ecookbook'}
|
||||
)
|
||||
assert_kind_of Issue, issue
|
||||
assert_equal 1, issue.attachments.size
|
||||
|
||||
|
@ -297,7 +350,12 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
def test_should_ignore_emails_from_emission_address
|
||||
Role.anonymous.add_permission!(:add_issues)
|
||||
assert_no_difference 'User.count' do
|
||||
assert_equal false, submit_email('ticket_from_emission_address.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'create')
|
||||
assert_equal false,
|
||||
submit_email(
|
||||
'ticket_from_emission_address.eml',
|
||||
:issue => {:project => 'ecookbook'},
|
||||
:unknown_user => 'create'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -367,7 +425,10 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_update_issue_should_not_set_defaults
|
||||
journal = submit_email('ticket_reply.eml', :issue => {:tracker => 'Support request', :priority => 'High'})
|
||||
journal = submit_email(
|
||||
'ticket_reply.eml',
|
||||
:issue => {:tracker => 'Support request', :priority => 'High'}
|
||||
)
|
||||
assert journal.is_a?(Journal)
|
||||
assert_match /This is reply/, journal.notes
|
||||
assert_equal 'Feature request', journal.issue.tracker.name
|
||||
|
|
Loading…
Reference in New Issue