summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-06-12 16:09:37 +0000
committerGo MAEDA <maeda@farend.jp>2024-06-12 16:09:37 +0000
commitb803bddb1f32842b0a5ec93640778d902b5f7999 (patch)
treefb1dba7c75c0dc0111516d2d4384b89ecefb5e1a /test
parente41bc39322cae528d1c24256f6f404f5937d78ab (diff)
downloadredmine-b803bddb1f32842b0a5ec93640778d902b5f7999.tar.gz
redmine-b803bddb1f32842b0a5ec93640778d902b5f7999.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/functional/issues_controller_test.rb2
-rw-r--r--test/functional/mail_handler_controller_test.rb2
-rw-r--r--test/functional/my_controller_test.rb2
-rw-r--r--test/functional/sys_controller_test.rb2
-rw-r--r--test/functional/users_controller_test.rb4
-rw-r--r--test/integration/api_test/attachments_test.rb4
-rw-r--r--test/integration/api_test/groups_test.rb6
-rw-r--r--test/integration/api_test/issue_categories_test.rb4
-rw-r--r--test/integration/api_test/issue_relations_test.rb2
-rw-r--r--test/integration/api_test/issues_test.rb14
-rw-r--r--test/integration/api_test/memberships_test.rb6
-rw-r--r--test/integration/api_test/my_test.rb4
-rw-r--r--test/integration/api_test/news_test.rb4
-rw-r--r--test/integration/api_test/projects_test.rb4
-rw-r--r--test/integration/api_test/repositories_test.rb4
-rw-r--r--test/integration/api_test/time_entries_test.rb6
-rw-r--r--test/integration/api_test/users_test.rb8
-rw-r--r--test/integration/api_test/versions_test.rb2
-rw-r--r--test/integration/application_test.rb4
19 files changed, 42 insertions, 42 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index ca09ee8f1..fbdae4163 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -4748,7 +4748,7 @@ class IssuesControllerTest < Redmine::ControllerTest
}
}
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
end
diff --git a/test/functional/mail_handler_controller_test.rb b/test/functional/mail_handler_controller_test.rb
index 3227fe5ca..16eb1fbe2 100644
--- a/test/functional/mail_handler_controller_test.rb
+++ b/test/functional/mail_handler_controller_test.rb
@@ -117,7 +117,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest
)
end
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
def test_should_not_allow_with_api_disabled
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb
index da16e7c50..b485b5c9a 100644
--- a/test/functional/my_controller_test.rb
+++ b/test/functional/my_controller_test.rb
@@ -730,7 +730,7 @@ class MyControllerTest < Redmine::ControllerTest
:block => 'invalid'
}
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
def test_remove_block
diff --git a/test/functional/sys_controller_test.rb b/test/functional/sys_controller_test.rb
index fb116b4d9..17e03b133 100644
--- a/test/functional/sys_controller_test.rb
+++ b/test/functional/sys_controller_test.rb
@@ -95,7 +95,7 @@ class SysControllerTest < Redmine::ControllerTest
:repository => {:url => 'invalid url'}
}
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
def test_fetch_changesets
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 5d6e6b754..b869db0d0 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -1114,7 +1114,7 @@ class UsersControllerTest < Redmine::ControllerTest
assert_no_difference 'User.count' do
delete :destroy, params: {id: user.id}
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
end
@@ -1125,7 +1125,7 @@ class UsersControllerTest < Redmine::ControllerTest
assert_no_difference 'User.count' do
delete :destroy, params: {id: user.id}
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
end
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb
index 4bb40a302..a3d4ef21a 100644
--- a/test/integration/api_test/attachments_test.rb
+++ b/test/integration/api_test/attachments_test.rb
@@ -118,7 +118,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
:params => {:attachment => {:filename => '', :description => 'updated'}},
:headers => credentials('jsmith')
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
assert_include "File cannot be blank", json['errors']
@@ -224,7 +224,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
"CONTENT_TYPE" => 'application/octet-stream'
}.merge(credentials('jsmith'))
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'error', :text => /exceeds the maximum allowed file size/
end
end
diff --git a/test/integration/api_test/groups_test.rb b/test/integration/api_test/groups_test.rb
index 8e57d8352..fa4cbb205 100644
--- a/test/integration/api_test/groups_test.rb
+++ b/test/integration/api_test/groups_test.rb
@@ -150,7 +150,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
:headers => credentials('admin')
)
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', response.media_type
assert_select 'errors' do
@@ -179,7 +179,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
:params => {:group => {:name => ''}},
:headers => credentials('admin')
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', response.media_type
assert_select 'errors' do
@@ -220,7 +220,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
:params => {:user_id => 5},
:headers => credentials('admin')
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
assert_select 'errors' do
diff --git a/test/integration/api_test/issue_categories_test.rb b/test/integration/api_test/issue_categories_test.rb
index 1de78cd90..676c8d013 100644
--- a/test/integration/api_test/issue_categories_test.rb
+++ b/test/integration/api_test/issue_categories_test.rb
@@ -62,7 +62,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
:params => {:issue_category => {:name => ''}},
:headers => credentials('jsmith'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "Name cannot be blank"
@@ -87,7 +87,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
:params => {:issue_category => {:name => ''}},
:headers => credentials('jsmith'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "Name cannot be blank"
diff --git a/test/integration/api_test/issue_relations_test.rb b/test/integration/api_test/issue_relations_test.rb
index 9189875b2..3ac12e276 100644
--- a/test/integration/api_test/issue_relations_test.rb
+++ b/test/integration/api_test/issue_relations_test.rb
@@ -87,7 +87,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
)
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => /Relation type is not included in the list/
end
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb
index 142dc86b8..84abe70ed 100644
--- a/test/integration/api_test/issues_test.rb
+++ b/test/integration/api_test/issues_test.rb
@@ -105,7 +105,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
test "GET /issues.xml with invalid query params" do
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_select 'errors error', :text => "Start date cannot be blank"
end
@@ -725,7 +725,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
'/issues.json',
:params => {:issue => {:project_id => 999, :subject => "API"}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
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'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
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'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
test "PUT /issues/:id.xml" do
@@ -885,7 +885,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
'/issues/6.xml',
:params => {:issue => {:subject => ''}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => "Subject cannot be blank"
end
@@ -895,7 +895,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
'/issues/6.xml',
:params => {:issue => {:assigned_to_id => user.id}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => "Assignee is invalid"
end
@@ -920,7 +920,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
'/issues/6.json',
:params => {:issue => {:subject => ''}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
json = ActiveSupport::JSON.decode(response.body)
assert json['errors'].include?("Subject cannot be blank")
end
diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb
index 3346e844d..0b7c70608 100644
--- a/test/integration/api_test/memberships_test.rb
+++ b/test/integration/api_test/memberships_test.rb
@@ -101,7 +101,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
:params => {:membership => {:role_ids => [2, 3]}},
:headers => credentials('jsmith')
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => 'User or Group cannot be blank'
end
@@ -158,7 +158,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
:params => {:membership => {:user_id => 3, :role_ids => [99]}},
:headers => credentials('jsmith')
)
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "Role cannot be empty"
end
@@ -179,7 +179,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
Member.find(2).member_roles.first.update_attribute :inherited_from, 99
delete '/memberships/2.xml', :headers => credentials('jsmith')
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
end
end
end
diff --git a/test/integration/api_test/my_test.rb b/test/integration/api_test/my_test.rb
index e84d9d619..81a952b2e 100644
--- a/test/integration/api_test/my_test.rb
+++ b/test/integration/api_test/my_test.rb
@@ -81,7 +81,7 @@ class Redmine::ApiTest::MyTest < Redmine::ApiTest::Base
}
},
:headers => credentials('dlopper', 'foo'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "First name cannot be blank"
end
@@ -95,7 +95,7 @@ class Redmine::ApiTest::MyTest < Redmine::ApiTest::Base
}
},
:headers => credentials('dlopper', 'foo'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/json', @response.media_type
json = ActiveSupport::JSON.decode(response.body)
assert_kind_of Hash, json
diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb
index ee802e103..1a3bb824e 100644
--- a/test/integration/api_test/news_test.rb
+++ b/test/integration/api_test/news_test.rb
@@ -310,7 +310,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
'/news/1.xml',
:params => {:news => {:title => ''}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => "Title cannot be blank"
end
@@ -319,7 +319,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
'/news/1.json',
:params => {:news => {:title => ''}},
:headers => credentials('jsmith'))
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
json = ActiveSupport::JSON.decode(response.body)
assert json['errors'].include?("Title cannot be blank")
end
diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb
index 1ab995d45..d1dd6c24a 100644
--- a/test/integration/api_test/projects_test.rb
+++ b/test/integration/api_test/projects_test.rb
@@ -304,7 +304,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
)
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "Identifier cannot be blank"
end
@@ -366,7 +366,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
)
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "Name cannot be blank"
end
diff --git a/test/integration/api_test/repositories_test.rb b/test/integration/api_test/repositories_test.rb
index c35023b60..ae59cd8ca 100644
--- a/test/integration/api_test/repositories_test.rb
+++ b/test/integration/api_test/repositories_test.rb
@@ -70,7 +70,7 @@ class Redmine::ApiTest::RepositoriesTest < Redmine::ApiTest::Base
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'}
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => 'Issue is invalid'
end
@@ -78,7 +78,7 @@ class Redmine::ApiTest::RepositoriesTest < Redmine::ApiTest::Base
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'}
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
json = ActiveSupport::JSON.decode(response.body)
assert json['errors'].include?('Issue is invalid')
end
diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb
index f2c38d80b..bd417ab2d 100644
--- a/test/integration/api_test/time_entries_test.rb
+++ b/test/integration/api_test/time_entries_test.rb
@@ -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'}},
:headers => credentials('jsmith'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
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'}},
:headers => credentials('jsmith'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
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
delete '/time_entries/2.xml', :headers => credentials('jsmith')
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors'
end
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 183dd3af9..27772be29 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -417,7 +417,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
:headers => credentials('admin'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "First name cannot be blank"
end
@@ -434,7 +434,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
:headers => credentials('admin'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/json', @response.media_type
json = ActiveSupport::JSON.decode(response.body)
assert_kind_of Hash, json
@@ -503,7 +503,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
:headers => credentials('admin'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/xml', @response.media_type
assert_select 'errors error', :text => "First name cannot be blank"
end
@@ -521,7 +521,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
:headers => credentials('admin'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal 'application/json', @response.media_type
json = ActiveSupport::JSON.decode(response.body)
assert_kind_of Hash, json
diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb
index 614d98950..96d70095c 100644
--- a/test/integration/api_test/versions_test.rb
+++ b/test/integration/api_test/versions_test.rb
@@ -120,7 +120,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
:params => {:version => {:name => ''}},
:headers => credentials('jsmith'))
end
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_select 'errors error', :text => "Name cannot be blank"
end
diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb
index 7f077b571..77c96d89b 100644
--- a/test/integration/application_test.rb
+++ b/test/integration/application_test.rb
@@ -73,7 +73,7 @@ class ApplicationTest < Redmine::IntegrationTest
def test_invalid_token_should_call_custom_handler
ActionController::Base.allow_forgery_protection = true
post '/issues'
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_include "Invalid form authenticity token.", response.body
ensure
ActionController::Base.allow_forgery_protection = false
@@ -83,7 +83,7 @@ class ApplicationTest < Redmine::IntegrationTest
ActionController::Base.allow_forgery_protection = true
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'}
- assert_response :unprocessable_entity
+ assert_response :unprocessable_content
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
ensure