git-svn-id: https://svn.redmine.org/redmine/trunk@22837 e93f8b46-1217-0410-a6f0-8f06a7374b81pull/149/merge
@@ -588,28 +588,6 @@ Rails/HasManyOrHasOneDependent: | |||
- 'app/models/wiki.rb' | |||
- 'app/models/wiki_page.rb' | |||
# This cop supports safe autocorrection (--autocorrect). | |||
# Configuration parameters: EnforcedStyle. | |||
# SupportedStyles: numeric, symbolic | |||
Rails/HttpStatus: | |||
Exclude: | |||
- 'app/controllers/attachments_controller.rb' | |||
- 'app/controllers/boards_controller.rb' | |||
- 'app/controllers/custom_fields_controller.rb' | |||
- 'app/controllers/enumerations_controller.rb' | |||
- 'app/controllers/issue_relations_controller.rb' | |||
- 'app/controllers/issue_statuses_controller.rb' | |||
- 'app/controllers/issues_controller.rb' | |||
- 'app/controllers/mail_handler_controller.rb' | |||
- 'app/controllers/members_controller.rb' | |||
- 'app/controllers/my_controller.rb' | |||
- 'app/controllers/repositories_controller.rb' | |||
- 'app/controllers/roles_controller.rb' | |||
- 'app/controllers/sys_controller.rb' | |||
- 'app/controllers/timelog_controller.rb' | |||
- 'app/controllers/trackers_controller.rb' | |||
- 'app/controllers/watchers_controller.rb' | |||
# Configuration parameters: Include. | |||
# Include: spec/**/*.rb, test/**/*.rb | |||
Rails/I18nLocaleAssignment: |
@@ -93,7 +93,7 @@ class AttachmentsController < ApplicationController | |||
end | |||
else | |||
# No thumbnail for the attachment or thumbnail could not be created | |||
head 404 | |||
head :not_found | |||
end | |||
end | |||
@@ -101,7 +101,7 @@ class AttachmentsController < ApplicationController | |||
# Make sure that API users get used to set this content type | |||
# as it won't trigger Rails' automatic parsing of the request body for parameters | |||
unless request.media_type == 'application/octet-stream' | |||
head 406 | |||
head :not_acceptable | |||
return | |||
end | |||
@@ -93,12 +93,12 @@ class BoardsController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to_settings_in_projects | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
format.html {render :action => 'edit'} | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -70,12 +70,12 @@ class CustomFieldsController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_back_or_default edit_custom_field_path(@custom_field) | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
format.html {render :action => 'edit'} | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -65,12 +65,12 @@ class EnumerationsController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to enumerations_path | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
format.html {render :action => 'edit'} | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -29,7 +29,7 @@ class IssueRelationsController < ApplicationController | |||
@relations = @issue.relations | |||
respond_to do |format| | |||
format.html {head 200} | |||
format.html {head :ok} | |||
format.api | |||
end | |||
end | |||
@@ -38,7 +38,7 @@ class IssueRelationsController < ApplicationController | |||
raise Unauthorized unless @relation.visible? | |||
respond_to do |format| | |||
format.html {head 200} | |||
format.html {head :ok} | |||
format.api | |||
end | |||
end |
@@ -61,12 +61,12 @@ class IssueStatusesController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to issue_statuses_path(:page => params[:page]) | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
format.html {render :action => 'edit'} | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -84,7 +84,7 @@ class IssuesController < ApplicationController | |||
else | |||
respond_to do |format| | |||
format.html {render :layout => !request.xhr?} | |||
format.any(:atom, :csv, :pdf) {head 422} | |||
format.any(:atom, :csv, :pdf) {head :unprocessable_entity} | |||
format.api {render_validation_errors(@query)} | |||
end | |||
end |
@@ -70,7 +70,7 @@ class MailHandlerController < ActionController::Base | |||
def check_credential | |||
User.current = nil | |||
unless Setting.mail_handler_api_enabled? && secure_compare(params[:key].to_s, Setting.mail_handler_api_key.to_s) | |||
render :plain => 'Access denied. Incoming emails WS is disabled or key is invalid.', :status => 403 | |||
render :plain => 'Access denied. Incoming emails WS is disabled or key is invalid.', :status => :forbidden | |||
end | |||
end | |||
end |
@@ -36,14 +36,14 @@ class MembersController < ApplicationController | |||
@members = scope.includes(:principal, :roles).order(:id).limit(@limit).offset(@offset).to_a | |||
respond_to do |format| | |||
format.html {head 406} | |||
format.html {head :not_acceptable} | |||
format.api | |||
end | |||
end | |||
def show | |||
respond_to do |format| | |||
format.html {head 406} | |||
format.html {head :not_acceptable} | |||
format.api | |||
end | |||
end |
@@ -195,6 +195,6 @@ class MyController < ApplicationController | |||
@user = User.current | |||
@user.pref.order_blocks params[:group], params[:blocks] | |||
@user.pref.save | |||
head 200 | |||
head :ok | |||
end | |||
end |
@@ -89,7 +89,7 @@ class RepositoriesController < ApplicationController | |||
@entries = @repository.entries(@path, @rev) | |||
@changeset = @repository.find_changeset_by_name(@rev) | |||
if request.xhr? | |||
@entries ? render(:partial => 'dir_list_content') : head(200) | |||
@entries ? render(:partial => 'dir_list_content') : head(:ok) | |||
else | |||
(show_error_not_found; return) unless @entries | |||
@changesets = @repository.latest_changesets(@path, @rev) |
@@ -85,12 +85,12 @@ class RolesController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to roles_path(:page => params[:page]) | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
format.html {render :action => 'edit'} | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -37,16 +37,16 @@ class SysController < ActionController::Base | |||
def create_project_repository | |||
project = Project.find(params[:id]) | |||
if project.repository | |||
head 409 | |||
head :conflict | |||
else | |||
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}." | |||
repository = Repository.factory(params[:vendor]) | |||
repository.safe_attributes = params[:repository] | |||
repository.project = project | |||
if repository.save | |||
render :json => {repository.class.name.underscore.tr('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201 | |||
render :json => {repository.class.name.underscore.tr('/', '-') => {:id => repository.id, :url => repository.url}}, :status => :created | |||
else | |||
head 422 | |||
head :unprocessable_entity | |||
end | |||
end | |||
end | |||
@@ -72,9 +72,9 @@ class SysController < ActionController::Base | |||
repository.fetch_changesets | |||
end | |||
end | |||
head 200 | |||
head :ok | |||
rescue ActiveRecord::RecordNotFound | |||
head 404 | |||
head :not_found | |||
end | |||
protected | |||
@@ -82,7 +82,7 @@ class SysController < ActionController::Base | |||
def check_enabled | |||
User.current = nil | |||
unless Setting.sys_api_enabled? && secure_compare(params[:key].to_s, Setting.sys_api_key.to_s) | |||
render :plain => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403 | |||
render :plain => 'Access denied. Repository management WS is disabled or key is invalid.', :status => :forbidden | |||
return false | |||
end | |||
end |
@@ -90,7 +90,7 @@ class TimelogController < ApplicationController | |||
def show | |||
respond_to do |format| | |||
# TODO: Implement html response | |||
format.html {head 406} | |||
format.html {head :not_acceptable} | |||
format.api | |||
end | |||
end |
@@ -73,7 +73,7 @@ class TrackersController < ApplicationController | |||
flash[:notice] = l(:notice_successful_update) | |||
redirect_to trackers_path(:page => params[:page]) | |||
end | |||
format.js {head 200} | |||
format.js {head :ok} | |||
end | |||
else | |||
respond_to do |format| | |||
@@ -81,7 +81,7 @@ class TrackersController < ApplicationController | |||
edit | |||
render :action => 'edit' | |||
end | |||
format.js {head 422} | |||
format.js {head :unprocessable_entity} | |||
end | |||
end | |||
end |
@@ -57,7 +57,7 @@ class WatchersController < ApplicationController | |||
respond_to do |format| | |||
format.html do | |||
redirect_to_referer_or do | |||
render(:html => 'Watcher added.', :status => 200, :layout => true) | |||
render(:html => 'Watcher added.', :status => :ok, :layout => true) | |||
end | |||
end | |||
format.js {@users = users_for_new_watcher} | |||
@@ -71,7 +71,7 @@ class WatchersController < ApplicationController | |||
@users = Principal.assignable_watchers.where(:id => user_ids).to_a | |||
end | |||
if @users.blank? | |||
head 200 | |||
head :ok | |||
end | |||
end | |||
@@ -83,7 +83,7 @@ class WatchersController < ApplicationController | |||
respond_to do |format| | |||
format.html do | |||
redirect_to_referer_or do | |||
render(:html => 'Watcher removed.', :status => 200, :layout => true) | |||
render(:html => 'Watcher removed.', :status => :ok, :layout => true) | |||
end | |||
end | |||
format.js | |||
@@ -132,7 +132,7 @@ class WatchersController < ApplicationController | |||
format.html do | |||
text = watching ? 'Watcher added.' : 'Watcher removed.' | |||
redirect_to_referer_or do | |||
render(:html => text, :status => 200, :layout => true) | |||
render(:html => text, :status => :ok, :layout => true) | |||
end | |||
end | |||
format.js do |
@@ -230,7 +230,7 @@ class AccountControllerTest < Redmine::ControllerTest | |||
:password => 'jsmith' | |||
} | |||
) | |||
assert_response 500 | |||
assert_response :internal_server_error | |||
assert_select_error /Something wrong/ | |||
end | |||
@@ -243,7 +243,7 @@ class AccountControllerTest < Redmine::ControllerTest | |||
:password => 'jsmith' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_login_should_strip_whitespaces_from_user_name | |||
@@ -254,7 +254,7 @@ class AccountControllerTest < Redmine::ControllerTest | |||
:password => 'jsmith' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 2, @request.session[:user_id] | |||
end | |||
@@ -283,7 +283,7 @@ class AccountControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
post :logout | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_get_register_with_registration_on |
@@ -74,7 +74,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest | |||
def test_project_index_with_invalid_project_id_should_respond_404 | |||
get(:index, :params => {:id => 299}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_previous_project_index | |||
@@ -131,7 +131,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest | |||
:user_id => 299 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_user_index_with_non_visible_user_id_should_respond_404 | |||
@@ -143,7 +143,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest | |||
:user_id => user.id | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index_atom_feed |
@@ -267,7 +267,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) | |||
@request.session[:user_id] = 2 | |||
get(:show, :params => {:id => attachment.id}) | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_show_file_without_container_should_be_denied_to_other_users | |||
@@ -276,7 +276,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
get(:show, :params => {:id => attachment.id}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_show_issue_attachment_should_highlight_issues_menu_item | |||
@@ -287,7 +287,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
def test_show_invalid_should_respond_with_404 | |||
get(:show, :params => {:id => 999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_renders_pagination | |||
@@ -307,7 +307,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
@request.env["HTTP_IF_NONE_MATCH"] = etag | |||
get(:download, :params => {:id => 4}) | |||
assert_response 304 | |||
assert_response :not_modified | |||
end | |||
def test_download_js_file | |||
@@ -352,7 +352,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
def test_download_missing_file | |||
get(:download, :params => {:id => 2}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_download_should_be_denied_without_permission | |||
@@ -383,7 +383,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 16 | |||
} | |||
) | |||
assert_response 304 | |||
assert_response :not_modified | |||
end | |||
def test_thumbnail_should_not_exceed_maximum_size | |||
@@ -418,7 +418,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 15 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_thumbnail_should_return_404_if_thumbnail_generation_failed | |||
@@ -430,7 +430,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 16 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_thumbnail_should_be_denied_without_permission | |||
@@ -499,7 +499,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '999' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_edit_all_for_object_that_is_not_visible_should_return_403 | |||
@@ -510,7 +510,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '4' | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_edit_all_issue_attachment_by_user_without_edit_issue_permission_on_tracker_should_return_404 | |||
@@ -527,7 +527,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '4' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update_all | |||
@@ -549,7 +549,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
attachment = Attachment.find(4) | |||
assert_equal 'newname.rb', attachment.filename | |||
assert_equal 'Renamed', attachment.description | |||
@@ -592,7 +592,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '2' | |||
} | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal response.headers['Content-Type'], 'application/zip' | |||
assert_match /issue-2-attachments.zip/, response.headers['Content-Disposition'] | |||
assert_not_includes Dir.entries(Rails.root.join('tmp')), /attachments_zip/ | |||
@@ -607,7 +607,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '999' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_download_all_without_readable_attachments | |||
@@ -620,7 +620,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
assert_equal Issue.find(1).attachments, [] | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_download_all_with_invisible_journal | |||
@@ -636,7 +636,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:object_id => '3' | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_download_all_with_maximum_bulk_download_size_larger_than_attachments | |||
@@ -705,7 +705,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 3 | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -719,7 +719,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 8 | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -733,7 +733,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 9 | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -748,7 +748,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
:id => 9 | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -762,7 +762,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
assert Attachment.find_by_id(3) | |||
end | |||
@@ -783,7 +783,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert Attachment.find_by_id(7) | |||
end | |||
end |
@@ -55,6 +55,6 @@ class AttachmentsVisibilityTest < Redmine::ControllerTest | |||
@field.update!(:visible => false, :role_ids => [1]) | |||
get :show, :params => {:id => @attachment.id} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
end |
@@ -48,7 +48,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest | |||
:type => 'foo' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_create | |||
@@ -129,7 +129,7 @@ class AuthSourcesControllerTest < Redmine::ControllerTest | |||
:id => 99 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update |
@@ -44,7 +44,7 @@ class BoardsControllerTest < Redmine::ControllerTest | |||
:project_id => 97 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index_should_show_messages_if_only_one_board | |||
@@ -159,7 +159,7 @@ class BoardsControllerTest < Redmine::ControllerTest | |||
:id => 97 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_new |
@@ -75,7 +75,7 @@ class CommentsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
end | |||
@@ -384,12 +384,12 @@ class ContextMenusControllerTest < Redmine::ControllerTest | |||
:ids => [1, 4] # issue 4 is not visible | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_should_respond_with_404_without_ids | |||
get :issues | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_time_entries_context_menu |
@@ -101,7 +101,7 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
@bar.reload | |||
assert_equal "Baz", @bar.name | |||
@@ -164,7 +164,7 @@ class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest | |||
:reassign_to_id => @bar.id | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal @bar.id.to_s, group.reload.custom_field_value(@field) |
@@ -445,7 +445,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
field = IssueCustomField.order("id desc").first | |||
assert_equal [1, 3], field.projects.map(&:id).sort | |||
@@ -514,7 +514,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest | |||
:custom_field => {:name => 'Copy'} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
field = IssueCustomField.order('id desc').first | |||
assert_equal 'Copy', field.name | |||
@@ -540,7 +540,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest | |||
:id => 99 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update |
@@ -59,7 +59,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
def test_index_by_another_user_should_be_denied | |||
@request.session[:user_id] = 3 | |||
get(:index, :params => {:user_id => 2}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_create | |||
@@ -74,7 +74,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_redirected_to '/users/2/email_addresses' | |||
end | |||
email = EmailAddress.order('id DESC').first | |||
@@ -95,7 +95,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
}, | |||
:xhr => true | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
end | |||
@@ -188,7 +188,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
:notify => '0' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal false, email.reload.notify | |||
end | |||
@@ -206,7 +206,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
}, | |||
:xhr => true | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal false, email.reload.notify | |||
end | |||
@@ -245,7 +245,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
:id => email.id | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_redirected_to '/users/2/email_addresses' | |||
end | |||
end | |||
@@ -263,7 +263,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
}, | |||
:xhr => true | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
end | |||
@@ -278,7 +278,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest | |||
:id => User.find(2).email_address.id | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -35,7 +35,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest | |||
def test_index_should_require_admin | |||
@request.session[:user_id] = nil | |||
get :index | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_new | |||
@@ -48,7 +48,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest | |||
def test_new_with_invalid_type_should_respond_with_404 | |||
get(:new, :params => {:type => 'UnknownType'}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_create | |||
@@ -128,7 +128,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest | |||
def test_edit_invalid_should_respond_with_404 | |||
get(:edit, :params => {:id => 999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update | |||
@@ -177,7 +177,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 1, Enumeration.find(2).position | |||
end | |||
@@ -194,7 +194,7 @@ class EnumerationsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal "sample", enumeration.reload.custom_field_values.last.value | |||
end | |||
@@ -72,7 +72,7 @@ class GroupsControllerTest < Redmine::ControllerTest | |||
def test_show_invalid_should_return_404 | |||
get(:show, :params => {:id => 99}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_group_that_is_not_visible_should_return_404 | |||
@@ -80,7 +80,7 @@ class GroupsControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = nil | |||
get :show, :params => {:id => 10} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_should_display_only_visible_users |
@@ -61,7 +61,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
:file => uploaded_test_file('import_issues.csv', 'text/csv') | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal 2, import.user_id | |||
assert_match /\A[0-9a-f]+\z/, import.filename | |||
@@ -123,7 +123,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
import.reload | |||
assert_equal 2, import.total_items | |||
end | |||
@@ -142,7 +142,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
import.reload | |||
assert_nil import.total_items | |||
assert_select 'div#flash_error', /not a valid UTF-8 encoded file/ | |||
@@ -162,7 +162,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
import.reload | |||
assert_nil import.total_items | |||
assert_select 'div#flash_error', /not a valid Shift_JIS encoded file/ | |||
@@ -182,7 +182,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
import.reload | |||
assert_nil import.total_items | |||
@@ -203,7 +203,7 @@ class ImportsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 200 | |||
assert_response :ok | |||
import.reload | |||
assert_equal 0, import.total_items | |||
@@ -170,7 +170,7 @@ class IssueCategoriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_destroy_category_not_in_use |
@@ -71,7 +71,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -305,7 +305,7 @@ class IssueRelationsControllerTest < Redmine::ControllerTest | |||
def test_destroy_invalid_relation | |||
assert_no_difference 'IssueRelation.count' do | |||
delete(:destroy, :params => {:id => '999'}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -42,7 +42,7 @@ class IssueStatusesControllerTest < Redmine::ControllerTest | |||
def test_index_by_user_should_respond_with_406 | |||
@request.session[:user_id] = 2 | |||
get :index | |||
assert_response 406 | |||
assert_response :not_acceptable | |||
end | |||
def test_index_should_show_warning_when_no_workflow_is_defined |
@@ -705,7 +705,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:query_id => 999 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index_with_cross_project_query_in_session_should_show_project_issues | |||
@@ -734,7 +734,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
) | |||
@request.session[:user_id] = 3 | |||
get(:index, :params => {:query_id => q.id}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_private_query_should_be_available_to_its_user | |||
@@ -2392,28 +2392,28 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
Role.non_member.remove_permission!(:view_issues) | |||
@request.session[:user_id] = 9 | |||
get(:show, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_show_should_deny_non_member_access_to_private_issue | |||
Issue.where(:id => 1).update_all(["is_private = ?", true]) | |||
@request.session[:user_id] = 9 | |||
get(:show, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_show_should_deny_member_access_without_permission | |||
Role.find(1).remove_permission!(:view_issues) | |||
@request.session[:user_id] = 2 | |||
get(:show, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_show_should_deny_member_access_to_private_issue_without_permission | |||
Issue.where(:id => 1).update_all(["is_private = ?", true]) | |||
@request.session[:user_id] = 3 | |||
get(:show, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_show_should_allow_author_access_to_private_issue | |||
@@ -3158,7 +3158,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
def test_show_invalid_should_respond_with_404 | |||
get(:show, :params => {:id => 999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_on_active_project_should_display_edit_links | |||
@@ -3588,7 +3588,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
role.save! | |||
@request.session[:user_id] = 2 | |||
get(:new, :params => {:project_id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_new_without_projects_should_respond_with_403 | |||
@@ -3596,7 +3596,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
get :new | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_select_error /no projects/ | |||
end | |||
@@ -3604,7 +3604,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
Project.all.each {|p| p.trackers.clear} | |||
@request.session[:user_id] = 2 | |||
get :new | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_select_error /no projects/ | |||
end | |||
@@ -3873,7 +3873,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:project_id => 1 | |||
} | |||
) | |||
assert_response 500 | |||
assert_response :internal_server_error | |||
assert_select_error /No default issue/ | |||
end | |||
@@ -3886,7 +3886,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:project_id => 1 | |||
} | |||
) | |||
assert_response 500 | |||
assert_response :internal_server_error | |||
assert_select_error /No tracker/ | |||
end | |||
@@ -3898,7 +3898,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:project_id => 'invalid' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_new_with_parent_id_should_only_propose_valid_trackers | |||
@@ -4318,7 +4318,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.order('id DESC').first | |||
assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort | |||
end | |||
@@ -4344,7 +4344,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.order('id DESC').first | |||
assert_equal [''], issue.custom_field_value(1).sort | |||
end | |||
@@ -4372,7 +4372,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.order('id DESC').first | |||
assert_equal ['2', '3'], issue.custom_field_value(field).sort | |||
end | |||
@@ -4504,7 +4504,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
assert_equal Date.parse('2012-07-14'), issue.start_date | |||
@@ -4530,7 +4530,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal 3, issue.tracker_id | |||
end | |||
@@ -4587,7 +4587,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
assert_equal Issue.find(2), issue.parent | |||
@@ -4607,7 +4607,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
assert_equal Issue.find(2), issue.parent | |||
@@ -4707,7 +4707,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
assert_equal 3, issue.project_id | |||
@@ -4747,7 +4747,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
end | |||
@@ -5041,7 +5041,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -5365,7 +5365,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:copy_from => 99999 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_create_as_copy_on_different_project | |||
@@ -6177,7 +6177,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_put_update_with_tracker_change | |||
@@ -6460,7 +6460,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal parent, issue.parent | |||
end | |||
@@ -6892,7 +6892,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'Changed subject', issue.reload.subject | |||
end | |||
@@ -6912,7 +6912,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'Original subject', issue.reload.subject | |||
end | |||
@@ -6929,7 +6929,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 2, issue.reload.assigned_to_id | |||
end | |||
@@ -7279,7 +7279,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
# check that the issues were updated | |||
assert_equal [7, 7], Issue.where(:id =>[1, 2]).collect {|i| i.priority.id} | |||
@@ -7312,7 +7312,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to} | |||
end | |||
end | |||
@@ -7334,7 +7334,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
# check that the issues were updated | |||
assert_equal [7, 7, 7], Issue.find([1, 2, 6]).map(&:priority_id) | |||
@@ -7365,7 +7365,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_not_equal "Bulk should fail", Journal.last.notes | |||
end | |||
@@ -7385,7 +7385,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
# 4 emails for 2 members and 2 issues | |||
# 1 email for a watcher of issue #2 | |||
assert_equal 5, ActionMailer::Base.deliveries.size | |||
@@ -7472,7 +7472,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.find(1) | |||
assert issue.closed? | |||
end | |||
@@ -7542,7 +7542,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
parent = Issue.find(2) | |||
assert_equal parent.id, Issue.find(1).parent_id | |||
assert_equal parent.id, Issue.find(3).parent_id | |||
@@ -7582,7 +7582,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.find(1) | |||
journal = issue.journals.reorder('created_on DESC').first | |||
@@ -7608,7 +7608,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal '', Issue.find(1).custom_field_value(1) | |||
assert_equal '', Issue.find(3).custom_field_value(1) | |||
end | |||
@@ -7631,7 +7631,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal ['MySQL', 'Oracle'], Issue.find(1).custom_field_value(1).sort | |||
assert_equal ['MySQL', 'Oracle'], Issue.find(3).custom_field_value(1).sort | |||
# the custom field is not associated with the issue tracker | |||
@@ -7657,7 +7657,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal [''], Issue.find(1).custom_field_value(1) | |||
assert_equal [''], Issue.find(3).custom_field_value(1) | |||
end | |||
@@ -7676,7 +7676,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
# check that the issues were updated | |||
assert_nil Issue.find(2).assigned_to | |||
end | |||
@@ -7889,7 +7889,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:copy => '1' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -7906,7 +7906,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:copy => '1' | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_copy_on_different_project_without_add_issues_permission_should_be_denied | |||
@@ -7922,7 +7922,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:copy => '1' | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_copy_should_allow_not_changing_the_issue_attributes | |||
@@ -8364,7 +8364,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
:reassign_to_id => target.id | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'Successful deletion.', flash[:notice] | |||
end | |||
end | |||
@@ -8487,7 +8487,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'Successful deletion.', flash[:notice] | |||
end | |||
@@ -8496,7 +8496,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'Issue.count' do | |||
delete(:destroy, :params => {:id => 999}) | |||
end | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_destroy_with_permission_on_tracker_should_be_allowed | |||
@@ -8508,7 +8508,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
assert_difference 'Issue.count', -1 do | |||
delete(:destroy, :params => {:id => issue.id}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'Successful deletion.', flash[:notice] | |||
end | |||
@@ -8521,7 +8521,7 @@ class IssuesControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'Issue.count' do | |||
delete(:destroy, :params => {:id => issue.id}) | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_default_search_scope |
@@ -246,7 +246,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.find(1) | |||
assert_equal 4, issue.fixed_version_id | |||
journal = Journal.order('id DESC').first | |||
@@ -272,7 +272,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
issue = Issue.find(1) | |||
assert_nil issue.fixed_version_id | |||
journal = Journal.order('id DESC').first | |||
@@ -300,7 +300,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'add_privates_notes_conflict_resolution', journal.notes | |||
assert_equal true, journal.private_notes | |||
assert journal.details.empty? | |||
@@ -361,7 +361,7 @@ class IssuesControllerTransactionTest < Redmine::ControllerTest | |||
IssueQuery.any_instance.stubs(:statement).returns("INVALID STATEMENT") | |||
get :index | |||
assert_response 500 | |||
assert_response :internal_server_error | |||
assert_select 'p', :text => /An error occurred/ | |||
assert_nil session[:query] | |||
assert_nil session[:issues_index_sort] |
@@ -300,7 +300,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size | |||
@@ -341,7 +341,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size | |||
# tests that each user receives 1 email with the custom fields he is allowed to see only | |||
users_to_test.each do |user, fields| | |||
@@ -378,7 +378,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
users_to_test.each do |user, fields| | |||
mails = ActionMailer::Base.deliveries.select {|m| m.to.include? user.mail} | |||
if (fields & [@field2, @field3]).any? |
@@ -43,7 +43,7 @@ class JournalsControllerTest < Redmine::ControllerTest | |||
:query_id => 999 | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index_should_return_privates_notes_with_permission_only | |||
@@ -156,7 +156,7 @@ class JournalsControllerTest < Redmine::ControllerTest | |||
:detail_id => detail.id | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_diff_should_default_to_description_diff | |||
@@ -179,7 +179,7 @@ class JournalsControllerTest < Redmine::ControllerTest | |||
def test_reply_to_issue_without_permission | |||
@request.session[:user_id] = 7 | |||
get(:new, :params => {:id => 6}, :xhr => true) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_reply_to_note | |||
@@ -224,7 +224,7 @@ class JournalsControllerTest < Redmine::ControllerTest | |||
}, | |||
:xhr => true | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_edit_xhr | |||
@@ -247,7 +247,7 @@ class JournalsControllerTest < Redmine::ControllerTest | |||
Role.find(1).remove_permission! :view_private_notes | |||
get(:edit, :params => {:id => journal.id}, :xhr => true) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update_xhr |
@@ -49,7 +49,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
end | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
def test_should_create_issue_with_options | |||
@@ -74,7 +74,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
end | |||
assert_response 201 | |||
assert_response :created | |||
issue = Issue.order(:id => :desc).first | |||
assert_equal true, issue.is_private | |||
end | |||
@@ -97,7 +97,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
end | |||
end | |||
end | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
def test_should_respond_with_422_if_not_created | |||
@@ -117,7 +117,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
end | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
def test_should_not_allow_with_api_disabled | |||
@@ -137,7 +137,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_include 'Access denied', response.body | |||
end | |||
@@ -157,7 +157,7 @@ class MailHandlerControllerTest < Redmine::ControllerTest | |||
) | |||
end | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_include 'Access denied', response.body | |||
end | |||
@@ -207,7 +207,7 @@ class MembersControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
member = Member.find(2) | |||
assert member.user.locked? | |||
assert_equal [1], member.role_ids |
@@ -81,12 +81,12 @@ class MessagesControllerTest < Redmine::ControllerTest | |||
def test_show_message_not_found | |||
get(:show, :params => {:board_id => 1, :id => 99999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_message_from_invalid_board_should_respond_with_404 | |||
get(:show, :params => {:board_id => 999, :id => 1}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_should_display_watchers | |||
@@ -125,7 +125,7 @@ class MessagesControllerTest < Redmine::ControllerTest | |||
def test_get_new_with_invalid_board | |||
@request.session[:user_id] = 2 | |||
get(:new, :params => {:board_id => 99}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_post_new | |||
@@ -321,7 +321,7 @@ class MessagesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_preview_new |
@@ -730,7 +730,7 @@ class MyControllerTest < Redmine::ControllerTest | |||
:block => 'invalid' | |||
} | |||
) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
def test_remove_block |
@@ -44,14 +44,14 @@ class NewsControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
get(:index, :params => {:project_id => 999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index_with_invalid_project_should_respond_with_302_for_anonymous | |||
Role.anonymous.remove_permission! :view_news | |||
with_settings :login_required => '0' do | |||
get(:index, :params => {:project_id => 999}) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -60,7 +60,7 @@ class NewsControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
get :index | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_index_without_manage_news_permission_should_not_display_add_news_link | |||
@@ -107,7 +107,7 @@ class NewsControllerTest < Redmine::ControllerTest | |||
def test_show_not_found | |||
get(:show, :params => {:id => 999}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_get_new_with_project_id |
@@ -744,7 +744,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
project = Project.order('id desc').first | |||
assert_equal 'inherited', project.name | |||
@@ -839,7 +839,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
project = Project.find_by_identifier('ecookbook') | |||
project.archive | |||
get(:show, :params => {:id => 'ecookbook'}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_select 'p', :text => /archived/ | |||
assert_not_include project.name, response.body | |||
end | |||
@@ -849,7 +849,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
project = Project.find_by_identifier('ecookbook') | |||
project.archive | |||
get(:show, :params => {:id => 'ecookbook'}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_select 'a', :text => "Unarchive" | |||
end | |||
@@ -920,13 +920,13 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
Project.find(1).close | |||
@request.session[:user_id] = 2 # manager | |||
get(:settings, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_settings_should_be_denied_for_anonymous_on_closed_project | |||
Project.find(1).close | |||
get(:settings, :params => {:id => 1}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_settings_should_accept_version_status_filter | |||
@@ -1015,7 +1015,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
role.permissions = [] | |||
role.save | |||
get(:settings, :params => {:id => project.id}) | |||
assert_response 403 | |||
assert_response :forbidden | |||
role.add_permission! :manage_repository, :manage_boards, :manage_project_activities | |||
get(:settings, :params => {:id => project.id}) | |||
@@ -1105,7 +1105,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_equal 'eCookbook', Project.find(1).name | |||
end | |||
@@ -1120,7 +1120,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_equal 'eCookbook', Project.find(1).name | |||
end | |||
@@ -1138,7 +1138,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_match /Successful update/, flash[:notice] | |||
end | |||
@@ -1320,7 +1320,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
:confirm => 'ecookbook' | |||
} | |||
) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
assert Project.find(1) | |||
end | |||
@@ -1328,7 +1328,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
def test_bulk_destroy_should_require_admin | |||
@request.session[:user_id] = 2 # non-admin | |||
delete :bulk_destroy, params: { ids: [1, 2], confirm: 'Yes' } | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_destroy_should_require_confirmation | |||
@@ -1338,7 +1338,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
end | |||
assert Project.find(1) | |||
assert Project.find(2) | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_bulk_destroy_should_delete_projects | |||
@@ -1415,7 +1415,7 @@ class ProjectsControllerTest < Redmine::ControllerTest | |||
def test_get_copy_with_invalid_source_should_respond_with_404 | |||
@request.session[:user_id] = 1 | |||
get(:copy, :params => {:id => 99}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_get_copy_should_preselect_custom_fields |
@@ -34,7 +34,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
def test_index | |||
get :index | |||
# HTML response not implemented | |||
assert_response 406 | |||
assert_response :not_acceptable | |||
end | |||
def test_new_project_query | |||
@@ -62,7 +62,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
def test_new_on_invalid_project | |||
@request.session[:user_id] = 2 | |||
get(:new, :params => {:project_id => 'invalid'}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_new_should_not_render_show_inline_columns_option_for_query_without_available_inline_columns | |||
@@ -359,7 +359,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
) | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_create_global_query_without_permission_should_fail | |||
@@ -369,7 +369,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
assert_no_difference '::Query.count' do | |||
post(:create, :params => {:query => {:name => 'Foo'}}) | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_create_global_query_from_gantt | |||
@@ -393,7 +393,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
query = IssueQuery.order('id DESC').first | |||
assert_redirected_to "/issues/gantt?query_id=#{query.id}" | |||
@@ -424,7 +424,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
query = IssueQuery.order('id DESC').first | |||
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}" | |||
@@ -445,7 +445,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_not_nil query.project | |||
assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |||
@@ -464,7 +464,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_nil query.project | |||
assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |||
@@ -482,7 +482,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_not_nil query.project | |||
assert_equal Query::VISIBILITY_PUBLIC, query.visibility | |||
@@ -501,7 +501,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_nil query.project | |||
assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |||
@@ -520,7 +520,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_nil query.project | |||
assert_equal Query::VISIBILITY_PUBLIC, query.visibility | |||
@@ -662,7 +662,7 @@ class QueriesControllerTest < Redmine::ControllerTest | |||
def test_edit_invalid_query | |||
@request.session[:user_id] = 2 | |||
get(:edit, :params => {:id => 99}) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update_global_private_query |
@@ -242,7 +242,7 @@ class ReportsControllerTest < Redmine::ControllerTest | |||
:detail => 'invalid' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_issue_report_details_should_csv_export |
@@ -291,7 +291,7 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -317,7 +317,7 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -93,7 +93,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
repository = Repository.order('id DESC').first | |||
assert_kind_of Repository::Subversion, repository | |||
assert_equal 'file:///test', repository.url | |||
@@ -138,7 +138,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 'test_update', Repository.find(11).password | |||
end | |||
@@ -162,7 +162,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest | |||
assert_difference 'Repository.count', -1 do | |||
delete(:destroy, :params => {:id => 11}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
assert_nil Repository.find_by_id(11) | |||
end | |||
@@ -279,7 +279,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest | |||
:repository_id => 'foo' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_revision | |||
@@ -523,7 +523,7 @@ class RepositoriesControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal User.find(2), c.reload.user | |||
end | |||
end |
@@ -305,7 +305,7 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest | |||
assert_difference 'Repository.count', -1 do | |||
delete(:destroy, :params => {:id => @repository.id}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -327,7 +327,7 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest | |||
assert_difference 'Repository.count', -1 do | |||
delete(:destroy, :params => {:id => @repository.id}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -176,7 +176,7 @@ class RepositoriesFilesystemControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -198,7 +198,7 @@ class RepositoriesFilesystemControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -63,7 +63,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
repository = Repository.order('id DESC').first | |||
assert_kind_of Repository::Git, repository | |||
assert_equal '/test', repository.url | |||
@@ -78,7 +78,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
repo2 = Repository.find(repository.id) | |||
assert_equal false, repo2.report_last_commit | |||
end | |||
@@ -764,7 +764,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
:rev => r | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
end | |||
@@ -784,7 +784,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -811,7 +811,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -512,7 +512,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param] | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
@@ -614,7 +614,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
:rev => r | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
end | |||
@@ -633,7 +633,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -658,7 +658,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -414,7 +414,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest | |||
:rev => 'something_weird' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
@@ -428,7 +428,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest | |||
:rev_to => 'something_weird' | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
@@ -446,7 +446,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest | |||
:rev => r | |||
} | |||
) | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_select_error /was not found/ | |||
end | |||
end | |||
@@ -599,7 +599,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest | |||
assert_difference 'Repository.count', -1 do | |||
delete(:destroy, :params => {:id => @repository.id}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end | |||
@@ -619,7 +619,7 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest | |||
assert_difference 'Repository.count', -1 do | |||
delete(:destroy, :params => {:id => @repository.id}) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
@project.reload | |||
assert_nil @project.repository | |||
end |
@@ -160,7 +160,7 @@ class RolesControllerTest < Redmine::ControllerTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal false, role.all_roles_managed | |||
assert_equal [2, 3], role.managed_role_ids.sort | |||
@@ -186,7 +186,7 @@ class RolesControllerTest < Redmine::ControllerTest | |||
def test_edit_invalid_should_respond_with_404 | |||
get :edit, :params => {:id => 999} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update |
@@ -48,18 +48,18 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_on_archived_project_should_return_403 | |||
Project.find(3).archive | |||
get :index, :params => {:id => 3} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_search_on_invisible_project_by_user_should_be_denied | |||
@request.session[:user_id] = 7 | |||
get :index, :params => {:id => 2} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_search_on_invisible_project_by_anonymous_user_should_redirect | |||
get :index, :params => {:id => 2} | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_search_on_private_project_by_member_should_succeed | |||
@@ -352,7 +352,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_with_invalid_project_id | |||
get :index, :params => {:id => 195, :q => 'recipe'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_search_should_include_closed_projects |
@@ -219,7 +219,7 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
def test_get_invalid_plugin_settings | |||
get :plugin, :params => {:id => 'none'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_get_non_configurable_plugin_settings | |||
@@ -228,7 +228,7 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
end | |||
get :plugin, :params => {:id => 'foo'} | |||
assert_response 404 | |||
assert_response :not_found | |||
ensure | |||
Redmine::Plugin.unregister(:foo) | |||
@@ -274,7 +274,7 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
:id => 'foo', | |||
:settings => {'sample_setting' => 'Value'} | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
ensure | |||
Redmine::Plugin.unregister(:foo) |
@@ -118,13 +118,13 @@ class SysControllerTest < Redmine::ControllerTest | |||
def test_fetch_changesets_unknown_project | |||
get :fetch_changesets, :params => {:id => 'unknown'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_disabled_ws_should_respond_with_403_error | |||
with_settings :sys_api_enabled => '0' do | |||
get :projects | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_include 'Access denied', response.body | |||
end | |||
end | |||
@@ -139,7 +139,7 @@ class SysControllerTest < Redmine::ControllerTest | |||
def test_wrong_key_should_respond_with_403_error | |||
with_settings :sys_api_enabled => 'my_secret_key' do | |||
get :projects, :params => {:key => 'wrong_key'} | |||
assert_response 403 | |||
assert_response :forbidden | |||
assert_include 'Access denied', response.body | |||
end | |||
end |
@@ -86,7 +86,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
get :new | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_new_should_select_default_role_activity | |||
@@ -504,7 +504,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
:hours => '7.3' | |||
} | |||
} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_create_without_project_and_issue_should_fail | |||
@@ -582,7 +582,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
} | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_create_without_project_with_failure | |||
@@ -636,7 +636,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
:issue_id => '5' | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
entry.reload | |||
assert_equal 5, entry.issue_id | |||
@@ -668,7 +668,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
:project_id => '2' | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
entry.reload | |||
assert_equal 2, entry.project_id | |||
@@ -802,7 +802,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
# update time entry activity | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => {:activity_id => 9}} | |||
assert_response 302 | |||
assert_response :found | |||
# check that the issues were updated | |||
assert_equal [9, 9], TimeEntry.where(:id => [1, 2]).collect {|i| i.activity_id} | |||
end | |||
@@ -823,7 +823,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
# update time entry activity | |||
post :bulk_update, :params => {:ids => [1, 2, 4], :time_entry => {:activity_id => 9}} | |||
assert_response 302 | |||
assert_response :found | |||
# check that the issues were updated | |||
assert_equal [9, 9, 9], TimeEntry.where(:id => [1, 2, 4]).collect {|i| i.activity_id} | |||
end | |||
@@ -836,7 +836,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
assert ! user.allowed_to?(action, TimeEntry.find(5).project) | |||
post :bulk_update, :params => {:ids => [1, 5], :time_entry => {:activity_id => 9}} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_update_with_edit_own_time_entries_permission | |||
@@ -846,7 +846,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id} | |||
post :bulk_update, :params => {:ids => ids, :time_entry => {:activity_id => 9}} | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_bulk_update_with_edit_own_time_entries_permissions_should_be_denied_for_time_entries_of_other_user | |||
@@ -855,7 +855,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').add_permission! :edit_own_time_entries | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => {:activity_id => 9}} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_update_custom_field | |||
@@ -867,7 +867,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
:time_entry => {:custom_field_values => {'10' => '0'}} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} | |||
end | |||
@@ -881,7 +881,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
:time_entry => {:custom_field_values => {field.id.to_s => '__none__'}} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value} | |||
end | |||
@@ -906,7 +906,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').remove_permission! :edit_time_entries | |||
post :bulk_update, :params => {:ids => [1, 2]} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_destroy |
@@ -42,7 +42,7 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_index_by_user_should_respond_with_406 | |||
@request.session[:user_id] = 2 | |||
get :index | |||
assert_response 406 | |||
assert_response :not_acceptable | |||
end | |||
def test_new |
@@ -335,13 +335,13 @@ class UsersControllerTest < Redmine::ControllerTest | |||
def test_show_inactive | |||
@request.session[:user_id] = nil | |||
get :show, :params => {:id => 5} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_inactive_by_admin | |||
@request.session[:user_id] = 1 | |||
get :show, :params => {:id => 5} | |||
assert_response 200 | |||
assert_response :ok | |||
assert_select 'h2', :text => /Dave2 Lopper2/ | |||
end | |||
@@ -351,7 +351,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = nil | |||
get :show, :params => {:id => user.id} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_displays_memberships_based_on_project_visibility | |||
@@ -378,7 +378,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
def test_show_current_should_require_authentication | |||
@request.session[:user_id] = nil | |||
get :show, :params => {:id => 'current'} | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_show_current | |||
@@ -656,7 +656,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
get :edit, :params => {:id => 6} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_edit_user_with_full_text_formatting_custom_field_should_not_fail | |||
@@ -857,7 +857,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
:id => 2, | |||
:user => {:status => 3} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
user = User.find(2) | |||
assert_equal 3, user.status | |||
assert_equal '1', user.pref[:no_self_notified] | |||
@@ -997,7 +997,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
def test_update_should_be_denied_for_anonymous | |||
assert User.find(6).anonymous? | |||
put :update, :params => {:id => 6} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update_with_blank_email_should_not_raise_exception | |||
@@ -1051,7 +1051,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :destroy, :params => {:id => 2, :confirm => User.find(2).login} | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_destroy_should_be_denied_for_anonymous | |||
@@ -1059,7 +1059,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :destroy, :params => {:id => 6, :confirm => User.find(6).login} | |||
end | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_destroy_should_redirect_to_back_url_param | |||
@@ -1105,7 +1105,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :destroy, params: {id: user.id} | |||
end | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
end | |||
@@ -1116,7 +1116,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :destroy, params: {id: user.id} | |||
end | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
end | |||
@@ -1166,7 +1166,7 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :bulk_destroy, :params => {:ids => [2], :confirm => 'Yes'} | |||
end | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_bulk_destroy_should_be_denied_for_anonymous | |||
@@ -1174,6 +1174,6 @@ class UsersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'User.count' do | |||
delete :bulk_destroy, :params => {:ids => [6], :confirm => "Yes"} | |||
end | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end |
@@ -86,7 +86,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'Watcher.count' do | |||
post :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s}, :xhr => true | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
end | |||
@@ -95,7 +95,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
post :watch, :params => {:object_type => 'issue', :object_id => '1'}, :xhr => true | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
end | |||
@@ -103,7 +103,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
post :watch, :params => {:object_type => 'foo', :object_id => '1'}, :xhr => true | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -111,7 +111,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
post :watch, :params => {:object_type => 'issue', :object_id => '999'}, :xhr => true | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -159,7 +159,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_new_as_html_should_respond_with_404 | |||
@request.session[:user_id] = 2 | |||
get :new, :params => {:object_type => 'issue', :object_id => '2'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_new_for_message | |||
@@ -581,7 +581,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
delete :destroy, :params => { | |||
:object_type => 'issue', :object_id => '2', :user_id => '999' | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
end |
@@ -183,7 +183,7 @@ class WelcomeControllerTest < Redmine::ControllerTest | |||
WelcomeController.any_instance.stubs(:index).raises(::Unauthorized) | |||
get :index | |||
assert_response 302 | |||
assert_response :found | |||
assert_redirected_to('/login?back_url='+CGI.escape('http://test.host/')) | |||
end | |||
@@ -192,6 +192,6 @@ class WelcomeControllerTest < Redmine::ControllerTest | |||
@request.env["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest" | |||
get :index | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
end |
@@ -179,7 +179,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_unexistent_page_without_edit_right | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_unexistent_page_with_edit_right | |||
@@ -191,7 +191,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_specific_version_of_an_unexistent_page_without_edit_right | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page', :version => 1} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_unexistent_page_with_parent_should_preselect_parent | |||
@@ -204,14 +204,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_unexistent_version_page | |||
@request.session[:user_id] = 2 | |||
get :show, :params => {:project_id => 1, :id => 'CookBook_documentation', :version => 100} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_show_should_not_show_history_without_permission | |||
Role.anonymous.remove_permission! :view_wiki_edits | |||
get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2} | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_show_page_without_content_should_display_the_edit_form | |||
@@ -386,7 +386,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_update_page | |||
@@ -598,7 +598,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:id => 'NoContent', | |||
:content => {:text => 'Some content'} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
assert_equal 'Some content', page.reload.content.text | |||
@@ -780,7 +780,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => '99' | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_diff_with_invalid_version_from_should_respond_with_404 | |||
@@ -789,7 +789,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:version => '99', | |||
:version_from => '98' | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_annotate | |||
@@ -825,7 +825,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => '99' | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_get_rename | |||
@@ -1040,7 +1040,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
end | |||
end | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_index | |||
@@ -1097,7 +1097,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').remove_permission! :export_wiki_pages | |||
get :export, :params => {:project_id => 'ecookbook'} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_date_index | |||
@@ -1110,7 +1110,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_not_found | |||
get :show, :params => {:project_id => 999} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_protect_page | |||
@@ -1237,7 +1237,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
# Non members cannot edit protected wiki pages | |||
@request.session[:user_id] = 4 | |||
get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
def test_edit_protected_page_by_member | |||
@@ -1248,7 +1248,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_history_of_non_existing_page_should_return_404 | |||
get :history, :params => {:project_id => 1, :id => 'Unknown_page'} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
def test_add_attachment |
@@ -51,6 +51,6 @@ class WikisControllerTest < Redmine::ControllerTest | |||
def test_not_found | |||
@request.session[:user_id] = 1 | |||
post :destroy, :params => {:id => 999, :confirm => 1} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end |
@@ -158,7 +158,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
'3' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |||
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2).exists? | |||
@@ -175,7 +175,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
'0' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1).any? | |||
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 2).any? | |||
@@ -195,7 +195,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
'4' => {'always' => '0', 'author' => '1', 'assignee' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |||
@@ -371,7 +371,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
'3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |||
} | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
workflows = WorkflowPermission.all | |||
assert_equal 3, workflows.size | |||
@@ -409,7 +409,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['3'], :target_role_ids => ['1'] | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |||
end | |||
@@ -420,7 +420,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) | |||
assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |||
assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 3) | |||
@@ -435,7 +435,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
:source_tracker_id => 'any', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 302 | |||
assert_response :found | |||
assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) | |||
assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) | |||
assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 3) | |||
@@ -448,7 +448,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
:source_tracker_id => '', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 200 | |||
assert_response :ok | |||
assert_select 'div.flash.error', :text => 'Please select a source tracker or role' | |||
end | |||
end | |||
@@ -459,7 +459,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'] | |||
} | |||
assert_response 200 | |||
assert_response :ok | |||
assert_select 'div.flash.error', :text => 'Please select target tracker(s) and role(s)' | |||
end | |||
end |
@@ -97,7 +97,7 @@ class AccountTest < Redmine::IntegrationTest | |||
:autologin => 1 | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert cookies['custom_autologin'].present? | |||
token = cookies['custom_autologin'] |
@@ -35,7 +35,7 @@ class Redmine::ApiTest::ApiTest < Redmine::ApiTest::Base | |||
}, | |||
:headers => credentials('admin') | |||
) | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
ensure | |||
ActionController::Base.allow_forgery_protection = false |
@@ -61,7 +61,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base | |||
test "GET /attachments/:id.xml should deny access without credentials" do | |||
get '/attachments/7.xml' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
test "GET /attachments/download/:id/:filename should return the attachment content" do | |||
@@ -72,7 +72,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base | |||
test "GET /attachments/download/:id/:filename should deny access without credentials" do | |||
get '/attachments/download/7/archive.zip' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
test "GET /attachments/thumbnail/:id should return the thumbnail" do | |||
@@ -118,7 +118,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base | |||
:params => {:attachment => {:filename => '', :description => 'updated'}}, | |||
:headers => credentials('jsmith') | |||
) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
assert_equal 'application/json', response.media_type | |||
json = ActiveSupport::JSON.decode(response.body) | |||
assert_include "File cannot be blank", json['errors'] | |||
@@ -209,7 +209,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base | |||
"CONTENT_TYPE" => 'image/png' | |||
}.merge(credentials('jsmith')) | |||
) | |||
assert_response 406 | |||
assert_response :not_acceptable | |||
end | |||
end | |||
@@ -224,7 +224,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base | |||
"CONTENT_TYPE" => 'application/octet-stream' | |||
}.merge(credentials('jsmith')) | |||
) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
assert_select 'error', :text => /exceeds the maximum allowed file size/ | |||
end | |||
end |
@@ -28,7 +28,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
def test_api_should_deny_without_credentials | |||
get '/users/current.xml' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
assert response.headers.has_key?('WWW-Authenticate') | |||
end | |||
@@ -37,7 +37,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
user.password = 'my_password' | |||
end | |||
get '/users/current.xml', :headers => credentials(user.login, 'my_password') | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_api_should_deny_http_basic_auth_using_username_and_wrong_password | |||
@@ -45,7 +45,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
user.password = 'my_password' | |||
end | |||
get '/users/current.xml', :headers => credentials(user.login, 'wrong_password') | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_deny_http_basic_auth_if_twofa_is_active | |||
@@ -54,61 +54,61 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
user.update(twofa_scheme: 'totp') | |||
end | |||
get '/users/current.xml', :headers => credentials(user.login, 'my_password') | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_accept_http_basic_auth_using_api_key | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'api') | |||
get '/users/current.xml', :headers => credentials(token.value, 'X') | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_api_should_deny_http_basic_auth_using_wrong_api_key | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'feeds') # not the API key | |||
get '/users/current.xml', :headers => credentials(token.value, 'X') | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_accept_auth_using_api_key_as_parameter | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'api') | |||
get "/users/current.xml?key=#{token.value}" | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_api_should_deny_auth_using_wrong_api_key_as_parameter | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'feeds') # not the API key | |||
get "/users/current.xml?key=#{token.value}" | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_accept_auth_using_api_key_as_request_header | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'api') | |||
get "/users/current.xml", :headers => {'X-Redmine-API-Key' => token.value.to_s} | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_api_should_deny_auth_using_wrong_api_key_as_request_header | |||
user = User.generate! | |||
token = Token.create!(:user => user, :action => 'feeds') # not the API key | |||
get "/users/current.xml", :headers => {'X-Redmine-API-Key' => token.value.to_s} | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_trigger_basic_http_auth_with_basic_authorization_header | |||
ApplicationController.any_instance.expects(:authenticate_with_http_basic).once | |||
get '/users/current.xml', :headers => credentials('jsmith') | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_not_trigger_basic_http_auth_with_non_basic_authorization_header | |||
ApplicationController.any_instance.expects(:authenticate_with_http_basic).never | |||
get '/users/current.xml', :headers => {'HTTP_AUTHORIZATION' => 'Digest foo bar'} | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_invalid_utf8_credentials_should_not_trigger_an_error | |||
@@ -126,7 +126,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
assert_response :success | |||
get '/users/current.json' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
def test_api_should_accept_switch_user_header_for_admin_user | |||
@@ -140,7 +140,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
def test_api_should_respond_with_412_when_trying_to_switch_to_a_invalid_user | |||
get '/users/current', :headers => {'X-Redmine-API-Key' => User.find(1).api_key, 'X-Redmine-Switch-User' => 'foobar'} | |||
assert_response 412 | |||
assert_response :precondition_failed | |||
end | |||
def test_api_should_respond_with_412_when_trying_to_switch_to_a_locked_user | |||
@@ -148,7 +148,7 @@ class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base | |||
assert user.locked? | |||
get '/users/current', :headers => {'X-Redmine-API-Key' => User.find(1).api_key, 'X-Redmine-Switch-User' => user.login} | |||
assert_response 412 | |||
assert_response :precondition_failed | |||
end | |||
def test_api_should_not_accept_switch_user_header_for_non_admin_user |
@@ -42,7 +42,7 @@ class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base | |||
test "GET /enumerations/invalid_subclass.xml should return 404" do | |||
get '/enumerations/invalid_subclass.xml' | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_equal 'application/xml', response.media_type | |||
end | |||
end |
@@ -24,7 +24,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base | |||
test "GET /groups.xml should require authentication" do | |||
get '/groups.xml' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
test "GET /groups.xml should return givable groups" do | |||
@@ -61,7 +61,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base | |||
test "GET /groups.json should require authentication" do | |||
get '/groups.json' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
test "GET /groups.json should return groups" do |
@@ -723,7 +723,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base | |||
'/issues.json', | |||
:params => {:issue => {:project_id => 999, :subject => "API"}}, | |||
:headers => credentials('jsmith')) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
test "POST /issues.json with invalid project_id and any assigned_to_id should respond with 422" do | |||
@@ -737,7 +737,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base | |||
} | |||
}, | |||
:headers => credentials('jsmith')) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
test "POST /issues.json with invalid project_id and any fixed_version_id should respond with 422" do | |||
@@ -751,7 +751,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base | |||
} | |||
}, | |||
:headers => credentials('jsmith')) | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
end | |||
test "PUT /issues/:id.xml" do |
@@ -63,7 +63,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base | |||
test "GET /time_entries/:id.xml with invalid id should 404" do | |||
get '/time_entries/999.xml', :headers => credentials('jsmith') | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
test "POST /time_entries.xml with issue_id should create time entry" do | |||
@@ -211,7 +211,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base | |||
'/time_entries/2.xml', | |||
:params => {:time_entry => {:hours => '2.3', :comments => 'API Update'}}, | |||
:headers => credentials('dlopper')) | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
test "DELETE /time_entries/:id.xml should destroy time entry" do |
@@ -261,7 +261,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base | |||
test "GET /users/current.xml should require authentication" do | |||
get '/users/current.xml' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
end | |||
test "GET /users/current.xml should return current user" do |
@@ -26,7 +26,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
test "GET /projects/:project_id/wiki/index.xml should return wiki pages" do | |||
get '/projects/ecookbook/wiki/index.xml' | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal 'application/xml', response.media_type | |||
assert_select 'wiki_pages[type=array]' do | |||
assert_select 'wiki_page', :count => Wiki.find(1).pages.count | |||
@@ -45,7 +45,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
test "GET /projects/:project_id/wiki/:title.xml should return wiki page" do | |||
get '/projects/ecookbook/wiki/CookBook_documentation.xml' | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal 'application/xml', response.media_type | |||
assert_select 'wiki_page' do | |||
assert_select 'title', :text => 'CookBook_documentation' | |||
@@ -60,7 +60,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
test "GET /projects/:project_id/wiki/:title.xml?include=attachments should include attachments" do | |||
get '/projects/ecookbook/wiki/Page_with_an_inline_image.xml?include=attachments' | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal 'application/xml', response.media_type | |||
assert_select 'wiki_page' do | |||
assert_select 'title', :text => 'Page_with_an_inline_image' | |||
@@ -75,13 +75,13 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
test "GET /projects/:project_id/wiki/:title.xml with unknown title and edit permission should respond with 404" do | |||
get '/projects/ecookbook/wiki/Invalid_Page.xml', :headers => credentials('jsmith') | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_equal 'application/xml', response.media_type | |||
end | |||
test "GET /projects/:project_id/wiki/:title/:version.xml should return wiki page version" do | |||
get '/projects/ecookbook/wiki/CookBook_documentation/2.xml' | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal 'application/xml', response.media_type | |||
assert_select 'wiki_page' do | |||
assert_select 'title', :text => 'CookBook_documentation' | |||
@@ -98,7 +98,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
Role.anonymous.remove_permission! :view_wiki_edits | |||
get '/projects/ecookbook/wiki/CookBook_documentation/2.xml' | |||
assert_response 401 | |||
assert_response :unauthorized | |||
assert_equal 'application/xml', response.media_type | |||
end | |||
@@ -130,7 +130,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
WikiContentVersion.find_by_id(2).update(author_id: nil) | |||
get '/projects/ecookbook/wiki/CookBook_documentation/2.xml' | |||
assert_response 200 | |||
assert_response :ok | |||
assert_equal 'application/xml', response.media_type | |||
assert_select 'wiki_page' do | |||
assert_select 'author', 0 | |||
@@ -176,7 +176,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
}, | |||
:headers => credentials('jsmith') | |||
) | |||
assert_response 409 | |||
assert_response :conflict | |||
end | |||
end | |||
end | |||
@@ -194,7 +194,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
}, | |||
:headers => credentials('jsmith') | |||
) | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
end | |||
@@ -227,7 +227,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
}, | |||
:headers => credentials('jsmith') | |||
) | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
end | |||
@@ -251,7 +251,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base | |||
}, | |||
:headers => credentials('jsmith') | |||
) | |||
assert_response 201 | |||
assert_response :created | |||
end | |||
end | |||
@@ -57,23 +57,23 @@ class ApplicationTest < Redmine::IntegrationTest | |||
def test_token_based_access_should_not_start_session | |||
# issue of a private project | |||
get '/issues/4.atom' | |||
assert_response 302 | |||
assert_response :found | |||
atom_key = User.find(2).atom_key | |||
get "/issues/4.atom?key=#{atom_key}" | |||
assert_response 200 | |||
assert_response :ok | |||
assert_nil session[:user_id] | |||
end | |||
def test_missing_template_should_respond_with_4xx | |||
get '/login.png' | |||
assert_response 406 | |||
assert_response :not_acceptable | |||
end | |||
def test_invalid_token_should_call_custom_handler | |||
ActionController::Base.allow_forgery_protection = true | |||
post '/issues' | |||
assert_response 422 | |||
assert_response :unprocessable_entity | |||
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 422 | |||
assert_response :unprocessable_entity | |||
assert_equal :fr, current_language | |||
assert_select "html[lang=?]", "fr" | |||
ensure | |||
@@ -93,7 +93,7 @@ class ApplicationTest < Redmine::IntegrationTest | |||
def test_require_login_with_pdf_format_should_not_error | |||
with_settings :login_required => '1' do | |||
get '/issues/1.pdf' | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -101,7 +101,7 @@ class ApplicationTest < Redmine::IntegrationTest | |||
Role.anonymous.remove_permission! :view_gantt | |||
with_settings :login_required => '0' do | |||
get '/projects/nonexistingproject/issues/gantt' | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -109,6 +109,6 @@ class ApplicationTest < Redmine::IntegrationTest | |||
log_user('jsmith', 'jsmith') | |||
get '/projects/nonexistingproject/issues/gantt' | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end |
@@ -75,7 +75,7 @@ class AttachmentsTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
@@ -159,7 +159,7 @@ class AttachmentsTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
@@ -185,7 +185,7 @@ class AttachmentsTest < Redmine::IntegrationTest | |||
:attachments => {'p0' => {:filename => filename, :token => token}} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
issue = Issue.order('id DESC').first | |||
assert_equal 'Issue with upload', issue.subject | |||
@@ -258,7 +258,7 @@ class AttachmentsTest < Redmine::IntegrationTest | |||
with_settings :login_required => '0' do | |||
get "/attachments/journals/3/download" | |||
assert_response 403 | |||
assert_response :forbidden | |||
end | |||
with_settings :login_required => '1' do | |||
get "/attachments/journals/3/download" |
@@ -87,7 +87,7 @@ class IssuesTest < Redmine::IntegrationTest | |||
} | |||
) | |||
end | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
def test_create_issue_by_anonymous_with_custom_permission_should_succeed | |||
@@ -104,7 +104,7 @@ class IssuesTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
assert_equal User.anonymous, issue.author | |||
end | |||
@@ -341,7 +341,7 @@ class IssuesTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
# Issue view | |||
@@ -381,11 +381,11 @@ class IssuesTest < Redmine::IntegrationTest | |||
subject = 'Updated by an invalid http verb' | |||
get '/issues/update/1', :params => {:issue => {:subject => subject}} | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_not_equal subject, Issue.find(1).subject | |||
post '/issues/1', :params => {:issue => {:subject => subject}} | |||
assert_response 404 | |||
assert_response :not_found | |||
assert_not_equal subject, Issue.find(1).subject | |||
end | |||
@@ -394,7 +394,7 @@ class IssuesTest < Redmine::IntegrationTest | |||
assert_no_difference 'Watcher.count' do | |||
get '/watchers/watch?object_type=issue&object_id=1' | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
@@ -406,6 +406,6 @@ class IssuesTest < Redmine::IntegrationTest | |||
'v' => {'cf_9' => ['2021-05-25']} | |||
} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end |
@@ -68,7 +68,7 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -108,7 +108,7 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -166,7 +166,7 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
@@ -193,7 +193,7 @@ class AttachmentFieldFormatTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
end | |||
end | |||
end |
@@ -33,9 +33,9 @@ class ProjectsTest < Redmine::IntegrationTest | |||
assert !Project.find(1).active? | |||
get '/projects/1' | |||
assert_response 403 | |||
assert_response :forbidden | |||
get "/projects/#{subproject.id}" | |||
assert_response 403 | |||
assert_response :forbidden | |||
post "/projects/1/unarchive" | |||
assert_redirected_to "/admin/projects" | |||
@@ -49,7 +49,7 @@ class ProjectsTest < Redmine::IntegrationTest | |||
assert_no_difference 'EnabledModule.count' do | |||
get '/projects/1/modules', :params => {:enabled_module_names => ['']} | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
end |
@@ -38,7 +38,7 @@ class SessionsTest < Redmine::IntegrationTest | |||
jsmith.save! | |||
get '/my/account' | |||
assert_response 302 | |||
assert_response :found | |||
assert flash[:error].include?('Your session has expired') | |||
end | |||
@@ -50,7 +50,7 @@ class SessionsTest < Redmine::IntegrationTest | |||
assert jsmith.activate! | |||
get '/my/account' | |||
assert_response 302 | |||
assert_response :found | |||
assert flash[:error].include?('Your session has expired') | |||
end | |||
@@ -62,7 +62,7 @@ class SessionsTest < Redmine::IntegrationTest | |||
jsmith.save! | |||
get '/my/account' | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_change_password_generates_a_new_token_for_current_session | |||
@@ -70,7 +70,7 @@ class SessionsTest < Redmine::IntegrationTest | |||
assert_not_nil token = session[:tk] | |||
get '/my/password' | |||
assert_response 200 | |||
assert_response :ok | |||
post( | |||
'/my/password', | |||
:params => { | |||
@@ -79,11 +79,11 @@ class SessionsTest < Redmine::IntegrationTest | |||
:new_password_confirmation => 'secret123' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
assert_not_equal token, session[:tk] | |||
get '/my/account' | |||
assert_response 200 | |||
assert_response :ok | |||
end | |||
def test_simultaneous_sessions_should_be_valid |
@@ -28,7 +28,7 @@ class SudoModeTest < Redmine::IntegrationTest | |||
} | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
user = User.find_by_login("psmith") | |||
assert_kind_of User, user | |||
@@ -68,7 +68,7 @@ class SudoModeTest < Redmine::IntegrationTest | |||
:sudo_password => 'admin' | |||
} | |||
) | |||
assert_response 302 | |||
assert_response :found | |||
user = User.find_by_login("psmith") | |||
assert_kind_of User, user |
@@ -27,7 +27,7 @@ class UsersTest < Redmine::IntegrationTest | |||
assert_no_difference 'User.count' do | |||
get '/users/destroy/2' | |||
assert_response 404 | |||
assert_response :not_found | |||
end | |||
end | |||
end |