Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-06-30 21:23:34 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-06-30 22:24:10 +0300
commitce8db128a948a618eb297c27fdde4f8322c36e87 (patch)
tree8bfac196d22f044b02419f42bb78ef0de09a126e /spec
parent04c2c88b67956a01f3f0c59341862a33239726a2 (diff)
Merge branch 'fix/build-retry-button-in-view' into 'master'
Do not show build retry link when build is active Closes #19244 See merge request !4967 (cherry picked from commit dc2d0051dc64318d732e34aeae87f0b4291c8a82)
Diffstat (limited to 'spec')
-rw-r--r--spec/models/build_spec.rb18
-rw-r--r--spec/views/projects/builds/show.html.haml_spec.rb37
2 files changed, 55 insertions, 0 deletions
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 8154001cf46..97b28686d82 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -669,4 +669,22 @@ describe Ci::Build, models: true do
expect(build.commit).to eq project.commit
end
end
+
+ describe '#retryable?' do
+ context 'when build is running' do
+ before { build.run! }
+
+ it 'should return false' do
+ expect(build.retryable?).to be false
+ end
+ end
+
+ context 'when build is finished' do
+ before { build.success! }
+
+ it 'should return true' do
+ expect(build.retryable?).to be true
+ end
+ end
+ end
end
diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb
new file mode 100644
index 00000000000..cd18d19ef5e
--- /dev/null
+++ b/spec/views/projects/builds/show.html.haml_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe 'projects/builds/show' do
+ include Devise::TestHelpers
+
+ let(:build) { create(:ci_build) }
+ let(:project) { build.project }
+
+ before do
+ assign(:build, build)
+ assign(:project, project)
+
+ allow(view).to receive(:can?).and_return(true)
+ end
+
+ context 'when build is running' do
+ before do
+ build.run!
+ render
+ end
+
+ it 'does not show retry button' do
+ expect(rendered).not_to have_link('Retry')
+ end
+ end
+
+ context 'when build is not running' do
+ before do
+ build.success!
+ render
+ end
+
+ it 'shows retry button' do
+ expect(rendered).to have_link('Retry')
+ end
+ end
+end