Skip to content

Commit

Permalink
813427 - do not delete repos from Red Hat Providers
Browse files Browse the repository at this point in the history
since candlepin will reuse content objects globally
across owners, we should not delete content from
candlepin unless it is a custom provider
  • Loading branch information
jlsherrill committed Apr 19, 2012
1 parent 50dc43d commit c89ceaf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/app/models/glue/pulp/repo.rb
Expand Up @@ -202,10 +202,9 @@ def destroy_repo

def del_content
return true unless self.content_id

if other_repos_with_same_product_and_content.empty?
self.product.remove_content_by_id self.content_id
if other_repos_with_same_content.empty?
if other_repos_with_same_content.empty? && !self.product.provider.redhat_provider?
Candlepin::Content.destroy(self.content_id)
end
end
Expand Down
28 changes: 24 additions & 4 deletions src/spec/models/repo_spec.rb
Expand Up @@ -24,8 +24,6 @@
}
end



before :each do
disable_repo_orchestration
disable_org_orchestration
Expand All @@ -37,11 +35,19 @@
p.organization = @organization
end



@product1 = Product.create!({:cp_id => "product1_id", :name=> "product1", :productContent => [], :provider => @provider, :environments => [@organization.library]})
ep = EnvironmentProduct.find_or_create(@organization.library, @product1)
RepoTestData::REPO_PROPERTIES.merge!(:environment_product => ep)

@repo = Repository.create!(RepoTestData::REPO_PROPERTIES)

@rh_product = Product.create!({:cp_id => "rh_product1_id", :name=> "rh_product1", :productContent => [],
:provider => @organization.redhat_provider, :environments => [@organization.library]})
ep2 = EnvironmentProduct.find_or_create(@organization.library, @rh_product)
@rh_repo = Repository.create!(:name=>"red hat repo", :environment_product=>ep2, :pulp_id=>"redhat_pulp_id", :uri=>"http://redhat.com/cdn/content")

end

context "Create & destroy a repo" do
Expand All @@ -57,11 +63,25 @@
@repo.create_pulp_repo
end

it "should call the Pulp's delete api on destroy" do
it "should call Pulp and candlepin's delete api on destroy for custom providers" do
@repo.stub(:update_packages_index).and_return
@repo.stub(:update_errata_index).and_return
@repo.stub(:content_id).and_return("124321323")
Candlepin::Product.should_receive(:remove_content)
Candlepin::Content.should_receive(:destroy)
Pulp::Repository.should_receive(:destroy).with(RepoTestData::REPO_ID)
@repo.destroy_repo
@repo.destroy
end

it "should only call Pulp's repo delete api on destroy for redhat providers" do
@rh_repo.stub(:update_packages_index).and_return
@rh_repo.stub(:update_errata_index).and_return
@rh_repo.stub(:content_id).and_return("124321323")
Pulp::Repository.stub(:find).and_return({:groupid=>["product:123", "env:123", "org:123"]})
Candlepin::Product.should_receive(:remove_content)
Candlepin::Content.should_not_receive(:destroy)
Pulp::Repository.should_receive(:destroy).with(@rh_repo.pulp_id)
@rh_repo.destroy
end
end

Expand Down

0 comments on commit c89ceaf

Please sign in to comment.