2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe TriggerVariableEntity do
|
2019-02-15 15:39:39 +05:30
|
|
|
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
|
2022-04-04 11:22:00 +05:30
|
|
|
let(:user) { project.first_owner }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
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
|