summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/build_spec.rb6
-rw-r--r--spec/models/ci/pipeline_spec.rb33
2 files changed, 35 insertions, 4 deletions
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index dc88697199b..47c489e6af1 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -275,7 +275,8 @@ describe Ci::Build, models: true do
context 'when yaml_variables are undefined' do
before do
- build.yaml_variables = nil
+ build.update(yaml_variables: nil)
+ build.reload # reload pipeline so that it resets config_processor
end
context 'use from gitlab-ci.yml' do
@@ -854,7 +855,8 @@ describe Ci::Build, models: true do
context 'if is undefined' do
before do
- build.when = nil
+ build.update(when: nil)
+ build.reload # reload pipeline so that it resets config_processor
end
context 'use from gitlab-ci.yml' do
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 0d4c86955ce..aa05fc78f94 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -513,7 +513,7 @@ describe Ci::Pipeline, models: true do
create :ci_build, :success, pipeline: pipeline, name: 'rspec'
create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop'
end
-
+
it 'returns true' do
is_expected.to be_truthy
end
@@ -524,7 +524,7 @@ describe Ci::Pipeline, models: true do
create :ci_build, :success, pipeline: pipeline, name: 'rspec'
create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: 'rubocop'
end
-
+
it 'returns false' do
is_expected.to be_falsey
end
@@ -542,4 +542,33 @@ describe Ci::Pipeline, models: true do
end
end
end
+
+ describe '#execute_hooks' do
+ let!(:hook) do
+ create(:project_hook, project: project, pipeline_events: enabled)
+ end
+ let(:enabled) { raise NotImplementedError }
+
+ before do
+ WebMock.stub_request(:post, hook.url)
+ pipeline.touch
+ ProjectWebHookWorker.drain
+ end
+
+ context 'with pipeline hooks enabled' do
+ let(:enabled) { true }
+
+ it 'executes pipeline_hook after touched' do
+ expect(WebMock).to have_requested(:post, hook.url).once
+ end
+ end
+
+ context 'with pipeline hooks disabled' do
+ let(:enabled) { false }
+
+ it 'did not execute pipeline_hook after touched' do
+ expect(WebMock).not_to have_requested(:post, hook.url)
+ end
+ end
+ end
end