From 38da8197e22cae384d83d676253ed358bc61692e Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 8 Jan 2020 14:59:35 +0100 Subject: [PATCH 01/12] Add specific gem to provide legacy methods like assigns and assert_template --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 469b0bb..05405df 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ gem "rspec", "~> 3.6" gem "rspec-core", "~> 3.6" gem "rspec-rails", "~> 3.6" +gem 'rails-controller-testing' #for test coverage # gem 'simplecov', '~> 0.9.1', :require => false, :group => :test From 5b0b8b9f9d079297793d65334439443022fc3571 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Fri, 13 Mar 2020 09:46:18 +0100 Subject: [PATCH 02/12] Include ObjectHelpers in specs --- spec/rails_helper.rb | 3 +++ spec/spec_helper.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4371bcd..5ebeb3a 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,6 +7,9 @@ require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! +require File.expand_path('../../test/object_helpers', __FILE__) +include ObjectHelpers + # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0901824..0882316 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,9 @@ #load rails/redmine require File.expand_path('../../../../config/environment', __FILE__) +require File.expand_path('../../test/object_helpers', __FILE__) +include ObjectHelpers + #test gems require 'rspec/rails' # require 'rspec/autorun' From 1e466c1472b547cba0ca9533b0a796bc4122fab8 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 16 Mar 2020 16:04:44 +0100 Subject: [PATCH 03/12] Fix path to object_helper --- spec/rails_helper.rb | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5ebeb3a..07eb73c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -7,7 +7,7 @@ require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! -require File.expand_path('../../test/object_helpers', __FILE__) +require File.expand_path("#{::Rails.root}/test/object_helpers", __FILE__) include ObjectHelpers # Requires supporting ruby files with custom matchers and macros, etc, in diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0882316..24df437 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,7 +18,7 @@ #load rails/redmine require File.expand_path('../../../../config/environment', __FILE__) -require File.expand_path('../../test/object_helpers', __FILE__) +require File.expand_path("#{::Rails.root}/test/object_helpers", __FILE__) include ObjectHelpers #test gems From c560376c86259aa48429ca9b6abbb9e9ecb4f9a4 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 20 Jul 2020 18:03:54 +0200 Subject: [PATCH 04/12] Specify system specs web browser and options --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 24df437..63b1354 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,6 +42,9 @@ def document_root_element config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! config.include AssertSelectRoot, :type => :request + config.before(:each, type: :system) do + driven_by :selenium, using: :chrome, options: { args: ["headless", "no-sandbox", "disable-gpu"] } + end end def with_settings(options, &block) From 5ef6d5692957408ad79e36cdd246cb56820ec953 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 22 Jul 2020 10:59:16 +0200 Subject: [PATCH 05/12] Add log_user system helper --- spec/spec_helper.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 63b1354..7c388ef 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -62,3 +62,19 @@ def with_settings(options, &block) ensure saved_settings.each {|k, v| Setting[k] = v} if saved_settings end + +def log_user(login, password) + visit '/my/page' + expect(current_path).to eq '/login' + + if Redmine::Plugin.installed?(:redmine_scn) + click_on("ou s'authentifier par login / mot de passe") + end + + within('#login-form form') do + fill_in 'username', with: login + fill_in 'password', with: password + find('input[name=login]').click + end + expect(current_path).to eq '/my/page' +end From 9179e90ef4152cb436c8ec6547b69d4eaa9040a0 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 16 Dec 2020 11:02:22 +0100 Subject: [PATCH 06/12] Add helper methods --- spec/rails_helper.rb | 2 +- spec/spec_helper.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 07eb73c..5cf473d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -27,7 +27,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = "#{::Rails.root}/test/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7c388ef..d244d67 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -78,3 +78,23 @@ def log_user(login, password) end expect(current_path).to eq '/my/page' end + +def assert_mail_body_match(expected, mail, message=nil) + if expected.is_a?(String) + expect(mail_body(mail)).to include(expected) + else + assert_match expected, mail_body(mail), message + end +end + +def assert_mail_body_no_match(expected, mail, message=nil) + if expected.is_a?(String) + expect(mail_body(mail)).to_not include expected + else + assert_no_match expected, mail_body(mail), message + end +end + +def mail_body(mail) + mail.parts.first.body.encoded +end From 4f5ab32ad84bb3d6234da9aa8f6e84e05b480efd Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 23 Feb 2021 08:41:23 +0100 Subject: [PATCH 07/12] Add DB support files for CI configuration --- spec/support/database-postgres.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 spec/support/database-postgres.yml diff --git a/spec/support/database-postgres.yml b/spec/support/database-postgres.yml new file mode 100644 index 0000000..3e5b111 --- /dev/null +++ b/spec/support/database-postgres.yml @@ -0,0 +1,8 @@ +test: + adapter: postgresql + host: localhost + encoding: unicode + pool: 5 + database: pg_test + username: postgres + password: postgres From 6115c03f664156f9a8bc43b31e70a6c41bd2ae5c Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Wed, 6 Oct 2021 11:29:01 +0200 Subject: [PATCH 08/12] Add missing test helper to spec_helper --- spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d244d67..b9189d6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -98,3 +98,7 @@ def assert_mail_body_no_match(expected, mail, message=nil) def mail_body(mail) mail.parts.first.body.encoded end + +def uploaded_test_file(name, mime) + fixture_file_upload("files/#{name}", mime, true) +end From 7264e57e263cc8be6fd96f2157f8adc839a41748 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Tue, 19 Oct 2021 16:42:39 +0200 Subject: [PATCH 09/12] Update arguments for latest selenium-webdriver gem: v4.0 --- spec/spec_helper.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b9189d6..7eb372c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -43,7 +43,16 @@ def document_root_element config.infer_spec_type_from_file_location! config.include AssertSelectRoot, :type => :request config.before(:each, type: :system) do - driven_by :selenium, using: :chrome, options: { args: ["headless", "no-sandbox", "disable-gpu"] } + options = {} + options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( + 'goog:chromeOptions' => { + 'args' => ["headless", "no-sandbox", "disable-gpu"] + } + ) + driven_by( + :selenium, using: :chrome, screen_size: [1024, 900], + options: options + ) end end From f246a0e196cad819b0b2cb380b59edf74905b11b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 11 Apr 2022 14:40:35 +0200 Subject: [PATCH 10/12] Update Rspec for Redmine 5 --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 05405df..578890d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ -gem "rspec", "~> 3.6" -gem "rspec-core", "~> 3.6" -gem "rspec-rails", "~> 3.6" +gem "rspec", '~> 3.11.0' +gem "rspec-core", '~> 3.11.0' +gem 'rspec-rails', '~> 4.1.0' gem 'rails-controller-testing' #for test coverage # gem 'simplecov', '~> 0.9.1', :require => false, :group => :test From e643cac250bb2b24fd2e76b2e4e6faf91431d733 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 27 Jun 2022 12:24:27 +0200 Subject: [PATCH 11/12] Replace deprecated option --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7eb372c..87a0c69 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,7 +44,7 @@ def document_root_element config.include AssertSelectRoot, :type => :request config.before(:each, type: :system) do options = {} - options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( + options[:capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( 'goog:chromeOptions' => { 'args' => ["headless", "no-sandbox", "disable-gpu"] } From 129f00d2cf2cada7fb421c965b8924ebd2c575cc Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Mon, 18 Jul 2022 15:48:19 +0200 Subject: [PATCH 12/12] Improve compatibility with Redmine 5 - Use fullpath to fixtures/files --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 87a0c69..c34bb0d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -109,5 +109,5 @@ def mail_body(mail) end def uploaded_test_file(name, mime) - fixture_file_upload("files/#{name}", mime, true) + fixture_file_upload("#{::Rails.root}/test/fixtures/files/#{name}", mime, true) end