end
def create
- unless User.current.allowed_to?(:add_issues, @issue.project)
+ unless User.current.allowed_to?(:add_issues, @issue.project, :global => true)
raise ::Unauthorized
end
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
return
else
respond_to do |format|
- format.html { render :action => 'new' }
+ format.html {
+ if @issue.project.nil?
+ render_error :status => 422
+ else
+ render :action => 'new'
+ end
+ }
format.api { render_validation_errors(@issue) }
end
end
assert json['errors'].include?("Subject cannot be blank")
end
+ test "POST /issues.json with invalid project_id should respond with 422" do
+ post '/issues.json', {:issue => {:project_id => 999, :subject => "API"}}, credentials('jsmith')
+ assert_response 422
+ end
+
test "PUT /issues/:id.xml" do
assert_difference('Journal.count') do
put '/issues/6.xml',