diff options
author | Rémy Coutable <remy@rymai.me> | 2016-05-20 00:42:24 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-05-20 00:42:24 +0300 |
commit | f73def90a83e7cddda0960b2c780c59835c228fb (patch) | |
tree | 691d299c67ded801d2fd950937561c6756c33092 /spec | |
parent | fa7a682bb05080855c8de29535e9626dde63c145 (diff) | |
parent | b876993677edde4fee3a8ed349c522f1542190f7 (diff) |
Merge branch 'fix-ci-commit-creation' into 'master'
Fix creation of Ci::Commit object which can lead to pending, failed in some scenarios
## What does this MR do?
If we use a new `project.ci_commits` it will add it to array, and some other services which can do a save on a project can lead to a scenario when `ci_commit` will be saved, where it should not be.
## What are the relevant issue numbers?
https://gitlab.com/gitlab-com/support-forum/issues/717 https://gitlab.com/gitlab-com/support-forum/issues/715 https://gitlab.com/gitlab-org/gitlab-ce/issues/17596 https://gitlab.com/gitlab-com/support-forum/issues/714 https://gitlab.com/gitlab-org/gitlab-ce/issues/13402
cc @rymai
See merge request !4214
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/post_receive_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 94ff3457902..2f465bcf1e3 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -48,6 +48,22 @@ describe PostReceive do PostReceive.new.perform(pwd(project), key_id, base64_changes) end end + + context "gitlab-ci.yml" do + subject { PostReceive.new.perform(pwd(project), key_id, base64_changes) } + + context "creates a Ci::Commit for every change" do + before { stub_ci_commit_to_return_yaml_file } + + it { expect{ subject }.to change{ Ci::Commit.count }.by(2) } + end + + context "does not create a Ci::Commit" do + before { stub_ci_commit_yaml_file(nil) } + + it { expect{ subject }.to_not change{ Ci::Commit.count } } + end + end end context "webhook" do |