Skip to content

Commit

Permalink
Merge pull request #895 from yast/sw_24
Browse files Browse the repository at this point in the history
fix full media product selection (bsc#1179094, bsc#1176424)
  • Loading branch information
wfeldt committed Nov 26, 2020
2 parents 8d4b4c2 + 9875c22 commit df0e3e6
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 21 deletions.
6 changes: 6 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Nov 26 14:06:30 UTC 2020 - Steffen Winterfeldt <snwint@suse.com>

- fix full media product selection (bsc#1179094, bsc#1176424)
- 4.3.21

-------------------------------------------------------------------
Tue Oct 27 22:30:43 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.3.20
Version: 4.3.21
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand Down
20 changes: 16 additions & 4 deletions src/lib/installation/clients/inst_complex_welcome.rb
Expand Up @@ -158,7 +158,7 @@ def setup_final_choice
# list because the dialog will not show the license (we do not know which product we are
# upgrading yet) nor the product selector (as you cannot change the product during upgrade).
#
# @return [Array<Y2Packager::Product>,Array<Y2Packager::ProductControlProduct] List of
# @return [Array<Y2Packager::Product>, Array<Y2Packager::ProductControlProduct, Array<Y2Packager::ProductLocation>] List of
# available base products; if any, a list containing only the forced base product;
# empty list in update mode.
def products
Expand All @@ -171,7 +171,8 @@ def products

# Returns all available base products
#
# @return [Array<Y2Packager::Product>, Array<Y2Packager::ProductControlProduct>] List of available base products
# @return [Array<Y2Packager::Product>, Array<Y2Packager::ProductControlProduct>, Array<Y2Packager::ProductLocation>] List of
# available base products
def available_base_products
return @available_base_products if @available_base_products

Expand Down Expand Up @@ -224,13 +225,24 @@ def disable_buttons
end
end

# Show product selection screen even when only a single product is available.
#
# This serves mainly to delay the license confirmation to a later point
# (when the license has been read).
#
# @return [Boolean] true if product selection is preferred over license
# confirmation
def allow_single_product_selection?
products.size == 1 && !products.first.respond_to?(:license)
end

# Determine whether selected product license should be confirmed
#
# If more than 1 product exists, it is supposed to be accepted later.
#
# @return [Boolean] true if it should be accepted; false otherwise.
def license_confirmation_required?
return false if products.size > 1
return false if products.size > 1 || allow_single_product_selection?
selected_product.license_confirmation_required?
end

Expand All @@ -241,7 +253,7 @@ def license_confirmation_required?
# agreement confirmed when required; false otherwise
def product_selection_finished?
if selected_product.nil?
return true if products.size <= 1
return true if products.size <= 1 && !allow_single_product_selection?
Yast::Popup.Error(_("Please select a product to install."))
return false
elsif license_confirmation_required? && !selected_product.license_confirmed?
Expand Down
4 changes: 2 additions & 2 deletions src/lib/installation/dialogs/complex_welcome.rb
Expand Up @@ -133,11 +133,11 @@ def product_license

# Determine whether the license must be shown
#
# The license will be shown when only one product is available.
# The license will be shown when only one product with license information is available.
#
# @return [Boolean] true if the license must be shown; false otherwise
def show_license?
products.size == 1
products.size == 1 && products.first.respond_to?(:license)
end

# Determine whether some product is available or not
Expand Down
60 changes: 46 additions & 14 deletions test/dialogs/complex_welcome_test.rb
Expand Up @@ -4,6 +4,22 @@
require "installation/dialogs/complex_welcome"

describe Installation::Dialogs::ComplexWelcome do
RSpec.shared_examples "show_license" do
it "shows the product license" do
expect(Y2Packager::Widgets::ProductLicense).to receive(:new)
.with(products.first, skip_validation: true).and_return(license_widget)
expect(widget.contents.to_s).to include("license_widget")
end
end

RSpec.shared_examples "show_selector" do
it "shows the product selector" do
expect(Installation::Widgets::ProductSelector).to receive(:new)
.with(products, skip_validation: true)
expect(widget.contents.to_s).to include("selector_widget")
end
end

subject(:widget) { described_class.new(products) }

let(:products) { [] }
Expand All @@ -27,7 +43,14 @@
end

describe "#content" do
let(:sles_product) { instance_double("Y2Packager::Product", label: "SLES") }
let(:license) { instance_double("Y2Packager::ProductLicense") }
# there are 3 different 'product' classes: Y2Packager::Product, Y2Packager::ProductControlProduct, Y2Packager::ProductLocation
let(:sles_product) { instance_double("Y2Packager::Product", label: "SLES", license: license) }
let(:sles_online_product) { instance_double("Y2Packager::ProductControlProduct", label: "SLES", license: license) }
let(:sles_offline_product) { instance_double("Y2Packager::ProductLocation", label: "SLES") }
let(:sled_product) { instance_double("Y2Packager::Product", label: "SLED", license: license) }
let(:sled_online_product) { instance_double("Y2Packager::ProductControlProduct", label: "SLED", license: license) }
let(:sled_offline_product) { instance_double("Y2Packager::ProductLocation", label: "SLED") }
let(:language_widget) { Yast::Term.new(:language_widget) }
let(:keyboard_widget) { Yast::Term.new(:keyboard_widget) }
let(:license_widget) { Yast::Term.new(:license_widget) }
Expand All @@ -50,23 +73,32 @@
end

context "when only 1 product is available" do
let(:products) { [sles_product] }

it "shows the product license" do
expect(Y2Packager::Widgets::ProductLicense).to receive(:new)
.with(products.first, skip_validation: true).and_return(license_widget)
expect(widget.contents.to_s).to include("license_widget")
context "when it is the normal medium" do
let(:products) { [sles_product] }
include_examples "show_license"
end
context "when it is the online medium" do
let(:products) { [sles_online_product] }
include_examples "show_license"
end
context "when it is the offline medium" do
let(:products) { [sles_offline_product] }
include_examples "show_selector"
end
end

context "when more than 1 product is available" do
let(:sled_product) { instance_double("Y2Packager::Product", label: "SLED") }
let(:products) { [sles_product, sled_product] }

it "shows the product selector" do
expect(Installation::Widgets::ProductSelector).to receive(:new)
.with(products, skip_validation: true)
expect(widget.contents.to_s).to include("selector_widget")
context "when it is the normal medium" do
let(:products) { [sles_product, sled_product] }
include_examples "show_selector"
end
context "when it is the online medium" do
let(:products) { [sles_online_product, sled_online_product] }
include_examples "show_selector"
end
context "when it is the offline medium" do
let(:products) { [sles_offline_product, sled_offline_product] }
include_examples "show_selector"
end
end
end
Expand Down

0 comments on commit df0e3e6

Please sign in to comment.