Commit 44002f46 authored by Arturo Herrero's avatar Arturo Herrero

Update RSpec helper methods to *_next_instance_of

Auto-correct some references in RSpec as:
- expect_any_instance_of -> expect_next_instance_of
- allow_any_instance_of -> allow_next_instance_of

Related to https://gitlab.com/gitlab-org/gitlab/issues/34997
parent 037db4be
...@@ -12,7 +12,9 @@ describe Backup::Repository do ...@@ -12,7 +12,9 @@ describe Backup::Repository do
allow(progress).to receive(:print) allow(progress).to receive(:print)
allow(FileUtils).to receive(:mv).and_return(true) 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 end
describe '#dump' do describe '#dump' do
...@@ -47,7 +49,9 @@ describe Backup::Repository do ...@@ -47,7 +49,9 @@ describe Backup::Repository do
describe 'command failure' do describe 'command failure' do
before 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 end
context 'hashed storage' do context 'hashed storage' do
......
...@@ -60,7 +60,9 @@ describe Banzai::Filter::CommitReferenceFilter do ...@@ -60,7 +60,9 @@ describe Banzai::Filter::CommitReferenceFilter do
end end
it 'escapes the title attribute' do 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}") doc = reference_filter("See #{reference}")
expect(doc.text).to eq "See #{commit.short_id}" expect(doc.text).to eq "See #{commit.short_id}"
......
...@@ -7,13 +7,17 @@ describe Banzai::Filter::MarkdownFilter do ...@@ -7,13 +7,17 @@ describe Banzai::Filter::MarkdownFilter do
describe 'markdown engine from context' do describe 'markdown engine from context' do
it 'defaults to CommonMark' 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') filter('test')
end end
it 'uses CommonMark' do 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 }) filter('test', { markdown_engine: :common_mark })
end end
......
...@@ -214,7 +214,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -214,7 +214,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do
end end
it 'escapes the name attribute' do 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}") doc = reference_filter("See #{reference}")
...@@ -251,7 +253,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -251,7 +253,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do
end end
it 'escapes the name attribute' do 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}") doc = reference_filter("See #{reference}")
...@@ -288,7 +292,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do ...@@ -288,7 +292,9 @@ describe Banzai::Filter::MilestoneReferenceFilter do
end end
it 'escapes the name attribute' do 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}") doc = reference_filter("See #{reference}")
......
...@@ -42,7 +42,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do ...@@ -42,7 +42,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do
context 'valid projects' do context 'valid projects' do
before 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 end
it 'allows permitted Project references' do it 'allows permitted Project references' do
...@@ -59,7 +61,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do ...@@ -59,7 +61,9 @@ describe Banzai::Filter::ReferenceRedactorFilter do
context 'invalid projects' do context 'invalid projects' do
before 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 end
it 'removes unpermitted references' do it 'removes unpermitted references' do
......
...@@ -92,7 +92,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do ...@@ -92,7 +92,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do
context "when Rouge lexing fails" do context "when Rouge lexing fails" do
before 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 end
it "highlights as plaintext" do it "highlights as plaintext" do
...@@ -106,7 +108,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do ...@@ -106,7 +108,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do
context "when Rouge lexing fails after a retry" do context "when Rouge lexing fails after a retry" do
before 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 end
it "does not add highlighting classes" do it "does not add highlighting classes" do
......
...@@ -25,7 +25,9 @@ describe Banzai::ObjectRenderer do ...@@ -25,7 +25,9 @@ describe Banzai::ObjectRenderer do
end end
it 'calls Banzai::ReferenceRedactor to perform redaction' do 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) renderer.render([object], :note)
end end
...@@ -85,7 +87,9 @@ describe Banzai::ObjectRenderer do ...@@ -85,7 +87,9 @@ describe Banzai::ObjectRenderer do
end end
it 'calls Banzai::ReferenceRedactor to perform redaction' do 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) renderer.render([cacheless_thing], :title)
end end
......
...@@ -35,8 +35,9 @@ describe Banzai::ReferenceParser::CommitParser do ...@@ -35,8 +35,9 @@ describe Banzai::ReferenceParser::CommitParser do
it 'returns an Array of commits' do it 'returns an Array of commits' do
commit = double(:commit) commit = double(:commit)
allow_any_instance_of(Project).to receive(:valid_repo?) allow_next_instance_of(Project) do |instance|
.and_return(true) allow(instance).to receive(:valid_repo?).and_return(true)
end
expect(subject).to receive(:find_commits) expect(subject).to receive(:find_commits)
.with(project, ['123']) .with(project, ['123'])
...@@ -46,8 +47,9 @@ describe Banzai::ReferenceParser::CommitParser do ...@@ -46,8 +47,9 @@ describe Banzai::ReferenceParser::CommitParser do
end end
it 'returns an empty Array when the commit could not be found' do it 'returns an empty Array when the commit could not be found' do
allow_any_instance_of(Project).to receive(:valid_repo?) allow_next_instance_of(Project) do |instance|
.and_return(true) allow(instance).to receive(:valid_repo?).and_return(true)
end
expect(subject).to receive(:find_commits) expect(subject).to receive(:find_commits)
.with(project, ['123']) .with(project, ['123'])
...@@ -57,8 +59,9 @@ describe Banzai::ReferenceParser::CommitParser do ...@@ -57,8 +59,9 @@ describe Banzai::ReferenceParser::CommitParser do
end end
it 'skips projects without valid repositories' do it 'skips projects without valid repositories' do
allow_any_instance_of(Project).to receive(:valid_repo?) allow_next_instance_of(Project) do |instance|
.and_return(false) allow(instance).to receive(:valid_repo?).and_return(false)
end
expect(subject.referenced_by([link])).to eq([]) expect(subject.referenced_by([link])).to eq([])
end end
...@@ -66,8 +69,9 @@ describe Banzai::ReferenceParser::CommitParser do ...@@ -66,8 +69,9 @@ describe Banzai::ReferenceParser::CommitParser do
context 'when the link does not have a data-commit attribute' do context 'when the link does not have a data-commit attribute' do
it 'returns an empty Array' do it 'returns an empty Array' do
allow_any_instance_of(Project).to receive(:valid_repo?) allow_next_instance_of(Project) do |instance|
.and_return(true) allow(instance).to receive(:valid_repo?).and_return(true)
end
expect(subject.referenced_by([link])).to eq([]) expect(subject.referenced_by([link])).to eq([])
end end
...@@ -76,8 +80,9 @@ describe Banzai::ReferenceParser::CommitParser do ...@@ -76,8 +80,9 @@ describe Banzai::ReferenceParser::CommitParser do
context 'when the link does not have a data-project attribute' do context 'when the link does not have a data-project attribute' do
it 'returns an empty Array' do it 'returns an empty Array' do
allow_any_instance_of(Project).to receive(:valid_repo?) allow_next_instance_of(Project) do |instance|
.and_return(true) allow(instance).to receive(:valid_repo?).and_return(true)
end
expect(subject.referenced_by([link])).to eq([]) expect(subject.referenced_by([link])).to eq([])
end end
......
...@@ -173,10 +173,11 @@ describe Banzai::ReferenceRedactor do ...@@ -173,10 +173,11 @@ describe Banzai::ReferenceRedactor do
doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>') doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>')
node = doc.children[0] node = doc.children[0]
expect_any_instance_of(Banzai::ReferenceParser::IssueParser) expect_next_instance_of(Banzai::ReferenceParser::IssueParser) do |instance|
.to receive(:nodes_visible_to_user) expect(instance).to receive(:nodes_visible_to_user)
.with(user, [node]) .with(user, [node])
.and_return([node]) .and_return([node])
end
expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node])) expect(redactor.nodes_visible_to_user([node])).to eq(Set.new([node]))
end end
......
...@@ -4,12 +4,16 @@ require 'spec_helper' ...@@ -4,12 +4,16 @@ require 'spec_helper'
describe Bitbucket::Connection do describe Bitbucket::Connection do
before 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 end
describe '#get' do describe '#get' do
it 'calls OAuth2::AccessToken::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({}) connection = described_class.new({})
...@@ -19,7 +23,9 @@ describe Bitbucket::Connection do ...@@ -19,7 +23,9 @@ describe Bitbucket::Connection do
describe '#expired?' do describe '#expired?' do
it 'calls connection.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 expect(described_class.new({}).expired?).to be_truthy
end end
...@@ -29,7 +35,9 @@ describe Bitbucket::Connection do ...@@ -29,7 +35,9 @@ describe Bitbucket::Connection do
it 'calls connection.refresh!' do it 'calls connection.refresh!' do
response = double(token: nil, expires_at: nil, expires_in: nil, refresh_token: nil) 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! described_class.new({}).refresh!
end end
......
...@@ -88,7 +88,9 @@ describe ExtractsPath do ...@@ -88,7 +88,9 @@ describe ExtractsPath do
context 'subclass overrides get_id' do context 'subclass overrides get_id' do
it 'uses ref returned by 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 assign_ref_vars
......
...@@ -30,8 +30,9 @@ describe GoogleApi::Auth do ...@@ -30,8 +30,9 @@ describe GoogleApi::Auth do
end end
before do before do
allow_any_instance_of(OAuth2::Strategy::AuthCode) allow_next_instance_of(OAuth2::Strategy::AuthCode) do |instance|
.to receive(:get_token).and_return(token) allow(instance).to receive(:get_token).and_return(token)
end
end end
it 'returns token and expires_at' do it 'returns token and expires_at' do
......
...@@ -15,7 +15,9 @@ describe OmniAuth::Strategies::SAML, type: :strategy do ...@@ -15,7 +15,9 @@ describe OmniAuth::Strategies::SAML, type: :strategy do
it 'stores request ID during request phase' do it 'stores request ID during request phase' do
request_id = double 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' post '/users/auth/saml'
expect(session['last_authn_request_id']).to eq(request_id) expect(session['last_authn_request_id']).to eq(request_id)
......
...@@ -1095,7 +1095,9 @@ describe Notify do ...@@ -1095,7 +1095,9 @@ describe Notify do
context 'when note is not on text' do context 'when note is not on text' do
before 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 end
it 'does not include diffs with character-level highlighting' do it 'does not include diffs with character-level highlighting' do
......
...@@ -2770,7 +2770,9 @@ describe Ci::Pipeline, :mailer do ...@@ -2770,7 +2770,9 @@ describe Ci::Pipeline, :mailer do
let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: 'a288a022a53a5a944fae87bcec6efc87b7061808') } 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 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) 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]) expect(pipeline.merge_requests_as_head_pipeline).to eq([merge_request])
...@@ -2784,7 +2786,9 @@ describe Ci::Pipeline, :mailer do ...@@ -2784,7 +2786,9 @@ describe Ci::Pipeline, :mailer do
it "doesn't return merge requests whose `diff_head_sha` doesn't match the pipeline's SHA" 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) 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 expect(pipeline.merge_requests_as_head_pipeline).to be_empty
end end
......
...@@ -174,7 +174,9 @@ describe Clusters::Applications::Runner do ...@@ -174,7 +174,9 @@ describe Clusters::Applications::Runner do
subject { create(:clusters_applications_runner, :scheduled, runner: ci_runner) } subject { create(:clusters_applications_runner, :scheduled, runner: ci_runner) }
it 'calls prepare_uninstall' do 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! subject.make_uninstalling!
end end
......
...@@ -22,7 +22,9 @@ describe CycleAnalytics::GroupLevel do ...@@ -22,7 +22,9 @@ describe CycleAnalytics::GroupLevel do
describe '#stats' do describe '#stats' do
before 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) create_cycle(user, project, issue, mr, milestone, pipeline)
deploy_master(user, project) deploy_master(user, project)
......
...@@ -15,7 +15,9 @@ describe CycleAnalytics::ProjectLevel do ...@@ -15,7 +15,9 @@ describe CycleAnalytics::ProjectLevel do
describe '#all_medians_by_stage' do describe '#all_medians_by_stage' do
before 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) create_cycle(user, project, issue, mr, milestone, pipeline)
deploy_master(user, project) deploy_master(user, project)
......
...@@ -32,8 +32,9 @@ describe Deployment do ...@@ -32,8 +32,9 @@ describe Deployment do
let(:deployment) { create(:deployment, deployable: build) } let(:deployment) { create(:deployment, deployable: build) }
it 'delegates to other_scheduled_actions' do it 'delegates to other_scheduled_actions' do
expect_any_instance_of(Ci::Build) expect_next_instance_of(Ci::Build) do |instance|
.to receive(:other_scheduled_actions) expect(instance).to receive(:other_scheduled_actions)
end
subject subject
end end
......
...@@ -343,7 +343,9 @@ describe DiffNote do ...@@ -343,7 +343,9 @@ describe DiffNote do
context 'when line is not suggestible' do context 'when line is not suggestible' do
it 'returns false' 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) expect(subject.supports_suggestion?).to be(false)
end end
......
...@@ -60,7 +60,9 @@ describe DiffViewer::Base do ...@@ -60,7 +60,9 @@ describe DiffViewer::Base do
context 'when the binaryness does not match' do context 'when the binaryness does not match' do
before 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 end
it 'returns false' do it 'returns false' do
......
...@@ -484,7 +484,9 @@ describe Environment, :use_clean_rails_memory_store_caching do ...@@ -484,7 +484,9 @@ describe Environment, :use_clean_rails_memory_store_caching do
subject { environment.last_deployment } subject { environment.last_deployment }
before do 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 end
context 'when there is an old deployment record' do context 'when there is an old deployment record' do
...@@ -1025,7 +1027,9 @@ describe Environment, :use_clean_rails_memory_store_caching do ...@@ -1025,7 +1027,9 @@ describe Environment, :use_clean_rails_memory_store_caching do
describe '#prometheus_adapter' do describe '#prometheus_adapter' do
it 'calls prometheus adapter service' 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 subject.prometheus_adapter
end end
......
...@@ -20,7 +20,9 @@ describe Event do ...@@ -20,7 +20,9 @@ describe Event do
describe 'after_create :reset_project_activity' do describe 'after_create :reset_project_activity' do
it 'calls the reset_project_activity method' 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) create_push_event(project, project.owner)
end end
......
...@@ -75,7 +75,9 @@ RSpec.describe GpgSignature do ...@@ -75,7 +75,9 @@ RSpec.describe GpgSignature do
describe '#commit' do describe '#commit' do
it 'fetches the commit through the project' 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 gpg_signature.commit
end end
......
...@@ -49,10 +49,11 @@ RSpec.describe ResourceLabelEvent, type: :model do ...@@ -49,10 +49,11 @@ RSpec.describe ResourceLabelEvent, type: :model do
describe '#expire_etag_cache' do describe '#expire_etag_cache' do
def expect_expiration(issue) def expect_expiration(issue)
expect_any_instance_of(Gitlab::EtagCaching::Store) expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
.to receive(:touch) expect(instance).to receive(:touch)
.with("/#{issue.project.namespace.to_param}/#{issue.project.to_param}/noteable/issue/#{issue.id}/notes") .with("/#{issue.project.namespace.to_param}/#{issue.project.to_param}/noteable/issue/#{issue.id}/notes")
end end
end
it 'expires resource note etag cache on event save' do it 'expires resource note etag cache on event save' do
expect_expiration(subject.issuable) expect_expiration(subject.issuable)
......
...@@ -151,7 +151,9 @@ describe ObjectStorage do ...@@ -151,7 +151,9 @@ describe ObjectStorage do
describe 'fails' do describe 'fails' do
it 'is handled gracefully' do it 'is handled gracefully' do
store = uploader.object_store 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 { subject }.to raise_error("An error")
expect(uploader.exists?).to be_truthy expect(uploader.exists?).to be_truthy
......
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