diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 06:06:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 06:06:16 +0000 |
commit | 0282449e6ea95b54b32acfd2de24c8c5f64a8165 (patch) | |
tree | 017b43b103e45ff571d637a5efc77b5ed25c0686 | |
parent | 0ecdcf59f4342de55a7d2c3ee4ac0d9c3b116aa5 (diff) | |
download | gitlab-ce-0282449e6ea95b54b32acfd2de24c8c5f64a8165.tar.gz |
Add latest changes from gitlab-org/gitlab@master
31 files changed, 147 insertions, 55 deletions
diff --git a/changelogs/unreleased/13231-apollo-discussion-caching.yml b/changelogs/unreleased/13231-apollo-discussion-caching.yml new file mode 100644 index 00000000000..ced88739419 --- /dev/null +++ b/changelogs/unreleased/13231-apollo-discussion-caching.yml @@ -0,0 +1,5 @@ +--- +title: Removes caching for design tab discusisons +merge_request: 20374 +author: +type: changed diff --git a/doc/administration/geo/replication/index.md b/doc/administration/geo/replication/index.md index 1fef2e85ce6..0d2ca9ea9d9 100644 --- a/doc/administration/geo/replication/index.md +++ b/doc/administration/geo/replication/index.md @@ -266,7 +266,7 @@ these epics/issues: | All database content | **Yes** | **Yes** | | | Project repository | **Yes** | **Yes** | | | Project wiki repository | **Yes** | **Yes** | | -| Project designs repository | [No][design-replication] | [No][design-verification] | | +| Project designs repository | **Yes** | [No][design-verification] | Behind feature flag (2) | | Uploads | **Yes** | [No][upload-verification] | Verified only on transfer, or manually (1) | | LFS Objects | **Yes** | [No][lfs-verification] | Verified only on transfer, or manually (1) | | CI job artifacts (other than traces) | **Yes** | [No][artifact-verification] | Verified only manually (1) | @@ -307,6 +307,12 @@ these epics/issues: 1. The integrity can be verified manually using [Integrity Check Rake Task](../../raketasks/check.md) on both nodes and comparing the output between them. +1. Enable the `enable_geo_design_sync` feature flag by running the +following in a Rails console: + + ```ruby + Feature.disable(:enable_geo_design_sync) + ``` DANGER: **DANGER** Features not on this list, or with **No** in the **Replicated** column, diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index 5f120f258cd..82ae535e100 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -12,7 +12,9 @@ describe Backup::Repository do allow(progress).to receive(:print) allow(FileUtils).to receive(:mv).and_return(true) - allow_any_instance_of(described_class).to receive(:progress).and_return(progress) + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:progress).and_return(progress) + end end describe '#dump' do @@ -47,7 +49,9 @@ describe Backup::Repository do describe 'command failure' do before do - allow_any_instance_of(Gitlab::Shell).to receive(:create_repository).and_return(false) + allow_next_instance_of(Gitlab::Shell) do |instance| + allow(instance).to receive(:create_repository).and_return(false) + end end context 'hashed storage' do diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index 326703eea05..63ec597a0ba 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -60,7 +60,9 @@ describe Banzai::Filter::CommitReferenceFilter do end it 'escapes the title attribute' do - allow_any_instance_of(Commit).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_next_instance_of(Commit) do |instance| + allow(instance).to receive(:title).and_return(%{"></a>whatever<a title="}) + end doc = reference_filter("See #{reference}") expect(doc.text).to eq "See #{commit.short_id}" diff --git a/spec/lib/banzai/filter/markdown_filter_spec.rb b/spec/lib/banzai/filter/markdown_filter_spec.rb index 06df67facf9..d0a43564903 100644 --- a/spec/lib/banzai/filter/markdown_filter_spec.rb +++ b/spec/lib/banzai/filter/markdown_filter_spec.rb @@ -7,13 +7,17 @@ describe Banzai::Filter::MarkdownFilter do describe 'markdown engine from context' do it 'defaults to CommonMark' do - expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return('test') + expect_next_instance_of(Banzai::Filter::MarkdownEngines::CommonMark) do |instance| + expect(instance).to receive(:render).and_return('test') + end filter('test') end it 'uses CommonMark' do - expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return('test') + expect_next_instance_of(Banzai::Filter::MarkdownEngines::CommonMark) do |instance| + expect(instance).to receive(:render).and_return('test') + end filter('test', { markdown_engine: :common_mark }) end diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index ab0c2c383c5..2fe8c9074df 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -214,7 +214,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do end it 'escapes the name attribute' do - allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_next_instance_of(Milestone) do |instance| + allow(instance).to receive(:title).and_return(%{"></a>whatever<a title="}) + end doc = reference_filter("See #{reference}") @@ -251,7 +253,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do end it 'escapes the name attribute' do - allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_next_instance_of(Milestone) do |instance| + allow(instance).to receive(:title).and_return(%{"></a>whatever<a title="}) + end doc = reference_filter("See #{reference}") @@ -288,7 +292,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do end it 'escapes the name attribute' do - allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="}) + allow_next_instance_of(Milestone) do |instance| + allow(instance).to receive(:title).and_return(%{"></a>whatever<a title="}) + end doc = reference_filter("See #{reference}") diff --git a/spec/lib/banzai/filter/reference_redactor_filter_spec.rb b/spec/lib/banzai/filter/reference_redactor_filter_spec.rb index dc888a47988..9739afd3d57 100644 --- a/spec/lib/banzai/filter/reference_redactor_filter_spec.rb +++ b/spec/lib/banzai/filter/reference_redactor_filter_spec.rb @@ -42,7 +42,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do context 'valid projects' do before do - allow_any_instance_of(Banzai::ReferenceParser::BaseParser).to receive(:can_read_reference?).and_return(true) + allow_next_instance_of(Banzai::ReferenceParser::BaseParser) do |instance| + allow(instance).to receive(:can_read_reference?).and_return(true) + end end it 'allows permitted Project references' do @@ -59,7 +61,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do context 'invalid projects' do before do - allow_any_instance_of(Banzai::ReferenceParser::BaseParser).to receive(:can_read_reference?).and_return(false) + allow_next_instance_of(Banzai::ReferenceParser::BaseParser) do |instance| + allow(instance).to receive(:can_read_reference?).and_return(false) + end end it 'removes unpermitted references' do diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index f220ccecee1..5a844fb61e3 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -92,7 +92,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do context "when Rouge lexing fails" do before do - allow_any_instance_of(Rouge::Lexers::Ruby).to receive(:stream_tokens).and_raise(StandardError) + allow_next_instance_of(Rouge::Lexers::Ruby) do |instance| + allow(instance).to receive(:stream_tokens).and_raise(StandardError) + end end it "highlights as plaintext" do @@ -106,7 +108,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do context "when Rouge lexing fails after a retry" do before do - allow_any_instance_of(Rouge::Lexers::PlainText).to receive(:stream_tokens).and_raise(StandardError) + allow_next_instance_of(Rouge::Lexers::PlainText) do |instance| + allow(instance).to receive(:stream_tokens).and_raise(StandardError) + end end it "does not add highlighting classes" do diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb index a523608fa50..aef11775e60 100644 --- a/spec/lib/banzai/object_renderer_spec.rb +++ b/spec/lib/banzai/object_renderer_spec.rb @@ -25,7 +25,9 @@ describe Banzai::ObjectRenderer do end it 'calls Banzai::ReferenceRedactor to perform redaction' do - expect_any_instance_of(Banzai::ReferenceRedactor).to receive(:redact).and_call_original + expect_next_instance_of(Banzai::ReferenceRedactor) do |instance| + expect(instance).to receive(:redact).and_call_original + end renderer.render([object], :note) end @@ -85,7 +87,9 @@ describe Banzai::ObjectRenderer do end it 'calls Banzai::ReferenceRedactor to perform redaction' do - expect_any_instance_of(Banzai::ReferenceRedactor).to receive(:redact).and_call_original + expect_next_instance_of(Banzai::ReferenceRedactor) do |instance| + expect(instance).to receive(:redact).and_call_original + end renderer.render([cacheless_thing], :title) end diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb index eac1cf16a8f..7f7c750fe74 100644 --- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb @@ -35,8 +35,9 @@ describe Banzai::ReferenceParser::CommitParser do it 'returns an Array of commits' do commit = double(:commit) - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_next_instance_of(Project) do |instance| + allow(instance).to receive(:valid_repo?).and_return(true) + end expect(subject).to receive(:find_commits) .with(project, ['123']) @@ -46,8 +47,9 @@ describe Banzai::ReferenceParser::CommitParser do end it 'returns an empty Array when the commit could not be found' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_next_instance_of(Project) do |instance| + allow(instance).to receive(:valid_repo?).and_return(true) + end expect(subject).to receive(:find_commits) .with(project, ['123']) @@ -57,8 +59,9 @@ describe Banzai::ReferenceParser::CommitParser do end it 'skips projects without valid repositories' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(false) + allow_next_instance_of(Project) do |instance| + allow(instance).to receive(:valid_repo?).and_return(false) + end expect(subject.referenced_by([link])).to eq([]) end @@ -66,8 +69,9 @@ describe Banzai::ReferenceParser::CommitParser do context 'when the link does not have a data-commit attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_next_instance_of(Project) do |instance| + allow(instance).to receive(:valid_repo?).and_return(true) + end expect(subject.referenced_by([link])).to eq([]) end @@ -76,8 +80,9 @@ describe Banzai::ReferenceParser::CommitParser do context 'when the link does not have a data-project attribute' do it 'returns an empty Array' do - allow_any_instance_of(Project).to receive(:valid_repo?) - .and_return(true) + allow_next_instance_of(Project) do |instance| + allow(instance).to receive(:valid_repo?).and_return(true) + end expect(subject.referenced_by([link])).to eq([]) end diff --git a/spec/lib/banzai/reference_redactor_spec.rb b/spec/lib/banzai/reference_redactor_spec.rb index c30a194a0b3..9e1a389d2db 100644 --- a/spec/lib/banzai/reference_redactor_spec.rb +++ b/spec/lib/banzai/reference_redactor_spec.rb @@ -173,10 +173,11 @@ describe Banzai::ReferenceRedactor do doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>') node = doc.children[0] - expect_any_instance_of(Banzai::ReferenceParser::IssueParser) - .to receive(:nodes_visible_to_user) - .with(user, [node]) - .and_return([node]) + expect_next_instance_of(Banzai::ReferenceParser::IssueParser) do |instance| + expect(instance).to receive(:nodes_visible_to_user) + .with(user, [node]) + .and_return([node]) + end expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node])) end diff --git a/spec/lib/bitbucket/connection_spec.rb b/spec/lib/bitbucket/connection_spec.rb index ec8eac232cd..5aca93767dc 100644 --- a/spec/lib/bitbucket/connection_spec.rb +++ b/spec/lib/bitbucket/connection_spec.rb @@ -4,12 +4,16 @@ require 'spec_helper' describe Bitbucket::Connection do before do - allow_any_instance_of(described_class).to receive(:provider).and_return(double(app_id: '', app_secret: '')) + allow_next_instance_of(described_class) do |instance| + allow(instance).to receive(:provider).and_return(double(app_id: '', app_secret: '')) + end end describe '#get' do it 'calls OAuth2::AccessToken::get' do - expect_any_instance_of(OAuth2::AccessToken).to receive(:get).and_return(double(parsed: true)) + expect_next_instance_of(OAuth2::AccessToken) do |instance| + expect(instance).to receive(:get).and_return(double(parsed: true)) + end connection = described_class.new({}) @@ -19,7 +23,9 @@ describe Bitbucket::Connection do describe '#expired?' do it 'calls connection.expired?' do - expect_any_instance_of(OAuth2::AccessToken).to receive(:expired?).and_return(true) + expect_next_instance_of(OAuth2::AccessToken) do |instance| + expect(instance).to receive(:expired?).and_return(true) + end expect(described_class.new({}).expired?).to be_truthy end @@ -29,7 +35,9 @@ describe Bitbucket::Connection do it 'calls connection.refresh!' do response = double(token: nil, expires_at: nil, expires_in: nil, refresh_token: nil) - expect_any_instance_of(OAuth2::AccessToken).to receive(:refresh!).and_return(response) + expect_next_instance_of(OAuth2::AccessToken) do |instance| + expect(instance).to receive(:refresh!).and_return(response) + end described_class.new({}).refresh! end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index ffe7584a019..861ef79b2f8 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -88,7 +88,9 @@ describe ExtractsPath do context 'subclass overrides get_id' do it 'uses ref returned by get_id' do - allow_any_instance_of(self.class).to receive(:get_id) { '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' } + allow_next_instance_of(self.class) do |instance| + allow(instance).to receive(:get_id) { '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' } + end assign_ref_vars diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb index 0f1745fcc02..5753ff9cdeb 100644 --- a/spec/lib/gitlab/gitlab_import/client_spec.rb +++ b/spec/lib/gitlab/gitlab_import/client_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::GitlabImport::Client do diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb index 200edceca8c..2db1ddcfd0a 100644 --- a/spec/lib/gitlab/gitlab_import/importer_spec.rb +++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::GitlabImport::Importer do diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb index b814f5fc76c..c7ef978df37 100644 --- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb +++ b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe Gitlab::GitlabImport::ProjectCreator do diff --git a/spec/lib/google_api/auth_spec.rb b/spec/lib/google_api/auth_spec.rb index a25004ac385..719e98c5fdf 100644 --- a/spec/lib/google_api/auth_spec.rb +++ b/spec/lib/google_api/auth_spec.rb @@ -30,8 +30,9 @@ describe GoogleApi::Auth do end before do - allow_any_instance_of(OAuth2::Strategy::AuthCode) - .to receive(:get_token).and_return(token) + allow_next_instance_of(OAuth2::Strategy::AuthCode) do |instance| + allow(instance).to receive(:get_token).and_return(token) + end end it 'returns token and expires_at' do diff --git a/spec/lib/omni_auth/strategies/saml_spec.rb b/spec/lib/omni_auth/strategies/saml_spec.rb index 73e86872308..447800bd93c 100644 --- a/spec/lib/omni_auth/strategies/saml_spec.rb +++ b/spec/lib/omni_auth/strategies/saml_spec.rb @@ -15,7 +15,9 @@ describe OmniAuth::Strategies::SAML, type: :strategy do it 'stores request ID during request phase' do request_id = double - allow_any_instance_of(OneLogin::RubySaml::Authrequest).to receive(:uuid).and_return(request_id) + allow_next_instance_of(OneLogin::RubySaml::Authrequest) do |instance| + allow(instance).to receive(:uuid).and_return(request_id) + end post '/users/auth/saml' expect(session['last_authn_request_id']).to eq(request_id) diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index cafb96898b3..df82ac38fc6 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1095,7 +1095,9 @@ describe Notify do context 'when note is not on text' do before do - allow_any_instance_of(DiffDiscussion).to receive(:on_text?).and_return(false) + allow_next_instance_of(DiffDiscussion) do |instance| + allow(instance).to receive(:on_text?).and_return(false) + end end it 'does not include diffs with character-level highlighting' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 6d8d3799d57..e4c22bfb2e8 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -2474,7 +2474,9 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: 'a288a022a53a5a944fae87bcec6efc87b7061808') } it "returns merge requests whose `diff_head_sha` matches the pipeline's SHA" do - allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { 'a288a022a53a5a944fae87bcec6efc87b7061808' } + allow_next_instance_of(MergeRequest) do |instance| + allow(instance).to receive(:diff_head_sha) { 'a288a022a53a5a944fae87bcec6efc87b7061808' } + end merge_request = create(:merge_request, source_project: project, head_pipeline: pipeline, source_branch: pipeline.ref) expect(pipeline.merge_requests_as_head_pipeline).to eq([merge_request]) @@ -2488,7 +2490,9 @@ describe Ci::Pipeline, :mailer do it "doesn't return merge requests whose `diff_head_sha` doesn't match the pipeline's SHA" do create(:merge_request, source_project: project, source_branch: pipeline.ref) - allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { '97de212e80737a608d939f648d959671fb0a0142b' } + allow_next_instance_of(MergeRequest) do |instance| + allow(instance).to receive(:diff_head_sha) { '97de212e80737a608d939f648d959671fb0a0142b' } + end expect(pipeline.merge_requests_as_head_pipeline).to be_empty end diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb index b420a180524..6ee6711ec4b 100644 --- a/spec/models/clusters/applications/runner_spec.rb +++ b/spec/models/clusters/applications/runner_spec.rb @@ -174,7 +174,9 @@ describe Clusters::Applications::Runner do subject { create(:clusters_applications_runner, :scheduled, runner: ci_runner) } it 'calls prepare_uninstall' do - expect_any_instance_of(described_class).to receive(:prepare_uninstall).and_call_original + expect_next_instance_of(described_class) do |instance| + expect(instance).to receive(:prepare_uninstall).and_call_original + end subject.make_uninstalling! end diff --git a/spec/models/cycle_analytics/group_level_spec.rb b/spec/models/cycle_analytics/group_level_spec.rb index 154c1b9c0f8..0d2c14c29dd 100644 --- a/spec/models/cycle_analytics/group_level_spec.rb +++ b/spec/models/cycle_analytics/group_level_spec.rb @@ -22,7 +22,9 @@ describe CycleAnalytics::GroupLevel do describe '#stats' do before do - 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 create_cycle(user, project, issue, mr, milestone, pipeline) deploy_master(user, project) diff --git a/spec/models/cycle_analytics/project_level_spec.rb b/spec/models/cycle_analytics/project_level_spec.rb index 4de01b1c679..351eb139416 100644 --- a/spec/models/cycle_analytics/project_level_spec.rb +++ b/spec/models/cycle_analytics/project_level_spec.rb @@ -15,7 +15,9 @@ describe CycleAnalytics::ProjectLevel do describe '#all_medians_by_stage' do before do - 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 create_cycle(user, project, issue, mr, milestone, pipeline) deploy_master(user, project) diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 52c19d4814c..268542c39c4 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -32,8 +32,9 @@ describe Deployment do let(:deployment) { create(:deployment, deployable: build) } it 'delegates to other_scheduled_actions' do - expect_any_instance_of(Ci::Build) - .to receive(:other_scheduled_actions) + expect_next_instance_of(Ci::Build) do |instance| + expect(instance).to receive(:other_scheduled_actions) + end subject end diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb index 8d7dafc523d..601dac21e6a 100644 --- a/spec/models/diff_note_spec.rb +++ b/spec/models/diff_note_spec.rb @@ -343,7 +343,9 @@ describe DiffNote do context 'when line is not suggestible' do it 'returns false' do - allow_any_instance_of(Gitlab::Diff::Line).to receive(:suggestible?) { false } + allow_next_instance_of(Gitlab::Diff::Line) do |instance| + allow(instance).to receive(:suggestible?) { false } + end expect(subject.supports_suggestion?).to be(false) end diff --git a/spec/models/diff_viewer/base_spec.rb b/spec/models/diff_viewer/base_spec.rb index b8bdeb781dc..019597993cc 100644 --- a/spec/models/diff_viewer/base_spec.rb +++ b/spec/models/diff_viewer/base_spec.rb @@ -60,7 +60,9 @@ describe DiffViewer::Base do context 'when the binaryness does not match' do before do - allow_any_instance_of(Blob).to receive(:binary_in_repo?).and_return(true) + allow_next_instance_of(Blob) do |instance| + allow(instance).to receive(:binary_in_repo?).and_return(true) + end end it 'returns false' do diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 47e39e5fbe5..e1e4af63ef3 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -484,7 +484,9 @@ describe Environment, :use_clean_rails_memory_store_caching do subject { environment.last_deployment } before do - allow_any_instance_of(Deployment).to receive(:create_ref) + allow_next_instance_of(Deployment) do |instance| + allow(instance).to receive(:create_ref) + end end context 'when there is an old deployment record' do @@ -1031,7 +1033,9 @@ describe Environment, :use_clean_rails_memory_store_caching do describe '#prometheus_adapter' do it 'calls prometheus adapter service' do - expect_any_instance_of(Prometheus::AdapterService).to receive(:prometheus_adapter) + expect_next_instance_of(Prometheus::AdapterService) do |instance| + expect(instance).to receive(:prometheus_adapter) + end subject.prometheus_adapter end diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index ff2e1aa047e..990141cf511 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -20,7 +20,9 @@ describe Event do describe 'after_create :reset_project_activity' do it 'calls the reset_project_activity method' do - expect_any_instance_of(described_class).to receive(:reset_project_activity) + expect_next_instance_of(described_class) do |instance| + expect(instance).to receive(:reset_project_activity) + end create_push_event(project, project.owner) end diff --git a/spec/models/gpg_signature_spec.rb b/spec/models/gpg_signature_spec.rb index a780b8bfdf5..997d9bbec72 100644 --- a/spec/models/gpg_signature_spec.rb +++ b/spec/models/gpg_signature_spec.rb @@ -75,7 +75,9 @@ RSpec.describe GpgSignature do describe '#commit' do it 'fetches the commit through the project' do - expect_any_instance_of(Project).to receive(:commit).with(commit_sha).and_return(commit) + expect_next_instance_of(Project) do |instance| + expect(instance).to receive(:commit).with(commit_sha).and_return(commit) + end gpg_signature.commit end diff --git a/spec/models/resource_label_event_spec.rb b/spec/models/resource_label_event_spec.rb index f51041c9ddc..a92f5ee93e1 100644 --- a/spec/models/resource_label_event_spec.rb +++ b/spec/models/resource_label_event_spec.rb @@ -49,9 +49,10 @@ RSpec.describe ResourceLabelEvent, type: :model do describe '#expire_etag_cache' do def expect_expiration(issue) - expect_any_instance_of(Gitlab::EtagCaching::Store) - .to receive(:touch) - .with("/#{issue.project.namespace.to_param}/#{issue.project.to_param}/noteable/issue/#{issue.id}/notes") + expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance| + expect(instance).to receive(:touch) + .with("/#{issue.project.namespace.to_param}/#{issue.project.to_param}/noteable/issue/#{issue.id}/notes") + end end it 'expires resource note etag cache on event save' do diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index 37b107ee36e..2f2ed28891a 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -151,7 +151,9 @@ describe ObjectStorage do describe 'fails' do it 'is handled gracefully' do store = uploader.object_store - expect_any_instance_of(Upload).to receive(:save!).and_raise("An error") + expect_next_instance_of(Upload) do |instance| + expect(instance).to receive(:save!).and_raise("An error") + end expect { subject }.to raise_error("An error") expect(uploader.exists?).to be_truthy |