diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-12-07 17:01:31 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-12-07 17:16:33 +0100 |
commit | c1a098c78bf270f222a6ae98db38c820dfc6ed72 (patch) | |
tree | aa0848af4c04d15a8122d964476e633dbc83e77e /spec/serializers | |
parent | c2f72ad8a2ff02e310c1f3420342d10bec211277 (diff) | |
download | gitlab-ce-c1a098c78bf270f222a6ae98db38c820dfc6ed72.tar.gz |
Add specs for TriggerVariableEntity
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/trigger_variable_entity_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/serializers/trigger_variable_entity_spec.rb b/spec/serializers/trigger_variable_entity_spec.rb new file mode 100644 index 00000000000..66567c05f52 --- /dev/null +++ b/spec/serializers/trigger_variable_entity_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe TriggerVariableEntity do + let(:project) { create(:project) } + let(:request) { double('request') } + let(:user) { create(:user) } + let(:variable) { { key: 'TEST_KEY', value: 'TEST_VALUE' } } + + subject { described_class.new(variable, request: request).as_json } + + before do + allow(request).to receive(:current_user).and_return(user) + allow(request).to receive(:project).and_return(project) + end + + it 'exposes the variable key' do + expect(subject).to include(:key) + end + + context 'when user has access to the value' do + context 'when user is maintainer' do + before do + project.team.add_maintainer(user) + end + + it 'exposes the variable value' do + expect(subject).to include(:value) + end + end + + context 'when user is owner' do + let(:user) { project.owner } + + it 'exposes the variable value' do + expect(subject).to include(:value) + end + end + end + + context 'when user does not have access to the value' do + before do + project.team.add_developer(user) + end + + it 'does not expose the variable value' do + expect(subject).not_to include(:value) + end + end +end |