Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/groups/create_service_spec.rb')
-rw-r--r--spec/services/groups/create_service_spec.rb41
1 files changed, 39 insertions, 2 deletions
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index bcba39b0eb4..7ea08131419 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -171,7 +171,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active group-level integration' do
let(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
- let!(:group_integration) { create(:prometheus_integration, group: group, project: nil, api_url: 'https://prometheus.group.com/') }
+ let!(:group_integration) { create(:prometheus_integration, :group, group: group, api_url: 'https://prometheus.group.com/') }
let(:group) do
create(:group).tap do |group|
group.add_owner(user)
@@ -186,7 +186,7 @@ RSpec.describe Groups::CreateService, '#execute' do
context 'with an active subgroup' do
let(:service) { described_class.new(user, group_params.merge(parent_id: subgroup.id)) }
- let!(:subgroup_integration) { create(:prometheus_integration, group: subgroup, project: nil, api_url: 'https://prometheus.subgroup.com/') }
+ let!(:subgroup_integration) { create(:prometheus_integration, :group, group: subgroup, api_url: 'https://prometheus.subgroup.com/') }
let(:subgroup) do
create(:group, parent: group).tap do |subgroup|
subgroup.add_owner(user)
@@ -242,4 +242,41 @@ RSpec.describe Groups::CreateService, '#execute' do
end
end
end
+
+ describe 'invite team email' do
+ let(:service) { described_class.new(user, group_params) }
+
+ before do
+ allow(Namespaces::InviteTeamEmailWorker).to receive(:perform_in)
+ end
+
+ it 'is sent' do
+ group = service.execute
+ delay = Namespaces::InviteTeamEmailService::DELIVERY_DELAY_IN_MINUTES
+ expect(Namespaces::InviteTeamEmailWorker).to have_received(:perform_in).with(delay, group.id, user.id)
+ end
+
+ context 'when group has not been persisted' do
+ let(:service) { described_class.new(user, group_params.merge(name: '<script>alert("Attack!")</script>')) }
+
+ it 'not sent' do
+ expect(Namespaces::InviteTeamEmailWorker).not_to receive(:perform_in)
+ service.execute
+ end
+ end
+
+ context 'when group is not root' do
+ let(:parent_group) { create :group }
+ let(:service) { described_class.new(user, group_params.merge(parent_id: parent_group.id)) }
+
+ before do
+ parent_group.add_owner(user)
+ end
+
+ it 'not sent' do
+ expect(Namespaces::InviteTeamEmailWorker).not_to receive(:perform_in)
+ service.execute
+ end
+ end
+ end
end