Skip to content

Commit

Permalink
Fixes #23084 - activation-key copy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjan authored and jlsherrill committed May 4, 2018
1 parent 64110fe commit 556b48d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -97,7 +97,7 @@ def copy
@activation_key.pools.each do |pool|
@new_activation_key.subscribe(pool[:id])
end
@new_activation_key.set_content_overrides(@activation_key.content_overrides)
@new_activation_key.set_content_overrides(@activation_key.content_overrides) unless @activation_key.content_overrides.blank?
respond_for_show(:resource => @new_activation_key)
end

Expand Down
2 changes: 1 addition & 1 deletion app/lib/katello/resources/candlepin/activation_key.rb
Expand Up @@ -88,7 +88,7 @@ def update_content_overrides(id, content_overrides)
client.options[:payload] = attrs_to_delete.to_json
result = client.delete({:accept => :json, :content_type => :json}.merge(User.cp_oauth_header))
end
::Katello::Util::Data.array_with_indifferent_access(JSON.parse(result))
::Katello::Util::Data.array_with_indifferent_access(JSON.parse(result || '{}'))
end

def path(id = nil)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v2/activation_keys_controller_test.rb
Expand Up @@ -173,7 +173,7 @@ def test_copy
assert_equal activation_key_params[:auto_attach], @activation_key.auto_attach
end
content_overrides = [::Katello::ContentOverride.new("foo", :enabled => 1), ::Katello::ContentOverride.new("bar", :enabled => nil)]
@activation_key.expects(:content_overrides).returns(content_overrides)
@activation_key.expects(:content_overrides).at_least_once.returns(content_overrides)

::Katello::Resources::Candlepin::ActivationKey.expects(:update_content_overrides).with do |id, hash|
id.wont_equal(@activation_key.cp_id)
Expand Down

0 comments on commit 556b48d

Please sign in to comment.