summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-12-20 14:37:37 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2019-01-15 10:23:42 +0100
commitba8a1ec92c783dae6f050e80c491bd1a42e1023d (patch)
tree809ee87262076d99d77c34c161e28f17b7b8ca73
parent69486116331bb262687ade4dfd4ab0619fad4063 (diff)
downloadgitlab-ce-ba8a1ec92c783dae6f050e80c491bd1a42e1023d.tar.gz
Add some specs for trigger presenter
-rw-r--r--spec/presenters/ci/trigger_presenter_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/presenters/ci/trigger_presenter_spec.rb b/spec/presenters/ci/trigger_presenter_spec.rb
new file mode 100644
index 00000000000..a589759f379
--- /dev/null
+++ b/spec/presenters/ci/trigger_presenter_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe Ci::TriggerPresenter do
+ set(:user) { create(:user) }
+ set(:project) { create(:project) }
+
+ set(:trigger) do
+ create(:ci_trigger, token: '123456789abcd', project: project)
+ end
+
+ let(:subject) do
+ described_class.new(trigger, current_user: user)
+ end
+
+ before do
+ project.add_maintainer(user)
+ end
+
+ context 'when user is not a trigger owner' do
+ describe '#token' do
+ it 'exposes only short token' do
+ expect(subject.token).not_to eq trigger.token
+ expect(subject.token).to eq '1234'
+ end
+ end
+
+ describe '#has_token_exposed?' do
+ it 'does not have token exposed' do
+ expect(subject).not_to have_token_exposed
+ end
+ end
+ end
+
+ context 'when user is a trigger owner and builds admin' do
+ before do
+ trigger.update(owner: user)
+ end
+
+ describe '#token' do
+ it 'exposes full token' do
+ expect(subject.token).to eq trigger.token
+ end
+ end
+
+ describe '#has_token_exposed?' do
+ it 'has token exposed' do
+ expect(subject).to have_token_exposed
+ end
+ end
+ end
+end