summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-09 19:40:25 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-09 19:40:25 +0100
commitd7ba85c7496fb24625f3ebf3e78af42ec23e842e (patch)
tree8707d8a02ae055838bcd80b0aa0a7ce2e1c564e3 /spec
parent1a5a3be84080808554568a8c61a80cc6f3f536ed (diff)
downloadgitlab-ce-d7ba85c7496fb24625f3ebf3e78af42ec23e842e.tar.gz
Refine specs for build show page with environments
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb7
-rw-r--r--spec/views/projects/builds/show.html.haml_spec.rb55
2 files changed, 39 insertions, 23 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 73cf4c9a24c..bead1a006d1 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -26,10 +26,11 @@ RSpec.configure do |config|
config.verbose_retry = true
config.display_try_failure_messages = true
- config.include Devise::Test::ControllerHelpers, type: :controller
+ config.include Devise::Test::ControllerHelpers, type: :controller
+ config.include Devise::Test::ControllerHelpers, type: :view
config.include Warden::Test::Helpers, type: :request
- config.include LoginHelpers, type: :feature
- config.include SearchHelpers, type: :feature
+ config.include LoginHelpers, type: :feature
+ config.include SearchHelpers, type: :feature
config.include StubConfiguration
config.include EmailHelpers
config.include TestEnv
diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb
index 0e702d80bd3..98b68e730e6 100644
--- a/spec/views/projects/builds/show.html.haml_spec.rb
+++ b/spec/views/projects/builds/show.html.haml_spec.rb
@@ -1,14 +1,12 @@
require 'spec_helper'
-describe 'projects/builds/show' do
- include Devise::Test::ControllerHelpers
-
+describe 'projects/builds/show', :view do
let(:project) { create(:project) }
+ let(:build) { create(:ci_build, pipeline: pipeline) }
+
let(:pipeline) do
- create(:ci_pipeline, project: project,
- sha: project.commit.id)
+ create(:ci_pipeline, project: project, sha: project.commit.id)
end
- let(:build) { create(:ci_build, pipeline: pipeline) }
before do
assign(:build, build)
@@ -19,31 +17,48 @@ describe 'projects/builds/show' do
describe 'environment info in build view' do
context 'build with latest deployment' do
- let(:build) { create(:ci_build, :success, environment: 'staging') }
- let(:environment) { create(:environment, name: 'staging') }
- let!(:deployment) { create(:deployment, deployable: build) }
+ let(:build) do
+ create(:ci_build, :success, environment: 'staging')
+ end
+
+ before do
+ create(:environment, name: 'staging')
+ create(:deployment, deployable: build)
+ end
it 'shows deployment message' do
- expect(rendered).to have_css('.environment-information', text: 'This build is the most recent deployment')
+ expected_text = 'This build is the most recent deployment'
+
+ render
+
+ expect(rendered).to have_css(
+ '.environment-information', text: expected_text)
end
end
context 'build with outdated deployment' do
- let(:build) { create(:ci_build, :success, environment: 'staging', pipeline: pipeline) }
- let(:environment) { create(:environment, name: 'staging', project: project) }
- let!(:deployment) { create(:deployment, environment: environment, deployable: build) }
- let!(:newer_deployment) { create(:deployment, environment: environment, deployable: build) }
+ let(:build) do
+ create(:ci_build, :success, environment: 'staging', pipeline: pipeline)
+ end
- before do
- assign(:build, build)
- assign(:project, project)
+ let(:environment) do
+ create(:environment, name: 'staging', project: project)
+ end
- allow(view).to receive(:can?).and_return(true)
- render
+ let!(:first_deployment) do
+ create(:deployment, environment: environment, deployable: build)
+ end
+
+ let!(:second_deployment) do
+ create(:deployment, environment: environment, deployable: build)
end
it 'shows deployment message' do
- expect(rendered).to have_css('.environment-information', text: "This build is an out-of-date deployment to #{environment.name}. View the most recent deployment #1")
+ expected_text = 'This build is an out-of-date deployment ' \
+ "to staging. View the most recent deployment ##{first_deployment.id}"
+ render
+
+ expect(rendered).to have_css('.environment-information', text: expected_text)
end
end