diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/tasks | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/admin_mode_spec.rb | 32 | ||||
-rw-r--r-- | spec/tasks/gitlab/packages/composer_rake_spec.rb | 28 |
2 files changed, 60 insertions, 0 deletions
diff --git a/spec/tasks/admin_mode_spec.rb b/spec/tasks/admin_mode_spec.rb new file mode 100644 index 00000000000..9dd35650ab6 --- /dev/null +++ b/spec/tasks/admin_mode_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'admin mode on tasks' do + before do + allow(::Gitlab::Runtime).to receive(:test_suite?).and_return(false) + allow(::Gitlab::Runtime).to receive(:rake?).and_return(true) + end + + shared_examples 'verify admin mode' do |state| + it 'matches the expected admin mode' do + Rake::Task.define_task :verify_admin_mode do + expect(Gitlab::Auth::CurrentUserMode.new(user).admin_mode?).to be(state) + end + + run_rake_task('verify_admin_mode') + end + end + + describe 'with a regular user' do + let(:user) { create(:user) } + + include_examples 'verify admin mode', false + end + + describe 'with an admin' do + let(:user) { create(:admin) } + + include_examples 'verify admin mode', true + end +end diff --git a/spec/tasks/gitlab/packages/composer_rake_spec.rb b/spec/tasks/gitlab/packages/composer_rake_spec.rb new file mode 100644 index 00000000000..d54e1b02599 --- /dev/null +++ b/spec/tasks/gitlab/packages/composer_rake_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'rake_helper' + +RSpec.describe 'gitlab:packages:build_composer_cache namespace rake task' do + let_it_be(:package_name) { 'sample-project' } + let_it_be(:package_name2) { 'sample-project2' } + let_it_be(:json) { { 'name' => package_name } } + let_it_be(:json2) { { 'name' => package_name2 } } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json.to_json }, group: group) } + let_it_be(:project2) { create(:project, :custom_repo, files: { 'composer.json' => json2.to_json }, group: group) } + let!(:package) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '1.0.0', json: json) } + let!(:package2) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '2.0.0', json: json) } + let!(:package3) { create(:composer_package, :with_metadatum, project: project2, name: package_name2, version: '3.0.0', json: json2) } + + before :all do + Rake.application.rake_require 'tasks/gitlab/packages/composer' + end + + subject do + run_rake_task("gitlab:packages:build_composer_cache") + end + + it 'generates the cache files' do + expect { subject }.to change { Packages::Composer::CacheFile.count }.by(2) + end +end |