From 3baf0fd6627fa55137e6e54a7a9f93ac2ea4970e Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Sun, 15 Jul 2018 13:14:41 +0200 Subject: [PATCH] Fix functional tests --- .travis.yml | 1 + test/functional/account_controller_test.rb | 2 +- .../additionals_assign_to_me_controller_test.rb | 2 +- .../additionals_change_status_controller_test.rb | 2 +- test/functional/issues_controller_test.rb | 2 +- test/functional/projects_controller_test.rb | 2 +- test/functional/users_controller_test.rb | 2 +- test/functional/welcome_controller_test.rb | 2 +- test/functional/wiki_controller_test.rb | 2 +- test/integration/library_test.rb | 5 +++++ test/test_helper.rb | 14 ++++++++++++++ 11 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78276da0..0bda81ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: false language: ruby +cache: bundler rvm: - 2.2.7 - 2.3.4 diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index f23fbf5c..fa4ab002 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class AccountControllerTest < ActionController::TestCase +class AccountControllerTest < Additionals::ControllerTest fixtures :users, :email_addresses, :roles def setup diff --git a/test/functional/additionals_assign_to_me_controller_test.rb b/test/functional/additionals_assign_to_me_controller_test.rb index acdc4a97..5aaa0e25 100644 --- a/test/functional/additionals_assign_to_me_controller_test.rb +++ b/test/functional/additionals_assign_to_me_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class AdditionalsAssignToMeControllerTest < ActionController::TestCase +class AdditionalsAssignToMeControllerTest < Additionals::ControllerTest fixtures :projects, :users, :email_addresses, :user_preferences, :roles, diff --git a/test/functional/additionals_change_status_controller_test.rb b/test/functional/additionals_change_status_controller_test.rb index 3004aa0a..e5d28d29 100644 --- a/test/functional/additionals_change_status_controller_test.rb +++ b/test/functional/additionals_change_status_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class AdditionalsChangeStatusControllerTest < ActionController::TestCase +class AdditionalsChangeStatusControllerTest < Additionals::ControllerTest fixtures :projects, :users, :email_addresses, :user_preferences, :roles, diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index b9ea699e..6eb17770 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class IssuesControllerTest < ActionController::TestCase +class IssuesControllerTest < Additionals::ControllerTest fixtures :projects, :users, :email_addresses, :user_preferences, :roles, diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index e8d0f6e5..e8f16ca1 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class ProjectsControllerTest < ActionController::TestCase +class ProjectsControllerTest < Additionals::ControllerTest fixtures :projects, :users, :roles, diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 30bfff12..bc611a45 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class UsersControllerTest < ActionController::TestCase +class UsersControllerTest < Additionals::ControllerTest fixtures :projects, :users, :roles, diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb index bb45d501..c8de3bfd 100644 --- a/test/functional/welcome_controller_test.rb +++ b/test/functional/welcome_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class WelcomeControllerTest < ActionController::TestCase +class WelcomeControllerTest < Additionals::ControllerTest fixtures :projects, :news, :users, :members def setup diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index ee3354b4..d0f00b38 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -1,6 +1,6 @@ require File.expand_path('../../test_helper', __FILE__) -class WikiControllerTest < ActionController::TestCase +class WikiControllerTest < Additionals::ControllerTest fixtures :projects, :users, :roles, diff --git a/test/integration/library_test.rb b/test/integration/library_test.rb index 1721e59f..dc0017b5 100644 --- a/test/integration/library_test.rb +++ b/test/integration/library_test.rb @@ -6,12 +6,17 @@ class JavascriptLibraryTest < Redmine::IntegrationTest assert_response :success assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/fontawesome-all.min.css' + + return unless Redmine::Plugin.installed?('redmine_reporting') + assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/nv.d3.min.css', count: 1 end def test_not_loaded_css_libraries get '/' assert_response :success + + return if Redmine::Plugin.installed?('redmine_reporting') assert_select 'link[rel=stylesheet][href^=?]', '/plugin_assets/additionals/stylesheets/nv.d3.min.css', count: 0 end diff --git a/test/test_helper.rb b/test/test_helper.rb index 04d5bb72..b3201087 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -17,6 +17,20 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper') # Additionals helper class for tests module Additionals + class ControllerTest < ActionController::TestCase + # can be removed if Redmine 3.4 and higher is supported only + def process(action, http_method = 'GET', *args) + parameters, _session, _flash = *args + if args.size == 1 && parameters[:xhr] == true + xhr http_method.downcase.to_sym, action, parameters.except(:xhr) + elsif parameters && (parameters.key?(:params) || parameters.key?(:session) || parameters.key?(:flash)) + super action, http_method, parameters[:params], parameters[:session], parameters[:flash] + else + super + end + end + end + class TestCase include ActionDispatch::TestProcess def self.plugin_fixtures(plugin, *fixture_names)