diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-11-24 14:31:20 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2016-11-24 14:31:20 +0000 |
commit | 8b694ae89174c72a9d7f71b43554965031ffa3fb (patch) | |
tree | 8bef72adcdcafb4f4500d56f46a38b63064a695d /spec/views | |
parent | 604870a6cf57623a4fa36117ec8fd53544dd4b23 (diff) | |
parent | 2f5637d6e39efa4b1a1cd2acdffa478e903ecd98 (diff) | |
download | gitlab-ce-8b694ae89174c72a9d7f71b43554965031ffa3fb.tar.gz |
Merge branch '24779-last-deployment-call-on-nil-environment-fix' into 'master'
changes environment.last_deployment to a try expression so it does not fail if e…
## What does this MR do?
Fixes the call on `environment.last_deployment` to not break when `environment`is not yet set.
## Does this MR meet the acceptance criteria?
- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
## What are the relevant issue numbers?
Closes #24779
See merge request !7671
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/builds/show.html.haml_spec.rb | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb index e0c77201116..745d0c745bd 100644 --- a/spec/views/projects/builds/show.html.haml_spec.rb +++ b/spec/views/projects/builds/show.html.haml_spec.rb @@ -88,16 +88,46 @@ describe 'projects/builds/show', :view do create(:ci_build, :running, environment: 'staging', pipeline: pipeline) end - let!(:environment) do - create(:environment, name: 'staging', project: project) - end - - it 'shows deployment message' do - expected_text = 'This build is creating a deployment to staging' - render - - expect(rendered).to have_css( - '.environment-information', text: expected_text) + context 'when environment exists' do + let!(:environment) do + create(:environment, name: 'staging', project: project) + end + + it 'shows deployment message' do + expected_text = 'This build is creating a deployment to staging' + render + + expect(rendered).to have_css( + '.environment-information', text: expected_text) + end + + context 'when it has deployment' do + let!(:deployment) do + create(:deployment, environment: environment) + end + + it 'shows that deployment will be overwritten' do + expected_text = 'This build is creating a deployment to staging' + render + + expect(rendered).to have_css( + '.environment-information', text: expected_text) + expect(rendered).to have_css( + '.environment-information', text: 'latest deployment') + end + end + end + + context 'when environment does not exist' do + it 'shows deployment message' do + expected_text = 'This build is creating a deployment to staging' + render + + expect(rendered).to have_css( + '.environment-information', text: expected_text) + expect(rendered).not_to have_css( + '.environment-information', text: 'latest deployment') + end end end @@ -134,6 +164,8 @@ describe 'projects/builds/show', :view do expect(rendered).to have_css( '.environment-information', text: expected_text) + expect(rendered).not_to have_css( + '.environment-information', text: 'latest deployment') end end end |