mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 17:56:03 +01:00
Fix "ArgumentError: Invalid response name: unprocessable_entity" with Rack 3.1.0+ in assert_response (#39889).
Rack 3.1.0 changed the symbol for HTTP status code 422 from `:unprocessable_entity` to `:unprocessable_content`. Due to the change, `assert_response(:unprocessable_entity, ...)` raises ArgumentError with Rack 3.1.0+. This fix is a follow-up to r22837. git-svn-id: https://svn.redmine.org/redmine/trunk@22876 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -15,6 +15,7 @@ gem 'rbpdf', '~> 1.21.3'
|
|||||||
gem 'addressable'
|
gem 'addressable'
|
||||||
gem 'rubyzip', '~> 2.3.0'
|
gem 'rubyzip', '~> 2.3.0'
|
||||||
gem 'propshaft', '~> 0.8.0'
|
gem 'propshaft', '~> 0.8.0'
|
||||||
|
gem 'rack', '>= 3.1.3'
|
||||||
|
|
||||||
# Ruby Standard Gems
|
# Ruby Standard Gems
|
||||||
gem 'csv', '~> 3.2.8'
|
gem 'csv', '~> 3.2.8'
|
||||||
|
|||||||
@@ -766,7 +766,7 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
def render_api_errors(*messages)
|
def render_api_errors(*messages)
|
||||||
@error_messages = messages.flatten
|
@error_messages = messages.flatten
|
||||||
render :template => 'common/error_messages', :format => [:api], :status => :unprocessable_entity, :layout => nil
|
render :template => 'common/error_messages', :format => [:api], :status => :unprocessable_content, :layout => nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Overrides #_include_layout? so that #render with no arguments
|
# Overrides #_include_layout? so that #render with no arguments
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class BoardsController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :action => 'edit'}
|
format.html {render :action => 'edit'}
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class CustomFieldsController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :action => 'edit'}
|
format.html {render :action => 'edit'}
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class EnumerationsController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :action => 'edit'}
|
format.html {render :action => 'edit'}
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class IssueStatusesController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :action => 'edit'}
|
format.html {render :action => 'edit'}
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class IssuesController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :layout => !request.xhr?}
|
format.html {render :layout => !request.xhr?}
|
||||||
format.any(:atom, :csv, :pdf) {head :unprocessable_entity}
|
format.any(:atom, :csv, :pdf) {head :unprocessable_content}
|
||||||
format.api {render_validation_errors(@query)}
|
format.api {render_validation_errors(@query)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class MailHandlerController < ActionController::Base
|
|||||||
if MailHandler.safe_receive(email, options)
|
if MailHandler.safe_receive(email, options)
|
||||||
head :created
|
head :created
|
||||||
else
|
else
|
||||||
head :unprocessable_entity
|
head :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class MembersController < ApplicationController
|
|||||||
if @member.destroyed?
|
if @member.destroyed?
|
||||||
render_api_ok
|
render_api_ok
|
||||||
else
|
else
|
||||||
head :unprocessable_entity
|
head :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class RolesController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :action => 'edit'}
|
format.html {render :action => 'edit'}
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class SysController < ActionController::Base
|
|||||||
if repository.save
|
if repository.save
|
||||||
render :json => {repository.class.name.underscore.tr('/', '-') => {:id => repository.id, :url => repository.url}}, :status => :created
|
render :json => {repository.class.name.underscore.tr('/', '-') => {:id => repository.id, :url => repository.url}}, :status => :created
|
||||||
else
|
else
|
||||||
head :unprocessable_entity
|
head :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class TrackersController < ApplicationController
|
|||||||
edit
|
edit
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
format.js {head :unprocessable_entity}
|
format.js {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class UsersController < ApplicationController
|
|||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :layout => !request.xhr?}
|
format.html {render :layout => !request.xhr?}
|
||||||
format.csv {head :unprocessable_entity}
|
format.csv {head :unprocessable_content}
|
||||||
format.api {render_validation_errors(@query)}
|
format.api {render_validation_errors(@query)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class VersionsController < ApplicationController
|
|||||||
flash[:error] = l(:notice_unable_delete_version)
|
flash[:error] = l(:notice_unable_delete_version)
|
||||||
redirect_to settings_project_path(@project, :tab => 'versions')
|
redirect_to settings_project_path(@project, :tab => 'versions')
|
||||||
end
|
end
|
||||||
format.api {head :unprocessable_entity}
|
format.api {head :unprocessable_content}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4748,7 +4748,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_allow_with_api_disabled
|
def test_should_not_allow_with_api_disabled
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ class MyControllerTest < Redmine::ControllerTest
|
|||||||
:block => 'invalid'
|
:block => 'invalid'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_block
|
def test_remove_block
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class SysControllerTest < Redmine::ControllerTest
|
|||||||
:repository => {:url => 'invalid url'}
|
:repository => {:url => 'invalid url'}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fetch_changesets
|
def test_fetch_changesets
|
||||||
|
|||||||
@@ -1114,7 +1114,7 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||||||
assert_no_difference 'User.count' do
|
assert_no_difference 'User.count' do
|
||||||
delete :destroy, params: {id: user.id}
|
delete :destroy, params: {id: user.id}
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1125,7 +1125,7 @@ class UsersControllerTest < Redmine::ControllerTest
|
|||||||
assert_no_difference 'User.count' do
|
assert_no_difference 'User.count' do
|
||||||
delete :destroy, params: {id: user.id}
|
delete :destroy, params: {id: user.id}
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:attachment => {:filename => '', :description => 'updated'}},
|
:params => {:attachment => {:filename => '', :description => 'updated'}},
|
||||||
:headers => credentials('jsmith')
|
:headers => credentials('jsmith')
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/json', response.media_type
|
assert_equal 'application/json', response.media_type
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert_include "File cannot be blank", json['errors']
|
assert_include "File cannot be blank", json['errors']
|
||||||
@@ -224,7 +224,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
|
|||||||
"CONTENT_TYPE" => 'application/octet-stream'
|
"CONTENT_TYPE" => 'application/octet-stream'
|
||||||
}.merge(credentials('jsmith'))
|
}.merge(credentials('jsmith'))
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'error', :text => /exceeds the maximum allowed file size/
|
assert_select 'error', :text => /exceeds the maximum allowed file size/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
|||||||
:headers => credentials('admin')
|
:headers => credentials('admin')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', response.media_type
|
assert_equal 'application/xml', response.media_type
|
||||||
|
|
||||||
assert_select 'errors' do
|
assert_select 'errors' do
|
||||||
@@ -179,7 +179,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:group => {:name => ''}},
|
:params => {:group => {:name => ''}},
|
||||||
:headers => credentials('admin')
|
:headers => credentials('admin')
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', response.media_type
|
assert_equal 'application/xml', response.media_type
|
||||||
|
|
||||||
assert_select 'errors' do
|
assert_select 'errors' do
|
||||||
@@ -220,7 +220,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:user_id => 5},
|
:params => {:user_id => 5},
|
||||||
:headers => credentials('admin')
|
:headers => credentials('admin')
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_select 'errors' do
|
assert_select 'errors' do
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
|||||||
:params => {:issue_category => {:name => ''}},
|
:params => {:issue_category => {:name => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
|
|
||||||
assert_select 'errors error', :text => "Name cannot be blank"
|
assert_select 'errors error', :text => "Name cannot be blank"
|
||||||
@@ -87,7 +87,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
|||||||
:params => {:issue_category => {:name => ''}},
|
:params => {:issue_category => {:name => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
|
|
||||||
assert_select 'errors error', :text => "Name cannot be blank"
|
assert_select 'errors error', :text => "Name cannot be blank"
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => /Relation type is not included in the list/
|
assert_select 'errors error', :text => /Relation type is not included in the list/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
test "GET /issues.xml with invalid query params" do
|
test "GET /issues.xml with invalid query params" do
|
||||||
get '/issues.xml', :params => {:f => ['start_date'], :op => {:start_date => '='}}
|
get '/issues.xml', :params => {:f => ['start_date'], :op => {:start_date => '='}}
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "Start date cannot be blank"
|
assert_select 'errors error', :text => "Start date cannot be blank"
|
||||||
end
|
end
|
||||||
@@ -725,7 +725,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
'/issues.json',
|
'/issues.json',
|
||||||
:params => {:issue => {:project_id => 999, :subject => "API"}},
|
:params => {:issue => {:project_id => 999, :subject => "API"}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
test "POST /issues.json with invalid project_id and any assigned_to_id should respond with 422" do
|
test "POST /issues.json with invalid project_id and any assigned_to_id should respond with 422" do
|
||||||
@@ -739,7 +739,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
test "POST /issues.json with invalid project_id and any fixed_version_id should respond with 422" do
|
test "POST /issues.json with invalid project_id and any fixed_version_id should respond with 422" do
|
||||||
@@ -753,7 +753,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
|
|
||||||
test "PUT /issues/:id.xml" do
|
test "PUT /issues/:id.xml" do
|
||||||
@@ -885,7 +885,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
'/issues/6.xml',
|
'/issues/6.xml',
|
||||||
:params => {:issue => {:subject => ''}},
|
:params => {:issue => {:subject => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => "Subject cannot be blank"
|
assert_select 'errors error', :text => "Subject cannot be blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -895,7 +895,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
'/issues/6.xml',
|
'/issues/6.xml',
|
||||||
:params => {:issue => {:assigned_to_id => user.id}},
|
:params => {:issue => {:assigned_to_id => user.id}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => "Assignee is invalid"
|
assert_select 'errors error', :text => "Assignee is invalid"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -920,7 +920,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
'/issues/6.json',
|
'/issues/6.json',
|
||||||
:params => {:issue => {:subject => ''}},
|
:params => {:issue => {:subject => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert json['errors'].include?("Subject cannot be blank")
|
assert json['errors'].include?("Subject cannot be blank")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:membership => {:role_ids => [2, 3]}},
|
:params => {:membership => {:role_ids => [2, 3]}},
|
||||||
:headers => credentials('jsmith')
|
:headers => credentials('jsmith')
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => 'User or Group cannot be blank'
|
assert_select 'errors error', :text => 'User or Group cannot be blank'
|
||||||
end
|
end
|
||||||
@@ -158,7 +158,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:membership => {:user_id => 3, :role_ids => [99]}},
|
:params => {:membership => {:user_id => 3, :role_ids => [99]}},
|
||||||
:headers => credentials('jsmith')
|
:headers => credentials('jsmith')
|
||||||
)
|
)
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "Role cannot be empty"
|
assert_select 'errors error', :text => "Role cannot be empty"
|
||||||
end
|
end
|
||||||
@@ -179,7 +179,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
|||||||
Member.find(2).member_roles.first.update_attribute :inherited_from, 99
|
Member.find(2).member_roles.first.update_attribute :inherited_from, 99
|
||||||
delete '/memberships/2.xml', :headers => credentials('jsmith')
|
delete '/memberships/2.xml', :headers => credentials('jsmith')
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class Redmine::ApiTest::MyTest < Redmine::ApiTest::Base
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
:headers => credentials('dlopper', 'foo'))
|
:headers => credentials('dlopper', 'foo'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "First name cannot be blank"
|
assert_select 'errors error', :text => "First name cannot be blank"
|
||||||
end
|
end
|
||||||
@@ -95,7 +95,7 @@ class Redmine::ApiTest::MyTest < Redmine::ApiTest::Base
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
:headers => credentials('dlopper', 'foo'))
|
:headers => credentials('dlopper', 'foo'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/json', @response.media_type
|
assert_equal 'application/json', @response.media_type
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert_kind_of Hash, json
|
assert_kind_of Hash, json
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
|||||||
'/news/1.xml',
|
'/news/1.xml',
|
||||||
:params => {:news => {:title => ''}},
|
:params => {:news => {:title => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => "Title cannot be blank"
|
assert_select 'errors error', :text => "Title cannot be blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
|||||||
'/news/1.json',
|
'/news/1.json',
|
||||||
:params => {:news => {:title => ''}},
|
:params => {:news => {:title => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert json['errors'].include?("Title cannot be blank")
|
assert json['errors'].include?("Title cannot be blank")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "Identifier cannot be blank"
|
assert_select 'errors error', :text => "Identifier cannot be blank"
|
||||||
end
|
end
|
||||||
@@ -366,7 +366,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "Name cannot be blank"
|
assert_select 'errors error', :text => "Name cannot be blank"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Redmine::ApiTest::RepositoriesTest < Redmine::ApiTest::Base
|
|||||||
assert_no_difference 'Changeset.find(103).issues.size' do
|
assert_no_difference 'Changeset.find(103).issues.size' do
|
||||||
post '/projects/1/repository/10/revisions/4/issues.xml', :headers => credentials('jsmith'), :params => {:issue_id => '9999'}
|
post '/projects/1/repository/10/revisions/4/issues.xml', :headers => credentials('jsmith'), :params => {:issue_id => '9999'}
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => 'Issue is invalid'
|
assert_select 'errors error', :text => 'Issue is invalid'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class Redmine::ApiTest::RepositoriesTest < Redmine::ApiTest::Base
|
|||||||
assert_no_difference 'Changeset.find(103).issues.size' do
|
assert_no_difference 'Changeset.find(103).issues.size' do
|
||||||
post '/projects/1/repository/10/revisions/4/issues.json', :headers => credentials('jsmith'), :params => {:issue_id => '9999'}
|
post '/projects/1/repository/10/revisions/4/issues.json', :headers => credentials('jsmith'), :params => {:issue_id => '9999'}
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert json['errors'].include?('Issue is invalid')
|
assert json['errors'].include?('Issue is invalid')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
|
|||||||
:params => {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}},
|
:params => {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
|
|
||||||
assert_select 'errors error', :text => "Hours cannot be blank"
|
assert_select 'errors error', :text => "Hours cannot be blank"
|
||||||
@@ -200,7 +200,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
|
|||||||
:params => {:time_entry => {:hours => '', :comments => 'API Update'}},
|
:params => {:time_entry => {:hours => '', :comments => 'API Update'}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
|
|
||||||
assert_select 'errors error', :text => "Hours cannot be blank"
|
assert_select 'errors error', :text => "Hours cannot be blank"
|
||||||
@@ -229,7 +229,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
|
|||||||
assert_no_difference 'TimeEntry.count' do
|
assert_no_difference 'TimeEntry.count' do
|
||||||
delete '/time_entries/2.xml', :headers => credentials('jsmith')
|
delete '/time_entries/2.xml', :headers => credentials('jsmith')
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors'
|
assert_select 'errors'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
|||||||
:headers => credentials('admin'))
|
:headers => credentials('admin'))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "First name cannot be blank"
|
assert_select 'errors error', :text => "First name cannot be blank"
|
||||||
end
|
end
|
||||||
@@ -434,7 +434,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
|||||||
:headers => credentials('admin'))
|
:headers => credentials('admin'))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/json', @response.media_type
|
assert_equal 'application/json', @response.media_type
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert_kind_of Hash, json
|
assert_kind_of Hash, json
|
||||||
@@ -503,7 +503,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
|||||||
:headers => credentials('admin'))
|
:headers => credentials('admin'))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/xml', @response.media_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
assert_select 'errors error', :text => "First name cannot be blank"
|
assert_select 'errors error', :text => "First name cannot be blank"
|
||||||
end
|
end
|
||||||
@@ -521,7 +521,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
|||||||
:headers => credentials('admin'))
|
:headers => credentials('admin'))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal 'application/json', @response.media_type
|
assert_equal 'application/json', @response.media_type
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
assert_kind_of Hash, json
|
assert_kind_of Hash, json
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
|
|||||||
:params => {:version => {:name => ''}},
|
:params => {:version => {:name => ''}},
|
||||||
:headers => credentials('jsmith'))
|
:headers => credentials('jsmith'))
|
||||||
end
|
end
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_select 'errors error', :text => "Name cannot be blank"
|
assert_select 'errors error', :text => "Name cannot be blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class ApplicationTest < Redmine::IntegrationTest
|
|||||||
def test_invalid_token_should_call_custom_handler
|
def test_invalid_token_should_call_custom_handler
|
||||||
ActionController::Base.allow_forgery_protection = true
|
ActionController::Base.allow_forgery_protection = true
|
||||||
post '/issues'
|
post '/issues'
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_include "Invalid form authenticity token.", response.body
|
assert_include "Invalid form authenticity token.", response.body
|
||||||
ensure
|
ensure
|
||||||
ActionController::Base.allow_forgery_protection = false
|
ActionController::Base.allow_forgery_protection = false
|
||||||
@@ -83,7 +83,7 @@ class ApplicationTest < Redmine::IntegrationTest
|
|||||||
ActionController::Base.allow_forgery_protection = true
|
ActionController::Base.allow_forgery_protection = true
|
||||||
Setting.default_language = 'en'
|
Setting.default_language = 'en'
|
||||||
post '/issues', :headers => {'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'}
|
post '/issues', :headers => {'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'}
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_content
|
||||||
assert_equal :fr, current_language
|
assert_equal :fr, current_language
|
||||||
assert_select "html[lang=?]", "fr"
|
assert_select "html[lang=?]", "fr"
|
||||||
ensure
|
ensure
|
||||||
|
|||||||
Reference in New Issue
Block a user