From 8e84b1a48f49919806650baad353f3abd70ef1f4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 30 Nov 2014 15:16:43 +0000 Subject: [PATCH] Moved helpers for integration tests in a specific class. git-svn-id: http://svn.redmine.org/redmine/trunk@13680 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/integration/account_test.rb | 2 +- test/integration/admin_test.rb | 2 +- test/integration/application_test.rb | 2 +- test/integration/attachments_test.rb | 2 +- test/integration/feeds_test.rb | 2 +- test/integration/issues_test.rb | 2 +- test/integration/layout_test.rb | 2 +- test/integration/lib/redmine/hook_test.rb | 2 +- .../lib/redmine/menu_manager_test.rb | 2 +- test/integration/lib/redmine/themes_test.rb | 2 +- test/integration/projects_test.rb | 2 +- test/integration/repositories_git_test.rb | 2 +- test/integration/users_test.rb | 2 +- test/test_helper.rb | 32 ++++++++++--------- 14 files changed, 30 insertions(+), 28 deletions(-) diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb index 8d8444a9d..ca6516b9d 100644 --- a/test/integration/account_test.rb +++ b/test/integration/account_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class AccountTest < ActionDispatch::IntegrationTest +class AccountTest < Redmine::IntegrationTest fixtures :users, :roles def test_login diff --git a/test/integration/admin_test.rb b/test/integration/admin_test.rb index 3b60f0c95..c3334f501 100644 --- a/test/integration/admin_test.rb +++ b/test/integration/admin_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class AdminTest < ActionDispatch::IntegrationTest +class AdminTest < Redmine::IntegrationTest fixtures :projects, :trackers, :issue_statuses, :issues, :enumerations, :users, :issue_categories, :projects_trackers, diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb index e40dda8ea..5b8368732 100644 --- a/test/integration/application_test.rb +++ b/test/integration/application_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class ApplicationTest < ActionDispatch::IntegrationTest +class ApplicationTest < Redmine::IntegrationTest include Redmine::I18n fixtures :projects, :trackers, :issue_statuses, :issues, diff --git a/test/integration/attachments_test.rb b/test/integration/attachments_test.rb index 69d42d48a..47577cbd0 100644 --- a/test/integration/attachments_test.rb +++ b/test/integration/attachments_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class AttachmentsTest < ActionDispatch::IntegrationTest +class AttachmentsTest < Redmine::IntegrationTest fixtures :projects, :enabled_modules, :users, :roles, :members, :member_roles, :trackers, :projects_trackers, diff --git a/test/integration/feeds_test.rb b/test/integration/feeds_test.rb index 160174f68..6b7a245fa 100644 --- a/test/integration/feeds_test.rb +++ b/test/integration/feeds_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class FeedsTest < ActionDispatch::IntegrationTest +class FeedsTest < Redmine::IntegrationTest fixtures :projects, :trackers, :issue_statuses, :issues, :enumerations, :users, :issue_categories, :projects_trackers, :enabled_modules, diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 358389325..201105ceb 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class IssuesTest < ActionDispatch::IntegrationTest +class IssuesTest < Redmine::IntegrationTest fixtures :projects, :users, :roles, diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb index b4f472a75..91c16c364 100644 --- a/test/integration/layout_test.rb +++ b/test/integration/layout_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class LayoutTest < ActionDispatch::IntegrationTest +class LayoutTest < Redmine::IntegrationTest fixtures :projects, :trackers, :issue_statuses, :issues, :enumerations, :users, :issue_categories, :projects_trackers, diff --git a/test/integration/lib/redmine/hook_test.rb b/test/integration/lib/redmine/hook_test.rb index 9e5c5bbb1..20509ce4e 100644 --- a/test/integration/lib/redmine/hook_test.rb +++ b/test/integration/lib/redmine/hook_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../test_helper', __FILE__) -class HookTest < ActionDispatch::IntegrationTest +class HookTest < Redmine::IntegrationTest fixtures :users, :roles, :projects, :members, :member_roles # Hooks that are manually registered later diff --git a/test/integration/lib/redmine/menu_manager_test.rb b/test/integration/lib/redmine/menu_manager_test.rb index bc4fbf017..531af524a 100644 --- a/test/integration/lib/redmine/menu_manager_test.rb +++ b/test/integration/lib/redmine/menu_manager_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../test_helper', __FILE__) -class MenuManagerTest < ActionDispatch::IntegrationTest +class MenuManagerTest < Redmine::IntegrationTest include Redmine::I18n fixtures :projects, :trackers, :issue_statuses, :issues, diff --git a/test/integration/lib/redmine/themes_test.rb b/test/integration/lib/redmine/themes_test.rb index f0d422c58..601e2e2b4 100644 --- a/test/integration/lib/redmine/themes_test.rb +++ b/test/integration/lib/redmine/themes_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../../../test_helper', __FILE__) -class ThemesTest < ActionDispatch::IntegrationTest +class ThemesTest < Redmine::IntegrationTest def setup @theme = Redmine::Themes.themes.last diff --git a/test/integration/projects_test.rb b/test/integration/projects_test.rb index fcbf71dae..6bbeb656e 100644 --- a/test/integration/projects_test.rb +++ b/test/integration/projects_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class ProjectsTest < ActionDispatch::IntegrationTest +class ProjectsTest < Redmine::IntegrationTest fixtures :projects, :users, :members, :enabled_modules def test_archive_project diff --git a/test/integration/repositories_git_test.rb b/test/integration/repositories_git_test.rb index 14c7d087f..e36602698 100644 --- a/test/integration/repositories_git_test.rb +++ b/test/integration/repositories_git_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class RepositoriesGitTest < ActionDispatch::IntegrationTest +class RepositoriesGitTest < Redmine::IntegrationTest fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules diff --git a/test/integration/users_test.rb b/test/integration/users_test.rb index de5e35e18..85c6f31a2 100644 --- a/test/integration/users_test.rb +++ b/test/integration/users_test.rb @@ -17,7 +17,7 @@ require File.expand_path('../../test_helper', __FILE__) -class UsersTest < ActionDispatch::IntegrationTest +class UsersTest < Redmine::IntegrationTest fixtures :users def test_destroy_should_not_accept_get_requests diff --git a/test/test_helper.rb b/test/test_helper.rb index 7ec75708e..4754aaf06 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -43,24 +43,10 @@ class ActiveSupport::TestCase ESCAPED_CANT = 'can't' ESCAPED_UCANT = 'Can't' - def log_user(login, password) - User.anonymous - get "/login" - assert_equal nil, session[:user_id] - assert_response :success - assert_template "account/login" - post "/login", :username => login, :password => password - assert_equal login, User.find(session[:user_id]).login - end - def uploaded_test_file(name, mime) fixture_file_upload("files/#{name}", mime, true) end - def credentials(user, password=nil) - {'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)} - end - # Mock out a file def self.mock_file file = 'a_file.png' @@ -248,11 +234,27 @@ module Redmine end end + class IntegrationTest < ActionDispatch::IntegrationTest + def log_user(login, password) + User.anonymous + get "/login" + assert_equal nil, session[:user_id] + assert_response :success + assert_template "account/login" + post "/login", :username => login, :password => password + assert_equal login, User.find(session[:user_id]).login + end + + def credentials(user, password=nil) + {'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)} + end + end + module ApiTest API_FORMATS = %w(json xml).freeze # Base class for API tests - class Base < ActionDispatch::IntegrationTest + class Base < Redmine::IntegrationTest def setup Setting.rest_api_enabled = '1' end -- 2.39.5