Skip to content

Commit

Permalink
properly mark child addons as registered
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Sep 16, 2014
1 parent f2ed04a commit d33c7f6
Show file tree
Hide file tree
Showing 4 changed files with 872 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/registration/addon.rb
Expand Up @@ -32,8 +32,12 @@ def find_all(registration)

@cached_addons = pure_addons.reduce([]) do |res, addon|
yast_addons = create_addon_with_deps(addon)

# mark as registered if found in the status call
yast_addons.first.registered if activated_addon_ids.include?(addon.id)
yast_addons.each do |yast_addon|
yast_addon.registered if activated_addon_ids.include?(yast_addon.id)
end

res.concat(yast_addons)
end
end
Expand Down Expand Up @@ -75,6 +79,7 @@ def create_addon_with_deps(root)
:eula_url,
:free,
:friendly_name,
:id,
:identifier,
:name,
:product_type,
Expand Down
16 changes: 16 additions & 0 deletions test/addon_spec.rb
Expand Up @@ -4,6 +4,7 @@

require "registration/addon"
require "suse/connect"
require "yaml"

describe Registration::Addon do

Expand Down Expand Up @@ -65,6 +66,21 @@
expect(addon1.registered?).to be_true
expect(addon2.registered?).to be_false
end

it "sets the registration status for dependent addons" do
registration = double(
:activated_products => YAML.load_file(fixtures_file("activated_products.yml")),
:get_addon_list => YAML.load_file(fixtures_file("pure_addons.yml"))
)

addons = Registration::Addon.find_all(registration)

ha = addons.find{ |addon| addon.identifier == "sle-ha"}
ha_geo = ha.children.first

expect(ha.registered?).to be_true
expect(ha_geo.registered?).to be_true
end
end

describe ".selected" do
Expand Down

0 comments on commit d33c7f6

Please sign in to comment.