Commit 20fc42e9 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve post_receive spec by not stubbing private methods

parent 9ad48a74
...@@ -66,19 +66,21 @@ describe PostReceive do ...@@ -66,19 +66,21 @@ describe PostReceive do
end end
context "gitlab-ci.yml" do context "gitlab-ci.yml" do
let(:changes) { "123456 789012 refs/heads/feature\n654321 210987 refs/tags/tag" }
subject { described_class.new.perform(gl_repository, key_id, base64_changes) } subject { described_class.new.perform(gl_repository, key_id, base64_changes) }
context "creates a Ci::Pipeline for every change" do context "creates a Ci::Pipeline for every change" do
before do before do
stub_ci_pipeline_to_return_yaml_file stub_ci_pipeline_to_return_yaml_file
# TODO, don't stub private methods allow_any_instance_of(Project)
# .to receive(:commit)
allow_any_instance_of(Ci::CreatePipelineService) .and_return(project.commit)
.to receive(:commit).and_return(OpenStruct.new(id: '123456'))
allow_any_instance_of(Repository) allow_any_instance_of(Repository)
.to receive(:branch_exists?).and_return(true) .to receive(:branch_exists?)
.and_return(true)
end end
it { expect { subject }.to change { Ci::Pipeline.count }.by(2) } it { expect { subject }.to change { Ci::Pipeline.count }.by(2) }
......
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