Hello community, here is the log from the commit of package yast2-installation for openSUSE:Factory checked in at 2018-03-26 12:17:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-installation (Old) and /work/SRC/openSUSE:Factory/.yast2-installation.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-installation" Mon Mar 26 12:17:31 2018 rev:399 rq:590705 version:4.0.42 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-installation/yast2-installation.changes 2018-03-14 19:34:54.218012605 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-installation.new/yast2-installation.changes 2018-03-26 12:17:36.451548813 +0200 @@ -1,0 +2,22 @@ +Fri Mar 23 09:57:56 UTC 2018 - mvid...@suse.com + +- System roles: make the radio buttons match other dialogs, + using images (bsc#1084674) +- 4.0.42 + +------------------------------------------------------------------- +Tue Mar 20 16:10:24 UTC 2018 - mvid...@suse.com + +- Make many system roles fit in the dialog (using a RichText + widget, bsc#1084674) +- 4.0.41 + +------------------------------------------------------------------- +Mon Mar 19 22:53:57 UTC 2018 - knut.anders...@suse.com + +- Self-Update report errors when the self_update is enabled + explicitly by linuxrc or using an AutoYaST profile. + (bsc#1084820) +- 4.0.40 + +------------------------------------------------------------------- Old: ---- yast2-installation-4.0.39.tar.bz2 New: ---- yast2-installation-4.0.42.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-installation.spec ++++++ --- /var/tmp/diff_new_pack.qooGZ3/_old 2018-03-26 12:17:37.323517545 +0200 +++ /var/tmp/diff_new_pack.qooGZ3/_new 2018-03-26 12:17:37.323517545 +0200 @@ -17,7 +17,7 @@ Name: yast2-installation -Version: 4.0.39 +Version: 4.0.42 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-installation-4.0.39.tar.bz2 -> yast2-installation-4.0.42.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/doc/SELF_UPDATE.md new/yast2-installation-4.0.42/doc/SELF_UPDATE.md --- old/yast2-installation-4.0.39/doc/SELF_UPDATE.md 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/doc/SELF_UPDATE.md 2018-03-23 15:04:28.000000000 +0100 @@ -111,9 +111,19 @@ required just like in manual installation. 4. Default SUSE Customer Center API (`https://scc.suse.com/`). - Registration server is then asked for URL providing product on media. - For multi-product media it is possible to specify ID used instead of product - name in control.xml as globals->self_update_id. + The registration server is then asked for the list of update repositories. + In order to determine such list, the product `name`, `version` and + `architecture` are used + + In case of a multi-product installation medium, as the installer is the same + for all the included products, the product `name` can be hard-coded in the + `control.xml` file with the `/globals/self_update_id` XML node. + + ```xml + <globals> + <self_update_id>SLES</self_update_id> + </globals> + ``` 4. Hard-coded in the `control.xml` file on the installation medium (thus it depends on the base product): @@ -249,6 +259,9 @@ * If SCC/SMT is used and it returns no URL or fails then the fallback URL from `control.xml` is used. * If the updates repository is found but it is empty or not valid: + * if the installer update was enabled explicitly (using the *SelfUpdate* boot + option or through the *self_update* element in an AutoYaST profile), an error + will be shown. * in the case that the URL was specified by the user (using the *SelfUpdate* boot option or through the *self_update_url* element in an AutoYaST profile), an error message will be shown. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/package/yast2-installation.changes new/yast2-installation-4.0.42/package/yast2-installation.changes --- old/yast2-installation-4.0.39/package/yast2-installation.changes 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/package/yast2-installation.changes 2018-03-23 15:04:28.000000000 +0100 @@ -1,4 +1,26 @@ ------------------------------------------------------------------- +Fri Mar 23 09:57:56 UTC 2018 - mvid...@suse.com + +- System roles: make the radio buttons match other dialogs, + using images (bsc#1084674) +- 4.0.42 + +------------------------------------------------------------------- +Tue Mar 20 16:10:24 UTC 2018 - mvid...@suse.com + +- Make many system roles fit in the dialog (using a RichText + widget, bsc#1084674) +- 4.0.41 + +------------------------------------------------------------------- +Mon Mar 19 22:53:57 UTC 2018 - knut.anders...@suse.com + +- Self-Update report errors when the self_update is enabled + explicitly by linuxrc or using an AutoYaST profile. + (bsc#1084820) +- 4.0.40 + +------------------------------------------------------------------- Tue Mar 13 16:37:23 UTC 2018 - igonzalezs...@suse.com - Set the 'ro' property on Btrfs filesystem when using an AutoYaST diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/package/yast2-installation.spec new/yast2-installation-4.0.42/package/yast2-installation.spec --- old/yast2-installation-4.0.39/package/yast2-installation.spec 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/package/yast2-installation.spec 2018-03-23 15:04:28.000000000 +0100 @@ -16,7 +16,7 @@ # Name: yast2-installation -Version: 4.0.39 +Version: 4.0.42 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/src/lib/installation/select_system_role.rb new/yast2-installation-4.0.42/src/lib/installation/select_system_role.rb --- old/yast2-installation-4.0.39/src/lib/installation/select_system_role.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/src/lib/installation/select_system_role.rb 2018-03-23 15:04:28.000000000 +0100 @@ -17,6 +17,7 @@ # To contact SUSE about this file by physical or electronic mail, # you may find current contact information at www.suse.com +require "cgi" require "yast" require "ui/installation_dialog" require "installation/services" @@ -72,19 +73,21 @@ end def dialog_content - HSquash(VBox(role_buttons)) + @selected_role_id = self.class.original_role_id + @selected_role_id ||= roles.first && roles.first.id if SystemRole.default? + + HCenter(ReplacePoint(Id(:rp), role_buttons(selected_role_id: @selected_role_id))) end def create_dialog clear_role ok = super - role_id = self.class.original_role_id || (roles.first && roles.first.id) - Yast::UI.ChangeWidget(Id(:roles), :CurrentButton, role_id) + Yast::UI.SetFocus(Id(:roles_richtext)) if ok ok end def next_handler - role_id = Yast::UI.QueryWidget(Id(:roles), :CurrentButton) + role_id = @selected_role_id if role_id.nil? # no role selected (bsc#1078809) # An Error popup @@ -116,6 +119,19 @@ end end + # called if a specific FOO_handler is not defined + def handle_event(id) + role = SystemRole.find(id) + if role.nil? + log.info "Not a role: #{id.inspect}, skipping" + return + end + + @selected_role_id = id + Yast::UI.ReplaceWidget(Id(:rp), role_buttons(selected_role_id: id)) + Yast::UI.SetFocus(Id(:roles_richtext)) + end + private # gets array of clients to run for given role @@ -170,15 +186,6 @@ Yast::ProductFeatures.ClearOverlay end - # Returns the content for the role buttons - # - # @return [Yast::Term] Role buttons - # - # @see role_buttons_options - def role_buttons - role_buttons_content(role_buttons_options) - end - # Applies given role to configuration def apply_role(role) log.info "Applying system role '#{role.id}'" @@ -210,114 +217,65 @@ SystemRole.all end - # Returns the content for the role buttons according to the available space - # - # @param separation [Integer] Separation between roles - # @param indentation [Integer] Roles indentation - # @param margin [Integer] Top marging - # @param description [Boolean] Indicates whether the description should be included + # Returns the content for the role buttons + # @param selected_role_id [String] which role radiobutton gets selected # @return [Yast::Term] Role buttons - def role_buttons_content(margin: 2, indentation: 4, separation: 2, description: true, show_intro: true) - box = [] - box << Left(Label(Yast::ProductControl.GetTranslatedText("roles_text"))) if show_intro - box << VSpacing(margin) unless margin.zero? - - ui_roles = roles.each_with_object(box) do |role, vbox| + def role_buttons(selected_role_id:) + role_rt_radios = roles.map do |role| # FIXME: following workaround can be removed as soon as bsc#997402 is fixed: # bsc#995082: System role descriptions use a character that is missing in console font - role_description = Yast::UI.TextMode ? role.description.tr("•", "*") : role.description - vbox << Left(RadioButton(Id(role.id), role.label)) - vbox << HBox(HSpacing(indentation), Left(Label(role_description))) if description - vbox << VSpacing(separation) unless roles.last == role || separation.zero? - end - - RadioButtonGroup(Id(:roles), VBox(*ui_roles)) - end - - # Default role buttons options for the Qt UI - DEFAULT_ROLE_BUTTONS_QT_OPTS = { - indentation: 4, - margin: 2, - separation: 2, - show_intro: true, - description: true - }.freeze - - # Default role buttons options for the textmode UI - DEFAULT_ROLE_BUTTONS_TEXT_OPTS = { - indentation: 2, - margin: 1, - separation: 2, - show_intro: true, - description: true - }.freeze - - def intro_text - @intro_text ||= Yast::ProductControl.GetTranslatedText("roles_text") - end - - # Space for roles - # - # @return [Hash] Options to distribute roles - # - # @see available_lines_for_roles - def role_buttons_options - return DEFAULT_ROLE_BUTTONS_QT_OPTS unless Yast::UI.TextMode - - opts = textmode_role_buttons_options - log.info "Options for role buttons: #{opts.inspect}" - opts - end - - # Returns space options for roles in textmode - # - # @return [Hash] Options to distribute roles - def textmode_role_buttons_options - opts = DEFAULT_ROLE_BUTTONS_TEXT_OPTS.dup - - # Set separation - separation = [ - DEFAULT_ROLE_BUTTONS_TEXT_OPTS[:separation], - (available_lines_for_roles - needed_lines_for_roles - opts[:margin]) / 2 - ].min - separation = 0 if separation < 0 - opts = DEFAULT_ROLE_BUTTONS_TEXT_OPTS.merge(separation: separation) - - # Set intro size - intro_lines = intro_text.lines.size + description = Yast::UI.TextMode ? role.description.tr("•", "*") : role.description - # No space for descriptions - opts[:description] = false if needed_lines_for_roles > available_lines_for_roles - - # No space for margin - opts[:margin] = 0 if roles.size + intro_lines + opts[:margin] > available_lines_for_roles - - # No space for intro - opts[:show_intro] = false if roles.size + intro_lines > available_lines_for_roles + rb = richtext_radiobutton(id: role.id, + label: role.label, + selected: role.id == selected_role_id) + + description = CGI.escape_html(description).gsub("\n", "<br>\n") + # extra empty paragraphs for better spacing + "<p></p>#{rb}<p></p><ul>#{description}</ul>" + end - opts + intro_text = Yast::ProductControl.GetTranslatedText("roles_text") + VBox( + Left(Label(intro_text)), + VSpacing(2), + RichText(Id(:roles_richtext), role_rt_radios.join("\n")) + ) end - # Number of required lines to show roles information and buttons - # - # Title + Descriptions - # - # @return [Integer] Number of lines needed to display roles information - def needed_lines_for_roles - return @needed_lines_for_roles if @needed_lines_for_roles - texts = roles.map(&:description) - texts << intro_text unless intro_text.nil? - lines_qty = texts.compact.map(&:lines).map(&:size).reduce(:+) - @needed_lines_for_roles = roles.size + lines_qty + def richtext_radiobutton(id:, label:, selected:) + if Yast::UI.TextMode + richtext_radiobutton_tui(id: id, label: label, selected: selected) + else + richtext_radiobutton_gui(id: id, label: label, selected: selected) + end end - # Space taken by header/footer and not available for the roles buttons - RESERVED_LINES = 4 - # Returns an estimation of the available space for displaying the roles buttons - # - # @return [Integer] Estimated amount of available space - def available_lines_for_roles - @available_lines_for_roles ||= Yast::UI.GetDisplayInfo()["Height"] - RESERVED_LINES + def richtext_radiobutton_tui(id:, label:, selected:) + check = selected ? "(x)" : "( )" + widget = "#{check} #{CGI.escape_html(label)}" + enabled_widget = "<a href=\"#{id}\">#{widget}</a>" + "#{enabled_widget}<br>" + end + + IMAGE_DIR = "/usr/share/YaST2/theme/current/wizard".freeze + + BUTTON_ON = "◉".freeze # U+25C9 Fisheye + BUTTON_OFF = "○".freeze # U+25CB White Circle + + def richtext_radiobutton_gui(id:, label:, selected:) + # check for installation style, which is dark, FIXME: find better way + installation = ENV["Y2STYLE"] == "installation.qss" + if installation + image = selected ? "inst_radio-button-checked.png" : "inst_radio-button-unchecked.png" + bullet = "<img src=\"#{IMAGE_DIR}/#{image}\"></img>" + else + bullet = selected ? BUTTON_ON : BUTTON_OFF + end + widget = "#{bullet} #{CGI.escape_html(label)}" + color = installation ? "white" : "black" + enabled_widget = "<a style='text-decoration:none; color:#{color}' href=\"#{id}\">#{widget}</a>" + "<p>#{enabled_widget}</p>" end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/src/lib/installation/update_repositories_finder.rb new/yast2-installation-4.0.42/src/lib/installation/update_repositories_finder.rb --- old/yast2-installation-4.0.39/src/lib/installation/update_repositories_finder.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/src/lib/installation/update_repositories_finder.rb 2018-03-23 15:04:28.000000000 +0100 @@ -25,6 +25,7 @@ Yast.import "Mode" Yast.import "Profile" Yast.import "ProductFeatures" +Yast.import "InstFunctions" module Installation # Invalid registration URL error @@ -141,7 +142,8 @@ # Set custom_url into installation options Registration::Storage::InstallationOptions.instance.custom_url = registration.url - handle_registration_errors(custom_regserver) do + show_errors = custom_regserver || Yast::InstFunctions.self_update_explicitly_enabled? + handle_registration_errors(show_errors) do registration.get_updates_list.map { |u| URI(u.url) } end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/src/modules/InstFunctions.rb new/yast2-installation-4.0.42/src/modules/InstFunctions.rb --- old/yast2-installation-4.0.39/src/modules/InstFunctions.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/src/modules/InstFunctions.rb 2018-03-23 15:04:28.000000000 +0100 @@ -30,6 +30,7 @@ module Yast class InstFunctionsClass < Module + include Yast::Logger def main textdomain "installation" @@ -38,6 +39,8 @@ Yast.import "Stage" Yast.import "Mode" Yast.import "ProductControl" + Yast.import "Profile" + Yast.import "SCR" end # Returns list of ignored features defined via Linuxrc commandline @@ -131,12 +134,42 @@ end alias_method :second_stage_required, :second_stage_required? + # Determine whether the installer update has been explicitly enabled by + # linuxrc or by the AY profile. + # + # return [Boolean] true if enabled explicitly; false otherwise + def self_update_explicitly_enabled? + # Linuxrc always export SelfUpdate with the default value even if not has + # been set by the user. For that reason we need to check the cmdline for + # knowing whether the user has requested the self update explicitly. + if self_update_in_cmdline? + log.info("Self update was enabled explicitly by linuxrc cmdline") + return true + end + + return false unless Mode.auto + + profile = Profile.current + in_profile = profile.fetch("general", {}).fetch("self_update", false) + log.info("Self update was enabled explicitly by the AY profile") if in_profile + in_profile + end + publish function: :ignored_features, type: "list ()" publish function: :feature_ignored?, type: "boolean (string)" publish function: :second_stage_required, type: "boolean ()" private + # Return whether self_update has been explicitly enabled by linuxrc or not + # + # return [Boolean] true if enabled; false otherwise + def self_update_in_cmdline? + cmdline = polish(SCR.Read(path(".target.string"), "/proc/cmdline").to_s) + + cmdline.split.any? { |s| s.start_with?("selfupdate=") && s != "selfupdate=0" } + end + # Removes unneeded characters from the given string # for easier handling # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/test/inst_functions_test.rb new/yast2-installation-4.0.42/test/inst_functions_test.rb --- old/yast2-installation-4.0.39/test/inst_functions_test.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/test/inst_functions_test.rb 2018-03-23 15:04:28.000000000 +0100 @@ -262,4 +262,49 @@ end end end + + describe "#self_update_explicitly_enabled?" do + let(:self_update_in_cmdline) { false } + before do + allow(Yast::Linuxrc).to receive(:value_for).with("self_update") + .and_return(self_update_in_cmdline) + allow(subject).to receive(:self_update_in_cmdline?) + .and_return(self_update_in_cmdline) + end + + context "when self_update=1 is provided by linuxrc" do + let(:self_update_in_cmdline) { true } + it "returns true" do + expect(subject.self_update_explicitly_enabled?).to eq true + end + end + + context "when self_update=custom_url is provided by linuxrc" do + let(:self_update_in_cmdline) { true } + it "returns true" do + expect(subject.self_update_explicitly_enabled?).to eq true + end + end + + context "when self_update is explicitly enabled in an AutoYaST profile" do + let(:profile) { { "general" => { "self_update" => true } } } + + it "returns true" do + allow(Yast::Mode).to receive("auto").and_return(true) + allow(Yast::Profile).to receive("current").and_return(profile) + + expect(subject.self_update_explicitly_enabled?).to eq true + end + end + + context "when sel_update has not been explicitly enabled" do + it "returns false" do + stub_install_inf("Cmdline" => nil) + allow(Yast::Mode).to receive("auto").and_return(true) + allow(Yast::Profile).to receive("current").and_return({}) + + expect(subject.self_update_explicitly_enabled?).to eq false + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/test/lib/update_repositories_finder_test.rb new/yast2-installation-4.0.42/test/lib/update_repositories_finder_test.rb --- old/yast2-installation-4.0.39/test/lib/update_repositories_finder_test.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/test/lib/update_repositories_finder_test.rb 2018-03-23 15:04:28.000000000 +0100 @@ -16,6 +16,7 @@ let(:profile) { {} } let(:ay_profile) { double("Yast::Profile", current: profile) } let(:repo) { double("UpdateRepository") } + let(:self_update_in_cmdline) { false } subject(:finder) { described_class.new } @@ -23,6 +24,8 @@ stub_const("Yast::Profile", ay_profile) stub_const("::Registration::ConnectHelpers", FakeConnectHelpers) allow(finder).to receive(:require).with("registration/connect_helpers") + allow(Yast::InstFunctions).to receive("self_update_in_cmdline?") + .and_return(self_update_in_cmdline) allow(Yast::Linuxrc).to receive(:InstallInf).with("SelfUpdate") .and_return(url_from_linuxrc) allow(Yast::Pkg).to receive(:GetArchitecture).and_return(arch) @@ -185,9 +188,33 @@ finder.updates end - it "does not handle registration errors" do - expect(Registration::ConnectHelpers).to_not receive(:catch_registration_errors) - finder.updates + context "and enables the installer update explicitly by linuxrc" do + let(:self_update_in_cmdline) { true } + + it "handles registration errors" do + expect(Registration::ConnectHelpers).to receive(:catch_registration_errors) + .and_call_original + finder.updates + end + end + + context "and enables the installer update explicitly by an AutoYaST profile" do + let(:profile) { { "general" => { "self_update" => true } } } + + it "handles registration errors" do + allow(Yast::Mode).to receive(:auto).and_return(true) + allow(finder).to receive(:import_registration_ayconfig) + expect(Registration::ConnectHelpers).to receive(:catch_registration_errors) + .and_call_original + finder.updates + end + end + + context "and does not enable the installer update explicitly" do + it "does not handle registration errors" do + expect(Registration::ConnectHelpers).to_not receive(:catch_registration_errors) + finder.updates + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.0.39/test/select_system_role_test.rb new/yast2-installation-4.0.42/test/select_system_role_test.rb --- old/yast2-installation-4.0.39/test/select_system_role_test.rb 2018-03-14 09:42:14.000000000 +0100 +++ new/yast2-installation-4.0.42/test/select_system_role_test.rb 2018-03-23 15:04:28.000000000 +0100 @@ -56,9 +56,7 @@ it "displays dialog, and sets ProductFeatures on Next" do allow(Yast::Wizard).to receive(:SetContents) allow(Yast::UI).to receive(:UserInput) - .and_return(:next) - allow(Yast::UI).to receive(:QueryWidget) - .with(Id(:roles), :CurrentButton).and_return("foo") + .and_return("foo", :next) expect(Yast::ProductFeatures).to receive(:ClearOverlay) expect(Yast::ProductFeatures).to receive(:SetOverlay) # .with @@ -80,9 +78,7 @@ it "shows the first dialog when going forward" do allow(Yast::Wizard).to receive(:SetContents) allow(Yast::UI).to receive(:UserInput) - .and_return(:next) - allow(Yast::UI).to receive(:QueryWidget) - .with(Id(:roles), :CurrentButton).and_return("bar") + .and_return("bar", :next) allow(Yast::WFM).to receive(:CallFunction).and_return(:next) expect(Yast::WFM).to receive(:CallFunction).with("a", anything).and_return(:next) @@ -109,9 +105,7 @@ allow(Yast::Wizard).to receive(:SetContents) allow(Yast::UI).to receive(:UserInput) - .and_return(:next) - allow(Yast::UI).to receive(:QueryWidget) - .with(Id(:roles), :CurrentButton).and_return("foo") + .and_return("foo", :next) expect(Yast::Popup).to_not receive(:ContinueCancel) @@ -128,9 +122,7 @@ allow(Yast::Wizard).to receive(:SetContents) allow(Yast::UI).to receive(:UserInput) - .and_return(:next) - allow(Yast::UI).to receive(:QueryWidget) - .with(Id(:roles), :CurrentButton).and_return("foo") + .and_return("foo", :next) expect(Yast::Popup).to receive(:ContinueCancel) .and_return(true) @@ -146,9 +138,7 @@ allow(Yast::Wizard).to receive(:SetContents) allow(Yast::UI).to receive(:UserInput) - .and_return(:next, :back) - allow(Yast::UI).to receive(:QueryWidget) - .with(Id(:roles), :CurrentButton).and_return("foo") + .and_return("foo", :next, :back) expect(Yast::Popup).to receive(:ContinueCancel) .and_return(false) @@ -166,6 +156,8 @@ .and_return(:next, :back) allow(Yast::UI).to receive(:QueryWidget) .with(Id(:roles), :CurrentButton).and_return(nil) + allow(Installation::SystemRole).to receive(:default?) + .and_return(false) expect(Yast::Popup).to receive(:Error) expect(Yast::ProductFeatures).to receive(:ClearOverlay) @@ -176,98 +168,4 @@ end end end - - describe "#dialog_content" do - let(:system_roles) do # 5 lines are needed - [ - ::Installation::SystemRole.new(id: "role1", order: "100", description: "Line 1\nLine 2"), - ::Installation::SystemRole.new(id: "role2", order: "200", description: "Line 1") - ] - end - - let(:textmode) { true } - let(:height) { 25 } - let(:display_info) do - { - "Height" => height, - "Width" => 80 - } - end - let(:intro_text) { "Some introductory\ntest" } - - before do - allow(Yast::UI).to receive(:TextMode).and_return(textmode) - allow(Yast::UI).to receive(:GetDisplayInfo).and_return(display_info) - allow(::Installation::SystemRole).to receive(:all).and_return(system_roles) - allow(Yast::ProductControl).to receive(:GetTranslatedText).with("roles_text") - .and_return(intro_text) - end - - context "when there's enough room" do - it "shows intro, separations, radio buttons and roles descriptions" do - expect(subject).to receive(:Label).with(intro_text) # intro - expect(subject).to receive(:VSpacing).with(1) # margin - expect(subject).to receive(:RadioButton).with(anything, system_roles[0].label) # rol label - expect(subject).to receive(:Label).with(/#{system_roles[0].description}/) # rol description - expect(subject).to receive(:VSpacing).with(2) # separator - expect(subject).to receive(:RadioButton).with(anything, system_roles[1].label) # rol label - expect(subject).to receive(:Label).with(/#{system_roles[1].description}/) # rol description - subject.dialog_content - end - end - - context "when there is enough room just reducing separations" do - let(:height) { 14 } - - it "reduces separation" do - expect(subject).to receive(:VSpacing).with(1).twice # margin + separator - subject.dialog_content - end - end - - context "when there is not enough room even reducing separations" do - let(:height) { 10 } - - it "reduces separation and omits descriptions" do - expect(subject).to_not receive(:Label).with(/#{system_roles[0].description}/) - expect(subject).to_not receive(:Label).with(/#{system_roles[1].description}/) - subject.dialog_content - end - end - - context "when there is not enough room even omitting descriptions" do - let(:height) { 8 } - - it "reduces separation, omits descriptions and removes the margin" do - expect(subject).to receive(:Label).with(intro_text) # intro - expect(subject).to_not receive(:VSpacing) - subject.dialog_content - end - end - - context "when there is not enough room even removing the margin" do - let(:height) { 7 } - - it "reduces separation, omits description and hides the introductory text" do - expect(subject).to_not receive(:Label).with(intro_text) # intro - expect(subject).to_not receive(:VSpacing) - subject.dialog_content - end - end - - context "when not in textmode" do - let(:textmode) { false } - - it "shows intro, separations, radio buttons and roles descriptions" do - expect(subject).to receive(:Label).with(intro_text) # intro - expect(subject).to receive(:VSpacing).with(2) # margin - expect(subject).to receive(:RadioButton).with(anything, system_roles[0].label) # rol label - expect(subject).to receive(:Label).with(/#{system_roles[0].description}/) # rol description - expect(subject).to receive(:VSpacing).with(2) # separator - expect(subject).to receive(:RadioButton).with(anything, system_roles[1].label) # rol label - expect(subject).to receive(:Label).with(/#{system_roles[1].description}/) # rol description - subject.dialog_content - end - end - end end