Hello from hook!
') + context 'with hooks' do + # A hook that is manually registered later + class ProjectBasedTemplate < Redmine::Hook::ViewListener + def view_layouts_base_html_head(context) + context[:controller].send(:render, html: 'Hello from hook!
'.html_safe) + end + end + + before do + # Don't use this hook now + Redmine::Hook.clear_listeners + end + + after do + Redmine::Hook.clear_listeners + end + + it 'should hook response' do + Redmine::Hook.add_listener(ProjectBasedTemplate) + get :show, params: { id: 1 } + assert_select('p#hookselector') end end - # Don't use this hook now - Redmine::Hook.clear_listeners - - it 'should hook response' do - Redmine::Hook.add_listener(ProjectBasedTemplate) - get :show, id: 1 - assert_select('p#hookselector') - - Redmine::Hook.clear_listeners - end end diff --git a/spec_legacy/functional/repositories_controller_spec.rb b/spec_legacy/functional/repositories_controller_spec.rb index a1c0e8fcb4c..8ef015a0184 100644 --- a/spec_legacy/functional/repositories_controller_spec.rb +++ b/spec_legacy/functional/repositories_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -26,7 +27,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'repositories_controller' describe RepositoriesController, type: :controller do @@ -50,52 +51,57 @@ describe RepositoriesController, type: :controller do end it 'should revisions' do - get :revisions, project_id: 1 + get :revisions, params: { project_id: 1 } assert_response :success assert_template 'revisions' refute_nil assigns(:changesets) end it 'should revision' do - get :revision, project_id: 1, rev: 1 + get :revision, params: { project_id: 1, rev: 1 } assert_response :success refute_nil assigns(:changeset) assert_equal '1', assigns(:changeset).revision end it 'should revision with before nil and after normal' do - get :revision, project_id: 1, rev: 1 + get :revision, params: { project_id: 1, rev: 1 } assert_response :success assert_template 'revision' - assert_select('ul', - {attributes: { class: 'toolbar-items' }, - descendant: { tag: 'a', - attributes: { - href: @controller.url_for( - only_path: true, - controller: 'repositories', - action: 'revision', - project_id: 'ecookbook', - rev: '0' - ) - }}}, false) + assert_select('ul', + { + attributes: { class: 'toolbar-items' }, + descendant: { + tag: 'a', + attributes: { + href: @controller.url_for( + only_path: true, + controller: 'repositories', + action: 'revision', + project_id: 'ecookbook', + rev: '0' + ) + } + } + }, false) assert_select 'ul', - attributes: { class: 'toolbar-items' }, - descendant: { tag: 'a', - attributes: { - href: @controller.url_for( - only_path: true, - controller: 'repositories', - action: 'revision', - project_id: 'ecookbook', - rev: '2' - ) - } - } + attributes: { class: 'toolbar-items' }, + descendant: { + tag: 'a', + attributes: { + href: @controller.url_for( + only_path: true, + controller: 'repositories', + action: 'revision', + project_id: 'ecookbook', + rev: '2' + ) + } + } end it 'should graph commits per month' do - get :graph, project_id: 1, graph: 'commits_per_month' + get :graph, params: { project_id: 1, graph: 'commits_per_month' } assert_response :success assert_equal 'image/svg+xml', response.content_type end @@ -111,24 +117,27 @@ describe RepositoriesController, type: :controller do comments: 'Committed by foo.' ) - get :committers, project_id: 1 + get :committers, params: { project_id: 1 } assert_response :success assert_template 'committers' assert_select 'td', - content: 'foo', - sibling: { - tag: 'td', - child: { tag: 'select', - attributes: { name: %r{^committers\[\d+\]\[\]$} } - } - } - assert_select('td', - {content: 'foo', + content: 'foo', sibling: { tag: 'td', - descendant: { tag: 'option', attributes: { selected: 'selected' } } - }}, false) + child: { + tag: 'select', + attributes: { name: %r{^committers\[\d+\]\[\]$} } + } + } + assert_select('td', + { + content: 'foo', + sibling: { + tag: 'td', + descendant: { tag: 'option', attributes: { selected: 'selected' } } + } + }, false) end it 'should map committers' do @@ -142,8 +151,12 @@ describe RepositoriesController, type: :controller do comments: 'Committed by foo.' ) assert_no_difference "Changeset.where('user_id = 3').count" do - post :committers, project_id: 1, - committers: { '0' => ['foo', '2'], '1' => ['dlopper', '3'] } + post :committers, + params: { + project_id: 1, + committers: { '0' => ['foo', '2'], + '1' => ['dlopper', '3'] } + } assert_redirected_to '/projects/ecookbook/repository/committers' assert_equal User.find(2), c.reload.user end diff --git a/spec_legacy/functional/repositories_git_controller_spec.rb b/spec_legacy/functional/repositories_git_controller_spec.rb index 596cecd9448..10bca8ee931 100644 --- a/spec_legacy/functional/repositories_git_controller_spec.rb +++ b/spec_legacy/functional/repositories_git_controller_spec.rb @@ -26,7 +26,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'repositories_controller' describe RepositoriesController, 'Git', type: :controller do @@ -64,7 +64,7 @@ describe RepositoriesController, 'Git', type: :controller do it 'should browse root' do @repository.fetch_changesets @repository.reload - get :show, project_id: 3 + get :show, params: { project_id: 3 } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -85,7 +85,7 @@ describe RepositoriesController, 'Git', type: :controller do it 'should browse branch' do @repository.fetch_changesets @repository.reload - get :show, project_id: 3, rev: 'test_branch' + get :show, params: { project_id: 3, rev: 'test_branch' } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -105,7 +105,7 @@ describe RepositoriesController, 'Git', type: :controller do 'tag00.lightweight', 'tag01.annotated', ].each do |t1| - get :show, project_id: 3, rev: t1 + get :show, params: { project_id: 3, rev: t1 } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -118,7 +118,7 @@ describe RepositoriesController, 'Git', type: :controller do it 'should browse directory' do @repository.fetch_changesets @repository.reload - get :show, project_id: 3, path: 'images' + get :show, params: { project_id: 3, path: 'images' } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -134,7 +134,7 @@ describe RepositoriesController, 'Git', type: :controller do it 'should browse at given revision' do @repository.fetch_changesets @repository.reload - get :show, project_id: 3, path: 'images', rev: '7234cb2750b63f47bff735edc50a1c0a433c2518' + get :show, params: { project_id: 3, path: 'images', rev: '7234cb2750b63f47bff735edc50a1c0a433c2518' } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -144,7 +144,7 @@ describe RepositoriesController, 'Git', type: :controller do end it 'should changes' do - get :changes, project_id: 3, path: 'images/edit.png' + get :changes, params: { project_id: 3, path: 'images/edit.png' } assert_response :success assert_template 'changes' assert_select 'div', @@ -153,25 +153,25 @@ describe RepositoriesController, 'Git', type: :controller do end it 'should entry show' do - get :entry, project_id: 3, path: 'sources/watchers_controller.rb' + get :entry, params: { project_id: 3, path: 'sources/watchers_controller.rb' } assert_response :success assert_template 'entry' # Line 19 assert_select 'th', - content: /11/, - attributes: { class: /line-num/ }, - sibling: { tag: 'td', content: /WITHOUT ANY WARRANTY/ } + content: /11/, + attributes: { class: /line-num/ }, + sibling: { tag: 'td', content: /WITHOUT ANY WARRANTY/ } end it 'should entry download' do - get :entry, project_id: 3, path: 'sources/watchers_controller.rb', format: 'raw' + get :entry, params: { project_id: 3, path: 'sources/watchers_controller.rb', format: 'raw' } assert_response :success # File content assert response.body.include?('WITHOUT ANY WARRANTY') end it 'should directory entry' do - get :entry, project_id: 3, path: 'sources' + get :entry, params: { project_id: 3, path: 'sources' } assert_response :success assert_template 'show' refute_nil assigns(:entry) @@ -183,7 +183,7 @@ describe RepositoriesController, 'Git', type: :controller do @repository.reload # Full diff of changeset 2f9c0091 - get :diff, project_id: 3, rev: '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' + get :diff, params: { project_id: 3, rev: '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' } assert_response :success assert_template 'diff' # Line 22 removed @@ -199,8 +199,8 @@ describe RepositoriesController, 'Git', type: :controller do @repository.fetch_changesets @repository.reload - get :diff, project_id: 3, rev: '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', - rev_to: '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' + get :diff, params: { project_id: 3, rev: '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', + rev_to: '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' } assert_response :success assert_template 'diff' @@ -210,7 +210,7 @@ describe RepositoriesController, 'Git', type: :controller do end it 'should annotate' do - get :annotate, project_id: 3, path: 'sources/watchers_controller.rb' + get :annotate, params: { project_id: 3, path: 'sources/watchers_controller.rb' } assert_response :success assert_template 'annotate' # Line 23, changeset 2f9c0091 @@ -223,7 +223,7 @@ describe RepositoriesController, 'Git', type: :controller do it 'should annotate at given revision' do @repository.fetch_changesets @repository.reload - get :annotate, project_id: 3, rev: 'deff7', path: 'sources/watchers_controller.rb' + get :annotate, params: { project_id: 3, rev: 'deff7', path: 'sources/watchers_controller.rb' } assert_response :success assert_template 'annotate' assert_select 'div', @@ -232,7 +232,7 @@ describe RepositoriesController, 'Git', type: :controller do end it 'should annotate binary file' do - get :annotate, project_id: 3, path: 'images/edit.png' + get :annotate, params: { project_id: 3, path: 'images/edit.png' } assert_response 200 assert_select 'p', attributes: { class: /nodata/ }, @@ -243,7 +243,7 @@ describe RepositoriesController, 'Git', type: :controller do @repository.fetch_changesets @repository.reload ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| - get :revision, project_id: 3, rev: r + get :revision, params: { project_id: 3, rev: r } assert_response :success assert_template 'revision' end @@ -253,7 +253,7 @@ describe RepositoriesController, 'Git', type: :controller do @repository.fetch_changesets @repository.reload ['', ' ', nil].each do |r| - get :revision, project_id: 3, rev: r + get :revision, params: { project_id: 3, rev: r } assert_response 404 assert_error_tag content: /was not found/ end diff --git a/spec_legacy/functional/repositories_subversion_controller_spec.rb b/spec_legacy/functional/repositories_subversion_controller_spec.rb index c74f8e9f0d1..3ddbf980349 100644 --- a/spec_legacy/functional/repositories_subversion_controller_spec.rb +++ b/spec_legacy/functional/repositories_subversion_controller_spec.rb @@ -26,7 +26,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'repositories_controller' describe RepositoriesController, 'Subversion', type: :controller do @@ -61,7 +61,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should show' do @repository.fetch_changesets @repository.reload - get :show, project_id: PRJ_ID + get :show, params: { project_id: PRJ_ID } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -71,7 +71,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should browse root' do @repository.fetch_changesets @repository.reload - get :show, project_id: PRJ_ID + get :show, params: { project_id: PRJ_ID } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -82,7 +82,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should browse directory' do @repository.fetch_changesets @repository.reload - get :show, project_id: PRJ_ID, path: 'subversion_test' + get :show, params: { project_id: PRJ_ID, path: 'subversion_test' } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -96,7 +96,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should browse at given revision' do @repository.fetch_changesets @repository.reload - get :show, project_id: PRJ_ID, path: 'subversion_test', rev: 4 + get :show, params: { project_id: PRJ_ID, path: 'subversion_test', rev: 4 } assert_response :success assert_template 'show' refute_nil assigns(:entries) @@ -106,7 +106,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should file changes' do @repository.fetch_changesets @repository.reload - get :changes, project_id: PRJ_ID, path: 'subversion_test/folder/helloworld.rb' + get :changes, params: { project_id: PRJ_ID, path: 'subversion_test/folder/helloworld.rb' } assert_response :success assert_template 'changes' @@ -128,7 +128,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should directory changes' do @repository.fetch_changesets @repository.reload - get :changes, project_id: PRJ_ID, path: 'subversion_test/folder' + get :changes, params: { project_id: PRJ_ID, path: 'subversion_test/folder' } assert_response :success assert_template 'changes' @@ -140,7 +140,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should entry' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c' + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/helloworld.c' } assert_response :success assert_template 'entry' end @@ -151,7 +151,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should entry should send if too big' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c' + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/helloworld.c' } assert_response :success assert_template nil assert_equal 'attachment; filename="helloworld.c"', response.headers['Content-Disposition'] @@ -161,7 +161,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should entry at given revision' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.rb', rev: 2 + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/helloworld.rb', rev: 2 } assert_response :success assert_template 'entry' # this line was removed in r3 and file was moved in r6 @@ -172,7 +172,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should entry not found' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/zzz.c' + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/zzz.c' } assert_select 'div', attributes: { id: /errorExplanation/ }, content: /The entry or revision was not found in the repository/ end @@ -180,7 +180,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should entry download' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c', format: 'raw' + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/helloworld.c', format: 'raw' } assert_response :success assert_template nil assert_equal 'attachment; filename="helloworld.c"', response.headers['Content-Disposition'] @@ -189,7 +189,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should directory entry' do @repository.fetch_changesets @repository.reload - get :entry, project_id: PRJ_ID, path: 'subversion_test/folder' + get :entry, params: { project_id: PRJ_ID, path: 'subversion_test/folder' } assert_response :success assert_template 'show' refute_nil assigns(:entry) @@ -200,7 +200,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should revision' do @repository.fetch_changesets @repository.reload - get :revision, project_id: 1, rev: 2 + get :revision, params: { project_id: 1, rev: 2 } assert_response :success assert_template 'revision' assert_select 'ul', @@ -220,13 +220,13 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should invalid revision' do @repository.fetch_changesets @repository.reload - get :revision, project_id: PRJ_ID, rev: 'something_weird' + get :revision, params: { project_id: PRJ_ID, rev: 'something_weird' } assert_response 404 assert_error_tag content: /was not found/ end it 'should invalid revision diff' do - get :diff, project_id: PRJ_ID, rev: '1', rev_to: 'something_weird' + get :diff, params: { project_id: PRJ_ID, rev: '1', rev_to: 'something_weird' } assert_response 404 assert_error_tag content: /was not found/ end @@ -235,7 +235,7 @@ describe RepositoriesController, 'Subversion', type: :controller do @repository.fetch_changesets @repository.reload ['', ' ', nil].each do |r| - get :revision, project_id: PRJ_ID, rev: r + get :revision, params: { project_id: PRJ_ID, rev: r } assert_response 404 assert_error_tag content: /was not found/ end @@ -247,7 +247,7 @@ describe RepositoriesController, 'Subversion', type: :controller do # Changes repository url to a subdirectory r.update_attribute :url, (r.url + '/subversion_test/folder/') - get :revision, project_id: 1, rev: 2 + get :revision, params: { project_id: 1, rev: 2 } assert_response :success assert_template 'revision' assert_select 'ul', @@ -267,7 +267,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should revision diff' do @repository.fetch_changesets @repository.reload - get :diff, project_id: PRJ_ID, rev: 3 + get :diff, params: { project_id: PRJ_ID, rev: 3 } assert_response :success assert_template 'diff' @@ -277,7 +277,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should directory diff' do @repository.fetch_changesets @repository.reload - get :diff, project_id: PRJ_ID, rev: 6, rev_to: 2, path: 'subversion_test/folder' + get :diff, params: { project_id: PRJ_ID, rev: 6, rev_to: 2, path: 'subversion_test/folder' } assert_response :success assert_template 'diff' @@ -292,7 +292,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should annotate' do @repository.fetch_changesets @repository.reload - get :annotate, project_id: PRJ_ID, path: 'subversion_test/helloworld.c' + get :annotate, params: { project_id: PRJ_ID, path: 'subversion_test/helloworld.c' } assert_response :success assert_template 'annotate' end @@ -300,7 +300,7 @@ describe RepositoriesController, 'Subversion', type: :controller do it 'should annotate at given revision' do @repository.fetch_changesets @repository.reload - get :annotate, project_id: PRJ_ID, rev: 8, path: 'subversion_test/helloworld.c' + get :annotate, params: { project_id: PRJ_ID, rev: 8, path: 'subversion_test/helloworld.c' } assert_response :success assert_template 'annotate' assert_select 'div', diff --git a/spec_legacy/functional/roles_controller_spec.rb b/spec_legacy/functional/roles_controller_spec.rb index 27bb268b74c..8f1a59445e1 100644 --- a/spec_legacy/functional/roles_controller_spec.rb +++ b/spec_legacy/functional/roles_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -47,8 +48,9 @@ describe RolesController, type: :controller do refute_nil assigns(:roles) assert_equal Role.order('builtin, position').to_a, assigns(:roles) - assert_select 'a', attributes: { href: edit_role_path(1) }, - content: 'Manager' + assert_select 'a', + attributes: { href: edit_role_path(1) }, + content: 'Manager' end it 'should get new' do @@ -58,9 +60,14 @@ describe RolesController, type: :controller do end it 'should post new with validaton failure' do - post :create, role: { name: '', - permissions: ['add_work_packages', 'edit_work_packages', 'log_time', ''], - assignable: '0' } + post :create, + params: { + role: { + name: '', + permissions: ['add_work_packages', 'edit_work_packages', 'log_time', ''], + assignable: '0' + } + } assert_response :success assert_template 'new' @@ -68,9 +75,14 @@ describe RolesController, type: :controller do end it 'should post new without workflow copy' do - post :create, role: { name: 'RoleWithoutWorkflowCopy', - permissions: ['add_work_packages', 'edit_work_packages', 'log_time'], - assignable: '0' } + post :create, + params: { + role: { + name: 'RoleWithoutWorkflowCopy', + permissions: ['add_work_packages', 'edit_work_packages', 'log_time'], + assignable: '0' + } + } assert_redirected_to roles_path role = Role.find_by(name: 'RoleWithoutWorkflowCopy') @@ -80,10 +92,15 @@ describe RolesController, type: :controller do end it 'should post new with workflow copy' do - post :create, role: { name: 'RoleWithWorkflowCopy', - permissions: ['add_work_packages', 'edit_work_packages', 'log_time'], - assignable: '0' }, - copy_workflow_from: '1' + post :create, + params: { + role: { + name: 'RoleWithWorkflowCopy', + permissions: ['add_work_packages', 'edit_work_packages', 'log_time'], + assignable: '0' + }, + copy_workflow_from: '1' + } assert_redirected_to roles_path role = Role.find_by(name: 'RoleWithWorkflowCopy') @@ -92,17 +109,22 @@ describe RolesController, type: :controller do end it 'should get edit' do - get :edit, id: 1 + get :edit, params: { id: 1 } assert_response :success assert_template 'edit' assert_equal Role.find(1), assigns(:role) end it 'should put update' do - put :update, id: 1, - role: { name: 'Manager', - permissions: ['edit_project'], - assignable: '0' } + put :update, + params: { + id: 1, + role: { + name: 'Manager', + permissions: ['edit_project'], + assignable: '0' + } + } assert_redirected_to roles_path role = Role.find(1) @@ -113,13 +135,13 @@ describe RolesController, type: :controller do r = Role.new(name: 'ToBeDestroyed', permissions: [:view_wiki_pages]) assert r.save - delete :destroy, id: r + delete :destroy, params: { id: r } assert_redirected_to roles_path assert_nil Role.find_by(id: r.id) end it 'should destroy role in use' do - delete :destroy, id: 1 + delete :destroy, params: { id: 1 } assert_redirected_to roles_path assert flash[:error] == 'This role is in use and cannot be deleted.' refute_nil Role.find_by(id: 1) @@ -134,18 +156,21 @@ describe RolesController, type: :controller do assert_equal Role.order('builtin, position'), assigns(:roles) assert_select 'input', attributes: { type: 'checkbox', - name: 'permissions[3][]', - value: 'add_work_packages', - checked: 'checked' } + name: 'permissions[3][]', + value: 'add_work_packages', + checked: 'checked' } assert_select 'input', attributes: { type: 'checkbox', - name: 'permissions[3][]', - value: 'delete_work_packages', - checked: nil } + name: 'permissions[3][]', + value: 'delete_work_packages', + checked: nil } end it 'should put bulk update' do - put :bulk_update, permissions: { '0' => '', '1' => ['edit_work_packages'], '3' => ['add_work_packages', 'delete_work_packages'] } + put :bulk_update, + params: { + permissions: { '0' => '', '1' => ['edit_work_packages'], '3' => ['add_work_packages', 'delete_work_packages'] } + } assert_redirected_to roles_path assert_equal [:edit_work_packages], Role.find(1).permissions @@ -154,33 +179,33 @@ describe RolesController, type: :controller do end it 'should clear all permissions' do - put :bulk_update, permissions: { '0' => '' } + put :bulk_update, params: { permissions: { '0' => '' } } assert_redirected_to roles_path assert Role.find(1).permissions.empty? end it 'should move highest' do - put :update, id: 3, role: { move_to: 'highest' } + put :update, params: { id: 3, role: { move_to: 'highest' } } assert_redirected_to roles_path assert_equal 1, Role.find(3).position end it 'should move higher' do position = Role.find(3).position - put :update, id: 3, role: { move_to: 'higher' } + put :update, params: { id: 3, role: { move_to: 'higher' } } assert_redirected_to roles_path assert_equal position - 1, Role.find(3).position end it 'should move lower' do position = Role.find(2).position - put :update, id: 2, role: { move_to: 'lower' } + put :update, params: { id: 2, role: { move_to: 'lower' } } assert_redirected_to roles_path assert_equal position + 1, Role.find(2).position end it 'should move lowest' do - put :update, id: 2, role: { move_to: 'lowest' } + put :update, params: { id: 2, role: { move_to: 'lowest' } } assert_redirected_to roles_path assert_equal Role.count, Role.find(2).position end diff --git a/spec_legacy/functional/search_controller_spec.rb b/spec_legacy/functional/search_controller_spec.rb index 1b0e1e0765f..0370ff60684 100644 --- a/spec_legacy/functional/search_controller_spec.rb +++ b/spec_legacy/functional/search_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -27,7 +28,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'search_controller' describe SearchController, type: :controller do @@ -40,7 +41,7 @@ describe SearchController, type: :controller do end it 'should search all projects' do - get :index, q: 'recipe subproject commit', submit: 'Search' + get :index, params: { q: 'recipe subproject commit', submit: 'Search' } assert_response :success assert_template 'index' @@ -54,7 +55,7 @@ describe SearchController, type: :controller do end it 'should search project and subprojects' do - get :index, project_id: 1, q: 'recipe subproject', scope: 'subprojects', submit: 'Search' + get :index, params: { project_id: 1, q: 'recipe subproject', scope: 'subprojects', submit: 'Search' } assert_response :success assert_template 'index' assert assigns(:results).include?(WorkPackage.find(1)) @@ -64,18 +65,18 @@ describe SearchController, type: :controller do it 'should search without searchable custom fields' do CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" - get :index, project_id: 1 + get :index, params: { project_id: 1 } assert_response :success assert_template 'index' refute_nil assigns(:project) - get :index, project_id: 1, q: 'can' + get :index, params: { project_id: 1, q: 'can' } assert_response :success assert_template 'index' end it 'should search with searchable custom fields' do - get :index, project_id: 1, q: 'stringforcustomfield' + get :index, params: { project_id: 1, q: 'stringforcustomfield' } assert_response :success results = assigns(:results) refute_nil results @@ -85,7 +86,7 @@ describe SearchController, type: :controller do it 'should search all words' do # 'all words' is on by default - get :index, project_id: 1, q: 'recipe updating saving' + get :index, params: { project_id: 1, q: 'recipe updating saving' } results = assigns(:results) refute_nil results assert_equal 1, results.size @@ -93,7 +94,7 @@ describe SearchController, type: :controller do end it 'should search one of the words' do - get :index, project_id: 1, q: 'recipe updating saving', submit: 'Search' + get :index, params: { project_id: 1, q: 'recipe updating saving', submit: 'Search' } results = assigns(:results) refute_nil results assert_equal 3, results.size @@ -101,45 +102,45 @@ describe SearchController, type: :controller do end it 'should search titles only without result' do - get :index, project_id: 1, q: 'recipe updating saving', all_words: '1', titles_only: '1', submit: 'Search' + get :index, params: { project_id: 1, q: 'recipe updating saving', all_words: '1', titles_only: '1', submit: 'Search' } results = assigns(:results) refute_nil results assert_equal 0, results.size end it 'should search titles only' do - get :index, project_id: 1, q: 'recipe', titles_only: '1', submit: 'Search' + get :index, params: { project_id: 1, q: 'recipe', titles_only: '1', submit: 'Search' } results = assigns(:results) refute_nil results assert_equal 2, results.size end it 'should search with invalid project id' do - get :index, project_id: 195, q: 'recipe' + get :index, params: { project_id: 195, q: 'recipe' } assert_response 404 assert_nil assigns(:results) end it 'should quick jump to work packages' do # work_package of a public project - get :index, q: '3' + get :index, params: { q: '3' } assert_redirected_to '/work_packages/3' end it 'should not jump to an invisible WP' do - get :index, q: '4' + get :index, params: { q: '4' } assert_response :success assert_template 'index' end it 'should large integer' do - get :index, q: '4615713488' + get :index, params: { q: '4615713488' } assert_response :success assert_template 'index' end it 'should tokens with quotes' do - get :index, project_id: 1, q: '"good bye" hello "bye bye"' + get :index, params: { project_id: 1, q: '"good bye" hello "bye bye"' } assert_equal ['good bye', 'hello', 'bye bye'], assigns(:tokens) end end diff --git a/spec_legacy/functional/settings_controller_spec.rb b/spec_legacy/functional/settings_controller_spec.rb index e5ebd5c8837..c1a119f041d 100644 --- a/spec_legacy/functional/settings_controller_spec.rb +++ b/spec_legacy/functional/settings_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -27,7 +28,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'settings_controller' describe SettingsController, type: :controller do @@ -51,11 +52,15 @@ describe SettingsController, type: :controller do end it 'should post edit notifications' do - post :edit, settings: { mail_from: 'functional@test.foo', - bcc_recipients: '0', - notified_events: %w(work_package_added work_package_updated news_added), - emails_footer: 'Test footer' - } + post :edit, + params: { + settings: { + mail_from: 'functional@test.foo', + bcc_recipients: '0', + notified_events: %w(work_package_added work_package_updated news_added), + emails_footer: 'Test footer' + } + } assert_redirected_to '/settings/edit' assert_equal 'functional@test.foo', Setting.mail_from assert !Setting.bcc_recipients? diff --git a/spec_legacy/functional/sys_controller_spec.rb b/spec_legacy/functional/sys_controller_spec.rb index 391a204add8..3abf343693b 100644 --- a/spec_legacy/functional/sys_controller_spec.rb +++ b/spec_legacy/functional/sys_controller_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'sys_controller' describe SysController, type: :controller do @@ -44,7 +44,7 @@ describe SysController, type: :controller do get :projects assert_response :success assert_equal 'application/xml', response.content_type - assert_select 'projects', children: { count: Project.active.has_module(:repository).count } + assert_select 'projects', children: { count: Project.active.has_module(:repository).count } end it 'should fetch changesets' do @@ -55,23 +55,23 @@ describe SysController, type: :controller do it 'should fetch changesets one project' do expect_any_instance_of(Repository::Subversion).to receive(:fetch_changesets).and_return(true) - get :fetch_changesets, id: 'ecookbook' + get :fetch_changesets, params: { id: 'ecookbook' } assert_response :success end it 'should fetch changesets unknown project' do - get :fetch_changesets, id: 'unknown' + get :fetch_changesets, params: { id: 'unknown' } assert_response 404 end describe 'api key', with_settings: { sys_api_key: 'my_secret_key' } do it 'should api key' do - get :projects, key: 'my_secret_key' + get :projects, params: { key: 'my_secret_key' } assert_response :success end it 'should wrong key should respond with 403 error' do - get :projects, key: 'wrong_key' + get :projects, params: { key: 'wrong_key' } assert_response 403 end end diff --git a/spec_legacy/functional/time_entries/reports_controller_spec.rb b/spec_legacy/functional/time_entries/reports_controller_spec.rb index 1907256579b..b36b219f016 100644 --- a/spec_legacy/functional/time_entries/reports_controller_spec.rb +++ b/spec_legacy/functional/time_entries/reports_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -27,7 +28,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe TimeEntries::ReportsController, type: :controller do render_views @@ -35,11 +36,11 @@ describe TimeEntries::ReportsController, type: :controller do fixtures :all it 'should report at project level' do - get :show, project_id: 'ecookbook' + get :show, params: { project_id: 'ecookbook' } assert_response :success assert_template 'time_entries/reports/show' assert_select 'form', - attributes: { action: '/projects/ecookbook/time_entries/report', id: 'query_form' } + attributes: { action: '/projects/ecookbook/time_entries/report', id: 'query_form' } end it 'should report all projects' do @@ -47,7 +48,7 @@ describe TimeEntries::ReportsController, type: :controller do assert_response :success assert_template 'time_entries/reports/show' assert_select 'form', - attributes: { action: '/time_entries/report', id: 'query_form' } + attributes: { action: '/time_entries/report', id: 'query_form' } end it 'should report all projects denied' do @@ -59,7 +60,7 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report all projects one criteria' do - get :show, columns: 'week', from: '2007-04-01', to: '2007-04-30', criterias: ['project'] + get :show, params: { columns: 'week', from: '2007-04-01', to: '2007-04-30', criterias: ['project'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -67,7 +68,7 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report all time' do - get :show, project_id: 1, criterias: ['project', 'issue'] + get :show, params: { project_id: 1, criterias: ['project', 'issue'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -75,7 +76,7 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report all time by day' do - get :show, project_id: 1, criterias: ['project', 'issue'], columns: 'day' + get :show, params: { project_id: 1, criterias: ['project', 'issue'], columns: 'day' } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -84,7 +85,7 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report one criteria' do - get :show, project_id: 1, columns: 'week', from: '2007-04-01', to: '2007-04-30', criterias: ['project'] + get :show, params: { project_id: 1, columns: 'week', from: '2007-04-01', to: '2007-04-30', criterias: ['project'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -92,7 +93,11 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report two criterias' do - get :show, project_id: 1, columns: 'month', from: '2007-01-01', to: '2007-12-31', criterias: ['member', 'activity'] + get :show, params: { project_id: 1, + columns: 'month', + from: '2007-01-01', + to: '2007-12-31', + criterias: ['member', 'activity'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -100,7 +105,7 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report one day' do - get :show, project_id: 1, columns: 'day', from: '2007-03-23', to: '2007-03-23', criterias: ['member', 'activity'] + get :show, params: { project_id: 1, columns: 'day', from: '2007-03-23', to: '2007-03-23', criterias: ['member', 'activity'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -108,17 +113,22 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report at issue level' do - get :show, project_id: 1, work_package_id: 1, columns: 'month', from: '2007-01-01', to: '2007-12-31', criterias: ['member', 'activity'] + get :show, params: { project_id: 1, + work_package_id: 1, + columns: 'month', + from: '2007-01-01', + to: '2007-12-31', + criterias: ['member', 'activity'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) assert_equal '154.25', '%.2f' % assigns(:total_hours) assert_select 'form', - attributes: { action: work_package_time_entries_report_path(1), id: 'query_form' } + attributes: { action: work_package_time_entries_report_path(1), id: 'query_form' } end it 'should report custom field criteria' do - get :show, project_id: 1, criterias: ['project', 'cf_1', 'cf_7'] + get :show, params: { project_id: 1, criterias: ['project', 'cf_1', 'cf_7'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -128,16 +138,17 @@ describe TimeEntries::ReportsController, type: :controller do # Custom field column assert_select 'th', descendant: { content: /\s*Database\s*/ } # Custom field row - assert_select 'td', content: 'MySQL', - sibling: { tag: 'td', attributes: { class: 'hours' }, - child: { tag: 'span', attributes: { class: 'hours hours-int' }, - content: '1' } } + assert_select 'td', + content: 'MySQL', + sibling: { tag: 'td', attributes: { class: 'hours' }, + child: { tag: 'span', attributes: { class: 'hours hours-int' }, + content: '1' } } # Second custom field column assert_select 'th', descendant: { content: /\s*Billable\s*/ } end it 'should report one criteria no result' do - get :show, project_id: 1, columns: 'week', from: '1998-04-01', to: '1998-04-30', criterias: ['project'] + get :show, params: { project_id: 1, columns: 'week', from: '1998-04-01', to: '1998-04-30', criterias: ['project'] } assert_response :success assert_template 'time_entries/reports/show' refute_nil assigns(:total_hours) @@ -145,7 +156,11 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report all projects csv export' do - get :show, columns: 'month', from: '2007-01-01', to: '2007-06-30', criterias: ['project', 'member', 'activity'], format: 'csv' + get :show, params: { columns: 'month', + from: '2007-01-01', + to: '2007-06-30', + criterias: ['project', 'member', 'activity'], + format: 'csv' } assert_response :success assert_match(/text\/csv/, response.content_type) lines = response.body.chomp.split("\n") @@ -156,7 +171,12 @@ describe TimeEntries::ReportsController, type: :controller do end it 'should report csv export' do - get :show, project_id: 1, columns: 'month', from: '2007-01-01', to: '2007-06-30', criterias: ['project', 'member', 'activity'], format: 'csv' + get :show, params: { project_id: 1, + columns: 'month', + from: '2007-01-01', + to: '2007-06-30', + criterias: ['project', 'member', 'activity'], + format: 'csv' } assert_response :success assert_match(/text\/csv/, response.content_type) lines = response.body.chomp.split("\n") diff --git a/spec_legacy/functional/timelog_controller_spec.rb b/spec_legacy/functional/timelog_controller_spec.rb index 0d2abed3b03..9e20a1028bb 100644 --- a/spec_legacy/functional/timelog_controller_spec.rb +++ b/spec_legacy/functional/timelog_controller_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'timelog_controller' describe TimelogController, type: :controller do @@ -37,25 +37,26 @@ describe TimelogController, type: :controller do it 'should get new' do session[:user_id] = 3 - get :new, project_id: 1 + get :new, params: { project_id: 1 } assert_response :success assert_template 'edit' # Default activity selected - assert_select 'option', attributes: { selected: 'selected' }, - content: 'Development' + assert_select 'option', + attributes: { selected: 'selected' }, + content: 'Development' end it 'should get new should only show active time entry activities' do session[:user_id] = 3 - get :new, project_id: 1 + get :new, params: { project_id: 1 } assert_response :success assert_template 'edit' - assert_select('option', {content: 'Inactive Activity'}, false) + assert_select('option', { content: 'Inactive Activity' }, false) end it 'should get edit existing time' do session[:user_id] = 2 - get :edit, id: 2, project_id: nil + get :edit, params: { id: 2, project_id: nil } assert_response :success assert_template 'edit' # Default activity selected @@ -68,7 +69,7 @@ describe TimelogController, type: :controller do te.save! session[:user_id] = 1 - get :edit, project_id: 1, id: 1 + get :edit, params: { project_id: 1, id: 1 } assert_response :success assert_template 'edit' # Blank option since nothing is pre-selected @@ -79,13 +80,13 @@ describe TimelogController, type: :controller do # TODO: should POST to issues’ time log instead of project. change form # and routing session[:user_id] = 3 - post :create, project_id: 1, - time_entry: { comments: 'Some work on TimelogControllerTest', - # Not the default activity - activity_id: '11', - spent_on: '2008-03-14', - work_package_id: '1', - hours: '7.3' } + post :create, params: { project_id: 1, + time_entry: { comments: 'Some work on TimelogControllerTest', + # Not the default activity + activity_id: '11', + spent_on: '2008-03-14', + work_package_id: '1', + hours: '7.3' } } assert_redirected_to action: 'index', project_id: 'ecookbook' i = WorkPackage.find(1) @@ -102,13 +103,13 @@ describe TimelogController, type: :controller do # TODO: should POST to issues’ time log instead of project. change form # and routing session[:user_id] = 3 - post :create, project_id: 1, - time_entry: { comments: 'Some work on TimelogControllerTest', - # Not the default activity - activity_id: '11', - work_package_id: '', - spent_on: '2008-03-14', - hours: '7.3' } + post :create, params: { project_id: 1, + time_entry: { comments: 'Some work on TimelogControllerTest', + # Not the default activity + activity_id: '11', + work_package_id: '', + spent_on: '2008-03-14', + hours: '7.3' } } assert_redirected_to action: 'index', project_id: 'ecookbook' t = TimeEntry.find_by(comments: 'Some work on TimelogControllerTest') @@ -124,9 +125,9 @@ describe TimelogController, type: :controller do assert_equal 2, entry.user_id session[:user_id] = 1 - put :update, id: 1, - time_entry: { work_package_id: '2', - hours: '8' } + put :update, params: { id: 1, + time_entry: { work_package_id: '2', + hours: '8' } } assert_redirected_to action: 'index', project_id: 'ecookbook' entry.reload @@ -137,7 +138,7 @@ describe TimelogController, type: :controller do it 'should destroy' do session[:user_id] = 2 - delete :destroy, id: 1 + delete :destroy, params: { id: 1 } assert_redirected_to action: 'index', project_id: 'ecookbook' assert_equal I18n.t(:notice_successful_delete), flash[:notice] assert_nil TimeEntry.find_by(id: 1) @@ -151,7 +152,7 @@ describe TimelogController, type: :controller do end session[:user_id] = 2 - delete :destroy, id: 1 + delete :destroy, params: { id: 1 } assert_redirected_to action: 'index', project_id: 'ecookbook' assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] refute_nil TimeEntry.find_by(id: 1) @@ -171,7 +172,7 @@ describe TimelogController, type: :controller do end it 'should index at project level' do - get :index, project_id: 'ecookbook' + get :index, params: { project_id: 'ecookbook' } assert_response :success assert_template 'index' refute_nil assigns(:entries) @@ -188,7 +189,7 @@ describe TimelogController, type: :controller do end it 'should index at project level with date range' do - get :index, project_id: 'ecookbook', from: '2007-03-20', to: '2007-04-30' + get :index, params: { project_id: 'ecookbook', from: '2007-03-20', to: '2007-04-30' } assert_response :success assert_template 'index' refute_nil assigns(:entries) @@ -202,7 +203,7 @@ describe TimelogController, type: :controller do end it 'should index at project level with period' do - get :index, project_id: 'ecookbook', period: '7_days' + get :index, params: { project_id: 'ecookbook', period: '7_days' } assert_response :success assert_template 'index' refute_nil assigns(:entries) @@ -214,7 +215,7 @@ describe TimelogController, type: :controller do end it 'should index one day' do - get :index, project_id: 'ecookbook', from: '2007-03-23', to: '2007-03-23' + get :index, params: { project_id: 'ecookbook', from: '2007-03-23', to: '2007-03-23' } assert_response :success assert_template 'index' refute_nil assigns(:total_hours) @@ -224,7 +225,7 @@ describe TimelogController, type: :controller do end it 'should index at issue level' do - get :index, work_package_id: 1 + get :index, params: { work_package_id: 1 } assert_response :success assert_template 'index' refute_nil assigns(:entries) @@ -241,7 +242,7 @@ describe TimelogController, type: :controller do it 'should index atom feed' do TimeEntry.all.each(&:recreate_initial_journal!) - get :index, project_id: 1, format: 'atom' + get :index, params: { project_id: 1, format: 'atom' } assert_response :success assert_equal 'application/atom+xml', response.content_type refute_nil assigns(:items) diff --git a/spec_legacy/functional/types_controller_spec.rb b/spec_legacy/functional/types_controller_spec.rb index 0a131a31633..ea178c703c3 100644 --- a/spec_legacy/functional/types_controller_spec.rb +++ b/spec_legacy/functional/types_controller_spec.rb @@ -54,16 +54,14 @@ describe TypesController, type: :controller do end it 'should post create' do - post :create, tab: "settings", type: { - name: 'New type' - } + post :create, params: { tab: "settings", type: { name: 'New type' } } type = ::Type.find_by(name: 'New type') assert_redirected_to action: 'edit', tab: 'settings', id: type.id assert_equal 0, type.workflows.count end it 'should post create with workflow copy' do - post :create, type: { name: 'New type' }, copy_workflow_from: 1 + post :create, params: { type: { name: 'New type' }, copy_workflow_from: 1 } type = ::Type.find_by(name: 'New type') assert_redirected_to action: 'edit', tab: 'settings', id: type.id assert_equal 0, type.projects.count @@ -73,7 +71,7 @@ describe TypesController, type: :controller do it 'should get edit' do ::Type.find(1).project_ids = [1, 3] - get :edit, id: 1, tab: 'settings' + get :edit, params: { id: 1, tab: 'settings' } assert_response :success assert_template 'edit' assert_template 'types/form/_settings' @@ -92,33 +90,33 @@ describe TypesController, type: :controller do end it 'should post update name' do - post :update, id: 1, tab: "settings", type: { name: 'Renamed' } + post :update, params: { id: 1, tab: "settings", type: { name: 'Renamed' } } assert_equal "Renamed", ::Type.find(1).name assert_redirected_to action: 'edit' end it 'should post update projects' do - post :update, id: 1, tab: "projects", type: { project_ids: ['1', '2', ''] } + post :update, params: { id: 1, tab: "projects", type: { project_ids: ['1', '2', ''] } } assert_redirected_to action: 'edit' assert_equal [1, 2], ::Type.find(1).project_ids.sort end it 'should post update without projects' do - post :update, id: 1, tab: "projects", type: { project_ids: [''] } + post :update, params: { id: 1, tab: "projects", type: { project_ids: [''] } } assert_redirected_to action: 'edit' assert ::Type.find(1).project_ids.empty? end it 'should move lower' do type = ::Type.find_by(position: 1) - post :move, id: 1, type: { move_to: 'lower' } + post :move, params: { id: 1, type: { move_to: 'lower' } } assert_equal 2, type.reload.position end it 'should destroy' do type = ::Type.create!(name: 'Destroyable') assert_difference '::Type.count', -1 do - post :destroy, id: type.id + post :destroy, params: { id: type.id } end assert_redirected_to action: 'index' assert_nil flash[:error] @@ -126,7 +124,7 @@ describe TypesController, type: :controller do it 'should destroy type in use' do assert_no_difference '::Type.count' do - post :destroy, id: 1 + post :destroy, params: { id: 1 } end assert_redirected_to action: 'index' refute_nil flash[:error] diff --git a/spec_legacy/functional/user_mailer_spec.rb b/spec_legacy/functional/user_mailer_spec.rb index 21ad6b1ce7d..2ced655b0ae 100644 --- a/spec_legacy/functional/user_mailer_spec.rb +++ b/spec_legacy/functional/user_mailer_spec.rb @@ -26,7 +26,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' describe UserMailer, type: :mailer do include ::Rails::Dom::Testing::Assertions::SelectorAssertions diff --git a/spec_legacy/functional/users_controller_spec.rb b/spec_legacy/functional/users_controller_spec.rb index b6649bde80a..04a8ea20829 100644 --- a/spec_legacy/functional/users_controller_spec.rb +++ b/spec_legacy/functional/users_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -27,7 +28,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'users_controller' describe UsersController, type: :controller do @@ -52,11 +53,11 @@ describe UsersController, type: :controller do assert_template 'index' refute_nil assigns(:users) # active users only - assert_nil assigns(:users).detect { |u| !u.active? } + assert_nil(assigns(:users).detect { |u| !u.active? }) end it 'should index with name filter' do - get :index, name: 'john' + get :index, params: { name: 'john' } assert_response :success assert_template 'index' users = assigns(:users) @@ -66,7 +67,7 @@ describe UsersController, type: :controller do end it 'should index with group filter' do - get :index, group_id: '10' + get :index, params: { group_id: '10' } assert_response :success assert_template 'index' users = assigns(:users) @@ -77,7 +78,7 @@ describe UsersController, type: :controller do it 'should show should not display hidden custom fields' do session[:user_id] = nil UserCustomField.find_by(name: 'Phone number').update_attribute :visible, false - get :show, id: 2 + get :show, params: { id: 2 } assert_response :success assert_template 'show' refute_nil assigns(:user) @@ -93,34 +94,34 @@ describe UsersController, type: :controller do # Create a custom field to illustrate the issue custom_field = CustomField.create!(name: 'Testing', field_format: 'text') - custom_value = user.custom_values.build(custom_field: custom_field).save! + user.custom_values.build(custom_field: custom_field).save! - get :show, id: 2 + get :show, params: { id: 2 } assert_response :success end it 'should show inactive' do session[:user_id] = nil - get :show, id: 5 + get :show, params: { id: 5 } assert_response 404 end it 'should show should not reveal users with no visible activity or project' do session[:user_id] = nil - get :show, id: 9 + get :show, params: { id: 9 } assert_response 404 end it 'should show inactive by admin' do session[:user_id] = 1 - get :show, id: 5 + get :show, params: { id: 5 } assert_response 200 refute_nil assigns(:user) end it 'should show displays memberships based on project visibility' do session[:user_id] = 1 - get :show, id: 2 + get :show, params: { id: 2 } assert_response :success memberships = assigns(:memberships) refute_nil memberships @@ -130,13 +131,13 @@ describe UsersController, type: :controller do it 'should show current should require authentication' do session[:user_id] = nil - get :show, id: 'current' + get :show, params: { id: 'current' } assert_response 302 end it 'should show current' do session[:user_id] = 2 - get :show, id: 'current' + get :show, params: { id: 'current' } assert_response :success assert_template 'show' assert_equal User.find(2), assigns(:user) @@ -156,16 +157,18 @@ describe UsersController, type: :controller do assert_difference 'User.count' do assert_difference 'ActionMailer::Base.deliveries.size' do post :create, - user: { - firstname: 'John', - lastname: 'Doe', - login: 'jdoe', - password: 'adminADMIN!', - password_confirmation: 'adminADMIN!', - mail: 'jdoe@gmail.com', - mail_notification: 'none' - }, - pref: { } + params: { + user: { + firstname: 'John', + lastname: 'Doe', + login: 'jdoe', + password: 'adminADMIN!', + password_confirmation: 'adminADMIN!', + mail: 'jdoe@gmail.com', + mail_notification: 'none' + }, + pref: {} + } end end @@ -185,7 +188,8 @@ describe UsersController, type: :controller do activation_link = Regexp.new( "http://#{Setting.host_name}/account/activate\\?token=[a-f0-9]+", - Regexp::MULTILINE) + Regexp::MULTILINE + ) assert(mail.body.encoded =~ activation_link) end @@ -195,7 +199,7 @@ describe UsersController, type: :controller do # Provide at least one user field, otherwise strong_parameters regards the user parameter # as non-existent and raises ActionController::ParameterMissing, which in turn # results in a 400. - post :create, user: { login: 'jdoe' } + post :create, params: { user: { login: 'jdoe' } } end assert_response :success @@ -203,7 +207,7 @@ describe UsersController, type: :controller do end it 'should edit' do - get :edit, id: 2 + get :edit, params: { id: 2 } assert_response :success assert_template 'edit' @@ -212,7 +216,7 @@ describe UsersController, type: :controller do it 'should update with failure' do assert_no_difference 'User.count' do - put :update, id: 2, user: { firstname: '' } + put :update, params: { id: 2, user: { firstname: '' } } end assert_response :success @@ -220,7 +224,7 @@ describe UsersController, type: :controller do end it 'should update with group ids should assign groups' do - put :update, id: 2, user: { group_ids: ['10'] } + put :update, params: { id: 2, user: { group_ids: ['10'] } } user = User.find(2) assert_equal [10], user.group_ids @@ -229,7 +233,10 @@ describe UsersController, type: :controller do it 'should update with password change should send a notification' do Setting.bcc_recipients = '1' - put :update, id: 2, user: { password: 'newpassPASS!', password_confirmation: 'newpassPASS!' }, send_information: '1' + put :update, params: { id: 2, + user: { password: 'newpassPASS!', + password_confirmation: 'newpassPASS!' }, + send_information: '1' } u = User.find(2) assert u.check_password?('newpassPASS!') diff --git a/spec_legacy/functional/wiki_controller_spec.rb b/spec_legacy/functional/wiki_controller_spec.rb index d6dc0c440b9..b0028a813a5 100644 --- a/spec_legacy/functional/wiki_controller_spec.rb +++ b/spec_legacy/functional/wiki_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -26,7 +27,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'wiki_controller' describe WikiController, type: :controller do @@ -47,7 +48,7 @@ describe WikiController, type: :controller do end it 'should show start page' do - get :show, project_id: 'ecookbook' + get :show, params: { project_id: 'ecookbook' } assert_response :success assert_template 'show' assert_select 'h1', content: /CookBook documentation/ @@ -60,7 +61,7 @@ describe WikiController, type: :controller do end it 'should show page with name' do - get :show, project_id: 1, id: 'Another page' + get :show, params: { project_id: 1, id: 'Another page' } assert_response :success assert_template 'show' assert_select 'h1', content: /Another page/ @@ -75,30 +76,30 @@ describe WikiController, type: :controller do page.content = WikiContent.new(text: 'Side bar content for test_show_with_sidebar') page.save! - get :show, project_id: 1, id: 'Another page' + get :show, params: { project_id: 1, id: 'Another page' } assert_response :success assert_select 'div', attributes: { id: 'sidebar' }, content: /Side bar content for test_show_with_sidebar/ end it 'should show unexistent page without edit right' do - get :show, project_id: 1, id: 'Unexistent page' + get :show, params: { project_id: 1, id: 'Unexistent page' } assert_response 404 end it 'should show unexistent page with edit right' do session[:user_id] = 2 - get :show, project_id: 1, id: 'Unexistent page' + get :show, params: { project_id: 1, id: 'Unexistent page' } assert_response :success assert_template 'edit' end it 'should create page' do session[:user_id] = 2 - put :update, project_id: 1, - id: 'New page', - content: { comments: 'Created the page', - text: "h1. New page\n\nThis is a new page" } + put :update, params: { project_id: 1, + id: 'New page', + content: { comments: 'Created the page', + text: "h1. New page\n\nThis is a new page" } } assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'new-page' page = wiki.find_page('New page') assert !page.new_record? @@ -110,12 +111,12 @@ describe WikiController, type: :controller do session[:user_id] = 2 assert_difference 'WikiPage.count' do assert_difference 'Attachment.count' do - put :update, project_id: 1, - id: 'New page', - content: { comments: 'Created the page', - text: "h1. New page\n\nThis is a new page", - lock_version: 0 }, - attachments: { '1' => { 'file' => uploaded_test_file('testfile.txt', 'text/plain') } } + put :update, params: { project_id: 1, + id: 'New page', + content: { comments: 'Created the page', + text: "h1. New page\n\nThis is a new page", + lock_version: 0 }, + attachments: { '1' => { 'file' => uploaded_test_file('testfile.txt', 'text/plain') } } } end end page = wiki.find_page('New page') @@ -131,13 +132,13 @@ describe WikiController, type: :controller do assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiContent.count' do assert_difference 'Journal.count' do - put :update, project_id: 1, - id: 'Another page', - content: { - comments: 'my comments', - text: 'edited', - lock_version: 1 - } + put :update, params: { project_id: 1, + id: 'Another page', + content: { + comments: 'my comments', + text: 'edited', + lock_version: 1 + } } end end end @@ -154,13 +155,13 @@ describe WikiController, type: :controller do assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiContent.count' do assert_no_difference 'Journal.count' do - put :update, project_id: 1, - id: 'Another page', - content: { - comments: 'a' * 300, # failure here, comment is too long - text: 'edited', - lock_version: 1 - } + put :update, params: { project_id: 1, + id: 'Another page', + content: { + comments: 'a' * 300, # failure here, comment is too long + text: 'edited', + lock_version: 1 + } } end end end @@ -190,26 +191,26 @@ describe WikiController, type: :controller do assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiContent.count' do assert_no_difference 'Journal.count' do - put :update, project_id: 1, - id: 'Another page', - content: { - comments: 'My comments', - text: 'Text should not be lost', - lock_version: 1 - } + put :update, params: { project_id: 1, + id: 'Another page', + content: { + comments: 'My comments', + text: 'Text should not be lost', + lock_version: 1 + } } end end end assert_response :success assert_template 'edit' assert_select 'div', - attributes: { class: /error/ }, - content: /Information has been updated by at least one other user in the meantime/ + attributes: { class: /error/ }, + content: /Information has been updated by at least one other user in the meantime/ assert_select 'textarea', - attributes: { name: 'content[text]' }, - content: /Text should not be lost/ + attributes: { name: 'content[text]' }, + content: /Text should not be lost/ assert_select 'input', - attributes: { name: 'content[comments]', value: 'My comments' } + attributes: { name: 'content[comments]', value: 'My comments' } c.reload assert_equal 'Previous text', c.text @@ -230,7 +231,7 @@ describe WikiController, type: :controller do data: FactoryGirl.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\nSome updated [[documentation]] here...") - get :history, project_id: 1, id: 'CookBook documentation' + get :history, params: { project_id: 1, id: 'CookBook documentation' } assert_response :success assert_template 'history' refute_nil assigns(:versions) @@ -243,7 +244,7 @@ describe WikiController, type: :controller do journable_id: 2, data: FactoryGirl.build(:journal_wiki_content_journal, text: "h1. Another page\n\n\nthis is a link to ticket: #2") - get :history, project_id: 1, id: 'Another page' + get :history, params: { project_id: 1, id: 'Another page' } assert_response :success assert_template 'history' refute_nil assigns(:versions) @@ -261,7 +262,7 @@ describe WikiController, type: :controller do data: FactoryGirl.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...") - get :diff, project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version + get :diff, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version } assert_response :success assert_template 'diff' assert_select 'ins', attributes: { class: 'diffins' }, @@ -278,7 +279,7 @@ describe WikiController, type: :controller do data: FactoryGirl.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...") - get :annotate, project_id: 1, id: 'CookBook documentation', version: journal_to.version + get :annotate, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version } assert_response :success assert_template 'annotate' # Line 1 @@ -293,23 +294,23 @@ describe WikiController, type: :controller do it 'should get rename' do session[:user_id] = 2 - get :rename, project_id: 1, id: 'Another page' + get :rename, params: { project_id: 1, id: 'Another page' } assert_response :success assert_template 'rename' end it 'should get rename child page' do session[:user_id] = 2 - get :rename, project_id: 1, id: 'Child 1' + get :rename, params: { project_id: 1, id: 'Child 1' } assert_response :success assert_template 'rename' end it 'should rename with redirect' do session[:user_id] = 2 - patch :rename, project_id: 1, id: 'Another page', - page: { title: 'Another renamed page', - redirect_existing_links: 1 } + patch :rename, params: { project_id: 1, id: 'Another page', + page: { title: 'Another renamed page', + redirect_existing_links: 1 } } assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-renamed-page' # Check redirects refute_nil wiki.find_page('Another page') @@ -318,9 +319,9 @@ describe WikiController, type: :controller do it 'should rename without redirect' do session[:user_id] = 2 - patch :rename, project_id: 1, id: 'another-page', - page: { title: 'Another renamed page', - redirect_existing_links: '0' } + patch :rename, params: { project_id: 1, id: 'another-page', + page: { title: 'Another renamed page', + redirect_existing_links: '0' } } assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-renamed-page' # Check that there's no redirects assert_nil wiki.find_page('Another page') @@ -328,14 +329,14 @@ describe WikiController, type: :controller do it 'should destroy child' do session[:user_id] = 2 - delete :destroy, project_id: 1, id: 'Child 1' + delete :destroy, params: { project_id: 1, id: 'Child 1' } assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page end it 'should destroy parent' do session[:user_id] = 2 assert_no_difference('WikiPage.count') do - delete :destroy, project_id: 1, id: 'Another page' + delete :destroy, params: { project_id: 1, id: 'Another page' } end assert_response :success assert_template 'destroy' @@ -344,7 +345,7 @@ describe WikiController, type: :controller do it 'should destroy parent with nullify' do session[:user_id] = 2 assert_difference('WikiPage.count', -1) do - delete :destroy, project_id: 1, id: 'Another page', todo: 'nullify' + delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'nullify' } end assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page assert_nil WikiPage.find_by(id: 2) @@ -353,7 +354,7 @@ describe WikiController, type: :controller do it 'should destroy parent with cascade' do session[:user_id] = 2 assert_difference('WikiPage.count', -3) do - delete :destroy, project_id: 1, id: 'Another page', todo: 'destroy' + delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'destroy' } end assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page assert_nil WikiPage.find_by(id: 2) @@ -363,7 +364,7 @@ describe WikiController, type: :controller do it 'should destroy parent with reassign' do session[:user_id] = 2 assert_difference('WikiPage.count', -1) do - delete :destroy, project_id: 1, id: 'Another page', todo: 'reassign', reassign_to_id: 1 + delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'reassign', reassign_to_id: 1 } end assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page assert_nil WikiPage.find_by(id: 2) @@ -371,7 +372,7 @@ describe WikiController, type: :controller do end it 'should index' do - get :index, project_id: 'ecookbook' + get :index, params: { project_id: 'ecookbook' } assert_response :success assert_template 'index' pages = assigns(:pages) @@ -391,7 +392,7 @@ describe WikiController, type: :controller do end it 'should index should include atom link' do - get :index, project_id: 'ecookbook' + get :index, params: { project_id: 'ecookbook' } assert_select 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' } end @@ -399,7 +400,7 @@ describe WikiController, type: :controller do context 'with an authorized user to export the wiki' do before do session[:user_id] = 2 - get :export, project_id: 'ecookbook' + get :export, params: { project_id: 'ecookbook' } end it { is_expected.to respond_with :success } @@ -414,7 +415,7 @@ describe WikiController, type: :controller do context 'with an unauthorized user' do before do - get :export, project_id: 'ecookbook' + get :export, params: { project_id: 'ecookbook' } it { is_expected.to respond_with :redirect } it { is_expected.to redirect_to('wiki index') { { action: 'show', project_id: @project, id: nil } } } @@ -424,7 +425,7 @@ describe WikiController, type: :controller do context 'GET :date_index' do before do - get :date_index, project_id: 'ecookbook' + get :date_index, params: { project_id: 'ecookbook' } end it { is_expected.to respond_with :success } @@ -438,7 +439,7 @@ describe WikiController, type: :controller do end it 'should not found' do - get :show, project_id: 999 + get :show, params: { project_id: 999 } assert_response 404 end @@ -446,7 +447,7 @@ describe WikiController, type: :controller do page = WikiPage.find_by(wiki_id: 1, title: 'Another page') assert !page.protected? session[:user_id] = 2 - post :protect, project_id: 1, id: page.title, protected: '1' + post :protect, params: { project_id: 1, id: page.title, protected: '1' } assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-page' assert page.reload.protected? end @@ -455,14 +456,14 @@ describe WikiController, type: :controller do page = WikiPage.find_by(wiki_id: 1, title: 'CookBook documentation') assert page.protected? session[:user_id] = 2 - post :protect, project_id: 1, id: page.title, protected: '0' + post :protect, params: { project_id: 1, id: page.title, protected: '0' } assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'cookbook-documentation' assert !page.reload.protected? end it 'should show page with edit link' do session[:user_id] = 2 - get :show, project_id: 1 + get :show, params: { project_id: 1 } assert_response :success assert_template 'show' assert_select 'a', attributes: { href: '/projects/1/wiki/CookBook+documentation/edit' } @@ -470,16 +471,16 @@ describe WikiController, type: :controller do it 'should show page without edit link' do session[:user_id] = 4 - get :show, project_id: 1 + get :show, params: { project_id: 1 } assert_response :success assert_template 'show' - assert_select('a', {attributes: { href: '/projects/1/wiki/CookBook+documentation/edit' }}, false) + assert_select('a', { attributes: { href: '/projects/1/wiki/CookBook+documentation/edit' } }, false) end it 'should edit unprotected page' do # Non members can edit unprotected wiki pages session[:user_id] = 4 - get :edit, project_id: 1, id: 'Another page' + get :edit, params: { project_id: 1, id: 'Another page' } assert_response :success assert_template 'edit' end @@ -487,19 +488,19 @@ describe WikiController, type: :controller do it 'should edit protected page by nonmember' do # Non members can't edit protected wiki pages session[:user_id] = 4 - get :edit, project_id: 1, id: 'CookBook documentation' + get :edit, params: { project_id: 1, id: 'CookBook documentation' } assert_response 403 end it 'should edit protected page by member' do session[:user_id] = 2 - get :edit, project_id: 1, id: 'CookBook documentation' + get :edit, params: { project_id: 1, id: 'CookBook documentation' } assert_response :success assert_template 'edit' end it 'should history of non existing page should return 404' do - get :history, project_id: 1, id: 'Unknown page' + get :history, params: { project_id: 1, id: 'Unknown page' } assert_response 404 end end diff --git a/spec_legacy/functional/workflows_controller_spec.rb b/spec_legacy/functional/workflows_controller_spec.rb index 5ed5558a25b..1d2801c9509 100644 --- a/spec_legacy/functional/workflows_controller_spec.rb +++ b/spec_legacy/functional/workflows_controller_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -26,7 +27,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' require 'workflows_controller' describe WorkflowsController, type: :controller do @@ -46,7 +47,7 @@ describe WorkflowsController, type: :controller do count = Workflow.where('role_id = 1 AND type_id = 2').count assert_select 'a', content: count.to_s, - attributes: { href: '/workflows/edit?role_id=1&type_id=2' } + attributes: { href: '/workflows/edit?role_id=1&type_id=2' } end it 'should get edit' do @@ -62,7 +63,7 @@ describe WorkflowsController, type: :controller do Workflow.create!(role_id: 1, type_id: 1, old_status_id: 2, new_status_id: 3) Workflow.create!(role_id: 2, type_id: 1, old_status_id: 3, new_status_id: 5) - get :edit, role_id: 2, type_id: 1 + get :edit, params: { role_id: 2, type_id: 1 } assert_response :success assert_template 'edit' @@ -72,23 +73,23 @@ describe WorkflowsController, type: :controller do # allowed transitions assert_select 'input', attributes: { type: 'checkbox', - name: 'status[3][5][]', - value: 'always', - checked: 'checked' } + name: 'status[3][5][]', + value: 'always', + checked: 'checked' } # not allowed assert_select 'input', attributes: { type: 'checkbox', - name: 'status[3][2][]', - value: 'always', - checked: nil } + name: 'status[3][2][]', + value: 'always', + checked: nil } # unused - assert_select('input', {attributes: { type: 'checkbox', - name: 'status[1][1][]' }}, false) + assert_select('input', { attributes: { type: 'checkbox', + name: 'status[1][1][]' } }, false) end it 'should get edit with role and type and all statuses' do Workflow.delete_all - get :edit, role_id: 2, type_id: 1, used_statuses_only: '0' + get :edit, params: { role_id: 2, type_id: 1, used_statuses_only: '0' } assert_response :success assert_template 'edit' @@ -96,17 +97,17 @@ describe WorkflowsController, type: :controller do assert_equal Status.count, assigns(:statuses).size assert_select 'input', attributes: { type: 'checkbox', - name: 'status[1][1][]', - value: 'always', - checked: nil } + name: 'status[1][1][]', + value: 'always', + checked: nil } end it 'should post edit' do - post :edit, role_id: 2, type_id: 1, - status: { - '4' => { '5' => ['always'] }, - '3' => { '1' => ['always'], '2' => ['always'] } - } + post :edit, params: { role_id: 2, type_id: 1, + status: { + '4' => { '5' => ['always'] }, + '3' => { '1' => ['always'], '2' => ['always'] } + } } assert_redirected_to '/workflows/edit?role_id=2&type_id=1' assert_equal 3, Workflow.where(type_id: 1, role_id: 2).count @@ -115,11 +116,11 @@ describe WorkflowsController, type: :controller do end it 'should post edit with additional transitions' do - post :edit, role_id: 2, type_id: 1, - status: { - '4' => { '5' => ['always'] }, - '3' => { '1' => ['author'], '2' => ['assignee'], '4' => ['author', 'assignee'] } - } + post :edit, params: { role_id: 2, type_id: 1, + status: { + '4' => { '5' => ['always'] }, + '3' => { '1' => ['author'], '2' => ['assignee'], '4' => ['author', 'assignee'] } + } } assert_redirected_to '/workflows/edit?role_id=2&type_id=1' assert_equal 4, Workflow.where(type_id: 1, role_id: 2).count @@ -141,7 +142,7 @@ describe WorkflowsController, type: :controller do it 'should clear workflow' do assert Workflow.where(type_id: 1, role_id: 2).count > 0 - post :edit, role_id: 2, type_id: 1 + post :edit, params: { role_id: 2, type_id: 1 } assert_equal 0, Workflow.where(type_id: 1, role_id: 2).count end @@ -154,8 +155,8 @@ describe WorkflowsController, type: :controller do it 'should post copy one to one' do source_transitions = status_transitions(type_id: 1, role_id: 2) - post :copy, source_type_id: '1', source_role_id: '2', - target_type_ids: ['3'], target_role_ids: ['1'] + post :copy, params: { source_type_id: '1', source_role_id: '2', + target_type_ids: ['3'], target_role_ids: ['1'] } assert_response 302 assert_equal source_transitions, status_transitions(type_id: 3, role_id: 1) end @@ -163,8 +164,8 @@ describe WorkflowsController, type: :controller do it 'should post copy one to many' do source_transitions = status_transitions(type_id: 1, role_id: 2) - post :copy, source_type_id: '1', source_role_id: '2', - target_type_ids: ['2', '3'], target_role_ids: ['1', '3'] + post :copy, params: { source_type_id: '1', source_role_id: '2', + target_type_ids: ['2', '3'], target_role_ids: ['1', '3'] } assert_response 302 assert_equal source_transitions, status_transitions(type_id: 2, role_id: 1) assert_equal source_transitions, status_transitions(type_id: 3, role_id: 1) @@ -176,8 +177,8 @@ describe WorkflowsController, type: :controller do source_t2 = status_transitions(type_id: 2, role_id: 2) source_t3 = status_transitions(type_id: 3, role_id: 2) - post :copy, source_type_id: 'any', source_role_id: '2', - target_type_ids: ['2', '3'], target_role_ids: ['1', '3'] + post :copy, params: { source_type_id: 'any', source_role_id: '2', + target_type_ids: ['2', '3'], target_role_ids: ['1', '3'] } assert_response 302 assert_equal source_t2, status_transitions(type_id: 2, role_id: 1) assert_equal source_t3, status_transitions(type_id: 3, role_id: 1) @@ -187,7 +188,8 @@ describe WorkflowsController, type: :controller do # Returns an array of status transitions that can be compared def status_transitions(conditions) - Workflow.where(conditions) + Workflow + .where(conditions) .order('type_id, role_id, old_status_id, new_status_id') .map { |w| [w.old_status, w.new_status_id] } end diff --git a/spec_legacy/integration/api_spec/disabled_rest_api_spec.rb b/spec_legacy/integration/api_spec/disabled_rest_api_spec.rb index ddcbf3f76c5..7f595868ab7 100644 --- a/spec_legacy/integration/api_spec/disabled_rest_api_spec.rb +++ b/spec_legacy/integration/api_spec/disabled_rest_api_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe 'ApiTest: DisabledRestApiTest', type: :request do fixtures :all @@ -62,7 +62,7 @@ describe 'ApiTest: DisabledRestApiTest', type: :request do before do @user = FactoryGirl.create(:user, password: 'adminADMIN!', password_confirmation: 'adminADMIN!') @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'adminADMIN!') - get '/api/v2/projects.xml', nil, authorization: @authorization + get '/api/v2/projects.xml', params: { authorization: @authorization } end it { is_expected.to respond_with :unauthorized } @@ -77,7 +77,7 @@ describe 'ApiTest: DisabledRestApiTest', type: :request do @user = FactoryGirl.create(:user) @token = FactoryGirl.create(:token, user: @user, action: 'api') @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'X') - get '/api/v2/projects.xml', nil, authorization: @authorization + get '/api/v2/projects.xml', params: { authorization: @authorization } end it { is_expected.to respond_with :unauthorized } @@ -107,7 +107,7 @@ describe 'ApiTest: DisabledRestApiTest', type: :request do before do @user = FactoryGirl.create(:user, password: 'adminADMIN!', password_confirmation: 'adminADMIN!') @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@user.login, 'adminADMIN!') - get '/api/v2/projects.json', nil, authorization: @authorization + get '/api/v2/projects.json', params: { authorization: @authorization } end it { is_expected.to respond_with :unauthorized } @@ -122,7 +122,7 @@ describe 'ApiTest: DisabledRestApiTest', type: :request do @user = FactoryGirl.create(:user) @token = FactoryGirl.create(:token, user: @user, action: 'api') @authorization = ActionController::HttpAuthentication::Basic.encode_credentials(@token.value, 'DoesNotMatter') - get '/api/v2/projects.json', nil, authorization: @authorization + get '/api/v2/projects.json', params: { authorization: @authorization } end it { is_expected.to respond_with :unauthorized } diff --git a/spec_legacy/integration/api_spec/http_accept_auth_spec.rb b/spec_legacy/integration/api_spec/http_accept_auth_spec.rb index 4a69fc019eb..e12d343bbc0 100644 --- a/spec_legacy/integration/api_spec/http_accept_auth_spec.rb +++ b/spec_legacy/integration/api_spec/http_accept_auth_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe 'ApiTest: HttpAcceptAuthTest', type: :request do fixtures :all diff --git a/spec_legacy/integration/api_spec/http_basic_login_spec.rb b/spec_legacy/integration/api_spec/http_basic_login_spec.rb index 239ba3014e6..52a227822f7 100644 --- a/spec_legacy/integration/api_spec/http_basic_login_spec.rb +++ b/spec_legacy/integration/api_spec/http_basic_login_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe 'ApiTest: HttpBasicLoginTest', type: :request do fixtures :all diff --git a/spec_legacy/integration/api_spec/http_basic_login_with_api_token_spec.rb b/spec_legacy/integration/api_spec/http_basic_login_with_api_token_spec.rb index 30d02e3fd1f..fc42c3e1c65 100644 --- a/spec_legacy/integration/api_spec/http_basic_login_with_api_token_spec.rb +++ b/spec_legacy/integration/api_spec/http_basic_login_with_api_token_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe 'ApiTest: HttpBasicLoginWithApiToken', type: :request do fixtures :all diff --git a/spec_legacy/integration/api_spec/token_authentication_spec.rb b/spec_legacy/integration/api_spec/token_authentication_spec.rb index a691062078d..dbe55e0a0ae 100644 --- a/spec_legacy/integration/api_spec/token_authentication_spec.rb +++ b/spec_legacy/integration/api_spec/token_authentication_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -27,7 +28,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../legacy_spec_helper' describe 'ApiTest: TokenAuthentication', type: :request do fixtures :all diff --git a/spec_legacy/integration/application_spec.rb b/spec_legacy/integration/application_spec.rb index 886be0c781e..d337e2af629 100644 --- a/spec_legacy/integration/application_spec.rb +++ b/spec_legacy/integration/application_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -42,13 +43,13 @@ describe 'Application', with_settings: { login_required?: false } do allow(Setting).to receive(:default_language).and_return 'en' # a french user - get '/projects', {}, 'HTTP_ACCEPT_LANGUAGE' => 'de,de-de;q=0.8,en-us;q=0.5,en;q=0.3' + get '/projects', params: {}, headers: { 'HTTP_ACCEPT_LANGUAGE' => 'de,de-de;q=0.8,en-us;q=0.5,en;q=0.3' } assert_response :success assert_select 'h2', content: 'Projekte' assert_equal :de, current_language # not a supported language: default language should be used - get '/projects', {}, 'HTTP_ACCEPT_LANGUAGE' => 'zz' + get '/projects', params: {}, headers: { 'HTTP_ACCEPT_LANGUAGE' => 'zz' } assert_response :success assert_select 'h2', content: 'Projects' end diff --git a/spec_legacy/integration/layout_spec.rb b/spec_legacy/integration/layout_spec.rb index 7de1e1656fc..04b0dd07b5a 100644 --- a/spec_legacy/integration/layout_spec.rb +++ b/spec_legacy/integration/layout_spec.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' describe 'Layout' do fixtures :all diff --git a/spec_legacy/integration/lib/redmine/menu_manager_spec.rb b/spec_legacy/integration/lib/redmine/menu_manager_spec.rb index f9de609219e..f47bfe560ed 100644 --- a/spec_legacy/integration/lib/redmine/menu_manager_spec.rb +++ b/spec_legacy/integration/lib/redmine/menu_manager_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -26,7 +27,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../../legacy_spec_helper' describe 'MenuManager', with_settings: { login_required: 0 } do include Redmine::I18n @@ -39,7 +40,7 @@ describe 'MenuManager', with_settings: { login_required: 0 } do it 'project menu with specific locale' do Setting.available_languages = [:de, :en] - get '/projects/ecookbook', {}, 'HTTP_ACCEPT_LANGUAGE' => 'de,de-de;q=0.8,en-us;q=0.5,en;q=0.3' + get '/projects/ecookbook', params: {}, headers: { 'HTTP_ACCEPT_LANGUAGE' => 'de,de-de;q=0.8,en-us;q=0.5,en;q=0.3' } assert_select 'div', attributes: { id: 'main-menu' }, descendant: { tag: 'li', child: { tag: 'a', content: ll('de', :label_activity), diff --git a/spec_legacy/integration/routing_spec.rb b/spec_legacy/integration/routing_spec.rb index 0930bdda045..8e06e173fc9 100644 --- a/spec_legacy/integration/routing_spec.rb +++ b/spec_legacy/integration/routing_spec.rb @@ -26,7 +26,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../legacy_spec_helper' describe 'routing', type: :routing do before do diff --git a/spec_legacy/legacy_spec_helper.rb b/spec_legacy/legacy_spec_helper.rb index 55e3de0f152..eee3d696e4b 100644 --- a/spec_legacy/legacy_spec_helper.rb +++ b/spec_legacy/legacy_spec_helper.rb @@ -86,15 +86,6 @@ RSpec.configure do |config| I18n.locale = 'en' end - if ENV['CI'] - $stderr.puts <<-EOS - WARNING - - Silencing all ActiveSupport::Deprecation message output due to CI=true. - EOS - ActiveSupport::Deprecation.behavior = :silence - end - # colorized rspec output config.color = true config.formatter = 'progress' diff --git a/spec_legacy/support/legacy_assertions.rb b/spec_legacy/support/legacy_assertions.rb index 85342c2ac35..1cb7048a865 100644 --- a/spec_legacy/support/legacy_assertions.rb +++ b/spec_legacy/support/legacy_assertions.rb @@ -262,7 +262,7 @@ module LegacyAssertionsAndHelpers context "should not send www authenticate when header accept auth is session #{http_method} #{url}" do context 'without credentials' do before do - send(http_method, url, parameters, 'HTTP_X_AUTHENTICATION_SCHEME' => 'Session') + send(http_method, url, params: parameters, headers: { 'HTTP_X_AUTHENTICATION_SCHEME' => 'Session' }) end it { should respond_with failure_code } it { should_respond_with_content_type_based_on_url(url) } @@ -291,7 +291,7 @@ module LegacyAssertionsAndHelpers before do @user = FactoryGirl.create(:user, password: 'adminADMIN!', password_confirmation: 'adminADMIN!', admin: true) # Admin so they can access the project - send(http_method, url, parameters, credentials(@user.login, 'adminADMIN!')) + send(http_method, url, params: parameters, headers: credentials(@user.login, 'adminADMIN!')) end it { should respond_with success_code } it { should_respond_with_content_type_based_on_url(url) } @@ -304,7 +304,7 @@ module LegacyAssertionsAndHelpers before do @user = FactoryGirl.create(:user) - send(http_method, url, parameters, credentials(@user.login, 'wrong_password')) + send(http_method, url, params: parameters, headers: credentials(@user.login, 'wrong_password')) end it { should respond_with failure_code } it { should_respond_with_content_type_based_on_url(url) } @@ -315,7 +315,7 @@ module LegacyAssertionsAndHelpers context 'without credentials' do before do - send(http_method, url, parameters) + send(http_method, url, params: parameters) end it { should respond_with failure_code } it { should_respond_with_content_type_based_on_url(url) } @@ -344,7 +344,7 @@ module LegacyAssertionsAndHelpers @user = FactoryGirl.create(:user, admin: true) @token = FactoryGirl.create(:token, user: @user, action: 'api') - send(http_method, url, parameters, credentials(@token.value, 'X')) + send(http_method, url, params: parameters, headers: credentials(@token.value, 'X')) end it { should respond_with success_code } it { should_respond_with_content_type_based_on_url(url) } @@ -359,7 +359,7 @@ module LegacyAssertionsAndHelpers @user = FactoryGirl.create(:user) @token = FactoryGirl.create(:token, user: @user, action: 'feeds') - send(http_method, url, parameters, credentials(@token.value, 'X')) + send(http_method, url, params: parameters, headers: credentials(@token.value, 'X')) end it { should respond_with failure_code } it { should_respond_with_content_type_based_on_url(url) } @@ -393,7 +393,7 @@ module LegacyAssertionsAndHelpers else url + "?key=#{@token.value}" end - send(http_method, request_url, parameters) + send(http_method, request_url, params: parameters) end it { should respond_with success_code } it { should_respond_with_content_type_based_on_url(url) } @@ -413,7 +413,7 @@ module LegacyAssertionsAndHelpers else url + "?key=#{@token.value}" end - send(http_method, request_url, parameters) + send(http_method, request_url, params: parameters) end it { should respond_with failure_code } it { should_respond_with_content_type_based_on_url(url) } @@ -427,7 +427,7 @@ module LegacyAssertionsAndHelpers before do @user = FactoryGirl.create(:user, admin: true) @token = FactoryGirl.create(:token, user: @user, action: 'api') - send(http_method, url, {}, {'X-OpenProject-API-Key' => @token.value.to_s}) + send(http_method, url, params: {}, headers: { 'X-OpenProject-API-Key' => @token.value.to_s }) end it { should respond_with success_code } it { should_respond_with_content_type_based_on_url(url) } diff --git a/spec_legacy/unit/lib/redmine/hook_spec.rb b/spec_legacy/unit/lib/redmine/hook_spec.rb index bdb8e9bdf75..10a338b308d 100644 --- a/spec_legacy/unit/lib/redmine/hook_spec.rb +++ b/spec_legacy/unit/lib/redmine/hook_spec.rb @@ -26,7 +26,7 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' +require_relative '../../../legacy_spec_helper' describe 'Redmine::Hook::Manager' do # FIXME: naming (RSpec-port) fixtures :all diff --git a/spec_legacy/unit/search_spec.rb b/spec_legacy/unit/search_spec.rb index 904c7f5bda4..2fe67fad41c 100644 --- a/spec_legacy/unit/search_spec.rb +++ b/spec_legacy/unit/search_spec.rb @@ -128,7 +128,7 @@ describe 'Search' do # FIXME: naming (RSpec-port) it 'should search_issue_with_multiple_hits_in_journals' do i = WorkPackage.find(1) - Journal.delete_all journable_id: i.id + Journal.where(journable_id: i.id).delete_all i.add_journal User.current, 'Journal notes' i.save! i.add_journal User.current, 'Some notes with Redmine links: #2, r2.' diff --git a/spec_legacy/unit/status_spec.rb b/spec_legacy/unit/status_spec.rb index 8cf3226152a..223072f5d3b 100644 --- a/spec_legacy/unit/status_spec.rb +++ b/spec_legacy/unit/status_spec.rb @@ -1,4 +1,5 @@ #-- encoding: UTF-8 + #-- copyright # OpenProject is a project management system. # Copyright (C) 2012-2017 the OpenProject Foundation (OPF) @@ -26,7 +27,8 @@ # # See doc/COPYRIGHT.rdoc for more details. #++ -require 'legacy_spec_helper' + +require_relative '../legacy_spec_helper' describe Status, type: :model do fixtures :all diff --git a/spec_legacy/unit/wiki_page_spec.rb b/spec_legacy/unit/wiki_page_spec.rb index 1c2c90c4576..fac318ce38b 100644 --- a/spec_legacy/unit/wiki_page_spec.rb +++ b/spec_legacy/unit/wiki_page_spec.rb @@ -114,7 +114,7 @@ describe WikiPage, type: :model do # make sure that page content and its history are deleted assert WikiContent.where(page_id: 1).empty? content_ids.each do |wiki_content_id| - assert Journal.where(journable_type: WikiContent, + assert Journal.where(journable_type: 'WikiContent', journable_id: wiki_content_id) end end