Commit 8d6e8a04 authored by Matthias Kaeppler's avatar Matthias Kaeppler

Enable Deprecation Toolkit for qa tests

This will fail fast whenever we use syntax that
will cause hard errors in Ruby 3.
parent 308a3a85
......@@ -8,7 +8,7 @@ gem 'allure-rspec', '~> 2.14.1'
gem 'capybara', '~> 3.35.0'
gem 'capybara-screenshot', '~> 1.0.23'
gem 'rake', '~> 12.3.3'
gem 'rspec', '~> 3.7'
gem 'rspec', '~> 3.10'
gem 'selenium-webdriver', '~> 4.0.0.beta4'
gem 'airborne', '~> 0.3.4'
gem 'rest-client', '~> 2.1.0'
......@@ -28,6 +28,8 @@ gem 'webdrivers', '~> 4.6'
gem 'chemlab', '~> 0.7'
gem 'chemlab-library-www-gitlab-com', '~> 0.1'
gem 'deprecation_toolkit', '~> 1.5.1', require: false
group :development do
gem 'pry-byebug', '~> 3.5.1', platform: :mri
gem "ruby-debug-ide", "~> 0.7.0"
......
......@@ -56,6 +56,8 @@ GEM
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.1.9)
deprecation_toolkit (1.5.1)
activesupport (>= 4.2)
diff-lcs (1.3)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
......@@ -141,18 +143,18 @@ GEM
netrc (~> 0.8)
rexml (3.2.5)
rotp (3.1.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.1)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (~> 3.10.0)
rspec-parameterized (0.4.2)
binding_ninja (>= 0.2.3)
parser
......@@ -161,7 +163,7 @@ GEM
unparser
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.9.4)
rspec-support (3.10.2)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
ruby-debug-ide (0.7.2)
......@@ -215,6 +217,7 @@ DEPENDENCIES
capybara-screenshot (~> 1.0.23)
chemlab (~> 0.7)
chemlab-library-www-gitlab-com (~> 0.1)
deprecation_toolkit (~> 1.5.1)
faker (~> 1.6, >= 1.6.6)
gitlab-qa
knapsack (~> 1.17)
......@@ -226,7 +229,7 @@ DEPENDENCIES
rake (~> 12.3.3)
rest-client (~> 2.1.0)
rotp (~> 3.1.0)
rspec (~> 3.7)
rspec (~> 3.10)
rspec-parameterized (~> 0.4.2)
rspec-retry (~> 0.6.1)
rspec_junit_formatter (~> 0.4.1)
......
......@@ -108,7 +108,7 @@ module QA
wait_for_requests(skip_finished_loading_check: skip_finished_loading_check)
element_selector = element_selector_css(name, reject_capybara_query_keywords(kwargs))
find(element_selector, only_capybara_query_keywords(kwargs))
find(element_selector, **only_capybara_query_keywords(kwargs))
end
def only_capybara_query_keywords(kwargs)
......
......@@ -26,7 +26,7 @@ module QA
end
def restore_application_settings(*application_settings_keys)
set_application_settings(@original_application_settings.slice(*application_settings_keys))
set_application_settings(**@original_application_settings.slice(*application_settings_keys))
end
private
......
......@@ -148,7 +148,7 @@ module QA
Capybara::Selenium::Driver.new(
app,
selenium_options
**selenium_options
)
end
......
......@@ -32,7 +32,7 @@ module QA
def enabled?(key, **scopes)
feature = JSON.parse(get_features).find { |flag| flag['name'] == key.to_s }
feature && (feature['state'] == 'on' || feature['state'] == 'conditional' && scopes.present? && enabled_scope?(feature['gates'], scopes))
feature && (feature['state'] == 'on' || feature['state'] == 'conditional' && scopes.present? && enabled_scope?(feature['gates'], **scopes))
end
private
......@@ -43,7 +43,7 @@ module QA
raise AuthorizationError, "Administrator access is required to enable/disable feature flags. #{e.message}"
end
def enabled_scope?(gates, scopes)
def enabled_scope?(gates, **scopes)
scopes.each do |key, value|
case key
when :project, :group, :user
......@@ -71,16 +71,16 @@ module QA
# scopes: Any scope (user, project, group) to restrict the change to
def set_and_verify(key, enable:, **scopes)
msg = "#{enable ? 'En' : 'Dis'}abling feature: #{key}"
msg += " for scope \"#{scopes_to_s(scopes)}\"" if scopes.present?
msg += " for scope \"#{scopes_to_s(**scopes)}\"" if scopes.present?
QA::Runtime::Logger.info(msg)
Support::Retrier.retry_on_exception(sleep_interval: 2) do
set_feature(key, enable, scopes)
set_feature(key, enable, **scopes)
is_enabled = nil
QA::Support::Waiter.wait_until(sleep_interval: 1) do
is_enabled = enabled?(key, scopes)
is_enabled = enabled?(key, **scopes)
is_enabled == enable || !enable && scopes.present?
end
......
# frozen_string_literal: true
require 'deprecation_toolkit'
require 'deprecation_toolkit/rspec'
require 'concurrent/utility/monotonic_time'
require 'active_support/gem_version'
module QaDeprecationToolkitEnv
# Taken from https://github.com/jeremyevans/ruby-warning/blob/1.1.0/lib/warning.rb#L18
def self.kwargs_warning
%r{warning: (?:Using the last argument (?:for `.+' )?as keyword parameters is deprecated; maybe \*\* should be added to the call|Passing the keyword argument (?:for `.+' )?as the last hash parameter is deprecated|Splitting the last argument (?:for `.+' )?into positional and keyword parameters is deprecated|The called method (?:`.+' )?is defined here)\n\z}
end
def self.configure!
# Enable ruby deprecations for keywords, it's suppressed by default in Ruby 2.7.2
Warning[:deprecated] = true
DeprecationToolkit::Configuration.test_runner = :rspec
DeprecationToolkit::Configuration.deprecation_path = 'deprecations'
DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [kwargs_warning]
end
end
......@@ -14,7 +14,7 @@ RSpec.describe QA::Runtime::API::Request do
end
context 'when oauth_access_token is passed in the query string' do
let(:request) { described_class.new(client, '/users', { oauth_access_token: 'foo' }) }
let(:request) { described_class.new(client, '/users', oauth_access_token: 'foo') }
it 'does not adds a private_token query string' do
expect(request.url).to eq 'http://example.com/api/v4/users?oauth_access_token=foo'
......
......@@ -6,6 +6,9 @@ require 'rspec-parameterized'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require_relative 'qa_deprecation_toolkit_env'
QaDeprecationToolkitEnv.configure!
if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK']
require 'knapsack'
Knapsack::Adapters::RSpecAdapter.bind
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment