summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-02-14 08:03:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-02-14 08:03:51 +0000
commit3da7b1bc2882cfb02c5068680979158322242398 (patch)
tree87ed265520ff93243dbd7c1074e47f5e37c7abac /test
parentb17883a2dff6cd49ea407b449ac0e97dca38e56a (diff)
downloadredmine-3da7b1bc2882cfb02c5068680979158322242398.tar.gz
redmine-3da7b1bc2882cfb02c5068680979158322242398.zip
Implements /issues/new form for creating issues outside a project (#1003).
git-svn-id: http://svn.redmine.org/redmine/trunk@13999 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb69
-rw-r--r--test/integration/routing/issues_test.rb4
2 files changed, 73 insertions, 0 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 5e8762e08..3d048edbc 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1497,6 +1497,7 @@ class IssuesControllerTest < ActionController::TestCase
assert_response :success
assert_template 'new'
+ assert_select 'form#issue-form[action=?]', '/projects/ecookbook/issues'
assert_select 'form#issue-form' do
assert_select 'input[name=?]', 'issue[is_private]'
assert_select 'select[name=?]', 'issue[project_id]', 0
@@ -1552,6 +1553,21 @@ class IssuesControllerTest < ActionController::TestCase
end
end
+ def test_new_without_project_id
+ @request.session[:user_id] = 2
+ get :new
+ assert_response :success
+ assert_template 'new'
+
+ assert_select 'form#issue-form[action=?]', '/issues'
+ assert_select 'form#issue-form' do
+ assert_select 'select[name=?]', 'issue[project_id]'
+ end
+
+ assert_nil assigns(:project)
+ assert_not_nil assigns(:issue)
+ end
+
def test_new_should_select_default_status
@request.session[:user_id] = 2
@@ -2164,6 +2180,59 @@ class IssuesControllerTest < ActionController::TestCase
assert issue.is_private?
end
+ def test_create_without_project_id
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count' do
+ post :create,
+ :issue => {:project_id => 3,
+ :tracker_id => 2,
+ :subject => 'Foo'}
+ assert_response 302
+ end
+ issue = Issue.order('id DESC').first
+ assert_equal 3, issue.project_id
+ assert_equal 2, issue.tracker_id
+ end
+
+ def test_create_without_project_id_and_continue_should_redirect_without_project_id
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count' do
+ post :create,
+ :issue => {:project_id => 3,
+ :tracker_id => 2,
+ :subject => 'Foo'},
+ :continue => '1'
+ assert_redirected_to '/issues/new?issue%5Bproject_id%5D=3&issue%5Btracker_id%5D=2'
+ end
+ end
+
+ def test_create_without_project_id_should_be_denied_without_permission
+ Role.non_member.remove_permission! :add_issues
+ Role.anonymous.remove_permission! :add_issues
+ @request.session[:user_id] = 2
+
+ assert_no_difference 'Issue.count' do
+ post :create,
+ :issue => {:project_id => 3,
+ :tracker_id => 2,
+ :subject => 'Foo'}
+ assert_response 403
+ end
+ end
+
+ def test_create_without_project_id_with_failure
+ @request.session[:user_id] = 2
+
+ post :create,
+ :issue => {:project_id => 3,
+ :tracker_id => 2,
+ :subject => ''}
+ assert_response :success
+ assert_nil assigns(:project)
+ end
+
def test_post_create_should_send_a_notification
ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 2
diff --git a/test/integration/routing/issues_test.rb b/test/integration/routing/issues_test.rb
index 1b59f3214..c7d7523a7 100644
--- a/test/integration/routing/issues_test.rb
+++ b/test/integration/routing/issues_test.rb
@@ -27,6 +27,9 @@ class RoutingIssuesTest < Redmine::RoutingTest
should_route 'GET /issues/64.pdf' => 'issues#show', :id => '64', :format => 'pdf'
should_route 'GET /issues/64.atom' => 'issues#show', :id => '64', :format => 'atom'
+ should_route 'GET /issues/new' => 'issues#new'
+ should_route 'POST /issues' => 'issues#create'
+
should_route 'GET /issues/64/edit' => 'issues#edit', :id => '64'
should_route 'PUT /issues/64' => 'issues#update', :id => '64'
should_route 'DELETE /issues/64' => 'issues#destroy', :id => '64'
@@ -50,6 +53,7 @@ class RoutingIssuesTest < Redmine::RoutingTest
end
def test_issues_form_update
+ should_route 'POST /issues/new' => 'issues#new'
should_route 'POST /projects/23/issues/new' => 'issues#new', :project_id => '23'
should_route 'PATCH /issues/23/edit' => 'issues#edit', :id => '23'
end