summaryrefslogtreecommitdiff
path: root/spec/lib/api/helpers/authentication_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 14:36:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 14:36:54 +0000
commitf61bb2a16a514b71bf33aabbbb999d6732016a24 (patch)
tree9548caa89e60b4f40b99bbd1dac030420b812aa8 /spec/lib/api/helpers/authentication_spec.rb
parent35fc54e5d261f8898e390aea7c2f5ec5fdf0539d (diff)
downloadgitlab-ce-f61bb2a16a514b71bf33aabbbb999d6732016a24.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc42
Diffstat (limited to 'spec/lib/api/helpers/authentication_spec.rb')
-rw-r--r--spec/lib/api/helpers/authentication_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/lib/api/helpers/authentication_spec.rb b/spec/lib/api/helpers/authentication_spec.rb
index 461b0d2f6f9..eea5c10d4f8 100644
--- a/spec/lib/api/helpers/authentication_spec.rb
+++ b/spec/lib/api/helpers/authentication_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe API::Helpers::Authentication do
let_it_be(:project, reload: true) { create(:project, :public) }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
let_it_be(:deploy_token) { create(:deploy_token, read_package_registry: true, write_package_registry: true) }
+ let_it_be(:ci_build) { create(:ci_build, :running, user: user) }
describe 'class methods' do
subject { Class.new.include(described_class::ClassMethods).new }
@@ -176,6 +177,20 @@ RSpec.describe API::Helpers::Authentication do
end
end
+ describe '#ci_build_from_namespace_inheritable' do
+ subject { object.ci_build_from_namespace_inheritable }
+
+ it 'returns #token_from_namespace_inheritable if it is a ci build' do
+ expect(object).to receive(:token_from_namespace_inheritable).and_return(ci_build)
+ expect(subject).to be(ci_build)
+ end
+
+ it 'returns nil if #token_from_namespace_inheritable is not a ci build' do
+ expect(object).to receive(:token_from_namespace_inheritable).and_return(personal_access_token)
+ expect(subject).to eq(nil)
+ end
+ end
+
describe '#user_from_namespace_inheritable' do
subject { object.user_from_namespace_inheritable }