Skip to content
Snippets Groups Projects
Commit 0ab47b99 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 1308dc5e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -130,6 +130,38 @@ describe Projects::ContainerRepository::CleanupTagsService do
is_expected.to include(status: :success, deleted: %w(Bb Ba C))
end
end
context 'when running a container_expiration_policy' do
let(:user) { nil }
context 'with valid container_expiration_policy param' do
let(:params) do
{ 'name_regex' => '.*',
'keep_n' => 1,
'older_than' => '1 day',
'container_expiration_policy' => true }
end
it 'succeeds without a user' do
expect_delete('sha256:configB').twice
expect_delete('sha256:configC')
is_expected.to include(status: :success, deleted: %w(Bb Ba C))
end
end
context 'without container_expiration_policy param' do
let(:params) do
{ 'name_regex' => '.*',
'keep_n' => 1,
'older_than' => '1 day' }
end
it 'fails' do
is_expected.to include(status: :error, message: 'access denied')
end
end
end
end
 
private
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Users::BlockService do
let(:current_user) { create(:admin) }
subject(:service) { described_class.new(current_user) }
describe '#execute' do
subject(:operation) { service.execute(user) }
context 'when successful' do
let(:user) { create(:user) }
it { is_expected.to eq(status: :success) }
it "change the user's state" do
expect { operation }.to change { user.state }.to('blocked')
end
end
context 'when failed' do
let(:user) { create(:user, :blocked) }
it 'returns error result' do
aggregate_failures 'error result' do
expect(operation[:status]).to eq(:error)
expect(operation[:message]).to match(/State cannot transition/)
end
end
it "does not change the user's state" do
expect { operation }.not_to change { user.state }
end
end
end
end
Loading
Loading
@@ -37,6 +37,8 @@ module FakeBlobHelpers
end
 
def fake_blob(**kwargs)
Blob.decorate(FakeBlob.new(**kwargs), project)
container = kwargs.delete(:container) || project
Blob.decorate(FakeBlob.new(**kwargs), container)
end
end
Loading
Loading
@@ -29,4 +29,8 @@ module MetricsDashboardHelpers
def business_metric_title
PrometheusMetricEnums.group_details[:business][:group_title]
end
def self_monitoring_dashboard_path
Metrics::Dashboard::SelfMonitoringDashboardService::DASHBOARD_PATH
end
end
Loading
Loading
@@ -2,7 +2,7 @@
 
RSpec.shared_examples 'a repo type' do
describe '#identifier_for_container' do
subject { described_class.identifier_for_container(project) }
subject { described_class.identifier_for_container(expected_container) }
 
it { is_expected.to eq(expected_identifier) }
end
Loading
Loading
@@ -35,7 +35,7 @@ RSpec.shared_examples 'a repo type' do
 
describe '#repository_for' do
it 'finds the repository for the repo type' do
expect(described_class.repository_for(project)).to eq(expected_repository)
expect(described_class.repository_for(expected_container)).to eq(expected_repository)
end
end
end
Loading
Loading
@@ -18,7 +18,7 @@ RSpec.shared_examples 'model with repository' do
let(:only_path) { false }
 
it 'returns the full web URL for this repo' do
expect(subject).to eq("#{Gitlab.config.gitlab.url}/#{expected_full_path}")
expect(subject).to eq("#{Gitlab.config.gitlab.url}/#{expected_web_url_path}")
end
end
 
Loading
Loading
@@ -26,7 +26,7 @@ RSpec.shared_examples 'model with repository' do
let(:only_path) { true }
 
it 'returns the relative web URL for this repo' do
expect(subject).to eq("/#{expected_full_path}")
expect(subject).to eq("/#{expected_web_url_path}")
end
end
 
Loading
Loading
@@ -34,14 +34,14 @@ RSpec.shared_examples 'model with repository' do
let(:only_path) { nil }
 
it 'returns the full web URL for this repo' do
expect(subject).to eq("#{Gitlab.config.gitlab.url}/#{expected_full_path}")
expect(subject).to eq("#{Gitlab.config.gitlab.url}/#{expected_web_url_path}")
end
end
end
 
context 'when not given the only_path option' do
it 'returns the full web URL for this repo' do
expect(container.web_url).to eq("#{Gitlab.config.gitlab.url}/#{expected_full_path}")
expect(container.web_url).to eq("#{Gitlab.config.gitlab.url}/#{expected_web_url_path}")
end
end
end
Loading
Loading
@@ -72,7 +72,7 @@ RSpec.shared_examples 'model with repository' do
let(:custom_http_clone_url_root) { 'https://git.example.com:51234/mygitlab/' }
 
it 'returns the url to the repo, with the root replaced with the custom one' do
expect(subject).to eq("#{custom_http_clone_url_root}#{expected_full_path}.git")
expect(subject).to eq("#{custom_http_clone_url_root}#{expected_web_url_path}.git")
end
end
 
Loading
Loading
@@ -80,7 +80,7 @@ RSpec.shared_examples 'model with repository' do
let(:custom_http_clone_url_root) { 'https://git.example.com:51234/mygitlab' }
 
it 'returns the url to the repo, with the root replaced with the custom one' do
expect(subject).to eq("#{custom_http_clone_url_root}/#{expected_full_path}.git")
expect(subject).to eq("#{custom_http_clone_url_root}/#{expected_web_url_path}.git")
end
end
end
Loading
Loading
@@ -90,7 +90,7 @@ RSpec.shared_examples 'model with repository' do
let(:custom_http_clone_url_root) { 'https://git.example.com:51234/' }
 
it 'returns the url to the repo, with the root replaced with the custom one' do
expect(subject).to eq("#{custom_http_clone_url_root}#{expected_full_path}.git")
expect(subject).to eq("#{custom_http_clone_url_root}#{expected_web_url_path}.git")
end
end
 
Loading
Loading
@@ -98,7 +98,7 @@ RSpec.shared_examples 'model with repository' do
let(:custom_http_clone_url_root) { 'https://git.example.com:51234' }
 
it 'returns the url to the repo, with the root replaced with the custom one' do
expect(subject).to eq("#{custom_http_clone_url_root}/#{expected_full_path}.git")
expect(subject).to eq("#{custom_http_clone_url_root}/#{expected_web_url_path}.git")
end
end
end
Loading
Loading
Loading
Loading
@@ -50,5 +50,20 @@ RSpec.shared_examples 'multiple boards list service' do
it 'returns boards ordered by name' do
expect(service.execute).to eq [board_a, board_B, board_c]
end
context 'when wanting a specific board' do
it 'returns board specified by id' do
service = described_class.new(parent, double, board_id: board_c.id)
expect(service.execute).to eq [board_c]
end
it 'raises exception when board is not found' do
outside_board = create(:board, resource_parent: create(:project), name: 'outside board')
service = described_class.new(parent, double, board_id: outside_board.id)
expect { service.execute }.to raise_exception(ActiveRecord::RecordNotFound)
end
end
end
end
Loading
Loading
@@ -6,34 +6,49 @@ describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do
let(:repository) { create(:container_repository) }
let(:project) { repository.project }
let(:user) { project.owner }
let(:params) { { key: 'value' } }
 
subject { described_class.new }
 
describe '#perform' do
let(:service) { instance_double(Projects::ContainerRepository::CleanupTagsService) }
 
before do
allow(Projects::ContainerRepository::CleanupTagsService).to receive(:new)
.with(project, user, params).and_return(service)
context 'bulk delete api' do
let(:params) { { key: 'value', 'container_expiration_policy' => false } }
it 'executes the destroy service' do
expect(Projects::ContainerRepository::CleanupTagsService).to receive(:new)
.with(project, user, params.merge('container_expiration_policy' => false))
.and_return(service)
expect(service).to receive(:execute)
subject.perform(user.id, repository.id, params)
end
it 'does not raise error when user could not be found' do
expect do
subject.perform(-1, repository.id, params)
end.not_to raise_error
end
it 'does not raise error when repository could not be found' do
expect do
subject.perform(user.id, -1, params)
end.not_to raise_error
end
end
 
it 'executes the destroy service' do
expect(service).to receive(:execute)
context 'container expiration policy' do
let(:params) { { key: 'value', 'container_expiration_policy' => true } }
 
subject.perform(user.id, repository.id, params)
end
it 'executes the destroy service' do
expect(Projects::ContainerRepository::CleanupTagsService).to receive(:new)
.with(project, nil, params.merge('container_expiration_policy' => true))
.and_return(service)
 
it 'does not raise error when user could not be found' do
expect do
subject.perform(-1, repository.id, params)
end.not_to raise_error
end
expect(service).to receive(:execute)
 
it 'does not raise error when repository could not be found' do
expect do
subject.perform(user.id, -1, params)
end.not_to raise_error
subject.perform(nil, repository.id, params)
end
end
end
end
Loading
Loading
@@ -1774,10 +1774,9 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=
 
at.js@^1.5.4:
at.js@^1.5.4, "at.js@https://gitlab.com/gitlab-org/frontend/At.js.git#121ce9a557b51c33f5693ac8df52d2bda1e53cbe":
version "1.5.4"
resolved "https://registry.yarnpkg.com/at.js/-/at.js-1.5.4.tgz#8fc60cc80eadbe4874449b166a818e7ae1d784c1"
integrity sha512-G8mgUb/PqShPoH8AyjuxsTGvIr1o716BtQUKDM44C8qN2W615y7KGJ68MlTGamd0J0D/m28emUkzagaHTdrGZw==
resolved "https://gitlab.com/gitlab-org/frontend/At.js.git#121ce9a557b51c33f5693ac8df52d2bda1e53cbe"
 
atob@^2.1.1:
version "2.1.2"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment