diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-24 12:20:35 +0300 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-24 12:20:35 +0300 |
commit | 3dd5bedb54ce1bb150ab5304463c0a63d6e10ec9 (patch) | |
tree | deb65d3be6788e83d0831faadcc9a8425dbbbc3c | |
parent | 6078425118c27db2ffa394579316eb81cd231d83 (diff) | |
parent | 7e72fcaa095b77f7caac3fb6214ad21f7d6dd2b3 (diff) |
Merge branch '36400-trigger-job' into 'master'
Prevent 500 error when inspecting job after trigger was removed
Closes #36400
See merge request gitlab-org/gitlab-ce!15447
-rw-r--r-- | app/views/projects/jobs/_sidebar.html.haml | 7 | ||||
-rw-r--r-- | changelogs/unreleased/36400-trigger-job.yml | 5 | ||||
-rw-r--r-- | spec/views/projects/jobs/show.html.haml_spec.rb | 25 |
3 files changed, 34 insertions, 3 deletions
diff --git a/app/views/projects/jobs/_sidebar.html.haml b/app/views/projects/jobs/_sidebar.html.haml index 17ac8a20a30..a71333497e6 100644 --- a/app/views/projects/jobs/_sidebar.html.haml +++ b/app/views/projects/jobs/_sidebar.html.haml @@ -44,9 +44,10 @@ %h4.title Trigger - %p - %span.build-light-text Token: - #{@build.trigger_request.trigger.short_token} + - if @build.trigger_request&.trigger&.short_token + %p + %span.build-light-text Token: + #{@build.trigger_request.trigger.short_token} - if @build.trigger_variables.any? %p diff --git a/changelogs/unreleased/36400-trigger-job.yml b/changelogs/unreleased/36400-trigger-job.yml new file mode 100644 index 00000000000..27243813dc8 --- /dev/null +++ b/changelogs/unreleased/36400-trigger-job.yml @@ -0,0 +1,5 @@ +--- +title: Prevent 500 error when inspecting job after trigger was removed +merge_request: +author: +type: fixed diff --git a/spec/views/projects/jobs/show.html.haml_spec.rb b/spec/views/projects/jobs/show.html.haml_spec.rb index d4279626e75..6139529013f 100644 --- a/spec/views/projects/jobs/show.html.haml_spec.rb +++ b/spec/views/projects/jobs/show.html.haml_spec.rb @@ -185,6 +185,31 @@ describe 'projects/jobs/show' do end end + context 'when incomplete trigger_request is used' do + before do + build.trigger_request = FactoryGirl.build(:ci_trigger_request, trigger: nil) + end + + it 'test should not render token block' do + render + + expect(rendered).not_to have_content('Token') + end + end + + context 'when complete trigger_request is used' do + before do + build.trigger_request = FactoryGirl.build(:ci_trigger_request) + end + + it 'should render token' do + render + + expect(rendered).to have_content('Token') + expect(rendered).to have_content(build.trigger_request.trigger.short_token) + end + end + describe 'commit title in sidebar' do let(:commit_title) { project.commit.title } |