diff options
author | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-07-21 13:50:01 +0200 |
---|---|---|
committer | Katarzyna Kobierska <kkobierska@gmail.com> | 2016-07-26 11:19:40 +0200 |
commit | 842de4efc082c4c5ff6dcbe1869e1046569e7807 (patch) | |
tree | cb0c96cee53c043867a04b379d91320939120b83 /spec | |
parent | 79c29a67caa56fdff888221a71a446a3c4e7ac5e (diff) | |
download | gitlab-ce-842de4efc082c4c5ff6dcbe1869e1046569e7807.tar.gz |
Tests refactoring for trigger variables
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/ci/trigger_requests.rb | 3 | ||||
-rw-r--r-- | spec/views/projects/builds/show.html.haml_spec.rb | 17 |
2 files changed, 12 insertions, 8 deletions
diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb index 6d47d05f8ad..b8d8fab0e0b 100644 --- a/spec/factories/ci/trigger_requests.rb +++ b/spec/factories/ci/trigger_requests.rb @@ -5,7 +5,8 @@ FactoryGirl.define do variables do { - TRIGGER_KEY: 'TRIGGER_VALUE' + TRIGGER_KEY_1: 'TRIGGER_VALUE_1', + TRIGGER_KEY_2: 'TRIGGER_VALUE_2' } end end diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb index bc433a15a7c..88b96939720 100644 --- a/spec/views/projects/builds/show.html.haml_spec.rb +++ b/spec/views/projects/builds/show.html.haml_spec.rb @@ -51,19 +51,22 @@ describe 'projects/builds/show' do end describe 'shows trigger variables in sidebar' do - let(:trigger) { create(:ci_trigger, project: project) } - let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) } + let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) } before do build.trigger_request = trigger_request + render end it 'shows trigger variables in separate lines' do - trigger_request.update_attributes(variables: { TRIGGER_KEY: 'TRIGGER_VALUE', TRIGGER_KEY_1: 'TRIGGER_VALUE_1' }) - render - - expect(rendered).to have_css('code', text: /\A#{Regexp.escape('TRIGGER_KEY=TRIGGER_VALUE')}\Z/) - expect(rendered).to have_css('code', text: /\A#{Regexp.escape('TRIGGER_KEY_1=TRIGGER_VALUE_1')}\Z/) + expect(rendered).to have_css('code', text: variable_regexp('TRIGGER_KEY_1','TRIGGER_VALUE_1')) + expect(rendered).to have_css('code', text: variable_regexp('TRIGGER_KEY_2', 'TRIGGER_VALUE_2')) end end + + private + + def variable_regexp(key, value) + /\A#{Regexp.escape("#{key}=#{value}")}\Z/ + end end |