- '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:
end
else
# No thumbnail for the attachment or thumbnail could not be created
- head 404
+ head :not_found
end
end
# 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
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
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
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
@relations = @issue.relations
respond_to do |format|
- format.html {head 200}
+ format.html {head :ok}
format.api
end
end
raise Unauthorized unless @relation.visible?
respond_to do |format|
- format.html {head 200}
+ format.html {head :ok}
format.api
end
end
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
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
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
@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
@user = User.current
@user.pref.order_blocks params[:group], params[:blocks]
@user.pref.save
- head 200
+ head :ok
end
end
@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)
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
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
repository.fetch_changesets
end
end
- head 200
+ head :ok
rescue ActiveRecord::RecordNotFound
- head 404
+ head :not_found
end
protected
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
def show
respond_to do |format|
# TODO: Implement html response
- format.html {head 406}
+ format.html {head :not_acceptable}
format.api
end
end
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|
edit
render :action => 'edit'
end
- format.js {head 422}
+ format.js {head :unprocessable_entity}
end
end
end
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}
@users = Principal.assignable_watchers.where(:id => user_ids).to_a
end
if @users.blank?
- head 200
+ head :ok
end
end
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
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
:password => 'jsmith'
}
)
- assert_response 500
+ assert_response :internal_server_error
assert_select_error /Something wrong/
end
:password => 'jsmith'
}
)
- assert_response 302
+ assert_response :found
end
def test_login_should_strip_whitespaces_from_user_name
:password => 'jsmith'
}
)
- assert_response 302
+ assert_response :found
assert_equal 2, @request.session[:user_id]
end
@request.session[:user_id] = 2
post :logout
- assert_response 302
+ assert_response :found
end
def test_get_register_with_registration_on
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
:user_id => 299
}
)
- assert_response 404
+ assert_response :not_found
end
def test_user_index_with_non_visible_user_id_should_respond_404
:user_id => user.id
}
- assert_response 404
+ assert_response :not_found
end
def test_index_atom_feed
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
@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
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
@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
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
:id => 16
}
)
- assert_response 304
+ assert_response :not_modified
end
def test_thumbnail_should_not_exceed_maximum_size
:id => 15
}
)
- assert_response 404
+ assert_response :not_found
end
def test_thumbnail_should_return_404_if_thumbnail_generation_failed
:id => 16
}
)
- assert_response 404
+ assert_response :not_found
end
def test_thumbnail_should_be_denied_without_permission
:object_id => '999'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_edit_all_for_object_that_is_not_visible_should_return_403
: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
:object_id => '4'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_update_all
}
}
)
- assert_response 302
+ assert_response :found
attachment = Attachment.find(4)
assert_equal 'newname.rb', attachment.filename
assert_equal 'Renamed', attachment.description
: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/
:object_id => '999'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_download_all_without_readable_attachments
}
)
assert_equal Issue.find(1).attachments, []
- assert_response 404
+ assert_response :not_found
end
def test_download_all_with_invisible_journal
:object_id => '3'
}
)
- assert_response 403
+ assert_response :forbidden
end
def test_download_all_with_maximum_bulk_download_size_larger_than_attachments
:id => 3
}
)
- assert_response 302
+ assert_response :found
end
end
:id => 8
}
)
- assert_response 302
+ assert_response :found
end
end
:id => 9
}
)
- assert_response 302
+ assert_response :found
end
end
:id => 9
}
)
- assert_response 302
+ assert_response :found
end
end
}
)
end
- assert_response 302
+ assert_response :found
assert Attachment.find_by_id(3)
end
)
end
- assert_response 403
+ assert_response :forbidden
assert Attachment.find_by_id(7)
end
end
@field.update!(:visible => false, :role_ids => [1])
get :show, :params => {:id => @attachment.id}
- assert_response 403
+ assert_response :forbidden
end
end
:type => 'foo'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_create
:id => 99
}
)
- assert_response 404
+ assert_response :not_found
end
def test_update
:project_id => 97
}
)
- assert_response 404
+ assert_response :not_found
end
def test_index_should_show_messages_if_only_one_board
:id => 97
}
)
- assert_response 404
+ assert_response :not_found
end
def test_new
}
}
)
- assert_response 403
+ assert_response :forbidden
end
end
: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
}
}
)
- assert_response 302
+ assert_response :found
@bar.reload
assert_equal "Baz", @bar.name
:reassign_to_id => @bar.id
}
)
- assert_response 302
+ assert_response :found
end
assert_equal @bar.id.to_s, group.reload.custom_field_value(@field)
}
}
)
- assert_response 302
+ assert_response :found
end
field = IssueCustomField.order("id desc").first
assert_equal [1, 3], field.projects.map(&:id).sort
:custom_field => {:name => 'Copy'}
}
)
- assert_response 302
+ assert_response :found
end
field = IssueCustomField.order('id desc').first
assert_equal 'Copy', field.name
:id => 99
}
)
- assert_response 404
+ assert_response :not_found
end
def test_update
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
}
}
)
- assert_response 302
+ assert_response :found
assert_redirected_to '/users/2/email_addresses'
end
email = EmailAddress.order('id DESC').first
},
:xhr => true
)
- assert_response 200
+ assert_response :ok
end
end
:notify => '0'
}
)
- assert_response 302
+ assert_response :found
assert_equal false, email.reload.notify
end
},
:xhr => true
)
- assert_response 200
+ assert_response :ok
assert_equal false, email.reload.notify
end
:id => email.id
}
)
- assert_response 302
+ assert_response :found
assert_redirected_to '/users/2/email_addresses'
end
end
},
:xhr => true
)
- assert_response 200
+ assert_response :ok
end
end
:id => User.find(2).email_address.id
}
)
- assert_response 404
+ assert_response :not_found
end
end
def test_index_should_require_admin
@request.session[:user_id] = nil
get :index
- assert_response 302
+ assert_response :found
end
def test_new
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
def test_edit_invalid_should_respond_with_404
get(:edit, :params => {:id => 999})
- assert_response 404
+ assert_response :not_found
end
def test_update
}
}
)
- assert_response 302
+ assert_response :found
assert_equal 1, Enumeration.find(2).position
end
}
}
)
- assert_response 302
+ assert_response :found
assert_equal "sample", enumeration.reload.custom_field_values.last.value
end
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
@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
: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
}
}
)
- assert_response 302
+ assert_response :found
import.reload
assert_equal 2, import.total_items
end
}
}
)
- 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/
}
}
)
- 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/
}
}
)
- assert_response 200
+ assert_response :ok
import.reload
assert_nil import.total_items
}
}
)
- assert_response 200
+ assert_response :ok
import.reload
assert_equal 0, import.total_items
}
}
)
- assert_response 404
+ assert_response :not_found
end
def test_destroy_category_not_in_use
}
}
)
- assert_response 404
+ assert_response :not_found
end
end
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
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
:query_id => 999
}
)
- assert_response 404
+ assert_response :not_found
end
def test_index_with_cross_project_query_in_session_should_show_project_issues
)
@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
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
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
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
@request.session[:user_id] = 2
get :new
- assert_response 403
+ assert_response :forbidden
assert_select_error /no projects/
end
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
:project_id => 1
}
)
- assert_response 500
+ assert_response :internal_server_error
assert_select_error /No default issue/
end
:project_id => 1
}
)
- assert_response 500
+ assert_response :internal_server_error
assert_select_error /No tracker/
end
:project_id => 'invalid'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_new_with_parent_id_should_only_propose_valid_trackers
}
)
end
- assert_response 302
+ assert_response :found
issue = Issue.order('id DESC').first
assert_equal ['MySQL', 'Oracle'], issue.custom_field_value(1).sort
end
}
)
end
- assert_response 302
+ assert_response :found
issue = Issue.order('id DESC').first
assert_equal [''], issue.custom_field_value(1).sort
end
}
)
end
- assert_response 302
+ assert_response :found
issue = Issue.order('id DESC').first
assert_equal ['2', '3'], issue.custom_field_value(field).sort
end
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
assert_equal Date.parse('2012-07-14'), issue.start_date
}
}
)
- assert_response 302
+ assert_response :found
end
assert_equal 3, issue.tracker_id
end
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
assert_equal Issue.find(2), issue.parent
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
assert_equal Issue.find(2), issue.parent
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
assert_equal 3, issue.project_id
}
}
)
- assert_response 422
+ assert_response :unprocessable_entity
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
end
:copy_from => 99999
}
)
- assert_response 404
+ assert_response :not_found
end
def test_create_as_copy_on_different_project
}
}
)
- assert_response 302
+ assert_response :found
end
def test_put_update_with_tracker_change
}
}
)
- assert_response 302
+ assert_response :found
assert_equal parent, issue.parent
end
}
}
)
- assert_response 302
+ assert_response :found
assert_equal 'Changed subject', issue.reload.subject
end
}
}
)
- assert_response 302
+ assert_response :found
assert_equal 'Original subject', issue.reload.subject
end
}
}
)
- assert_response 302
+ assert_response :found
assert_equal 2, issue.reload.assigned_to_id
end
}
}
)
- 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}
}
}
)
- assert_response 302
+ assert_response :found
assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to}
end
end
}
}
)
- 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)
}
}
)
- assert_response 403
+ assert_response :forbidden
assert_not_equal "Bulk should fail", Journal.last.notes
end
}
}
)
- 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
}
}
)
- assert_response 302
+ assert_response :found
issue = Issue.find(1)
assert issue.closed?
end
}
}
)
- 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
}
}
)
- assert_response 302
+ assert_response :found
issue = Issue.find(1)
journal = issue.journals.reorder('created_on DESC').first
}
}
)
- 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
}
}
)
- 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
}
}
)
- 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
}
}
)
- assert_response 302
+ assert_response :found
# check that the issues were updated
assert_nil Issue.find(2).assigned_to
end
:copy => '1'
}
)
- assert_response 302
+ assert_response :found
end
end
:copy => '1'
}
)
- assert_response 403
+ assert_response :forbidden
end
def test_bulk_copy_on_different_project_without_add_issues_permission_should_be_denied
:copy => '1'
}
)
- assert_response 403
+ assert_response :forbidden
end
def test_bulk_copy_should_allow_not_changing_the_issue_attributes
:reassign_to_id => target.id
}
)
- assert_response 302
+ assert_response :found
assert_equal 'Successful deletion.', flash[:notice]
end
end
}
)
end
- assert_response 302
+ assert_response :found
assert_equal 'Successful deletion.', flash[:notice]
end
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
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
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
)
end
- assert_response 302
+ assert_response :found
issue = Issue.find(1)
assert_equal 4, issue.fixed_version_id
journal = Journal.order('id DESC').first
)
end
- assert_response 302
+ assert_response :found
issue = Issue.find(1)
assert_nil issue.fixed_version_id
journal = Journal.order('id DESC').first
)
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?
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]
}
}
)
- assert_response 302
+ assert_response :found
end
assert_equal users_to_test.keys.size, ActionMailer::Base.deliveries.size
}
}
)
- 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|
}
}
)
- 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?
:query_id => 999
}
)
- assert_response 404
+ assert_response :not_found
end
def test_index_should_return_privates_notes_with_permission_only
:detail_id => detail.id
}
)
- assert_response 302
+ assert_response :found
end
def test_diff_should_default_to_description_diff
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
},
:xhr => true
)
- assert_response 404
+ assert_response :not_found
end
def test_edit_xhr
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
)
end
end
- assert_response 201
+ assert_response :created
end
def test_should_create_issue_with_options
)
end
end
- assert_response 201
+ assert_response :created
issue = Issue.order(:id => :desc).first
assert_equal true, issue.is_private
end
end
end
end
- assert_response 201
+ assert_response :created
end
def test_should_respond_with_422_if_not_created
)
end
end
- assert_response 422
+ assert_response :unprocessable_entity
end
def test_should_not_allow_with_api_disabled
)
end
end
- assert_response 403
+ assert_response :forbidden
assert_include 'Access denied', response.body
end
)
end
end
- assert_response 403
+ assert_response :forbidden
assert_include 'Access denied', response.body
end
}
}
)
- assert_response 302
+ assert_response :found
member = Member.find(2)
assert member.user.locked?
assert_equal [1], member.role_ids
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
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
}
)
- assert_response 404
+ assert_response :not_found
end
def test_preview_new
:block => 'invalid'
}
)
- assert_response 422
+ assert_response :unprocessable_entity
end
def test_remove_block
@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
@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
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
}
}
)
- assert_response 302
+ assert_response :found
end
project = Project.order('id desc').first
assert_equal 'inherited', project.name
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
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
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
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})
}
}
)
- assert_response 403
+ assert_response :forbidden
assert_equal 'eCookbook', Project.find(1).name
end
}
}
)
- assert_response 403
+ assert_response :forbidden
assert_equal 'eCookbook', Project.find(1).name
end
}
}
)
- assert_response 302
+ assert_response :found
assert_match /Successful update/, flash[:notice]
end
:confirm => 'ecookbook'
}
)
- assert_response 403
+ assert_response :forbidden
end
assert Project.find(1)
end
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
end
assert Project.find(1)
assert Project.find(2)
- assert_response 200
+ assert_response :ok
end
def test_bulk_destroy_should_delete_projects
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
def test_index
get :index
# HTML response not implemented
- assert_response 406
+ assert_response :not_acceptable
end
def test_new_project_query
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
}
)
end
- assert_response 403
+ assert_response :forbidden
end
def test_create_global_query_without_permission_should_fail
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
}
}
)
- assert_response 302
+ assert_response :found
end
query = IssueQuery.order('id DESC').first
assert_redirected_to "/issues/gantt?query_id=#{query.id}"
}
}
)
- assert_response 302
+ assert_response :found
end
query = IssueQuery.order('id DESC').first
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
}
}
)
- assert_response 302
+ assert_response :found
end
assert_not_nil query.project
assert_equal Query::VISIBILITY_PRIVATE, query.visibility
}
}
)
- assert_response 302
+ assert_response :found
end
assert_nil query.project
assert_equal Query::VISIBILITY_PRIVATE, query.visibility
}
}
)
- assert_response 302
+ assert_response :found
end
assert_not_nil query.project
assert_equal Query::VISIBILITY_PUBLIC, query.visibility
}
}
)
- assert_response 302
+ assert_response :found
end
assert_nil query.project
assert_equal Query::VISIBILITY_PRIVATE, query.visibility
}
}
)
- assert_response 302
+ assert_response :found
end
assert_nil query.project
assert_equal Query::VISIBILITY_PUBLIC, query.visibility
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
:detail => 'invalid'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_issue_report_details_should_csv_export
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
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
}
}
)
- assert_response 302
+ assert_response :found
assert_equal 'test_update', Repository.find(11).password
end
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
:repository_id => 'foo'
}
)
- assert_response 404
+ assert_response :not_found
end
def test_revision
}
}
)
- assert_response 302
+ assert_response :found
assert_equal User.find(2), c.reload.user
end
end
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
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
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
end
- assert_response 302
+ assert_response :found
repository = Repository.order('id DESC').first
assert_kind_of Repository::Git, repository
assert_equal '/test', repository.url
}
}
)
- assert_response 302
+ assert_response :found
repo2 = Repository.find(repository.id)
assert_equal false, repo2.report_last_commit
end
:rev => r
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
:rev => r
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
}
)
end
- assert_response 302
+ assert_response :found
@project.reload
assert_nil @project.repository
end
:rev => 'something_weird'
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
:rev_to => 'something_weird'
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
:rev => r
}
)
- assert_response 404
+ assert_response :not_found
assert_select_error /was not found/
end
end
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
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
}
}
)
- assert_response 302
+ assert_response :found
end
assert_equal false, role.all_roles_managed
assert_equal [2, 3], role.managed_role_ids.sort
def test_edit_invalid_should_respond_with_404
get :edit, :params => {:id => 999}
- assert_response 404
+ assert_response :not_found
end
def test_update
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
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
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
end
get :plugin, :params => {:id => 'foo'}
- assert_response 404
+ assert_response :not_found
ensure
Redmine::Plugin.unregister(:foo)
:id => 'foo',
:settings => {'sample_setting' => 'Value'}
}
- assert_response 404
+ assert_response :not_found
ensure
Redmine::Plugin.unregister(:foo)
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
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
@request.session[:user_id] = 3
get :new
- assert_response 403
+ assert_response :forbidden
end
def test_new_should_select_default_role_activity
:hours => '7.3'
}
}
- assert_response 403
+ assert_response :forbidden
end
def test_create_without_project_and_issue_should_fail
}
end
- assert_response 403
+ assert_response :forbidden
end
def test_create_without_project_with_failure
:issue_id => '5'
}
}
- assert_response 302
+ assert_response :found
entry.reload
assert_equal 5, entry.issue_id
:project_id => '2'
}
}
- assert_response 302
+ assert_response :found
entry.reload
assert_equal 2, entry.project_id
# 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
# 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
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
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
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
: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
: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
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
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
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
@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
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
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
: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]
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
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
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
assert_no_difference 'User.count' do
delete :destroy, params: {id: user.id}
end
- assert_response 422
+ assert_response :unprocessable_entity
end
end
assert_no_difference 'User.count' do
delete :destroy, params: {id: user.id}
end
- assert_response 422
+ assert_response :unprocessable_entity
end
end
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
assert_no_difference 'User.count' do
delete :bulk_destroy, :params => {:ids => [6], :confirm => "Yes"}
end
- assert_response 404
+ assert_response :not_found
end
end
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
@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
@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
@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
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
delete :destroy, :params => {
:object_type => 'issue', :object_id => '2', :user_id => '999'
}
- assert_response 404
+ assert_response :not_found
end
end
end
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
@request.env["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest"
get :index
- assert_response 401
+ assert_response :unauthorized
end
end
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
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
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
@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
:id => 'NoContent',
:content => {:text => 'Some content'}
}
- assert_response 302
+ assert_response :found
end
end
assert_equal 'Some content', page.reload.content.text
: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
:version => '99',
:version_from => '98'
}
- assert_response 404
+ assert_response :not_found
end
def test_annotate
:project_id => 1, :id => 'CookBook_documentation',
:version => '99'
}
- assert_response 404
+ assert_response :not_found
end
def test_get_rename
end
end
end
- assert_response 404
+ assert_response :not_found
end
def test_index
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
def test_not_found
get :show, :params => {:project_id => 999}
- assert_response 404
+ assert_response :not_found
end
def test_protect_page
# 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
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
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
'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?
'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?
'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
'3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''}
}
}
- assert_response 302
+ assert_response :found
workflows = WorkflowPermission.all
assert_equal 3, workflows.size
: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
: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)
: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)
: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
: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
:autologin => 1
}
)
- assert_response 302
+ assert_response :found
end
assert cookies['custom_autologin'].present?
token = cookies['custom_autologin']
},
:headers => credentials('admin')
)
- assert_response 201
+ assert_response :created
end
ensure
ActionController::Base.allow_forgery_protection = false
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
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
: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']
"CONTENT_TYPE" => 'image/png'
}.merge(credentials('jsmith'))
)
- assert_response 406
+ assert_response :not_acceptable
end
end
"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
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
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
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
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
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
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
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
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
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
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
'/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
}
},
: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
}
},
:headers => credentials('jsmith'))
- assert_response 422
+ assert_response :unprocessable_entity
end
test "PUT /issues/:id.xml" do
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
'/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
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
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
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'
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'
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'
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
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
},
:headers => credentials('jsmith')
)
- assert_response 409
+ assert_response :conflict
end
end
end
},
:headers => credentials('jsmith')
)
- assert_response 201
+ assert_response :created
end
end
},
:headers => credentials('jsmith')
)
- assert_response 201
+ assert_response :created
end
end
},
:headers => credentials('jsmith')
)
- assert_response 201
+ assert_response :created
end
end
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
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
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
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
log_user('jsmith', 'jsmith')
get '/projects/nonexistingproject/issues/gantt'
- assert_response 404
+ assert_response :not_found
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
}
}
)
- assert_response 302
+ assert_response :found
end
issue = Issue.order('id DESC').first
: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
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"
}
)
end
- assert_response 302
+ assert_response :found
end
def test_create_issue_by_anonymous_with_custom_permission_should_succeed
}
}
)
- assert_response 302
+ assert_response :found
end
assert_equal User.anonymous, issue.author
end
}
}
)
- assert_response 302
+ assert_response :found
end
# Issue view
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
assert_no_difference 'Watcher.count' do
get '/watchers/watch?object_type=issue&object_id=1'
- assert_response 404
+ assert_response :not_found
end
end
'v' => {'cf_9' => ['2021-05-25']}
}
- assert_response 404
+ assert_response :not_found
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
end
}
}
)
- assert_response 302
+ assert_response :found
end
end
end
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"
assert_no_difference 'EnabledModule.count' do
get '/projects/1/modules', :params => {:enabled_module_names => ['']}
- assert_response 404
+ assert_response :not_found
end
end
end
jsmith.save!
get '/my/account'
- assert_response 302
+ assert_response :found
assert flash[:error].include?('Your session has expired')
end
assert jsmith.activate!
get '/my/account'
- assert_response 302
+ assert_response :found
assert flash[:error].include?('Your session has expired')
end
jsmith.save!
get '/my/account'
- assert_response 200
+ assert_response :ok
end
def test_change_password_generates_a_new_token_for_current_session
assert_not_nil token = session[:tk]
get '/my/password'
- assert_response 200
+ assert_response :ok
post(
'/my/password',
:params => {
: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
}
}
)
- assert_response 302
+ assert_response :found
user = User.find_by_login("psmith")
assert_kind_of User, user
:sudo_password => 'admin'
}
)
- assert_response 302
+ assert_response :found
user = User.find_by_login("psmith")
assert_kind_of User, user
assert_no_difference 'User.count' do
get '/users/destroy/2'
- assert_response 404
+ assert_response :not_found
end
end
end