Mercurial > hg > soundsoftware-site
comparison .svn/pristine/a2/a287706354ad35bfd9b7a22dc5edd1bfb0f897d3.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class MailHandlerControllerTest < ActionController::TestCase | |
21 fixtures :users, :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :issue_statuses, | |
22 :trackers, :projects_trackers, :enumerations | |
23 | |
24 FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler' | |
25 | |
26 def setup | |
27 User.current = nil | |
28 end | |
29 | |
30 def test_should_create_issue | |
31 # Enable API and set a key | |
32 Setting.mail_handler_api_enabled = 1 | |
33 Setting.mail_handler_api_key = 'secret' | |
34 | |
35 assert_difference 'Issue.count' do | |
36 post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')) | |
37 end | |
38 assert_response 201 | |
39 end | |
40 | |
41 def test_should_respond_with_422_if_not_created | |
42 Project.find('onlinestore').destroy | |
43 | |
44 Setting.mail_handler_api_enabled = 1 | |
45 Setting.mail_handler_api_key = 'secret' | |
46 | |
47 assert_no_difference 'Issue.count' do | |
48 post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')) | |
49 end | |
50 assert_response 422 | |
51 end | |
52 | |
53 def test_should_not_allow_with_api_disabled | |
54 # Disable API | |
55 Setting.mail_handler_api_enabled = 0 | |
56 Setting.mail_handler_api_key = 'secret' | |
57 | |
58 assert_no_difference 'Issue.count' do | |
59 post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')) | |
60 end | |
61 assert_response 403 | |
62 end | |
63 | |
64 def test_should_not_allow_with_wrong_key | |
65 # Disable API | |
66 Setting.mail_handler_api_enabled = 1 | |
67 Setting.mail_handler_api_key = 'secret' | |
68 | |
69 assert_no_difference 'Issue.count' do | |
70 post :index, :key => 'wrong', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml')) | |
71 end | |
72 assert_response 403 | |
73 end | |
74 end |