summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-08-12 12:03:30 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-08-12 12:03:30 +0200
commitca162699ebaf592f66a3fc5ae78ad94d3c87af3b (patch)
treed3e3e0ac968951cb132e7ff2ccd84c0db8e0d731 /spec/lib
parent2c06cf98a6dc982caf81c2e4faba195ece9a3b77 (diff)
parentad3e1edcfce1e24fb9889d5d73852680cf4facf9 (diff)
downloadgitlab-ce-ca162699ebaf592f66a3fc5ae78ad94d3c87af3b.tar.gz
Merge branch 'improve-pipeline-processing' into pipeline-hooks-without-slack
# Conflicts: # app/models/ci/pipeline.rb # app/models/commit_status.rb # app/services/ci/create_pipeline_service.rb # spec/models/ci/pipeline_spec.rb
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/ci/charts_spec.rb17
-rw-r--r--spec/lib/gitlab/changes_list_spec.rb30
2 files changed, 39 insertions, 8 deletions
diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb
index 2cd6b00dad6..fb6cc398307 100644
--- a/spec/lib/ci/charts_spec.rb
+++ b/spec/lib/ci/charts_spec.rb
@@ -2,22 +2,23 @@ require 'spec_helper'
describe Ci::Charts, lib: true do
context "build_times" do
+ let(:project) { create(:empty_project) }
+ let(:chart) { Ci::Charts::BuildTime.new(project) }
+
+ subject { chart.build_times }
+
before do
- @pipeline = FactoryGirl.create(:ci_pipeline)
- FactoryGirl.create(:ci_build, pipeline: @pipeline)
- @pipeline.reload_status!
+ create(:ci_empty_pipeline, project: project, duration: 120)
end
it 'returns build times in minutes' do
- chart = Ci::Charts::BuildTime.new(@pipeline.project)
- expect(chart.build_times).to eq([2])
+ is_expected.to contain_exactly(2)
end
it 'handles nil build times' do
- create(:ci_pipeline, duration: nil, project: @pipeline.project)
+ create(:ci_empty_pipeline, project: project, duration: nil)
- chart = Ci::Charts::BuildTime.new(@pipeline.project)
- expect(chart.build_times).to eq([2, 0])
+ is_expected.to contain_exactly(2, 0)
end
end
end
diff --git a/spec/lib/gitlab/changes_list_spec.rb b/spec/lib/gitlab/changes_list_spec.rb
new file mode 100644
index 00000000000..69d86144e32
--- /dev/null
+++ b/spec/lib/gitlab/changes_list_spec.rb
@@ -0,0 +1,30 @@
+require "spec_helper"
+
+describe Gitlab::ChangesList do
+ let(:valid_changes_string) { "\n000000 570e7b2 refs/heads/my_branch\nd14d6c 6fd24d refs/heads/master" }
+ let(:invalid_changes) { 1 }
+
+ context 'when changes is a valid string' do
+ let(:changes_list) { Gitlab::ChangesList.new(valid_changes_string) }
+
+ it 'splits elements by newline character' do
+ expect(changes_list).to contain_exactly({
+ oldrev: "000000",
+ newrev: "570e7b2",
+ ref: "refs/heads/my_branch"
+ }, {
+ oldrev: "d14d6c",
+ newrev: "6fd24d",
+ ref: "refs/heads/master"
+ })
+ end
+
+ it 'behaves like a list' do
+ expect(changes_list.first).to eq({
+ oldrev: "000000",
+ newrev: "570e7b2",
+ ref: "refs/heads/my_branch"
+ })
+ end
+ end
+end