Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #23084 - activation-key copy fix #7345

Merged
merged 1 commit into from May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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