Commit 2969c452 authored by Igor Drozdov's avatar Igor Drozdov Committed by Stan Hu
parent fd1c8b16
...@@ -359,7 +359,7 @@ group :development, :test do ...@@ -359,7 +359,7 @@ group :development, :test do
gem 'database_cleaner', '~> 1.7.0' gem 'database_cleaner', '~> 1.7.0'
gem 'factory_bot_rails', '~> 6.1.0' gem 'factory_bot_rails', '~> 6.1.0'
gem 'rspec-rails', '~> 4.0.1' gem 'rspec-rails', '~> 4.0.2'
# Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826) # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
gem 'minitest', '~> 5.11.0' gem 'minitest', '~> 5.11.0'
......
...@@ -1002,12 +1002,12 @@ GEM ...@@ -1002,12 +1002,12 @@ GEM
rspec-core (~> 3.10.0) rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0) rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0) rspec-mocks (~> 3.10.0)
rspec-core (3.10.0) rspec-core (3.10.1)
rspec-support (~> 3.10.0) rspec-support (~> 3.10.0)
rspec-expectations (3.10.0) rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.10.0)
rspec-mocks (3.10.0) rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.10.0)
rspec-parameterized (0.4.2) rspec-parameterized (0.4.2)
...@@ -1016,17 +1016,17 @@ GEM ...@@ -1016,17 +1016,17 @@ GEM
proc_to_ast proc_to_ast
rspec (>= 2.13, < 4) rspec (>= 2.13, < 4)
unparser unparser
rspec-rails (4.0.1) rspec-rails (4.0.2)
actionpack (>= 4.2) actionpack (>= 4.2)
activesupport (>= 4.2) activesupport (>= 4.2)
railties (>= 4.2) railties (>= 4.2)
rspec-core (~> 3.9) rspec-core (~> 3.10)
rspec-expectations (~> 3.9) rspec-expectations (~> 3.10)
rspec-mocks (~> 3.9) rspec-mocks (~> 3.10)
rspec-support (~> 3.9) rspec-support (~> 3.10)
rspec-retry (0.6.1) rspec-retry (0.6.1)
rspec-core (> 3.3) rspec-core (> 3.3)
rspec-support (3.10.0) rspec-support (3.10.2)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
rspec_profiling (0.0.6) rspec_profiling (0.0.6)
...@@ -1492,7 +1492,7 @@ DEPENDENCIES ...@@ -1492,7 +1492,7 @@ DEPENDENCIES
rouge (~> 3.26.0) rouge (~> 3.26.0)
rqrcode-rails3 (~> 0.1.7) rqrcode-rails3 (~> 0.1.7)
rspec-parameterized rspec-parameterized
rspec-rails (~> 4.0.1) rspec-rails (~> 4.0.2)
rspec-retry (~> 0.6.1) rspec-retry (~> 0.6.1)
rspec_junit_formatter rspec_junit_formatter
rspec_profiling (~> 0.0.6) rspec_profiling (~> 0.0.6)
......
---
title: Update rspec-* gem versions
merge_request: 52873
author:
type: other
...@@ -56,13 +56,9 @@ module DeprecationToolkitEnv ...@@ -56,13 +56,9 @@ module DeprecationToolkitEnv
def self.allowed_kwarg_warning_paths def self.allowed_kwarg_warning_paths
%w[ %w[
spec/support/gitlab_experiment.rb spec/support/gitlab_experiment.rb
spec/support/helpers/next_instance_of.rb
rspec-mocks-3.10.0/lib/rspec/mocks/message_expectation.rb
activerecord-6.0.3.4/lib/active_record/migration.rb activerecord-6.0.3.4/lib/active_record/migration.rb
devise-4.7.3/lib/devise/test/controller_helpers.rb devise-4.7.3/lib/devise/test/controller_helpers.rb
attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb
rspec-mocks-3.10.0/lib/rspec/mocks/message_expectation.rb
rspec-expectations-3.10.0/lib/rspec/matchers/built_in/has.rb
grape-1.5.1/lib/grape/middleware/stack.rb grape-1.5.1/lib/grape/middleware/stack.rb
grape-1.5.1/lib/grape/validations/validators/coerce.rb grape-1.5.1/lib/grape/validations/validators/coerce.rb
grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb grape_logging-1.8.3/lib/grape_logging/middleware/request_logger.rb
......
...@@ -302,36 +302,36 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do ...@@ -302,36 +302,36 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
it 'does not block urls from private networks' do it 'does not block urls from private networks' do
local_ips.each do |ip| local_ips.each do |ip|
stub_domain_resolv(fake_domain, ip) do stub_domain_resolv(fake_domain, ip) do
expect(described_class).not_to be_blocked_url("http://#{fake_domain}", url_blocker_attributes) expect(described_class).not_to be_blocked_url("http://#{fake_domain}", **url_blocker_attributes)
end end
expect(described_class).not_to be_blocked_url("http://#{ip}", url_blocker_attributes) expect(described_class).not_to be_blocked_url("http://#{ip}", **url_blocker_attributes)
end end
end end
it 'allows localhost endpoints' do it 'allows localhost endpoints' do
expect(described_class).not_to be_blocked_url('http://0.0.0.0', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://0.0.0.0', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://localhost', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://localhost', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://127.0.0.1', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://127.0.0.1', **url_blocker_attributes)
end end
it 'allows loopback endpoints' do it 'allows loopback endpoints' do
expect(described_class).not_to be_blocked_url('http://127.0.0.2', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://127.0.0.2', **url_blocker_attributes)
end end
it 'allows IPv4 link-local endpoints' do it 'allows IPv4 link-local endpoints' do
expect(described_class).not_to be_blocked_url('http://169.254.169.254', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://169.254.169.254', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://169.254.168.100', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://169.254.168.100', **url_blocker_attributes)
end end
it 'allows IPv6 link-local endpoints' do it 'allows IPv6 link-local endpoints' do
expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.169.254]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.169.254]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.169.254]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.169.254]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a9fe]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a9fe]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.168.100]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.168.100]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.168.100]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.168.100]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a864]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a864]', **url_blocker_attributes)
expect(described_class).not_to be_blocked_url('http://[fe80::c800:eff:fe74:8]', url_blocker_attributes) expect(described_class).not_to be_blocked_url('http://[fe80::c800:eff:fe74:8]', **url_blocker_attributes)
end end
end end
...@@ -416,11 +416,11 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do ...@@ -416,11 +416,11 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
attrs = url_blocker_attributes.merge(dns_rebind_protection: false) attrs = url_blocker_attributes.merge(dns_rebind_protection: false)
stub_domain_resolv('example.com', '192.168.1.2') do stub_domain_resolv('example.com', '192.168.1.2') do
expect(described_class).not_to be_blocked_url(url, attrs) expect(described_class).not_to be_blocked_url(url, **attrs)
end end
stub_domain_resolv('example.com', '192.168.1.3') do stub_domain_resolv('example.com', '192.168.1.3') do
expect(described_class).to be_blocked_url(url, attrs) expect(described_class).to be_blocked_url(url, **attrs)
end end
end end
end end
...@@ -442,18 +442,18 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do ...@@ -442,18 +442,18 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
stub_domain_resolv(domain, '192.168.1.1') do stub_domain_resolv(domain, '192.168.1.1') do
expect(described_class).not_to be_blocked_url("http://#{domain}", expect(described_class).not_to be_blocked_url("http://#{domain}",
url_blocker_attributes) **url_blocker_attributes)
end end
stub_domain_resolv(subdomain1, '192.168.1.1') do stub_domain_resolv(subdomain1, '192.168.1.1') do
expect(described_class).not_to be_blocked_url("http://#{subdomain1}", expect(described_class).not_to be_blocked_url("http://#{subdomain1}",
url_blocker_attributes) **url_blocker_attributes)
end end
# subdomain2 is not part of the allowlist so it should be blocked # subdomain2 is not part of the allowlist so it should be blocked
stub_domain_resolv(subdomain2, '192.168.1.1') do stub_domain_resolv(subdomain2, '192.168.1.1') do
expect(described_class).to be_blocked_url("http://#{subdomain2}", expect(described_class).to be_blocked_url("http://#{subdomain2}",
url_blocker_attributes) **url_blocker_attributes)
end end
end end
...@@ -463,12 +463,12 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do ...@@ -463,12 +463,12 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
stub_domain_resolv(unicode_domain, '192.168.1.1') do stub_domain_resolv(unicode_domain, '192.168.1.1') do
expect(described_class).not_to be_blocked_url("http://#{unicode_domain}", expect(described_class).not_to be_blocked_url("http://#{unicode_domain}",
url_blocker_attributes) **url_blocker_attributes)
end end
stub_domain_resolv(idna_encoded_domain, '192.168.1.1') do stub_domain_resolv(idna_encoded_domain, '192.168.1.1') do
expect(described_class).not_to be_blocked_url("http://#{idna_encoded_domain}", expect(described_class).not_to be_blocked_url("http://#{idna_encoded_domain}",
url_blocker_attributes) **url_blocker_attributes)
end end
end end
...@@ -525,7 +525,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do ...@@ -525,7 +525,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do
it 'allows domain with port when resolved ip has port allowed' do it 'allows domain with port when resolved ip has port allowed' do
stub_domain_resolv("www.resolve-domain.com", '127.0.0.1') do stub_domain_resolv("www.resolve-domain.com", '127.0.0.1') do
expect(described_class).not_to be_blocked_url("http://www.resolve-domain.com:2000", url_blocker_attributes) expect(described_class).not_to be_blocked_url("http://www.resolve-domain.com:2000", **url_blocker_attributes)
end end
end end
end end
......
...@@ -37,19 +37,19 @@ RSpec.describe Gitlab::UrlBlockers::UrlAllowlist do ...@@ -37,19 +37,19 @@ RSpec.describe Gitlab::UrlBlockers::UrlAllowlist do
let(:allowlist) { ['example.io:3000'] } let(:allowlist) { ['example.io:3000'] }
it 'returns true if domain and ports present in allowlist' do it 'returns true if domain and ports present in allowlist' do
parsed_allowlist = [['example.io', { port: 3000 }]] parsed_allowlist = [['example.io', 3000]]
not_allowed = [ not_allowed = [
'example.io', 'example.io',
['example.io', { port: 3001 }] ['example.io', 3001]
] ]
aggregate_failures do aggregate_failures do
parsed_allowlist.each do |domain_and_port| parsed_allowlist.each do |domain, port|
expect(described_class).to be_domain_allowed(*domain_and_port) expect(described_class).to be_domain_allowed(domain, port: port)
end end
not_allowed.each do |domain_and_port| not_allowed.each do |domain, port|
expect(described_class).not_to be_domain_allowed(*domain_and_port) expect(described_class).not_to be_domain_allowed(domain, port: port)
end end
end end
end end
...@@ -139,23 +139,23 @@ RSpec.describe Gitlab::UrlBlockers::UrlAllowlist do ...@@ -139,23 +139,23 @@ RSpec.describe Gitlab::UrlBlockers::UrlAllowlist do
it 'returns true if ip and ports present in allowlist' do it 'returns true if ip and ports present in allowlist' do
parsed_allowlist = [ parsed_allowlist = [
['127.0.0.9', { port: 3000 }], ['127.0.0.9', 3000],
['[2001:db8:85a3:8d3:1319:8a2e:370:7348]', { port: 443 }] ['[2001:db8:85a3:8d3:1319:8a2e:370:7348]', 443]
] ]
not_allowed = [ not_allowed = [
'127.0.0.9', '127.0.0.9',
['127.0.0.9', { port: 3001 }], ['127.0.0.9', 3001],
'[2001:db8:85a3:8d3:1319:8a2e:370:7348]', '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
['[2001:db8:85a3:8d3:1319:8a2e:370:7348]', { port: 3001 }] ['[2001:db8:85a3:8d3:1319:8a2e:370:7348]', 3001]
] ]
aggregate_failures do aggregate_failures do
parsed_allowlist.each do |ip_and_port| parsed_allowlist.each do |ip, port|
expect(described_class).to be_ip_allowed(*ip_and_port) expect(described_class).to be_ip_allowed(ip, port: port)
end end
not_allowed.each do |ip_and_port| not_allowed.each do |ip, port|
expect(described_class).not_to be_ip_allowed(*ip_and_port) expect(described_class).not_to be_ip_allowed(ip, port: port)
end end
end end
end end
......
...@@ -5105,10 +5105,8 @@ RSpec.describe Project, factory_default: :keep do ...@@ -5105,10 +5105,8 @@ RSpec.describe Project, factory_default: :keep do
it 'executes services with the specified scope' do it 'executes services with the specified scope' do
data = 'any data' data = 'any data'
expect(SlackService).to receive(:allocate).and_wrap_original do |method| expect_next_found_instance_of(SlackService) do |instance|
method.call.tap do |instance| expect(instance).to receive(:async_execute).with(data).once
expect(instance).to receive(:async_execute).with(data).once
end
end end
service.project.execute_services(data, :push_hooks) service.project.execute_services(data, :push_hooks)
......
...@@ -55,6 +55,8 @@ RSpec.describe Packages::Debian::DestroyDistributionService do ...@@ -55,6 +55,8 @@ RSpec.describe Packages::Debian::DestroyDistributionService do
end end
context 'when destroy fails' do context 'when destroy fails' do
let(:distribution) { create("debian_#{container_type}_distribution", container: container) }
before do before do
expect(distribution).to receive(:destroy).and_return(false) expect(distribution).to receive(:destroy).and_return(false)
end end
......
...@@ -6,7 +6,7 @@ module NextFoundInstanceOf ...@@ -6,7 +6,7 @@ module NextFoundInstanceOf
def expect_next_found_instance_of(klass) def expect_next_found_instance_of(klass)
check_if_active_record!(klass) check_if_active_record!(klass)
stub_allocate(expect(klass)) do |expectation| stub_allocate(expect(klass), klass) do |expectation|
yield(expectation) yield(expectation)
end end
end end
...@@ -14,7 +14,7 @@ module NextFoundInstanceOf ...@@ -14,7 +14,7 @@ module NextFoundInstanceOf
def allow_next_found_instance_of(klass) def allow_next_found_instance_of(klass)
check_if_active_record!(klass) check_if_active_record!(klass)
stub_allocate(allow(klass)) do |allowance| stub_allocate(allow(klass), klass) do |allowance|
yield(allowance) yield(allowance)
end end
end end
...@@ -25,9 +25,17 @@ module NextFoundInstanceOf ...@@ -25,9 +25,17 @@ module NextFoundInstanceOf
raise ArgumentError.new(ERROR_MESSAGE) unless klass < ActiveRecord::Base raise ArgumentError.new(ERROR_MESSAGE) unless klass < ActiveRecord::Base
end end
def stub_allocate(target) def stub_allocate(target, klass)
target.to receive(:allocate).and_wrap_original do |method| target.to receive(:allocate).and_wrap_original do |method|
method.call.tap { |allocation| yield(allocation) } method.call.tap do |allocation|
# ActiveRecord::Core.allocate returns a frozen object:
# https://github.com/rails/rails/blob/291a3d2ef29a3842d1156ada7526f4ee60dd2b59/activerecord/lib/active_record/core.rb#L620
# It's unexpected behavior and probably a bug in Rails
# Let's work it around by setting the attributes to default to unfreeze the object for now
allocation.instance_variable_set(:@attributes, klass._default_attributes)
yield(allocation)
end
end end
end end
end end
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