Commit b1f18a67 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '6119-extract-ee-specific-files-lines-for-spec-services-groups' into 'master'

Resolve "Extract EE specific files/lines for spec/services/groups"

Closes #6119

See merge request gitlab-org/gitlab-ee!10536
parents 85e20b5e 64775ced
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Groups::CreateService, '#execute' do
let!(:user) { create :user }
let!(:opts) do
let!(:group_params) do
{
name: 'GitLab',
path: 'group_path',
......@@ -12,7 +12,7 @@ describe Groups::CreateService, '#execute' do
context 'audit events' do
include_examples 'audit event logging' do
let(:operation) { create_group(user, opts) }
let(:operation) { create_group(user, group_params) }
let(:fail_condition!) do
allow(Gitlab::VisibilityLevel).to receive(:allowed_for?).and_return(false)
end
......@@ -33,6 +33,30 @@ describe Groups::CreateService, '#execute' do
end
end
context 'repository_size_limit assignment as Bytes' do
let(:admin_user) { create(:user, admin: true) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'assign repository_size_limit as Bytes' do
group = create_group(admin_user, group_params.merge(opts))
expect(group.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
group = create_group(admin_user, group_params.merge(opts))
expect(group.repository_size_limit).to be_nil
end
end
end
def create_group(user, opts)
described_class.new(user, opts).execute
end
......
......@@ -130,6 +130,30 @@ describe Groups::UpdateService, '#execute' do
end
end
context 'repository_size_limit assignment as Bytes' do
let(:group) { create(:group, :public, repository_size_limit: 0) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'converts from MB to Bytes' do
update_group(group, user, opts)
expect(group.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_group(group, user, opts)
expect(group.reload.repository_size_limit).to be_nil
end
end
end
def update_group(group, user, opts)
Groups::UpdateService.new(group, user, opts).execute
end
......
......@@ -88,31 +88,6 @@ describe Groups::CreateService, '#execute' do
end
end
context 'repository_size_limit assignment as Bytes' do
let(:admin_user) { create(:user, admin: true) }
let(:service) { described_class.new(admin_user, group_params.merge(opts)) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'assign repository_size_limit as Bytes' do
group = service.execute
expect(group.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
group = service.execute
expect(group.repository_size_limit).to be_nil
end
end
end
describe 'creating a mattermost team' do
let!(:params) { group_params.merge(create_chat_team: "true") }
let!(:service) { described_class.new(user, params) }
......
......@@ -82,31 +82,6 @@ describe Groups::UpdateService do
end
end
context 'repository_size_limit assignment as Bytes' do
let(:group) { create(:group, :public, repository_size_limit: 0) }
let(:service) { described_class.new(group, user, opts) }
context 'when param present' do
let(:opts) { { repository_size_limit: '100' } }
it 'converts from MB to Bytes' do
service.execute
expect(group.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
service.execute
expect(group.reload.repository_size_limit).to be_nil
end
end
end
context "unauthorized visibility_level validation" do
let!(:service) { described_class.new(internal_group, user, visibility_level: 99) }
before do
......
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