summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-11-19 12:08:30 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2015-11-19 12:09:34 +0100
commit0df7a32ea50baf251f03e6bfc5b91c5ccb68aad0 (patch)
tree7bf126f147581a9063ab3382760c5b35d33cac10
parent2b907f61ff5db3ff68b27a9d3bb164745ab7703b (diff)
downloadgitlab-ce-0df7a32ea50baf251f03e6bfc5b91c5ccb68aad0.tar.gz
Fix tests
-rw-r--r--app/models/ci/commit.rb2
-rw-r--r--spec/services/ci/create_commit_service_spec.rb38
2 files changed, 20 insertions, 20 deletions
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb
index 73c1570c212..b0c78499e49 100644
--- a/app/models/ci/commit.rb
+++ b/app/models/ci/commit.rb
@@ -196,7 +196,7 @@ module Ci
rescue Psych::SyntaxError => e
save_yaml_error(e.message)
nil
- rescue Exception => e
+ rescue Exception
save_yaml_error("Undefined yaml error")
nil
end
diff --git a/spec/services/ci/create_commit_service_spec.rb b/spec/services/ci/create_commit_service_spec.rb
index 392f5fce35f..58d81c46a6d 100644
--- a/spec/services/ci/create_commit_service_spec.rb
+++ b/spec/services/ci/create_commit_service_spec.rb
@@ -53,7 +53,7 @@ module Ci
end
end
- it 'fails commits without .gitlab-ci.yml' do
+ it 'skips commits without .gitlab-ci.yml' do
stub_ci_commit_yaml_file(nil)
result = service.execute(project, user,
ref: 'refs/heads/0_1',
@@ -63,7 +63,24 @@ module Ci
)
expect(result).to be_persisted
expect(result.builds.any?).to be_falsey
- expect(result.status).to eq('failed')
+ expect(result.status).to eq('skipped')
+ expect(commit.yaml_errors).to_not be_nil
+ end
+
+ it 'skips commits if yaml is invalid' do
+ message = 'message'
+ allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { message }
+ stub_ci_commit_yaml_file('invalid: file: file')
+ commits = [{ message: message }]
+ commit = service.execute(project, user,
+ ref: 'refs/tags/0_1',
+ before: '00000000',
+ after: '31das312',
+ commits: commits
+ )
+ expect(commit.builds.any?).to be false
+ expect(commit.status).to eq('skipped')
+ expect(commit.yaml_errors).to_not be_nil
end
describe :ci_skip? do
@@ -114,23 +131,6 @@ module Ci
end
end
- describe :config_processor do
- it "skips builds creation if yaml is invalid" do
- allow_any_instance_of(Ci::Commit).to receive(:git_commit_message) { "message" }
- stub_ci_commit_yaml_file('invalid: file: file')
- commits = [{ message: message }]
- commit = service.execute(project, user,
- ref: 'refs/tags/0_1',
- before: '00000000',
- after: '31das312',
- commits: commits
- )
- expect(commit.builds.any?).to be false
- expect(commit.status).to eq("skipped")
- expect(commit.yaml_errors).to_not be_nil
- end
- end
-
it "skips build creation if there are already builds" do
allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file) { gitlab_ci_yaml }