Commit 88e0549d authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'ml-ignore-reusable-group-scheduled-for-deletion' into 'master'

Ignore reusable group scheduled for deletion

See merge request gitlab-org/gitlab!81485
parents 53f8e502 0a1b7872
...@@ -36,6 +36,10 @@ module QA ...@@ -36,6 +36,10 @@ module QA
next QA::Runtime::Logger.debug("#{resource.class.name} reused as :#{reuse_as} has already been removed.") unless resource.exists? next QA::Runtime::Logger.debug("#{resource.class.name} reused as :#{reuse_as} has already been removed.") unless resource.exists?
next if resource.respond_to?(:marked_for_deletion?) && resource.marked_for_deletion? next if resource.respond_to?(:marked_for_deletion?) && resource.marked_for_deletion?
if resource.reload!.api_resource[:marked_for_deletion_on].present?
next QA::Runtime::Logger.debug("#{resource.class.name} reused as :#{reuse_as} is already scheduled to be removed.")
end
resource.method(:remove_via_api!).super_method.call resource.method(:remove_via_api!).super_method.call
end end
end end
......
...@@ -20,6 +20,10 @@ RSpec.describe QA::Resource::ReusableCollection do ...@@ -20,6 +20,10 @@ RSpec.describe QA::Resource::ReusableCollection do
end end
def exists?() end def exists?() end
def reload!
Struct.new(:api_resource).new({ marked_for_deletion_on: false })
end
end end
end end
...@@ -88,8 +92,22 @@ RSpec.describe QA::Resource::ReusableCollection do ...@@ -88,8 +92,22 @@ RSpec.describe QA::Resource::ReusableCollection do
it 'removes each instance of each resource class' do it 'removes each instance of each resource class' do
described_class.remove_all_via_api! described_class.remove_all_via_api!
expect(a_resource_instance.removed).to be true expect(a_resource_instance.removed).to be_truthy
expect(another_resource_instance.removed).to be true expect(another_resource_instance.removed).to be_truthy
end
context 'when a resource is marked for deletion' do
before do
marked_for_deletion = Struct.new(:api_resource).new({ marked_for_deletion_on: true })
allow(a_resource_instance).to receive(:reload!).and_return(marked_for_deletion)
allow(another_resource_instance).to receive(:reload!).and_return(marked_for_deletion)
end
it 'does not remove the resource' do
expect(a_resource_instance.removed).to be_falsey
expect(another_resource_instance.removed).to be_falsy
end
end end
end 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