Commit 2c66e7b2 authored by James Fargher's avatar James Fargher

Merge branch 'simplify-gitlab-ci-yaml-stub' into 'master'

Consolidate stub helpers and use them consistently

See merge request gitlab-org/gitlab!68810
parents e963af89 2fe9ee6a
...@@ -44,7 +44,7 @@ RSpec.describe Gitlab::Chat::Command do ...@@ -44,7 +44,7 @@ RSpec.describe Gitlab::Chat::Command do
let(:pipeline) { command.create_pipeline } let(:pipeline) { command.create_pipeline }
before do before do
stub_ci_pipeline_yaml_file(gitlab_ci_yaml) stub_ci_pipeline_to_return_yaml_file
project.add_developer(chat_name.user) project.add_developer(chat_name.user)
end end
......
...@@ -11,7 +11,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -11,7 +11,7 @@ RSpec.describe Ci::CreatePipelineService do
let(:ref_name) { 'refs/heads/master' } let(:ref_name) { 'refs/heads/master' }
before do before do
stub_ci_pipeline_yaml_file(gitlab_ci_yaml) stub_ci_pipeline_to_return_yaml_file
end end
describe '#execute' do describe '#execute' do
......
...@@ -160,7 +160,6 @@ RSpec.configure do |config| ...@@ -160,7 +160,6 @@ RSpec.configure do |config|
config.include GitlabRoutingHelper config.include GitlabRoutingHelper
config.include StubExperiments config.include StubExperiments
config.include StubGitlabCalls config.include StubGitlabCalls
config.include StubGitlabData
config.include NextFoundInstanceOf config.include NextFoundInstanceOf
config.include NextInstanceOf config.include NextInstanceOf
config.include TestEnv config.include TestEnv
......
...@@ -18,6 +18,10 @@ module StubGitlabCalls ...@@ -18,6 +18,10 @@ module StubGitlabCalls
stub_ci_pipeline_yaml_file(gitlab_ci_yaml) stub_ci_pipeline_yaml_file(gitlab_ci_yaml)
end end
def gitlab_ci_yaml
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
end
def stub_ci_pipeline_yaml_file(ci_yaml_content) def stub_ci_pipeline_yaml_file(ci_yaml_content)
allow_any_instance_of(Repository) allow_any_instance_of(Repository)
.to receive(:gitlab_ci_yml_for) .to receive(:gitlab_ci_yml_for)
......
# frozen_string_literal: true
module StubGitlabData
def gitlab_ci_yaml
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
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