From: Jean-Philippe Lang Date: Sun, 14 Nov 2010 16:45:32 +0000 (+0000) Subject: Adds leading slash to all assert_redirected_to arguments (#6887). X-Git-Tag: 1.1.0~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2fab7bd9b1f16d8e8c352dfe0c13d80ff896ea76;p=redmine.git Adds leading slash to all assert_redirected_to arguments (#6887). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4407 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 1d66d01d3..ac8af4abb 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -64,7 +64,7 @@ class AccountControllerTest < ActionController::TestCase assert existing_user.save! post :login, :openid_url => existing_user.identity_url - assert_redirected_to 'my/page' + assert_redirected_to '/my/page' end def test_login_with_invalid_openid_provider @@ -86,14 +86,14 @@ class AccountControllerTest < ActionController::TestCase assert existing_user.save! post :login, :openid_url => existing_user.identity_url - assert_redirected_to 'login' + assert_redirected_to '/login' end def test_login_with_openid_with_new_user_created Setting.self_registration = '3' Setting.openid = '1' post :login, :openid_url => 'http://openid.example.com/good_user' - assert_redirected_to 'my/account' + assert_redirected_to '/my/account' user = User.find_by_login('cool_user') assert user assert_equal 'Cool', user.firstname @@ -113,7 +113,7 @@ class AccountControllerTest < ActionController::TestCase Setting.self_registration = '1' Setting.openid = '1' post :login, :openid_url => 'http://openid.example.com/good_user' - assert_redirected_to 'login' + assert_redirected_to '/login' user = User.find_by_login('cool_user') assert user @@ -125,7 +125,7 @@ class AccountControllerTest < ActionController::TestCase Setting.self_registration = '2' Setting.openid = '1' post :login, :openid_url => 'http://openid.example.com/good_user' - assert_redirected_to 'login' + assert_redirected_to '/login' user = User.find_by_login('cool_user') assert user assert_equal User::STATUS_REGISTERED, user.status @@ -157,7 +157,7 @@ class AccountControllerTest < ActionController::TestCase def test_logout @request.session[:user_id] = 2 get :logout - assert_redirected_to '' + assert_redirected_to '/' assert_nil @request.session[:user_id] end diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 22e5d1ea7..3cc393ba1 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -95,7 +95,7 @@ class AttachmentsControllerTest < ActionController::TestCase post :destroy, :id => 1 end # no referrer - assert_redirected_to 'projects/ecookbook' + assert_redirected_to '/projects/ecookbook' assert_nil Attachment.find_by_id(1) j = issue.journals.find(:first, :order => 'created_on DESC') assert_equal 'attachment', j.details.first.property diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 1887c4896..7f3f2508f 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -27,7 +27,7 @@ class CommentsControllerTest < ActionController::TestCase def test_add_comment @request.session[:user_id] = 2 post :create, :id => 1, :comment => { :comments => 'This is a test comment' } - assert_redirected_to 'news/1' + assert_redirected_to '/news/1' comment = News.find(1).comments.find(:first, :order => 'created_on DESC') assert_not_nil comment @@ -40,7 +40,7 @@ class CommentsControllerTest < ActionController::TestCase assert_no_difference 'Comment.count' do post :create, :id => 1, :comment => { :comments => '' } assert_response :redirect - assert_redirected_to 'news/1' + assert_redirected_to '/news/1' end end @@ -48,7 +48,7 @@ class CommentsControllerTest < ActionController::TestCase comments_count = News.find(1).comments.size @request.session[:user_id] = 2 delete :destroy, :id => 1, :comment_id => 2 - assert_redirected_to 'news/1' + assert_redirected_to '/news/1' assert_nil Comment.find_by_id(2) assert_equal comments_count - 1, News.find(1).comments.size end diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index a1ce7ea77..594bd980b 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -77,7 +77,7 @@ LOREM :category_id => 2}, :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} - assert_redirected_to 'projects/ecookbook/documents' + assert_redirected_to '/projects/ecookbook/documents' document = Document.find_by_title('DocumentsControllerTest#test_post_new') assert_not_nil document @@ -90,7 +90,7 @@ LOREM def test_destroy @request.session[:user_id] = 2 post :destroy, :id => 1 - assert_redirected_to 'projects/ecookbook/documents' + assert_redirected_to '/projects/ecookbook/documents' assert_nil Document.find_by_id(1) end end diff --git a/test/functional/files_controller_test.rb b/test/functional/files_controller_test.rb index 6035c4be5..e2efde5e3 100644 --- a/test/functional/files_controller_test.rb +++ b/test/functional/files_controller_test.rb @@ -37,7 +37,7 @@ class FilesControllerTest < ActionController::TestCase :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} assert_response :redirect end - assert_redirected_to 'projects/ecookbook/files' + assert_redirected_to '/projects/ecookbook/files' a = Attachment.find(:first, :order => 'created_on DESC') assert_equal 'testfile.txt', a.filename assert_equal Project.find(1), a.container @@ -58,7 +58,7 @@ class FilesControllerTest < ActionController::TestCase :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} assert_response :redirect end - assert_redirected_to 'projects/ecookbook/files' + assert_redirected_to '/projects/ecookbook/files' a = Attachment.find(:first, :order => 'created_on DESC') assert_equal 'testfile.txt', a.filename assert_equal Version.find(2), a.container diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index d7bdbb788..d836375a2 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -54,7 +54,7 @@ class GroupsControllerTest < ActionController::TestCase assert_difference 'Group.count' do post :create, :group => {:lastname => 'New group'} end - assert_redirected_to 'groups' + assert_redirected_to '/groups' end def test_edit @@ -65,14 +65,14 @@ class GroupsControllerTest < ActionController::TestCase def test_update post :update, :id => 10 - assert_redirected_to 'groups' + assert_redirected_to '/groups' end def test_destroy assert_difference 'Group.count', -1 do post :destroy, :id => 10 end - assert_redirected_to 'groups' + assert_redirected_to '/groups' end def test_add_users diff --git a/test/functional/issue_moves_controller_test.rb b/test/functional/issue_moves_controller_test.rb index dc19ddc8d..e8c367964 100644 --- a/test/functional/issue_moves_controller_test.rb +++ b/test/functional/issue_moves_controller_test.rb @@ -72,7 +72,7 @@ class IssueMovesControllerTest < ActionController::TestCase post :create, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'} end end - assert_redirected_to 'projects/ecookbook/issues' + assert_redirected_to '/projects/ecookbook/issues' end context "#create via bulk copy" do diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index d614bc843..59dc704e4 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -87,7 +87,7 @@ class MessagesControllerTest < ActionController::TestCase :content => 'Message body'} message = Message.find_by_subject('Test created message') assert_not_nil message - assert_redirected_to "boards/1/topics/#{message.to_param}" + assert_redirected_to "/boards/1/topics/#{message.to_param}" assert_equal 'Message body', message.content assert_equal 2, message.author_id assert_equal 1, message.board_id @@ -114,7 +114,7 @@ class MessagesControllerTest < ActionController::TestCase post :edit, :board_id => 1, :id => 1, :message => { :subject => 'New subject', :content => 'New body'} - assert_redirected_to 'boards/1/topics/1' + assert_redirected_to '/boards/1/topics/1' message = Message.find(1) assert_equal 'New subject', message.subject assert_equal 'New body', message.content @@ -124,14 +124,14 @@ class MessagesControllerTest < ActionController::TestCase @request.session[:user_id] = 2 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } reply = Message.find(:first, :order => 'id DESC') - assert_redirected_to "boards/1/topics/1?r=#{reply.id}" + assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" assert Message.find_by_subject('Test reply') end def test_destroy_topic @request.session[:user_id] = 2 post :destroy, :board_id => 1, :id => 1 - assert_redirected_to 'projects/ecookbook/boards/1' + assert_redirected_to '/projects/ecookbook/boards/1' assert_nil Message.find_by_id(1) end diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index 877095dfb..3fefa0675 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -68,7 +68,7 @@ class MyControllerTest < ActionController::TestCase :login => "root", :admin => 1, :custom_field_values => {"4" => "0100562500"}} - assert_redirected_to 'my/account' + assert_redirected_to '/my/account' user = User.find(2) assert_equal user, assigns(:user) assert_equal "Joe", user.firstname @@ -102,7 +102,7 @@ class MyControllerTest < ActionController::TestCase post :password, :password => 'jsmith', :new_password => 'hello', :new_password_confirmation => 'hello' - assert_redirected_to 'my/account' + assert_redirected_to '/my/account' assert User.try_to_login('jsmith', 'hello') end diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index de5c055a4..5a20e8973 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -73,7 +73,7 @@ class NewsControllerTest < ActionController::TestCase post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', :description => 'This is the description', :summary => '' } - assert_redirected_to 'projects/ecookbook/news' + assert_redirected_to '/projects/ecookbook/news' news = News.find_by_title('NewsControllerTest') assert_not_nil news @@ -93,7 +93,7 @@ class NewsControllerTest < ActionController::TestCase def test_put_update @request.session[:user_id] = 2 put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } - assert_redirected_to 'news/1' + assert_redirected_to '/news/1' news = News.find(1) assert_equal 'Description changed by test_post_edit', news.description end @@ -114,7 +114,7 @@ class NewsControllerTest < ActionController::TestCase def test_destroy @request.session[:user_id] = 2 delete :destroy, :id => 1 - assert_redirected_to 'projects/ecookbook/news' + assert_redirected_to '/projects/ecookbook/news' assert_nil News.find_by_id(1) end end diff --git a/test/functional/project_enumerations_controller_test.rb b/test/functional/project_enumerations_controller_test.rb index 942399a96..ae39f3e55 100644 --- a/test/functional/project_enumerations_controller_test.rb +++ b/test/functional/project_enumerations_controller_test.rb @@ -20,7 +20,7 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase } assert_response :redirect - assert_redirected_to 'projects/ecookbook/settings/activities' + assert_redirected_to '/projects/ecookbook/settings/activities' # Created project specific activities... project = Project.find('ecookbook') @@ -83,7 +83,7 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase } assert_response :redirect - assert_redirected_to 'projects/ecookbook/settings/activities' + assert_redirected_to '/projects/ecookbook/settings/activities' # Created project specific activities... project = Project.find('ecookbook') @@ -159,7 +159,7 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase delete :destroy, :project_id => 1 assert_response :redirect - assert_redirected_to 'projects/ecookbook/settings/activities' + assert_redirected_to '/projects/ecookbook/settings/activities' assert_nil TimeEntryActivity.find_by_id(project_activity.id) assert_nil TimeEntryActivity.find_by_id(project_activity_two.id) @@ -179,7 +179,7 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase delete :destroy, :project_id => 1 assert_response :redirect - assert_redirected_to 'projects/ecookbook/settings/activities' + assert_redirected_to '/projects/ecookbook/settings/activities' assert_nil TimeEntryActivity.find_by_id(project_activity.id) assert_equal 0, TimeEntry.find_all_by_activity_id_and_project_id(project_activity.id, 1).size, "TimeEntries still assigned to project specific activity" diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 59d6286a1..3cd7c3dbf 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -344,7 +344,7 @@ class ProjectsControllerTest < ActionController::TestCase @request.session[:user_id] = 2 # manager post :update, :id => 1, :project => {:name => 'Test changed name', :issue_custom_field_ids => ['']} - assert_redirected_to 'projects/ecookbook/settings' + assert_redirected_to '/projects/ecookbook/settings' project = Project.find(1) assert_equal 'Test changed name', project.name end @@ -360,14 +360,14 @@ class ProjectsControllerTest < ActionController::TestCase def test_post_destroy @request.session[:user_id] = 1 # admin post :destroy, :id => 1, :confirm => 1 - assert_redirected_to 'admin/projects' + assert_redirected_to '/admin/projects' assert_nil Project.find_by_id(1) end def test_archive @request.session[:user_id] = 1 # admin post :archive, :id => 1 - assert_redirected_to 'admin/projects' + assert_redirected_to '/admin/projects' assert !Project.find(1).active? end @@ -375,7 +375,7 @@ class ProjectsControllerTest < ActionController::TestCase @request.session[:user_id] = 1 # admin Project.find(1).archive post :unarchive, :id => 1 - assert_redirected_to 'admin/projects' + assert_redirected_to '/admin/projects' assert Project.find(1).active? end @@ -424,7 +424,7 @@ class ProjectsControllerTest < ActionController::TestCase def test_jump_should_redirect_to_active_tab get :show, :id => 1, :jump => 'issues' - assert_redirected_to 'projects/ecookbook/issues' + assert_redirected_to '/projects/ecookbook/issues' end def test_jump_should_not_redirect_to_inactive_tab diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 2858617e7..2409e5005 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -98,7 +98,7 @@ class RepositoriesControllerTest < ActionController::TestCase assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} - assert_redirected_to 'projects/ecookbook/repository/committers' + assert_redirected_to '/projects/ecookbook/repository/committers' assert_equal User.find(2), c.reload.user end end diff --git a/test/functional/roles_controller_test.rb b/test/functional/roles_controller_test.rb index 9159742c9..1e0e3ea64 100644 --- a/test/functional/roles_controller_test.rb +++ b/test/functional/roles_controller_test.rb @@ -65,7 +65,7 @@ class RolesControllerTest < ActionController::TestCase :permissions => ['add_issues', 'edit_issues', 'log_time', ''], :assignable => '0'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' role = Role.find_by_name('RoleWithoutWorkflowCopy') assert_not_nil role assert_equal [:add_issues, :edit_issues, :log_time], role.permissions @@ -78,7 +78,7 @@ class RolesControllerTest < ActionController::TestCase :assignable => '0'}, :copy_workflow_from => '1' - assert_redirected_to 'roles' + assert_redirected_to '/roles' role = Role.find_by_name('RoleWithWorkflowCopy') assert_not_nil role assert_equal Role.find(1).workflows.size, role.workflows.size @@ -97,7 +97,7 @@ class RolesControllerTest < ActionController::TestCase :permissions => ['edit_project', ''], :assignable => '0'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' role = Role.find(1) assert_equal [:edit_project], role.permissions end @@ -107,13 +107,13 @@ class RolesControllerTest < ActionController::TestCase assert r.save post :destroy, :id => r - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_nil Role.find_by_id(r.id) end def test_destroy_role_in_use post :destroy, :id => 1 - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert flash[:error] == 'This role is in use and can not be deleted.' assert_not_nil Role.find_by_id(1) end @@ -139,7 +139,7 @@ class RolesControllerTest < ActionController::TestCase def test_post_report post :report, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']} - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_equal [:edit_issues], Role.find(1).permissions assert_equal [:add_issues, :delete_issues], Role.find(3).permissions @@ -148,33 +148,33 @@ class RolesControllerTest < ActionController::TestCase def test_clear_all_permissions post :report, :permissions => { '0' => '' } - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert Role.find(1).permissions.empty? end def test_move_highest post :edit, :id => 3, :role => {:move_to => 'highest'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_equal 1, Role.find(3).position end def test_move_higher position = Role.find(3).position post :edit, :id => 3, :role => {:move_to => 'higher'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_equal position - 1, Role.find(3).position end def test_move_lower position = Role.find(2).position post :edit, :id => 2, :role => {:move_to => 'lower'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_equal position + 1, Role.find(2).position end def test_move_lowest post :edit, :id => 2, :role => {:move_to => 'lowest'} - assert_redirected_to 'roles' + assert_redirected_to '/roles' assert_equal Role.count, Role.find(2).position end end diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 58e3ca881..cb87114d8 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -126,7 +126,7 @@ class SearchControllerTest < ActionController::TestCase def test_quick_jump_to_issue # issue of a public project get :index, :q => "3" - assert_redirected_to 'issues/3' + assert_redirected_to '/issues/3' # issue of a private project get :index, :q => "4" diff --git a/test/functional/settings_controller_test.rb b/test/functional/settings_controller_test.rb index f7ff2d16b..d7be054f3 100644 --- a/test/functional/settings_controller_test.rb +++ b/test/functional/settings_controller_test.rb @@ -50,7 +50,7 @@ class SettingsControllerTest < ActionController::TestCase :notified_events => %w(issue_added issue_updated news_added), :emails_footer => 'Test footer' } - assert_redirected_to 'settings/edit' + assert_redirected_to '/settings/edit' assert_equal 'functional@test.foo', Setting.mail_from assert !Setting.bcc_recipients? assert_equal %w(issue_added issue_updated news_added), Setting.notified_events diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb index 8307702e0..69e42f6d1 100644 --- a/test/integration/account_test.rb +++ b/test/integration/account_test.rb @@ -44,7 +44,7 @@ class AccountTest < ActionController::IntegrationTest # User logs in with 'autologin' checked post '/login', :username => user.login, :password => 'admin', :autologin => 1 - assert_redirected_to 'my/page' + assert_redirected_to '/my/page' token = Token.find :first assert_not_nil token assert_equal user, token.user @@ -105,7 +105,7 @@ class AccountTest < ActionController::IntegrationTest post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"}, :password => "newpass", :password_confirmation => "newpass" - assert_redirected_to 'my/account' + assert_redirected_to '/my/account' follow_redirect! assert_response :success assert_template 'my/account' @@ -152,7 +152,7 @@ class AccountTest < ActionController::IntegrationTest AuthSource.expects(:authenticate).returns({:login => 'foo', :firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com', :auth_source_id => 66}) post 'account/login', :username => 'foo', :password => 'bar' - assert_redirected_to 'my/page' + assert_redirected_to '/my/page' user = User.find_by_login('foo') assert user.is_a?(User) @@ -187,7 +187,7 @@ class AccountTest < ActionController::IntegrationTest sid = session[:session_id] post '/login', :username => 'admin', :password => 'admin' - assert_redirected_to 'my/page' + assert_redirected_to '/my/page' assert_not_equal sid, session[:session_id], "login should reset session" assert_equal 1, session[:user_id] sid = session[:session_id] diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index c8a151cfd..61024ce22 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -72,7 +72,7 @@ class IssuesTest < ActionController::IntegrationTest put 'issues/1', :notes => 'Some notes', :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} - assert_redirected_to "issues/1" + assert_redirected_to "/issues/1" # make sure attachment was saved attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") diff --git a/test/integration/projects_test.rb b/test/integration/projects_test.rb index 14175ea98..26b1a5ca9 100644 --- a/test/integration/projects_test.rb +++ b/test/integration/projects_test.rb @@ -27,7 +27,7 @@ class ProjectsTest < ActionController::IntegrationTest assert_response :success assert_template "admin/projects" post "projects/archive", :id => 1 - assert_redirected_to "admin/projects" + assert_redirected_to "/admin/projects" assert !Project.find(1).active? get 'projects/1' @@ -36,7 +36,7 @@ class ProjectsTest < ActionController::IntegrationTest assert_response 403 post "projects/unarchive", :id => 1 - assert_redirected_to "admin/projects" + assert_redirected_to "/admin/projects" assert Project.find(1).active? get "projects/1" assert_response :success