summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-07 00:07:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-07 00:07:51 +0000
commit4e375367b78bb44bd00957522cd9fc3e6d403fef (patch)
tree059b1ce541e4128bf03683407d7b5bbbc2094ed5 /spec/lib
parent99ddca0d88f1e4e49d61b1aa9d41b5785528d1dc (diff)
downloadgitlab-ce-4e375367b78bb44bd00957522cd9fc3e6d403fef.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/auth/ldap/access_spec.rb4
-rw-r--r--spec/lib/gitlab/auth/ldap/auth_hash_spec.rb4
-rw-r--r--spec/lib/gitlab/auth/ldap/authentication_spec.rb15
-rw-r--r--spec/lib/gitlab/auth/o_auth/user_spec.rb24
-rw-r--r--spec/lib/gitlab/bare_repository_import/importer_spec.rb4
-rw-r--r--spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb4
-rw-r--r--spec/lib/gitlab/checks/branch_check_spec.rb4
-rw-r--r--spec/lib/gitlab/checks/change_access_spec.rb20
-rw-r--r--spec/lib/gitlab/ci/build/credentials/factory_spec.rb12
-rw-r--r--spec/lib/gitlab/ci/config/external/file/project_spec.rb11
-rw-r--r--spec/lib/gitlab/ci/config/external/file/remote_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/config/external/file/template_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/config/external/mapper_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/config_spec.rb28
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb8
-rw-r--r--spec/lib/gitlab/ci/trace/chunked_io_spec.rb5
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb4
-rw-r--r--spec/lib/gitlab/cycle_analytics/usage_data_spec.rb4
-rw-r--r--spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb16
-rw-r--r--spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb4
-rw-r--r--spec/lib/gitlab/etag_caching/middleware_spec.rb16
-rw-r--r--spec/lib/gitlab/experimentation_spec.rb4
-rw-r--r--spec/lib/gitlab/fogbugz_import/client_spec.rb4
-rw-r--r--spec/lib/gitlab/fogbugz_import/importer_spec.rb73
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb4
-rw-r--r--spec/lib/gitlab/git/commit_spec.rb8
-rw-r--r--spec/lib/gitlab/git/tree_spec.rb4
-rw-r--r--spec/lib/gitlab/git_access_spec.rb4
-rw-r--r--spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb9
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb4
-rw-r--r--spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/importer/labels_importer_spec.rb5
-rw-r--r--spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb5
-rw-r--r--spec/lib/gitlab/github_import/importer/note_importer_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/sequential_importer_spec.rb5
-rw-r--r--spec/lib/gitlab/gitlab_import/client_spec.rb12
-rw-r--r--spec/lib/gitlab/http_io_spec.rb4
-rw-r--r--spec/lib/gitlab/request_context_spec.rb4
39 files changed, 266 insertions, 103 deletions
diff --git a/spec/lib/gitlab/auth/ldap/access_spec.rb b/spec/lib/gitlab/auth/ldap/access_spec.rb
index ecdd5b29986..f9eb4a30190 100644
--- a/spec/lib/gitlab/auth/ldap/access_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/access_spec.rb
@@ -136,7 +136,9 @@ describe Gitlab::Auth::LDAP::Access do
context 'without ActiveDirectory enabled' do
before do
allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true)
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:active_directory).and_return(false)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive(:active_directory).and_return(false)
+ end
end
it 'returns true' do
diff --git a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
index adb8e138ca7..f1050b9f830 100644
--- a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
@@ -58,7 +58,9 @@ describe Gitlab::Auth::LDAP::AuthHash do
end
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:attributes).and_return(attributes)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive(:attributes).and_return(attributes)
+ end
end
it "has the correct username" do
diff --git a/spec/lib/gitlab/auth/ldap/authentication_spec.rb b/spec/lib/gitlab/auth/ldap/authentication_spec.rb
index e68e83e4617..ebaf8383ce5 100644
--- a/spec/lib/gitlab/auth/ldap/authentication_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/authentication_spec.rb
@@ -18,8 +18,9 @@ describe Gitlab::Auth::LDAP::Authentication do
# try only to fake the LDAP call
adapter = double('adapter', dn: dn).as_null_object
- allow_any_instance_of(described_class)
- .to receive(:adapter).and_return(adapter)
+ allow_next_instance_of(described_class) do |instance|
+ allow(instance).to receive(:adapter).and_return(adapter)
+ end
expect(described_class.login(login, password)).to be_truthy
end
@@ -27,8 +28,9 @@ describe Gitlab::Auth::LDAP::Authentication do
it "is false if the user does not exist" do
# try only to fake the LDAP call
adapter = double('adapter', dn: dn).as_null_object
- allow_any_instance_of(described_class)
- .to receive(:adapter).and_return(adapter)
+ allow_next_instance_of(described_class) do |instance|
+ allow(instance).to receive(:adapter).and_return(adapter)
+ end
expect(described_class.login(login, password)).to be_falsey
end
@@ -38,8 +40,9 @@ describe Gitlab::Auth::LDAP::Authentication do
# try only to fake the LDAP call
adapter = double('adapter', bind_as: nil).as_null_object
- allow_any_instance_of(described_class)
- .to receive(:adapter).and_return(adapter)
+ allow_next_instance_of(described_class) do |instance|
+ allow(instance).to receive(:adapter).and_return(adapter)
+ end
expect(described_class.login(login, password)).to be_falsey
end
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb
index 1e3da4f7c2d..3b490646b6e 100644
--- a/spec/lib/gitlab/auth/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb
@@ -396,7 +396,9 @@ describe Gitlab::Auth::OAuth::User do
context "and no account for the LDAP user" do
context 'dont block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: false)
+ end
end
it do
@@ -408,7 +410,9 @@ describe Gitlab::Auth::OAuth::User do
context 'block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: true)
+ end
end
it do
@@ -424,7 +428,9 @@ describe Gitlab::Auth::OAuth::User do
context 'dont block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: false)
+ end
end
it do
@@ -436,7 +442,9 @@ describe Gitlab::Auth::OAuth::User do
context 'block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: true)
+ end
end
it do
@@ -480,7 +488,9 @@ describe Gitlab::Auth::OAuth::User do
context 'dont block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: false)
+ end
end
it do
@@ -492,7 +502,9 @@ describe Gitlab::Auth::OAuth::User do
context 'block on create (LDAP)' do
before do
- allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
+ allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
+ allow(instance).to receive_messages(block_auto_created_users: true)
+ end
end
it do
diff --git a/spec/lib/gitlab/bare_repository_import/importer_spec.rb b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
index ddb1d3cea21..75a23d4f49e 100644
--- a/spec/lib/gitlab/bare_repository_import/importer_spec.rb
+++ b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
@@ -75,7 +75,9 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
end
it 'does not schedule an import' do
- expect_any_instance_of(Project).not_to receive(:import_schedule)
+ expect_next_instance_of(Project) do |instance|
+ expect(instance).not_to receive(:import_schedule)
+ end
importer.create_project_if_needed
end
diff --git a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
index 91e7edaf704..c2816f35cec 100644
--- a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
+++ b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
@@ -9,7 +9,9 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
describe '.load_for_project' do
it "loads the status" do
- expect_any_instance_of(described_class).to receive(:load_status)
+ expect_next_instance_of(described_class) do |instance|
+ expect(instance).to receive(:load_status)
+ end
described_class.load_for_project(project)
end
diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb
index 71b64a3b9df..7cc1722dfd4 100644
--- a/spec/lib/gitlab/checks/branch_check_spec.rb
+++ b/spec/lib/gitlab/checks/branch_check_spec.rb
@@ -32,7 +32,9 @@ describe Gitlab::Checks::BranchCheck do
end
it 'raises an error if the user is not allowed to merge to protected branches' do
- expect_any_instance_of(Gitlab::Checks::MatchingMergeRequest).to receive(:match?).and_return(true)
+ expect_next_instance_of(Gitlab::Checks::MatchingMergeRequest) do |instance|
+ expect(instance).to receive(:match?).and_return(true)
+ end
expect(user_access).to receive(:can_merge_to_branch?).and_return(false)
expect(user_access).to receive(:can_push_to_branch?).and_return(false)
diff --git a/spec/lib/gitlab/checks/change_access_spec.rb b/spec/lib/gitlab/checks/change_access_spec.rb
index 3a8e8f67e16..dfc8c59fd74 100644
--- a/spec/lib/gitlab/checks/change_access_spec.rb
+++ b/spec/lib/gitlab/checks/change_access_spec.rb
@@ -14,31 +14,41 @@ describe Gitlab::Checks::ChangeAccess do
end
it 'calls pushes checks' do
- expect_any_instance_of(Gitlab::Checks::PushCheck).to receive(:validate!)
+ expect_next_instance_of(Gitlab::Checks::PushCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
subject.exec
end
it 'calls branches checks' do
- expect_any_instance_of(Gitlab::Checks::BranchCheck).to receive(:validate!)
+ expect_next_instance_of(Gitlab::Checks::BranchCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
subject.exec
end
it 'calls tags checks' do
- expect_any_instance_of(Gitlab::Checks::TagCheck).to receive(:validate!)
+ expect_next_instance_of(Gitlab::Checks::TagCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
subject.exec
end
it 'calls lfs checks' do
- expect_any_instance_of(Gitlab::Checks::LfsCheck).to receive(:validate!)
+ expect_next_instance_of(Gitlab::Checks::LfsCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
subject.exec
end
it 'calls diff checks' do
- expect_any_instance_of(Gitlab::Checks::DiffCheck).to receive(:validate!)
+ expect_next_instance_of(Gitlab::Checks::DiffCheck) do |instance|
+ expect(instance).to receive(:validate!)
+ end
subject.exec
end
diff --git a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
index 9148c0d579e..848adb2e6e5 100644
--- a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
+++ b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
@@ -12,12 +12,16 @@ describe Gitlab::Ci::Build::Credentials::Factory do
end
before do
- allow_any_instance_of(described_class).to receive(:providers).and_return([TestProvider])
+ allow_next_instance_of(described_class) do |instance|
+ allow(instance).to receive(:providers).and_return([TestProvider])
+ end
end
context 'when provider is valid' do
before do
- allow_any_instance_of(TestProvider).to receive(:valid?).and_return(true)
+ allow_next_instance_of(TestProvider) do |instance|
+ allow(instance).to receive(:valid?).and_return(true)
+ end
end
it 'generates an array of credentials objects' do
@@ -29,7 +33,9 @@ describe Gitlab::Ci::Build::Credentials::Factory do
context 'when provider is not valid' do
before do
- allow_any_instance_of(TestProvider).to receive(:valid?).and_return(false)
+ allow_next_instance_of(TestProvider) do |instance|
+ allow(instance).to receive(:valid?).and_return(false)
+ end
end
it 'generates an array without specific credential object' do
diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
index dd869c227a1..0aea3a59b33 100644
--- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
@@ -15,8 +15,9 @@ describe Gitlab::Ci::Config::External::File::Project do
before do
project.add_developer(user)
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!)
+ end
end
describe '#matching?' do
@@ -159,8 +160,8 @@ describe Gitlab::Ci::Config::External::File::Project do
private
def stub_project_blob(ref, path)
- allow_any_instance_of(Repository)
- .to receive(:blob_data_at)
- .with(ref, path) { yield }
+ allow_next_instance_of(Repository) do |instance|
+ allow(instance).to receive(:blob_data_at).with(ref, path) { yield }
+ end
end
end
diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
index 08db00dda9d..a23cce9b757 100644
--- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
@@ -21,8 +21,9 @@ describe Gitlab::Ci::Config::External::File::Remote do
end
before do
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!)
+ end
end
describe '#matching?' do
diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
index 164b5800abf..ee1660e4dfd 100644
--- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
@@ -14,8 +14,9 @@ describe Gitlab::Ci::Config::External::File::Template do
let(:template_file) { described_class.new(params, context) }
before do
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!)
+ end
end
describe '#matching?' do
diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
index 8d09aa47f12..2a5f62f7e74 100644
--- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
@@ -23,8 +23,9 @@ describe Gitlab::Ci::Config::External::Mapper do
before do
stub_full_request(remote_url).to_return(body: file_content)
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!)
+ end
end
describe '#process' do
diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb
index b254f9af2f1..6594a3dfa8b 100644
--- a/spec/lib/gitlab/ci/config_spec.rb
+++ b/spec/lib/gitlab/ci/config_spec.rb
@@ -8,8 +8,9 @@ describe Gitlab::Ci::Config do
set(:user) { create(:user) }
before do
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!)
+ end
end
let(:config) do
@@ -358,18 +359,11 @@ describe Gitlab::Ci::Config do
context "when it takes too long to evaluate includes" do
before do
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
- .and_call_original
-
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:set_deadline)
- .with(described_class::TIMEOUT_SECONDS)
- .and_call_original
-
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:execution_expired?)
- .and_return(true)
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!).and_call_original
+ allow(instance).to receive(:set_deadline).with(described_class::TIMEOUT_SECONDS).and_call_original
+ allow(instance).to receive(:execution_expired?).and_return(true)
+ end
end
it 'raises error TimeoutError' do
@@ -384,9 +378,9 @@ describe Gitlab::Ci::Config do
context 'when context expansion timeout is disabled' do
before do
- allow_any_instance_of(Gitlab::Ci::Config::External::Context)
- .to receive(:check_execution_time!)
- .and_call_original
+ allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
+ allow(instance).to receive(:check_execution_time!).and_call_original
+ end
allow(Feature)
.to receive(:enabled?)
diff --git a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
index a13335f63d5..a978084876f 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
@@ -81,7 +81,9 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
context 'when a ref is protected' do
before do
- allow_any_instance_of(Project).to receive(:protected_for?).and_return(true)
+ allow_next_instance_of(Project) do |instance|
+ allow(instance).to receive(:protected_for?).and_return(true)
+ end
end
it 'returns protected builds' do
@@ -91,7 +93,9 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
context 'when a ref is not protected' do
before do
- allow_any_instance_of(Project).to receive(:protected_for?).and_return(false)
+ allow_next_instance_of(Project) do |instance|
+ allow(instance).to receive(:protected_for?).and_return(false)
+ end
end
it 'returns unprotected builds' do
diff --git a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
index e0077a5280a..795e8e51276 100644
--- a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
+++ b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
@@ -112,8 +112,9 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
it 'calls get_chunk only once' do
- expect_any_instance_of(Gitlab::Ci::Trace::ChunkedIO)
- .to receive(:current_chunk).once.and_call_original
+ expect_next_instance_of(Gitlab::Ci::Trace::ChunkedIO) do |instance|
+ expect(instance).to receive(:current_chunk).once.and_call_original
+ end
chunked_io.each_line { |line| }
end
diff --git a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
index c5b17aafdd2..9c16fb6f6dc 100644
--- a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
@@ -9,7 +9,9 @@ shared_examples 'base stage' do
before do
allow(stage).to receive(:project_median).and_return(1.12)
- allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({})
+ allow_next_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher) do |instance|
+ allow(instance).to receive(:event_result).and_return({})
+ end
end
it 'has the median data value' do
diff --git a/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb b/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
index d4ab9bc225b..41ce9355708 100644
--- a/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
@@ -17,7 +17,9 @@ describe Gitlab::CycleAnalytics::UsageData do
projects.each_with_index do |project, time|
issue = create(:issue, project: project, created_at: (time + 1).hour.ago)
- allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue])
+ allow_next_instance_of(Gitlab::ReferenceExtractor) do |instance|
+ allow(instance).to receive(:issues).and_return([issue])
+ end
milestone = create(:milestone, project: project)
mr = create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}")
diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
index d8f1fd26aeb..a4f74ddc8c2 100644
--- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
@@ -10,17 +10,25 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
describe '#diff_files' do
it 'does not highlight binary files' do
- allow_any_instance_of(Gitlab::Diff::File).to receive(:text?).and_return(false)
+ allow_next_instance_of(Gitlab::Diff::File) do |instance|
+ allow(instance).to receive(:text?).and_return(false)
+ end
- expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
+ expect_next_instance_of(Gitlab::Diff::File) do |instance|
+ expect(instance).not_to receive(:highlighted_diff_lines)
+ end
diff_files
end
it 'does not highlight files marked as undiffable in .gitattributes' do
- allow_any_instance_of(Gitlab::Diff::File).to receive(:diffable?).and_return(false)
+ allow_next_instance_of(Gitlab::Diff::File) do |instance|
+ allow(instance).to receive(:diffable?).and_return(false)
+ end
- expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
+ expect_next_instance_of(Gitlab::Diff::File) do |instance|
+ expect(instance).not_to receive(:highlighted_diff_lines)
+ end
diff_files
end
diff --git a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
index 2fa86b2b46f..50e425f2bc1 100644
--- a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
@@ -95,7 +95,9 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
context "something is wrong" do
context "when the merge request could not be saved" do
before do
- allow_any_instance_of(MergeRequest).to receive(:save).and_return(false)
+ allow_next_instance_of(MergeRequest) do |instance|
+ allow(instance).to receive(:save).and_return(false)
+ end
end
it "raises an InvalidMergeRequestError" do
diff --git a/spec/lib/gitlab/etag_caching/middleware_spec.rb b/spec/lib/gitlab/etag_caching/middleware_spec.rb
index e7734c6f9f6..24df67b3058 100644
--- a/spec/lib/gitlab/etag_caching/middleware_spec.rb
+++ b/spec/lib/gitlab/etag_caching/middleware_spec.rb
@@ -38,8 +38,9 @@ describe Gitlab::EtagCaching::Middleware do
end
it 'generates ETag' do
- expect_any_instance_of(Gitlab::EtagCaching::Store)
- .to receive(:touch).and_return('123')
+ expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
+ expect(instance).to receive(:touch).and_return('123')
+ end
middleware.call(build_request(path, if_none_match))
end
@@ -177,9 +178,9 @@ describe Gitlab::EtagCaching::Middleware do
'SCRIPT_NAME' => '/relative-gitlab'
}
- expect_any_instance_of(Gitlab::EtagCaching::Store)
- .to receive(:get).with("/relative-gitlab#{enabled_path}")
- .and_return(nil)
+ expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
+ expect(instance).to receive(:get).with("/relative-gitlab#{enabled_path}").and_return(nil)
+ end
middleware.call(env)
end
@@ -190,8 +191,9 @@ describe Gitlab::EtagCaching::Middleware do
end
def mock_value_in_store(value)
- allow_any_instance_of(Gitlab::EtagCaching::Store)
- .to receive(:get).and_return(value)
+ allow_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
+ allow(instance).to receive(:get).and_return(value)
+ end
end
def build_request(path, if_none_match)
diff --git a/spec/lib/gitlab/experimentation_spec.rb b/spec/lib/gitlab/experimentation_spec.rb
index 9be6ace3be5..b8be72cf8d7 100644
--- a/spec/lib/gitlab/experimentation_spec.rb
+++ b/spec/lib/gitlab/experimentation_spec.rb
@@ -158,7 +158,9 @@ describe Gitlab::Experimentation do
context 'the user is part of the control group' do
before do
- allow_any_instance_of(described_class).to receive(:experiment_enabled?).with(:test_experiment).and_return(false)
+ allow_next_instance_of(described_class) do |instance|
+ allow(instance).to receive(:experiment_enabled?).with(:test_experiment).and_return(false)
+ end
end
it 'pushes the right parameters to gon' do
diff --git a/spec/lib/gitlab/fogbugz_import/client_spec.rb b/spec/lib/gitlab/fogbugz_import/client_spec.rb
index 676511211c8..ca6f374476c 100644
--- a/spec/lib/gitlab/fogbugz_import/client_spec.rb
+++ b/spec/lib/gitlab/fogbugz_import/client_spec.rb
@@ -20,6 +20,8 @@ describe Gitlab::FogbugzImport::Client do
end
def stub_api(users)
- allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listPeople).and_return(users)
+ allow_next_instance_of(::Fogbugz::Interface) do |instance|
+ allow(instance).to receive(:command).with(:listPeople).and_return(users)
+ end
end
end
diff --git a/spec/lib/gitlab/fogbugz_import/importer_spec.rb b/spec/lib/gitlab/fogbugz_import/importer_spec.rb
new file mode 100644
index 00000000000..9e67047eeda
--- /dev/null
+++ b/spec/lib/gitlab/fogbugz_import/importer_spec.rb
@@ -0,0 +1,73 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::FogbugzImport::Importer do
+ let(:project) { create(:project_empty_repo) }
+ let(:importer) { described_class.new(project) }
+ let(:repo) do
+ instance_double(Gitlab::FogbugzImport::Repository,
+ safe_name: 'vim',
+ path: 'vim',
+ raw_data: '')
+ end
+ let(:import_data) { { 'repo' => repo } }
+ let(:credentials) do
+ {
+ 'fb_session' => {
+ 'uri' => 'https://testing.fogbugz.com',
+ 'token' => 'token'
+ }
+ }
+ end
+
+ let(:closed_bug) do
+ {
+ fOpen: 'false',
+ sTitle: 'Closed bug',
+ sLatestTextSummary: "",
+ dtOpened: Time.now.to_s,
+ dtLastUpdated: Time.now.to_s,
+ events: { event: [] }
+ }.with_indifferent_access
+ end
+
+ let(:opened_bug) do
+ {
+ fOpen: 'true',
+ sTitle: 'Opened bug',
+ sLatestTextSummary: "",
+ dtOpened: Time.now.to_s,
+ dtLastUpdated: Time.now.to_s,
+ events: { event: [] }
+ }.with_indifferent_access
+ end
+
+ let(:fogbugz_bugs) { [opened_bug, closed_bug] }
+
+ before do
+ project.create_import_data(data: import_data, credentials: credentials)
+ allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listCategories).and_return([])
+ allow_any_instance_of(Gitlab::FogbugzImport::Client).to receive(:cases).and_return(fogbugz_bugs)
+ end
+
+ it 'imports bugs' do
+ expect { importer.execute }.to change { Issue.count }.by(2)
+ end
+
+ it 'imports opened bugs' do
+ importer.execute
+
+ issue = Issue.where(project_id: project.id).find_by_title(opened_bug[:sTitle])
+
+ expect(issue.state_id).to eq(Issue.available_states[:opened])
+ end
+
+ it 'imports closed bugs' do
+ importer.execute
+
+ issue = Issue.where(project_id: project.id).find_by_title(closed_bug[:sTitle])
+
+ expect(issue.state_id).to eq(Issue.available_states[:closed])
+ end
+end
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 15d03a481d5..a659af3d22e 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -134,7 +134,9 @@ describe Gitlab::Git::Blob, :seed_helper do
describe '.find with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
- allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ allow_next_instance_of(Rugged) do |instance|
+ allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ end
described_class.find(repository, SeedRepo::Commit::ID, 'files/images/6049019_460s.jpg')
end
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb
index 0ab3e513e24..63f443e19d2 100644
--- a/spec/lib/gitlab/git/commit_spec.rb
+++ b/spec/lib/gitlab/git/commit_spec.rb
@@ -176,7 +176,9 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '.find with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
- allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ allow_next_instance_of(Rugged) do |instance|
+ allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ end
described_class.find(repository, SeedRepo::Commit::ID)
end
@@ -438,7 +440,9 @@ describe Gitlab::Git::Commit, :seed_helper do
it_should_behave_like '.batch_by_oid'
it 'calls out to the Rugged implementation' do
- allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ allow_next_instance_of(Rugged) do |instance|
+ allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
+ end
described_class.batch_by_oid(repository, [SeedRepo::Commit::ID])
end
diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb
index 98bb4ffd0bd..d82acad866c 100644
--- a/spec/lib/gitlab/git/tree_spec.rb
+++ b/spec/lib/gitlab/git/tree_spec.rb
@@ -145,7 +145,9 @@ describe Gitlab::Git::Tree, :seed_helper do
describe '.where with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
- allow_any_instance_of(Rugged).to receive(:lookup).with(SeedRepo::Commit::ID)
+ allow_next_instance_of(Rugged) do |instance|
+ allow(instance).to receive(:lookup).with(SeedRepo::Commit::ID)
+ end
described_class.where(repository, SeedRepo::Commit::ID, 'files', false)
end
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index f74cc5623c9..36bde9de12d 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -730,7 +730,9 @@ describe Gitlab::GitAccess do
it 'checks LFS integrity only for first change' do
allow(project).to receive(:lfs_enabled?).and_return(true)
- expect_any_instance_of(Gitlab::Checks::LfsIntegrity).to receive(:objects_missing?).exactly(1).times
+ expect_next_instance_of(Gitlab::Checks::LfsIntegrity) do |instance|
+ expect(instance).to receive(:objects_missing?).exactly(1).times
+ end
push_access_check
end
diff --git a/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb b/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
index c6c7fa1c38a..f78bd26ea58 100644
--- a/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
@@ -10,10 +10,11 @@ describe Gitlab::GitalyClient::CleanupService do
describe '#apply_bfg_object_map_stream' do
it 'sends an apply_bfg_object_map_stream message' do
- expect_any_instance_of(Gitaly::CleanupService::Stub)
- .to receive(:apply_bfg_object_map_stream)
- .with(kind_of(Enumerator), kind_of(Hash))
- .and_return([])
+ expect_next_instance_of(Gitaly::CleanupService::Stub) do |instance|
+ expect(instance).to receive(:apply_bfg_object_map_stream)
+ .with(kind_of(Enumerator), kind_of(Hash))
+ .and_return([])
+ end
client.apply_bfg_object_map_stream(StringIO.new)
end
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index b6c0c0ad523..9ebd34140c1 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -55,7 +55,9 @@ describe Gitlab::GitalyClient do
it 'returns an empty string when the storage is not found in the response' do
response = double("response")
allow(response).to receive(:storage_statuses).and_return([])
- allow_any_instance_of(Gitlab::GitalyClient::ServerService).to receive(:info).and_return(response)
+ allow_next_instance_of(Gitlab::GitalyClient::ServerService) do |instance|
+ allow(instance).to receive(:info).and_return(response)
+ end
expect(described_class.filesystem_id('default')).to eq(nil)
end
diff --git a/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
index 484458289af..66909976b43 100644
--- a/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
@@ -144,9 +144,9 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
describe '#find_merge_request_id' do
it 'returns a merge request ID' do
- expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
- .to receive(:database_id)
- .and_return(10)
+ expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
+ expect(instance).to receive(:database_id).and_return(10)
+ end
expect(importer.find_merge_request_id).to eq(10)
end
diff --git a/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb b/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
index 19d40b2f380..9c02b0e280f 100644
--- a/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
@@ -74,9 +74,9 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
describe '#find_target_id' do
it 'returns the ID of the issuable to create the label link for' do
- expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
- .to receive(:database_id)
- .and_return(10)
+ expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
+ expect(instance).to receive(:database_id).and_return(10)
+ end
expect(importer.find_target_id).to eq(10)
end
diff --git a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
index 2dcf1433154..16326da9ca4 100644
--- a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
@@ -50,8 +50,9 @@ describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cac
describe '#build_labels_cache' do
it 'builds the labels cache' do
- expect_any_instance_of(Gitlab::GithubImport::LabelFinder)
- .to receive(:build_cache)
+ expect_next_instance_of(Gitlab::GithubImport::LabelFinder) do |instance|
+ expect(instance).to receive(:build_cache)
+ end
importer.build_labels_cache
end
diff --git a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
index eaf63e0e11b..294599c02f4 100644
--- a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
@@ -80,8 +80,9 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
describe '#build_milestones_cache' do
it 'builds the milestones cache' do
- expect_any_instance_of(Gitlab::GithubImport::MilestoneFinder)
- .to receive(:build_cache)
+ expect_next_instance_of(Gitlab::GithubImport::MilestoneFinder) do |instance|
+ expect(instance).to receive(:build_cache)
+ end
importer.build_milestones_cache
end
diff --git a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
index d2b8ba186c8..816041b771b 100644
--- a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
@@ -143,9 +143,9 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
describe '#find_noteable_id' do
it 'returns the ID of the noteable' do
- expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
- .to receive(:database_id)
- .and_return(10)
+ expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
+ expect(instance).to receive(:database_id).and_return(10)
+ end
expect(importer.find_noteable_id).to eq(10)
end
diff --git a/spec/lib/gitlab/github_import/sequential_importer_spec.rb b/spec/lib/gitlab/github_import/sequential_importer_spec.rb
index 8b1e8fbf3b7..256155dea03 100644
--- a/spec/lib/gitlab/github_import/sequential_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/sequential_importer_spec.rb
@@ -9,8 +9,9 @@ describe Gitlab::GithubImport::SequentialImporter do
project = double(:project, id: 1, repository: repository)
importer = described_class.new(project, token: 'foo')
- expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
- .to receive(:execute)
+ expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
+ expect(instance).to receive(:execute)
+ end
described_class::SEQUENTIAL_IMPORTERS.each do |klass|
instance = double(:instance)
diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb
index 5753ff9cdeb..246ef6c02f2 100644
--- a/spec/lib/gitlab/gitlab_import/client_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/client_spec.rb
@@ -21,18 +21,24 @@ describe Gitlab::GitlabImport::Client do
it 'uses membership and simple flags' do
stub_request('/api/v4/projects?membership=true&page=1&per_page=100&simple=true')
- expect_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
+ expect_next_instance_of(OAuth2::Response) do |instance|
+ expect(instance).to receive(:parsed).and_return([])
+ end
expect(client.projects.to_a).to eq []
end
shared_examples 'pagination params' do
before do
- allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
+ allow_next_instance_of(OAuth2::Response) do |instance|
+ allow(instance).to receive(:parsed).and_return([])
+ end
end
it 'allows page_limit param' do
- allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return(element_list)
+ allow_next_instance_of(OAuth2::Response) do |instance|
+ allow(instance).to receive(:parsed).and_return(element_list)
+ end
expect(client).to receive(:lazy_page_iterator).with(hash_including(page_limit: 2)).and_call_original
diff --git a/spec/lib/gitlab/http_io_spec.rb b/spec/lib/gitlab/http_io_spec.rb
index f30528916dc..4bb5fb7c198 100644
--- a/spec/lib/gitlab/http_io_spec.rb
+++ b/spec/lib/gitlab/http_io_spec.rb
@@ -109,7 +109,9 @@ describe Gitlab::HttpIO do
end
it 'calls get_chunk only once' do
- expect_any_instance_of(Net::HTTP).to receive(:request).once.and_call_original
+ expect_next_instance_of(Net::HTTP) do |instance|
+ expect(instance).to receive(:request).once.and_call_original
+ end
http_io.each_line { |line| }
end
diff --git a/spec/lib/gitlab/request_context_spec.rb b/spec/lib/gitlab/request_context_spec.rb
index cde12d4b310..87b8029de2e 100644
--- a/spec/lib/gitlab/request_context_spec.rb
+++ b/spec/lib/gitlab/request_context_spec.rb
@@ -43,7 +43,9 @@ describe Gitlab::RequestContext do
let(:ip) { '192.168.1.11' }
before do
- allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip)
+ allow_next_instance_of(Rack::Request) do |instance|
+ allow(instance).to receive(:ip).and_return(ip)
+ end
described_class.new(app).call(env)
end