diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/models/commit.rb | 2 | ||||
-rw-r--r-- | spec/services/create_commit_service_spec.rb | 15 |
3 files changed, 17 insertions, 1 deletions
@@ -10,6 +10,7 @@ v7.14.0 (unreleased) - Fix project API listing returning empty list when first projects are not added to CI - Allow to define variables from YAML - Added support for CI skipped status + - Fix broken yaml error saving - Rename type(s) to stage(s) v7.13.1 diff --git a/app/models/commit.rb b/app/models/commit.rb index c7e2d8b..ec65d19 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -250,7 +250,7 @@ class Commit < ActiveRecord::Base private def save_yaml_error(error) - return unless self.yaml_errors? + return if self.yaml_errors? self.yaml_errors = error save end diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb index c72ba6b..13f9663 100644 --- a/spec/services/create_commit_service_spec.rb +++ b/spec/services/create_commit_service_spec.rb @@ -98,5 +98,20 @@ describe CreateCommitService do ) commit.builds.count(:all).should == 2 end + + it "creates commit with failed status if yaml is invalid" do + commits = [{message: "some message"}] + + commit = service.execute(project, + ref: 'refs/tags/0_1', + before: '00000000', + after: '31das312', + commits: commits, + ci_yaml_file: "invalid: file" + ) + + commit.status.should == "failed" + commit.builds.any?.should be_false + end end end |