Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Created July 1, 2014 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddavis/e99d788dd1c23ee000b6 to your computer and use it in GitHub Desktop.
Save daviddavis/e99d788dd1c23ee000b6 to your computer and use it in GitHub Desktop.
diff --git a/app/models/katello/content_view.rb b/app/models/katello/content_view.rb
index 509762b..f37a37c 100644
--- a/app/models/katello/content_view.rb
+++ b/app/models/katello/content_view.rb
@@ -448,11 +448,6 @@ class ContentView < Katello::Model
self.content_view_environments.where(:environment_id => environment.try(:id)).first
end
- def update_cp_content(env)
- view_env = content_view_environment(env)
- view_env.update_cp_content if view_env
- end
-
# Associate an environment with this content view. This can occur whenever
# a version of the view is promoted to an environment. It is necessary for
# candlepin to become aware that the view is available for consumers.
diff --git a/app/models/katello/glue/candlepin/content.rb b/app/models/katello/glue/candlepin/content.rb
index 20634e5..80625a5 100644
--- a/app/models/katello/glue/candlepin/content.rb
+++ b/app/models/katello/glue/candlepin/content.rb
@@ -19,7 +19,6 @@ module Glue::Candlepin::Content
base.class_eval do
before_save :save_content_orchestration
- after_destroy :update_environment_content
after_create :rectify_gpg_key_orchestration
end
end
@@ -36,10 +35,6 @@ module Glue::Candlepin::Content
end
end
- def update_environment_content
- self.content_view.update_cp_content(self.environment)
- end
-
def rectify_gpg_key_orchestration
#if we are creating a repo with a gpg key, we have to create the content without the gpg key
# and then update the content with the gpg key (since repo needs content created before it is actually saved
diff --git a/app/models/katello/glue/candlepin/environment.rb b/app/models/katello/glue/candlepin/environment.rb
index e8142e6..c23c03c 100644
--- a/app/models/katello/glue/candlepin/environment.rb
+++ b/app/models/katello/glue/candlepin/environment.rb
@@ -41,32 +41,6 @@ module Glue::Candlepin::Environment
"#{self.label}: #{e}, #{e.backtrace.join("\n")}"
fail e
end
-
- def update_cp_content
- all_env_ids = all_env_content_ids
- saved_cp_ids = saved_env_content_ids
-
- add_ids = all_env_ids - saved_cp_ids
- Resources::Candlepin::Environment.add_content(self.cp_id, add_ids) unless add_ids.empty?
-
- delete_ids = saved_cp_ids - all_env_ids.to_a
- Resources::Candlepin::Environment.delete_content(self.cp_id, delete_ids) unless delete_ids.empty?
- end
-
- protected
-
- def all_env_content_ids
- self.content_view.repos(self.owner).select{|r| r.yum?}.reduce(Set.new) do |env_content_ids, repo|
- env_content_ids << repo.content_id
- end
- end
-
- def saved_env_content_ids
- Resources::Candlepin::Environment.find(self.cp_id)[:environmentContent].map do |content|
- content[:contentId]
- end
- end
-
end
end
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index b872935..d1d34e9 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -187,38 +187,6 @@ describe KTEnvironment do
@organization.library.must_be :valid?
end
end
-
- describe "updating CP content assignment" do
- it "should add content not already promoted" do
- @content_view_environment = @environment.content_views.first.
- content_view_environments.where(:environment_id=>@environment.id).first
- already_promoted_content("123", "456")
- newly_promoted_content("123", "456", "789", "10")
- Resources::Candlepin::Environment.expects(:add_content).with(@content_view_environment.cp_id,
- Set.new(["789", "10"]))
- @content_view_environment.update_cp_content
- end
-
- def already_promoted_content(*content_ids)
- @already_promoted_content_ids = content_ids
- Resources::Candlepin::Environment.stubs(:find).returns(
- {:environmentContent => @already_promoted_content_ids.map {|id| {:contentId => id}}})
- end
-
- def newly_promoted_content(*content_ids)
- promoted_repos = content_ids.map do |id|
- repo = stub
- repo.stubs(:content_id).returns(id)
- repo.stubs(:yum?).returns(true)
- repo
- end
-
- content_view = stub
- content_view.stubs(:repos).returns(promoted_repos)
- @content_view_environment.stubs(:content_view).returns(content_view)
- end
- end
-
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment