Adds tests for MailHandler.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8095 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e5bea933a8
commit
fe4c7237fb
|
@ -38,16 +38,43 @@ class MailHandlerControllerTest < ActionController::TestCase
|
|||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_difference 'Issue.count' do
|
||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
end
|
||||
assert_response 201
|
||||
end
|
||||
|
||||
def test_should_not_allow
|
||||
def test_should_respond_with_422_if_not_created
|
||||
Project.find('onlinestore').destroy
|
||||
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
end
|
||||
assert_response 422
|
||||
end
|
||||
|
||||
def test_should_not_allow_with_api_disabled
|
||||
# Disable API
|
||||
Setting.mail_handler_api_enabled = 0
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
end
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_should_not_allow_with_wrong_key
|
||||
# Disable API
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
post :index, :key => 'wrong', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
end
|
||||
assert_response 403
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue