diff options
author | Stan Hu <stanhu@gmail.com> | 2016-01-04 23:18:23 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-01-10 18:12:47 -0800 |
commit | 4b4fdf58c7f358fb06bed6dae166b758465850d0 (patch) | |
tree | 978877c7cfe4062cebe5533900616325013f5aa8 /spec | |
parent | 70cba8e9a833b6a5ae4d916ce50c394868de8116 (diff) | |
download | gitlab-ce-4b4fdf58c7f358fb06bed6dae166b758465850d0.tar.gz |
Fix Error 500 when visiting build page of project with nil runners_token
Properly ensure that the token exists and add defensively check for a
non-nil value.
Closes #4294
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/build_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb new file mode 100644 index 00000000000..36d10636ae9 --- /dev/null +++ b/spec/models/ci/build_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe Ci::Build, models: true do + let(:build) { create(:ci_build) } + let(:test_trace) { 'This is a test' } + + describe '#trace' do + it 'obfuscates project runners token' do + allow(build).to receive(:raw_trace).and_return("Test: #{build.project.runners_token}") + + expect(build.trace).to eq("Test: xxxxxx") + end + + it 'empty project runners token' do + allow(build).to receive(:raw_trace).and_return(test_trace) + # runners_token can't normally be set to nil + allow(build.project).to receive(:runners_token).and_return(nil) + + expect(build.trace).to eq(test_trace) + end + end +end |