2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe GroupDestroyWorker, feature_category: :subgroups do
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project) { create(:project, namespace: group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
subject(:worker) { described_class.new }
|
|
|
|
|
|
|
|
include_examples 'an idempotent worker' do
|
|
|
|
let(:job_args) { [group.id, user.id] }
|
|
|
|
|
|
|
|
it 'does not change groups when run twice' do
|
|
|
|
expect { worker.perform(group.id, user.id) }.to change { Group.count }.by(-1)
|
|
|
|
expect { worker.perform(group.id, user.id) }.not_to change { Group.count }
|
|
|
|
end
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
describe "#perform" do
|
2023-05-27 22:25:52 +05:30
|
|
|
it "deletes the group and associated projects" do
|
|
|
|
worker.perform(group.id, user.id)
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
expect(Group.all).not_to include(group)
|
|
|
|
expect(Project.all).not_to include(project)
|
|
|
|
expect(Dir.exist?(project.path)).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|