Skip to content

Commit

Permalink
Adapt InstProductLicense to ProductSpec API
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Oct 19, 2021
1 parent 0314718 commit 30f1a00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
27 changes: 4 additions & 23 deletions src/lib/y2packager/clients/inst_product_license.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

require "yast"
require "y2packager/dialogs/inst_product_license"
require "y2packager/medium_type"
require "y2packager/product"
require "y2packager/product_control_product"
require "y2packager/product_spec"
Yast.import "Language"
Yast.import "GetInstArgs"
Yast.import "Mode"
Expand Down Expand Up @@ -54,19 +52,12 @@ def main

# Return the selected base product
#
# @return [Y2Packager::Product]
# @return [Y2Packager::ProductSpec]
# @see Y2Packager::Product.selected_base
def product
return @product if @product

@product = if Y2Packager::MediumType.online?
# in an online installation read the products from the control.xml
Y2Packager::ProductControlProduct.selected
else
# otherwise read the product from the medium
Y2Packager::Product.selected_base
end

@product = Y2Packager::ProductSpec.selected_base
log.warn "No base product is selected for installation" unless @product
@product
end
Expand All @@ -77,17 +68,7 @@ def product
#
# @return [Boolean]
def multi_product_media?
if Y2Packager::MediumType.online?
# in an online installation read the products from the control.xml
Y2Packager::ProductControlProduct.products.size > 1
elsif Y2Packager::MediumType.offline?
# the offline medium always contains several products, but they are
# in separate sub-repositories so we cannot see them in libzypp
true
else
# otherwise read the products from the medium
Y2Packager::Product.available_base_products.size > 1
end
Y2Packager::ProductSpec.base_products.size > 1
end

# Determine whether the product's license should be shown
Expand Down
8 changes: 3 additions & 5 deletions test/lib/clients/inst_product_license_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:dialog) { instance_double(Y2Packager::Dialogs::InstProductLicense, run: :next) }
let(:product) do
instance_double(
Y2Packager::Product,
Y2Packager::ProductSpec,
label: "SLES",
license?: license?,
license_confirmation_required?: confirmation_required?,
Expand All @@ -28,11 +28,9 @@
before do
allow(Y2Packager::Dialogs::InstProductLicense).to receive(:new)
.and_return(dialog)
allow(Y2Packager::Product).to receive(:selected_base).and_return(product)
allow(Y2Packager::Product).to receive(:available_base_products).and_return(products)
allow(Y2Packager::ProductSpec).to receive(:selected_base).and_return(product)
allow(Y2Packager::ProductSpec).to receive(:base_products).and_return(products)
allow(Yast::Mode).to receive(:auto).and_return(auto)
allow(Y2Packager::MediumType).to receive(:online?).and_return(false)
allow(Y2Packager::MediumType).to receive(:offline?).and_return(false)
stub_const("Yast::Language", language)
end

Expand Down

0 comments on commit 30f1a00

Please sign in to comment.