debian-mirror-gitlab/spec/helpers/ci/secure_files_helper_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
Ruby
Raw Normal View History

2022-07-16 23:28:13 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::SecureFilesHelper do
let_it_be(:maintainer) { create(:user) }
let_it_be(:developer) { create(:user) }
let_it_be(:guest) { create(:user) }
let_it_be(:anonymous) { create(:user) }
let_it_be(:unconfirmed) { create(:user, :unconfirmed) }
let_it_be(:project) { create(:project, creator_id: maintainer.id) }
before_all do
project.add_maintainer(maintainer)
project.add_developer(developer)
project.add_guest(guest)
end
subject { helper.show_secure_files_setting(project, user) }
describe '#show_secure_files_setting' do
2023-03-04 22:38:38 +05:30
context 'authenticated user with admin permissions' do
let(:user) { maintainer }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be true }
end
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
context 'authenticated user with read permissions' do
let(:user) { developer }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be true }
end
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
context 'authenticated user with guest permissions' do
let(:user) { guest }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be false }
end
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
context 'authenticated user with no permissions' do
let(:user) { anonymous }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be false }
end
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
context 'unconfirmed user' do
let(:user) { unconfirmed }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be false }
2022-07-16 23:28:13 +05:30
end
2023-03-04 22:38:38 +05:30
context 'unauthenticated user' do
let(:user) { nil }
2022-07-16 23:28:13 +05:30
2023-03-04 22:38:38 +05:30
it { is_expected.to be false }
2022-07-16 23:28:13 +05:30
end
end
end