@@ -133,7 +133,7 class IssuesController < ApplicationController | |||||
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | def create |
|
135 | def create | |
136 | unless User.current.allowed_to?(:add_issues, @issue.project) |
|
136 | unless User.current.allowed_to?(:add_issues, @issue.project, :global => true) | |
137 | raise ::Unauthorized |
|
137 | raise ::Unauthorized | |
138 | end |
|
138 | end | |
139 | call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
|
139 | call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) | |
@@ -151,7 +151,13 class IssuesController < ApplicationController | |||||
151 | return |
|
151 | return | |
152 | else |
|
152 | else | |
153 | respond_to do |format| |
|
153 | respond_to do |format| | |
154 |
format.html { |
|
154 | format.html { | |
|
155 | if @issue.project.nil? | |||
|
156 | render_error :status => 422 | |||
|
157 | else | |||
|
158 | render :action => 'new' | |||
|
159 | end | |||
|
160 | } | |||
155 | format.api { render_validation_errors(@issue) } |
|
161 | format.api { render_validation_errors(@issue) } | |
156 | end |
|
162 | end | |
157 | end |
|
163 | end |
@@ -2218,7 +2218,7 class IssuesControllerTest < ActionController::TestCase | |||||
2218 | :issue => {:project_id => 3, |
|
2218 | :issue => {:project_id => 3, | |
2219 | :tracker_id => 2, |
|
2219 | :tracker_id => 2, | |
2220 | :subject => 'Foo'} |
|
2220 | :subject => 'Foo'} | |
2221 |
assert_response 4 |
|
2221 | assert_response 422 | |
2222 | end |
|
2222 | end | |
2223 | end |
|
2223 | end | |
2224 |
|
2224 |
@@ -444,6 +444,11 JSON | |||||
444 | assert json['errors'].include?("Subject cannot be blank") |
|
444 | assert json['errors'].include?("Subject cannot be blank") | |
445 | end |
|
445 | end | |
446 |
|
446 | |||
|
447 | test "POST /issues.json with invalid project_id should respond with 422" do | |||
|
448 | post '/issues.json', {:issue => {:project_id => 999, :subject => "API"}}, credentials('jsmith') | |||
|
449 | assert_response 422 | |||
|
450 | end | |||
|
451 | ||||
447 | test "PUT /issues/:id.xml" do |
|
452 | test "PUT /issues/:id.xml" do | |
448 | assert_difference('Journal.count') do |
|
453 | assert_difference('Journal.count') do | |
449 | put '/issues/6.xml', |
|
454 | put '/issues/6.xml', |
General Comments 0
You need to be logged in to leave comments.
Login now