Setting.mail_handler_api_key = 'secret'
assert_difference 'Issue.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'secret',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
}
+ )
end
assert_response 201
end
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
-
assert_difference 'Issue.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'secret',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')),
:issue => {
:is_private => '1'
}
}
+ )
end
assert_response 201
issue = Issue.order(:id => :desc).first
# Enable API and set a key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
-
assert_no_difference 'Issue.count' do
assert_difference 'Journal.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'secret',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_reply.eml'))
}
+ )
end
end
assert_response 201
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
-
assert_no_difference 'Issue.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'secret',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
}
+ )
end
assert_response 422
end
# Disable API
Setting.mail_handler_api_enabled = 0
Setting.mail_handler_api_key = 'secret'
-
assert_no_difference 'Issue.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'secret',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
}
+ )
end
assert_response 403
assert_include 'Access denied', response.body
def test_should_not_allow_with_wrong_key
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
-
assert_no_difference 'Issue.count' do
- post :index, :params => {
+ post(
+ :index,
+ :params => {
:key => 'wrong',
:email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
}
+ )
end
assert_response 403
assert_include 'Access denied', response.body
def test_new
Setting.mail_handler_api_enabled = 1
Setting.mail_handler_api_key = 'secret'
-
- get :new, :params => {
- :key => 'secret'
- }
+ get(:new, :params => {:key => 'secret'})
assert_response :success
end
end