Commit 842de4ef authored by Katarzyna Kobierska's avatar Katarzyna Kobierska

Tests refactoring for trigger variables

parent 79c29a67
...@@ -5,7 +5,8 @@ FactoryGirl.define do ...@@ -5,7 +5,8 @@ FactoryGirl.define do
variables do variables do
{ {
TRIGGER_KEY: 'TRIGGER_VALUE' TRIGGER_KEY_1: 'TRIGGER_VALUE_1',
TRIGGER_KEY_2: 'TRIGGER_VALUE_2'
} }
end end
end end
......
...@@ -51,19 +51,22 @@ describe 'projects/builds/show' do ...@@ -51,19 +51,22 @@ describe 'projects/builds/show' do
end end
describe 'shows trigger variables in sidebar' do 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) }
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline, trigger: trigger) }
before do before do
build.trigger_request = trigger_request build.trigger_request = trigger_request
render
end end
it 'shows trigger variables in separate lines' do it 'shows trigger variables in separate lines' do
trigger_request.update_attributes(variables: { TRIGGER_KEY: 'TRIGGER_VALUE', TRIGGER_KEY_1: 'TRIGGER_VALUE_1' }) expect(rendered).to have_css('code', text: variable_regexp('TRIGGER_KEY_1','TRIGGER_VALUE_1'))
render expect(rendered).to have_css('code', text: variable_regexp('TRIGGER_KEY_2', 'TRIGGER_VALUE_2'))
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/)
end end
end end
private
def variable_regexp(key, value)
/\A#{Regexp.escape("#{key}=#{value}")}\Z/
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