Commit 19bac158 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '6519-extract-ee-specific-files-lines-for-spec-services-projects-update_service_spec-rb' into 'master'

Extract EE lines for spec/services/projects/update_service_spec.rb

Closes #6519

See merge request gitlab-org/gitlab-ee!10583
parents 0c469979 26fdc902
......@@ -252,6 +252,72 @@ describe Projects::UpdateService, '#execute' do
end
end
describe 'repository_storage' do
let(:admin_user) { create(:user, admin: true) }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:opts) { { repository_storage: 'b' } }
before do
FileUtils.mkdir('tmp/tests/storage_b')
storages = {
'default' => Gitlab.config.repositories.storages.default,
'b' => { 'path' => 'tmp/tests/storage_b' }
}
stub_storage_settings(storages)
end
after do
FileUtils.rm_rf('tmp/tests/storage_b')
end
it 'calls the change repository storage method if the storage changed' do
expect(project).to receive(:change_repository_storage).with('b')
update_project(project, admin_user, opts).inspect
end
it "doesn't call the change repository storage for non-admin users" do
expect(project).not_to receive(:change_repository_storage)
update_project(project, user, opts).inspect
end
end
context 'repository_size_limit assignment as Bytes' do
let(:admin_user) { create(:user, admin: true) }
let(:project) { create(:project, repository_size_limit: 0) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'converts from MB to Bytes' do
update_project(project, admin_user, opts)
expect(project.reload.repository_size_limit).to eql(100 * 1024 * 1024)
end
end
context 'when param not present' do
let(:opts) { { repository_size_limit: '' } }
it 'assign nil value' do
update_project(project, admin_user, opts)
expect(project.reload.repository_size_limit).to be_nil
end
end
end
it 'returns an error result when record cannot be updated' do
admin = create(:admin)
result = update_project(project, admin, { name: 'foo&bar' })
expect(result).to eq({ status: :error, message: "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'." })
end
def update_project(project, user, opts)
Projects::UpdateService.new(project, user, opts).execute
end
......
require 'spec_helper'
describe Projects::UpdateService, '#execute' do
include StubConfiguration
describe Projects::UpdateService do
include ProjectForksHelper
let(:user) { create(:user) }
......@@ -419,72 +418,6 @@ describe Projects::UpdateService, '#execute' do
end
end
describe 'repository_storage' do
let(:admin_user) { create(:user, admin: true) }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:opts) { { repository_storage: 'b' } }
before do
FileUtils.mkdir('tmp/tests/storage_b')
storages = {
'default' => Gitlab.config.repositories.storages.default,
'b' => { 'path' => 'tmp/tests/storage_b' }
}
stub_storage_settings(storages)
end
after do
FileUtils.rm_rf('tmp/tests/storage_b')
end
it 'calls the change repository storage method if the storage changed' do
expect(project).to receive(:change_repository_storage).with('b')
update_project(project, admin_user, opts).inspect
end
it "doesn't call the change repository storage for non-admin users" do
expect(project).not_to receive(:change_repository_storage)
update_project(project, user, opts).inspect
end
end
context 'repository_size_limit assignment as Bytes' do
let(:admin_user) { create(:user, admin: true) }
let(:project) { create(:project, repository_size_limit: 0) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'converts from MB to Bytes' do
update_project(project, admin_user, opts)
expect(project.reload.repository_size_limit).to eql(100 * 1024 * 1024)
end
end
context 'when param not present' do
let(:opts) { { repository_size_limit: '' } }
it 'assign nil value' do
update_project(project, admin_user, opts)
expect(project.reload.repository_size_limit).to be_nil
end
end
end
it 'returns an error result when record cannot be updated' do
admin = create(:admin)
result = update_project(project, admin, { name: 'foo&bar' })
expect(result).to eq({ status: :error, message: "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'." })
end
def update_project(project, user, opts)
described_class.new(project, user, opts).execute
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment