Commit d7ba85c7 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refine specs for build show page with environments

parent 1a5a3be8
...@@ -26,10 +26,11 @@ RSpec.configure do |config| ...@@ -26,10 +26,11 @@ RSpec.configure do |config|
config.verbose_retry = true config.verbose_retry = true
config.display_try_failure_messages = 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 Warden::Test::Helpers, type: :request
config.include LoginHelpers, type: :feature config.include LoginHelpers, type: :feature
config.include SearchHelpers, type: :feature config.include SearchHelpers, type: :feature
config.include StubConfiguration config.include StubConfiguration
config.include EmailHelpers config.include EmailHelpers
config.include TestEnv config.include TestEnv
......
require 'spec_helper' require 'spec_helper'
describe 'projects/builds/show' do describe 'projects/builds/show', :view do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) } let(:project) { create(:project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, project: project, create(:ci_pipeline, project: project, sha: project.commit.id)
sha: project.commit.id)
end end
let(:build) { create(:ci_build, pipeline: pipeline) }
before do before do
assign(:build, build) assign(:build, build)
...@@ -19,31 +17,48 @@ describe 'projects/builds/show' do ...@@ -19,31 +17,48 @@ describe 'projects/builds/show' do
describe 'environment info in build view' do describe 'environment info in build view' do
context 'build with latest deployment' do context 'build with latest deployment' do
let(:build) { create(:ci_build, :success, environment: 'staging') } let(:build) do
let(:environment) { create(:environment, name: 'staging') } create(:ci_build, :success, environment: 'staging')
let!(:deployment) { create(:deployment, deployable: build) } end
before do
create(:environment, name: 'staging')
create(:deployment, deployable: build)
end
it 'shows deployment message' do 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
end end
context 'build with outdated deployment' do context 'build with outdated deployment' do
let(:build) { create(:ci_build, :success, environment: 'staging', pipeline: pipeline) } let(:build) do
let(:environment) { create(:environment, name: 'staging', project: project) } create(:ci_build, :success, environment: 'staging', pipeline: pipeline)
let!(:deployment) { create(:deployment, environment: environment, deployable: build) } end
let!(:newer_deployment) { create(:deployment, environment: environment, deployable: build) }
before do let(:environment) do
assign(:build, build) create(:environment, name: 'staging', project: project)
assign(:project, project) end
allow(view).to receive(:can?).and_return(true) let!(:first_deployment) do
render create(:deployment, environment: environment, deployable: build)
end
let!(:second_deployment) do
create(:deployment, environment: environment, deployable: build)
end end
it 'shows deployment message' do 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
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment