Hello community, here is the log from the commit of package yast2-registration for openSUSE:Leap:15.2 checked in at 2020-02-10 16:41:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/yast2-registration (Old) and /work/SRC/openSUSE:Leap:15.2/.yast2-registration.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-registration" Mon Feb 10 16:41:19 2020 rev:148 rq:772186 version:4.2.33 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/yast2-registration/yast2-registration.changes 2020-02-04 17:54:51.768765329 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.yast2-registration.new.26092/yast2-registration.changes 2020-02-10 16:41:27.567703584 +0100 @@ -1,0 +2,32 @@ +Thu Feb 6 10:07:27 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Improves online search mechanism UI (jsc#SLE-9109): + - Fix the "ignore case" checkbox behaviour. + - Add a help text. +- 4.2.33 + +------------------------------------------------------------------- +Wed Feb 5 14:35:00 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Improves online search mechanism UI (jsc#SLE-9109): + - Add a summary screen that enumerates which changes will + take place (addons and packages). + - Fix the 'Cancel' button label. + - Improve feedback when waiting for network I/O. + - Inform users about unsupported scenarios: unregistered and + SMT/RMT registered systems. +- 4.2.33 + +------------------------------------------------------------------- +Wed Feb 5 13:50:48 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Fix running registration in firstboot (bsc#1162841) +- 4.2.32 + +------------------------------------------------------------------- +Tue Feb 4 14:06:59 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Mark registration as WSL capable module (bsc#1162650) +- 4.2.31 + +------------------------------------------------------------------- Old: ---- yast2-registration-4.2.30.tar.bz2 New: ---- yast2-registration-4.2.33.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-registration.spec ++++++ --- /var/tmp/diff_new_pack.hFVhrU/_old 2020-02-10 16:41:28.003703892 +0100 +++ /var/tmp/diff_new_pack.hFVhrU/_new 2020-02-10 16:41:28.007703895 +0100 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.2.30 +Version: 4.2.33 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only ++++++ yast2-registration-4.2.30.tar.bz2 -> yast2-registration-4.2.33.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/package/yast2-registration.changes new/yast2-registration-4.2.33/package/yast2-registration.changes --- old/yast2-registration-4.2.30/package/yast2-registration.changes 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/package/yast2-registration.changes 2020-02-06 12:13:26.000000000 +0100 @@ -1,4 +1,36 @@ ------------------------------------------------------------------- +Thu Feb 6 10:07:27 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Improves online search mechanism UI (jsc#SLE-9109): + - Fix the "ignore case" checkbox behaviour. + - Add a help text. +- 4.2.33 + +------------------------------------------------------------------- +Wed Feb 5 14:35:00 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Improves online search mechanism UI (jsc#SLE-9109): + - Add a summary screen that enumerates which changes will + take place (addons and packages). + - Fix the 'Cancel' button label. + - Improve feedback when waiting for network I/O. + - Inform users about unsupported scenarios: unregistered and + SMT/RMT registered systems. +- 4.2.33 + +------------------------------------------------------------------- +Wed Feb 5 13:50:48 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Fix running registration in firstboot (bsc#1162841) +- 4.2.32 + +------------------------------------------------------------------- +Tue Feb 4 14:06:59 UTC 2020 - Josef Reidinger <jreidin...@suse.com> + +- Mark registration as WSL capable module (bsc#1162650) +- 4.2.31 + +------------------------------------------------------------------- Wed Jan 29 14:26:12 UTC 2020 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> - Fix random building problems (bsc#1162122). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/package/yast2-registration.spec new/yast2-registration-4.2.33/package/yast2-registration.spec --- old/yast2-registration-4.2.30/package/yast2-registration.spec 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/package/yast2-registration.spec 2020-02-06 12:13:26.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.2.30 +Version: 4.2.33 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/desktop/org.opensuse.yast.SCC.AddExtensions.desktop new/yast2-registration-4.2.33/src/desktop/org.opensuse.yast.SCC.AddExtensions.desktop --- old/yast2-registration-4.2.30/src/desktop/org.opensuse.yast.SCC.AddExtensions.desktop 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/desktop/org.opensuse.yast.SCC.AddExtensions.desktop 2020-02-06 12:13:26.000000000 +0100 @@ -7,6 +7,7 @@ X-SuSE-YaST-RootOnly=yes X-SuSE-YaST-Group=Software X-SuSE-YaST-Keywords=extensions,modules,software,registration,scc,package,repositories +X-SuSE-YaST-WSL=true Icon=yast-addon-extension Exec=/usr/bin/xdg-su -c "/sbin/yast2 scc select_extensions" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/desktop/org.opensuse.yast.SCC.desktop new/yast2-registration-4.2.33/src/desktop/org.opensuse.yast.SCC.desktop --- old/yast2-registration-4.2.30/src/desktop/org.opensuse.yast.SCC.desktop 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/desktop/org.opensuse.yast.SCC.desktop 2020-02-06 12:13:26.000000000 +0100 @@ -12,6 +12,7 @@ X-SuSE-YaST-AutoInstSchema=registration.rnc X-SuSE-YaST-AutoInstResource=suse_register X-SuSE-YaST-Keywords=scc,software,registration,smt,rmt,module,extension +X-SuSE-YaST-WSL=true Icon=yast-product-registration Exec=/usr/bin/xdg-su -c "/sbin/yast2 scc" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/clients/online_search.rb new/yast2-registration-4.2.33/src/lib/registration/clients/online_search.rb --- old/yast2-registration-4.2.30/src/lib/registration/clients/online_search.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/clients/online_search.rb 2020-02-06 12:13:26.000000000 +0100 @@ -19,7 +19,9 @@ require "yast" require "yast2/popup" +require "ui/text_helpers" require "registration/dialogs/online_search" +require "registration/dialogs/online_search_summary" require "registration/addon" require "registration/registration" require "registration/registration_ui" @@ -29,6 +31,7 @@ Yast.import "Pkg" Yast.import "Sequencer" +Yast.import "Popup" module Registration module Clients @@ -46,6 +49,7 @@ include Yast::I18n extend Yast::I18n include Yast::Logger + include ::UI::TextHelpers def initialize textdomain "registration" @@ -55,13 +59,16 @@ # # @see #find_addons # @see #search_packages + # @see #display_summary # @see #display_eula # @see #register_addons # @see #select_packages def workflow_aliases { + "check_support" => ->() { check_support }, "find_addons" => ->() { find_addons }, "search_packages" => ->() { search_packages }, + "display_summary" => ->() { display_summary }, "display_eula" => ->() { display_eula }, "register_addons" => ->() { register_addons }, "select_packages" => ->() { select_packages } @@ -81,13 +88,21 @@ # @return [Symbol] Sequence's result (:next or :abort) def run sequence = { - "ws_start" => "find_addons", + "ws_start" => "check_support", + "check_support" => { + abort: :abort, + next: "find_addons" + }, "find_addons" => { abort: :abort, next: "search_packages" }, "search_packages" => { abort: :abort, + next: "display_summary" + }, + "display_summary" => { + abort: :abort, next: "display_eula" }, "display_eula" => { @@ -110,11 +125,32 @@ private + # Determines whether the online search is supported in the running system + # + # @return [:next,:abort] + def check_support + unless ::Registration::Registration.is_registered? + registration_required_message + return :abort + end + unless ::Registration::UrlHelpers.default_registration_url? + smt_not_supported_message + return :abort + end + + :next + end + # Find all available addons # # @return [:next] def find_addons - ::Registration::Addon.find_all(registration) + Yast::Popup.Feedback( + _("Initializing..."), _("Fetching the list of known modules/extensions") + ) do + ::Registration::Addon.reset! + ::Registration::Addon.find_all(registration) + end :next end @@ -126,7 +162,17 @@ package_search_dialog.run end - # Display EULAs for the selected addons + # Displays a summary of the module/extensions to register and packages to install + # + # @return [:next] + def display_summary + return :next if selected_packages.empty? + ::Registration::Dialogs::OnlineSearchSummary.run( + selected_packages, selected_addons + ) + end + + # Displays EULAs for the selected addons # # @return [Symbol] User input (:next, :back, :abort) # or :next if there are not licenses to accept @@ -152,7 +198,7 @@ # @return [:next] def select_packages ::Registration::SwMgmt.select_addon_products - package_search_dialog.selected_packages.each do |pkg| + selected_packages.each do |pkg| pkg_install_error_message(pkg.name) unless Yast::Pkg.PkgInstall(pkg.name) end :next @@ -178,6 +224,10 @@ @selected_addons = ::Registration::Addon.registration_order(addons) end + def selected_packages + package_search_dialog.selected_packages + end + def reset_selected_addons_cache! @selected_addons = nil end @@ -191,6 +241,35 @@ ), headline: :error ) + end + + # Returns a message about unregistered systems not being able to use the online search feature + # + # @return [String] + def registration_required_message + Yast2::Popup.show( + wrap_text( + _("YaST requires your system to be registered in order to " \ + "perform an online search. Alternatively, use the web" \ + "version at 'https://scc.suse.com/packages/'.") + ), + headline: :error + ) + end + + # Returns a message about SMT/RMT not supporting the online search feature + # + # @return [String] + def smt_not_supported_message + Yast2::Popup.show( + wrap_text( + _("This system is registered through an SMT/RMT server. " \ + "Unfortunately, the online search feature is not supported " \ + "in this scenario. Alternatively, use the web version at" \ + "'https://scc.suse.com/packages/'.") + ), + headline: :error + ) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/controllers/package_search.rb new/yast2-registration-4.2.33/src/lib/registration/controllers/package_search.rb --- old/yast2-registration-4.2.30/src/lib/registration/controllers/package_search.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/controllers/package_search.rb 2020-02-06 12:13:26.000000000 +0100 @@ -0,0 +1,200 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "registration/package_search" + +Yast.import "Popup" +Yast.import "HTML" + +module Registration + module Controllers + # Implements the actions and keeps the state for the package search feature + class PackageSearch + include Yast::I18n + + # @return [Array<RemotePackage>] List of selected packages + attr_reader :selected_packages + + # Constructor + def initialize + textdomain "registration" + @selected_packages = [] + end + + # Performs a package search + # + # @param text [String] Term to search for + # @param ignore_case [Boolean] Whether the search is case sensitive or not + # @return [Array<Registration::RemotePackage>] List of packages + def search(text, ignore_case) + @search = ::Registration::PackageSearch.new(text: text, ignore_case: ignore_case) + @search.packages + end + + # Selects/unselects the current package for installation + # + # It does nothing if the package is already installed. + def toggle_package(package) + return if package.installed? + + if package.selected? + unselect_package(package) + else + select_package(package) + end + end + + private + + # Selects the current package for installation + # + # If required, it selects the corresponding addon + # + # @param package [RemotePackage] Package to select + def select_package(package) + log.info "Selecting package: #{package.inspect}" + addon = package.addon + select_addon(addon) if addon + set_package_as_selected(package) if addon.nil? || addon.selected? || addon.registered? + end + + # Unselects the current package for installation + # + # If not needed, unselects the corresponding addon + # + # @param package [RemotePackage] Package to unselect + # + # @see #unselect_addon + # @see #unselect_package! + def unselect_package(package) + log.info "Unselecting package: #{package.inspect}" + unset_package_as_selected(package) + unselect_addon(package.addon) if package.addon + end + + # Selects the given addon if needed + # + # If the addon is registered or selected, does nothing. If the addon + # was auto selected, it will be marked as selected. + # + # @param addon [Addon] Addon to select + def select_addon(addon) + log_addon("selecting the addon", addon) + return if addon.registered? || addon.selected? + addon.selected if addon.auto_selected? || enable_addon?(addon) + end + + # Unselects the given addon if required + # + # @param addon [Addon] Addon to unselect + def unselect_addon(addon) + log_addon("unselecting the addon", addon) + return if addon.registered? || needed_addon?(addon) + addon.unselected if disable_addon?(addon) + end + + # Sets the package as selected + # + # Marks the package as selected and adds it to the list of selected packages. + # + # @param package [RemotePackage] Package to add + def set_package_as_selected(package) + package.select! + selected_packages << package + end + + # Unsets the package as selected + # + # Marks the package as not selected and removes it from the list of selected packages. + # + # @param package [RemotePackage] Package to remove + def unset_package_as_selected(package) + package.unselect! + selected_packages.reject! { |p| p.id == package.id } + end + + # Asks the user to enable the addon + # + # @param addon [Addon] Addon to ask about + def enable_addon?(addon) + description = Yast::HTML.Para( + format( + _("The selected package is provided by the '%{name}', " \ + "which is not enabled on this system yet."), + name: addon.name + ) + ) + + unselected_deps = addon.dependencies.reject { |d| d.selected? || d.registered? } + if !unselected_deps.empty? + description << Yast::HTML.Para( + format( + _("Additionally, '%{name}' depends on the following modules/extensions:"), + name: addon.name + ) + ) + description << Yast::HTML.List(unselected_deps.map(&:name)) + end + # TRANSLATORS: 'it' and 'them' refers to the modules/extensions to enable + question = n_( + "Do you want to enable it?", "Do you want to enable them?", unselected_deps.size + 1 + ) + yes_no_popup(description + question) + end + + # Asks the user to disable the addon + # + # @param addon [Addon] Addon to ask about + def disable_addon?(addon) + message = format( + _("The '%{name}' is not needed anymore.\n" \ + "Do you want to unselect it?"), + name: addon.name + ) + yes_no_popup(message) + end + + # Determines whether the addon is still needed + # + # @param addon [Addon] Addon to compare with + def needed_addon?(addon) + selected_packages.any? { |pkg| pkg.addon && pkg.addon.id == addon.id } + end + + # Asks a yes/no question + # + # @return [Boolean] true if the answer is affirmative; false otherwise + def yes_no_popup(message) + ret = Yast2::Popup.show(message, richtext: true, buttons: :yes_no) + log.info "yes/no pop-up. The answer is '#{ret}" + ret == :yes + end + + # Logs information about a given addon + # + # @param msg [String] Message to display at the beginning of the line + # @param addon [Registration::Addon] + def log_addon(msg, addon) + log.info "#{msg}: #{addon.inspect}, registered=#{addon.registered?}, " \ + "selected=#{addon.selected?}, auto_selected=#{addon.auto_selected?}" + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search.rb new/yast2-registration-4.2.33/src/lib/registration/dialogs/online_search.rb --- old/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/dialogs/online_search.rb 2020-02-06 12:13:26.000000000 +0100 @@ -19,6 +19,7 @@ require "yast" require "cwm/dialog" +require "registration/controllers/package_search" require "registration/widgets/package_search" module Registration @@ -57,22 +58,44 @@ # @macro seeAbstractWidget def run ret = super - @selected_packages = ret == :next ? package_search_widget.selected_packages : [] + @selected_packages = ret == :next ? controller.selected_packages : [] ret end # @macro seeDialog + def abort_button + Yast::Label.CancelButton + end + + # @macro seeDialog def back_button "" end + # @macro seeDialog + def help + _("The online search feature allows the user to search for packages across all " \ + "modules and extensions, including those that have not been activated for this " \ + "system.\n\nOnce the wanted package is found, the user can select it for " \ + "installation. If it belongs to a not activated module, YaST will allow activating " \ + "the module/extension. Bear in mind that the activation will take place at the end, " \ + "after the user clicks the Next button.") + end + private # Package search widget # # @return [Registration::Widgets::PackageSearch] def package_search_widget - @package_search_widget ||= ::Registration::Widgets::PackageSearch.new + @package_search_widget ||= ::Registration::Widgets::PackageSearch.new(controller) + end + + # Package search controller + # + # @return [Registration::Controllers::PackageSearch] + def controller + @controller ||= ::Registration::Controllers::PackageSearch.new end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search_summary.rb new/yast2-registration-4.2.33/src/lib/registration/dialogs/online_search_summary.rb --- old/yast2-registration-4.2.30/src/lib/registration/dialogs/online_search_summary.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/dialogs/online_search_summary.rb 2020-02-06 12:13:26.000000000 +0100 @@ -0,0 +1,83 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "cwm/dialog" + +module Registration + module Dialogs + class OnlineSearchSummary < CWM::Dialog + include Yast::I18n + + # Constructor + # + # @param packages [Array<RemotePackage>] Packages to install + # @param addons [Array<Addon>] Addons to register + def initialize(packages, addons) + textdomain "registration" + @packages = packages + @addons = addons + end + + # @macro seeDialog + def contents + VBox( + RichText(Id(:summary), addons_text + packages_text) + ) + end + + # @macro seeDialog + def abort_button + Yast::Label.CancelButton + end + + def title + # TRANSLATORS: title for the dialog which displays modules/extensions to + # install and packages to register + _("Changes Summary") + end + + private + + # @return [Array<RemotePackage>] Packages to install + attr_reader :packages + + # @return [Array<Addon>] Addons to register + attr_reader :addons + + # Returns a string that contains a list of addons to register + # + # @return [String] text containing the list of addons; an empty string + # is returned if there are no addons + def addons_text + return "" if addons.empty? + heading = format(_("Modules/extensions to register (%{count})"), count: addons.size) + Yast::HTML.Heading(heading) + Yast::HTML.List(addons.map(&:name).sort) + end + + # Returns a string that contains the list of packages to select + # + # @return [String] text containing the list of packages + def packages_text + heading = format(_("Selected packages (%{count})"), count: packages.size) + Yast::HTML.Heading(heading) + Yast::HTML.List(packages.map(&:name).sort) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/ui/base_system_registration_dialog.rb new/yast2-registration-4.2.33/src/lib/registration/ui/base_system_registration_dialog.rb --- old/yast2-registration-4.2.30/src/lib/registration/ui/base_system_registration_dialog.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/ui/base_system_registration_dialog.rb 2020-02-06 12:13:26.000000000 +0100 @@ -396,11 +396,19 @@ # Convenience method to obtain the medium warning text depending on the # medium type def medium_warning_text - Y2Packager::MediumType.online? ? online_skipping_text : default_skipping_text + if Yast::Stage.initial && Y2Packager::MediumType.online? + online_skipping_text + else + default_skipping_text + end end def medium_warning_headline - Y2Packager::MediumType.online? ? online_skipping_headline : default_skipping_headline + if Yast::Stage.initial && Y2Packager::MediumType.online? + online_skipping_headline + else + default_skipping_headline + end end def online_skipping_headline @@ -465,7 +473,7 @@ # # @return [Symbol, nil] :skip if not the online medium def handle_skipping_registration - unless Y2Packager::MediumType.online? + if !Yast::Stage.initial || !Y2Packager::MediumType.online? log.info "Skipping registration on user request" return :skip end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/url_helpers.rb new/yast2-registration-4.2.33/src/lib/registration/url_helpers.rb --- old/yast2-registration-4.2.30/src/lib/registration/url_helpers.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/url_helpers.rb 2020-02-06 12:13:26.000000000 +0100 @@ -84,6 +84,10 @@ url end + def self.default_registration_url? + [nil, SUSE::Connect::YaST::DEFAULT_URL].include?(registration_url) + end + # @return [void] def self.reset_registration_url ::Registration::Storage::Cache.instance.reg_url = nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/src/lib/registration/widgets/package_search.rb new/yast2-registration-4.2.33/src/lib/registration/widgets/package_search.rb --- old/yast2-registration-4.2.30/src/lib/registration/widgets/package_search.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/src/lib/registration/widgets/package_search.rb 2020-02-06 12:13:26.000000000 +0100 @@ -22,11 +22,9 @@ require "registration/widgets/package_search_form" require "registration/widgets/remote_packages_table" require "registration/widgets/remote_package_details" -require "registration/package_search" require "yast2/popup" Yast.import "Popup" -Yast.import "HTML" module Registration module Widgets @@ -40,18 +38,18 @@ class PackageSearch < CWM::CustomWidget include Yast::Logger - # @return [Array<String>] List of selected packages - attr_reader :selected_packages - - # @return [::Registration::PackageSearch,nil] Current search - attr_reader :search + # @return [Array<RemotePackage>] Packages found in the current search + attr_reader :packages # Constructor - def initialize + # + # @param controller [Registration::Controllers::PackageSearch] Package search controller + def initialize(controller) textdomain "registration" self.handle_all_events = true - @selected_packages = [] # list of selected packages - super + @controller = controller + @packages = [] + super() end # @macro seeAbstractWidget @@ -67,7 +65,7 @@ MinWidth( 60, VBox( - packages_table, + MinHeight(14, packages_table), package_details ) ) @@ -78,7 +76,7 @@ # @macro seeAbstractWidget def handle(event) if start_search_event?(event) - search_package(search_form.text) + search_package(search_form.text, search_form.ignore_case) elsif event["WidgetID"] == "remote_packages_table" handle_packages_table_event(event) end @@ -89,6 +87,9 @@ private + # @return [Registration::Controllers::PackageSearch] Widget's controller + attr_reader :controller + # Search form widget # # @return [PackageSearchForm] Search form widget instance @@ -138,18 +139,19 @@ # Performs the search and updates the packages table # - # @param text [String] Text to search for - def search_package(text) + # @param text [String] Text to search for + # @param ignore_case [Boolean] Whether the search is case sensitive or not + def search_package(text, ignore_case) return unless valid_search_text?(text) - @search = ::Registration::PackageSearch.new(text: text) # TRANSLATORS: searching for packages Yast::Popup.Feedback(_("Searching..."), _("Searching for packages")) do - selected_package_ids = selected_packages.map(&:id) - @search.packages.each do |pkg| + @packages = controller.search(text, ignore_case) + selected_package_ids = controller.selected_packages.map(&:id) + @packages.each do |pkg| pkg.select! if selected_package_ids.include?(pkg.id) end end - packages_table.change_items(@search.packages) + packages_table.change_items(packages) update_details end @@ -157,135 +159,24 @@ # # @return [RemotePackage,nil] def find_current_package - return unless search && packages_table.value - selected_id = packages_table.value - search.packages.find { |p| p.id == selected_id } + packages.find { |p| p.id == packages_table.value } end # Selects/unselects the current package for installation - # - # It does nothing if the package is already installed. def toggle_package package = find_current_package - return if package.nil? || package.installed? - - if package.selected? - unselect_package(package) - else - select_package(package) - end - + controller.toggle_package(package) packages_table.update_item(package) update_details end - # Selects the current package for installation - # - # If required, it selects the corresponding addon - # - # @param package [RemotePackage] Package to select - def select_package(package) - addon = package.addon - select_addon(addon) if addon - set_package_as_selected(package) if addon.nil? || addon.selected? || addon.registered? - end - - # Unselects the current package for installation - # - # If not needed, unselects the corresponding addon - # - # @param package [RemotePackage] Package to unselect - # - # @see #unselect_addon - # @see #unselect_package! - def unselect_package(package) - unset_package_as_selected(package) - unselect_addon(package.addon) if package.addon - end - - # Selects the given addon if needed - # - # @param addon [Addon] Addon to select - def select_addon(addon) - return if addon.registered? || addon.selected? || addon.auto_selected? - addon.selected if enable_addon?(addon) - end - - # Unselects the given addon if required - # - # @param addon [Addon] Addon to unselect - def unselect_addon(addon) - return if addon.registered? || needed_addon?(addon) - addon.unselected if disable_addon?(addon) - end - - # Sets the package as selected - # - # Marks the package as selected and adds it to the list of selected packages. - # - # @param package [RemotePackage] Package to add - def set_package_as_selected(package) - package.select! - selected_packages << package - end - - # Unsets the package as selected - # - # Marks the package as not selected and removes it from the list of selected packages. - # - # @param package [RemotePackage] Package to remove - def unset_package_as_selected(package) - package.unselect! - selected_packages.delete(package) - end - # Updates the package details widget def update_details + # FIXME: remove the content if the current package is nil current_package = find_current_package package_details.update(current_package) if current_package end - # Asks the user to enable the addon - # - # @param addon [Addon] Addon to ask about - def enable_addon?(addon) - description = Yast::HTML.Para( - format( - _("The selected package is provided by the '%{name}', " \ - "which is not enabled on this system yet."), - name: addon.name - ) - ) - - unselected_deps = addon.dependencies.reject { |d| d.selected? || d.registered? } - if !unselected_deps.empty? - description << Yast::HTML.Para( - format( - _("Additionally, '%{name}' depends on the following modules/extensions:"), - name: addon.name - ) - ) - description << Yast::HTML.List(unselected_deps.map(&:name)) - end - # TRANSLATORS: 'it' and 'them' refers to the modules/extensions to enable - question = n_( - "Do you want to enable it?", "Do you want to enable them?", unselected_deps.size + 1 - ) - yes_no_popup(description + question) - end - - # Asks the user to disable the addon - # - # @param addon [Addon] Addon to ask about - def disable_addon?(addon) - message = format( - _("The '%{name}' is not needed anymore.\n" \ - "Do you want to unselect it?"), - name: addon.name - ) - yes_no_popup(message) - end - MINIMAL_SEARCH_TEXT_SIZE = 2 # Determines whether the search text is valid or not @@ -302,19 +193,6 @@ ) false end - - # Determines whether the addon is still needed - def needed_addon?(addon) - selected_packages.any? { |pkg| pkg.addon == addon } - end - - # Asks a yes/no question - # - # @return [Boolean] true if the answer is affirmative; false otherwise - def yes_no_popup(message) - ret = Yast2::Popup.show(message, richtext: true, buttons: :yes_no) - ret == :yes - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/registration/clients/online_search_test.rb new/yast2-registration-4.2.33/test/registration/clients/online_search_test.rb --- old/yast2-registration-4.2.30/test/registration/clients/online_search_test.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/test/registration/clients/online_search_test.rb 2020-02-06 12:13:26.000000000 +0100 @@ -36,16 +36,19 @@ let(:package) { instance_double(Registration::RemotePackage, name: "gnome-desktop") } let(:search_result) { :next } let(:registration_result) { :next } + let(:registration_url) { SUSE::Connect::YaST::DEFAULT_URL } before do allow(Registration::Addon).to receive(:find_all) allow(Registration::Dialogs::OnlineSearch).to receive(:new).and_return(search_dialog) + allow(Registration::Dialogs::OnlineSearchSummary).to receive(:run).and_return(:next) allow(Registration::RegistrationUI).to receive(:new).and_return(registration_ui) allow(Registration::UI::AddonEulaDialog).to receive(:run).and_return(:next) allow(Registration::SwMgmt).to receive(:select_addon_products) allow(Registration::UrlHelpers).to receive(:registration_url) - .and_return("https://scc.suse.com") # speed up the test + .and_return(registration_url) # speed up the test allow(Yast::Pkg).to receive(:PkgInstall).and_return(true) + allow(Registration::Registration).to receive(:is_registered?).and_return(true) end context "when an addon is selected" do @@ -133,6 +136,39 @@ it "returns :abort" do expect(subject.run).to eq(:abort) + end + end + + context "when the system is not registered" do + before do + allow(Registration::Registration).to receive(:is_registered?).and_return(false) + allow(Yast2::Popup).to receive(:show) + end + + it "displays a message" do + expect(Yast2::Popup).to receive(:show).with(/to be registered/, headline: :error) + subject.run + end + + it "returns :abort" do + expect(subject.run).to eq(:abort) + end + end + + context "when an SMT/RMT server was used" do + let(:registration_url) { "https://smt.example.net" } + + before do + allow(Yast2::Popup).to receive(:show) + end + + it "displays a message" do + expect(Yast2::Popup).to receive(:show).with(/SMT/, headline: :error) + subject.run + end + + it "returns :abort" do + expect(subject.run).to eq(:abort) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/registration/controllers/package_search_test.rb new/yast2-registration-4.2.33/test/registration/controllers/package_search_test.rb --- old/yast2-registration-4.2.30/test/registration/controllers/package_search_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.2.33/test/registration/controllers/package_search_test.rb 2020-02-06 12:13:26.000000000 +0100 @@ -0,0 +1,243 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../../spec_helper" +require "registration/controllers/package_search" + +describe Registration::Controllers::PackageSearch do + subject(:controller) { described_class.new } + + let(:package) do + instance_double( + Registration::RemotePackage, id: 1, name: "gnome-desktop", addon: addon, + selected?: false, select!: nil, installed?: installed? + ) + end + + let(:addon) do + instance_double( + Registration::Addon, name: "desktop", registered?: false, selected?: false, + auto_selected?: nil, selected: nil, unselected: nil, dependencies: [] + ) + end + + let(:search) do + instance_double(Registration::PackageSearch, packages: [package]) + end + + let(:installed?) { false } + + let(:text) { "gnome" } + + let(:ignore_case) { true } + + before do + allow(Registration::PackageSearch).to receive(:new) + .with(text: text, ignore_case: ignore_case).and_return(search) + end + + describe "#search" do + it "returns the list of packages from SCC" do + expect(controller.search(text, ignore_case)).to eq([package]) + end + end + + describe "#toggle_package" do + context "when the package is not selected for installation" do + context "and the addon is already registered" do + before do + allow(addon).to receive(:registered?).and_return(true) + end + + it "adds the package to the list of packages to install" do + subject.toggle_package(package) + expect(subject.selected_packages).to eq([package]) + end + end + + context "when the addon is not registered" do + before do + allow(Yast2::Popup).to receive(:show).and_return(register?) + end + + let(:addon) do + pure_addon = load_yaml_fixture("pure_addons.yml").first + Registration::Addon.new(pure_addon) + end + + context "but the user accepts to register the addon" do + let(:register?) { :yes } + + it "adds the package to the list of packages to install" do + subject.toggle_package(package) + expect(subject.selected_packages).to eq([package]) + end + + it "selects the addon for registration" do + expect(addon).to receive(:selected) + subject.toggle_package(package) + end + end + + context "and the user refuses to register the addon" do + let(:register?) { :no } + + it "does not add the package to the list of packages to install" do + subject.toggle_package(package) + expect(subject.selected_packages).to eq([]) + end + + it "does not select the addon for registration" do + expect(addon).to_not receive(:selected) + subject.toggle_package(package) + end + end + end + + context "when the addon is selected for registration" do + before do + allow(addon).to receive(:selected?).and_return(true) + end + + it "does not ask about registering the addon" do + expect(Yast2::Popup).to_not receive(:show) + subject.toggle_package(package) + end + + it "adds the package to the list of packages to install" do + subject.toggle_package(package) + expect(subject.selected_packages).to eq([package]) + end + end + + context "when the addon is auto selected for registration" do + let(:addon) do + pure_addon = load_yaml_fixture("pure_addons.yml").first + Registration::Addon.new(pure_addon) + end + + before do + allow(addon).to receive(:auto_selected?).and_return(true) + end + + it "does not ask about registering the addon" do + expect(Yast2::Popup).to_not receive(:show) + subject.toggle_package(package) + end + + it "selects the addon" do + expect(addon).to receive(:selected) + subject.toggle_package(package) + end + + it "adds the package to the list of packages to install" do + subject.toggle_package(package) + expect(subject.selected_packages).to eq([package]) + end + end + end + + context "when the package is already selected for installation" do + let(:selected_package) do + Registration::RemotePackage.new( + id: 1, name: "gnome-desktop", arch: :x86_64, version: "3.34", release: "1.1", addon: addon + ) + end + + let(:addon) do + pure_addon = load_yaml_fixture("pure_addons.yml").first + Registration::Addon.new(pure_addon) + end + + before do + allow(Yast2::Popup).to receive(:show).and_return(:yes) + subject.toggle_package(selected_package) + end + + context "and the package is already selected" do + let(:package) do + instance_double( + Registration::RemotePackage, id: 1, selected?: true, + installed?: false, unselect!: nil, addon: addon + ) + end + + it "unselects the package" do + allow(Yast2::Popup).to receive(:show).and_return(:yes) + expect(package).to receive(:unselect!) + subject.toggle_package(package) + expect(subject.selected_packages).to be_empty + end + + context "and the addon is still needed" do + let(:another_package) do + instance_double(Registration::RemotePackage, id: 2, name: "eog", addon: addon) + end + + before do + allow(subject).to receive(:selected_packages).and_return([package, another_package]) + end + + it "does not unselect the addon" do + expect(addon).to_not receive(:unselected) + subject.toggle_package(package) + end + end + + context "and the addon is not needed anymore" do + before do + allow(Yast2::Popup).to receive(:show).and_return(unselect?) + end + + context "and the user agrees to unselect it" do + let(:unselect?) { :yes } + + it "unselects the addon" do + expect(addon).to receive(:unselected) + subject.toggle_package(package) + end + end + + context "and the user wants to keep the addon" do + let(:unselect?) { :no } + + it "does not unselect the addon" do + expect(addon).to_not receive(:unselected) + subject.toggle_package(package) + end + end + end + end + end + + context "when an already installed package is selected for installation" do + let(:installed?) { true } + + before do + allow(addon).to receive(:registered?).and_return(true) + end + + it "does not select the package" do + subject.toggle_package(package) + expect(subject.selected_packages).to be_empty + end + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/registration/dialogs/online_search_summary_test.rb new/yast2-registration-4.2.33/test/registration/dialogs/online_search_summary_test.rb --- old/yast2-registration-4.2.30/test/registration/dialogs/online_search_summary_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.2.33/test/registration/dialogs/online_search_summary_test.rb 2020-02-06 12:13:26.000000000 +0100 @@ -0,0 +1,51 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../../spec_helper" +require "registration/dialogs/online_search_summary" +require "registration/addon" +require "registration/remote_package" +require "cwm/rspec" + +describe Registration::Dialogs::OnlineSearchSummary do + subject { described_class.new([package], [addon]) } + + include_examples "CWM::Dialog" + + let(:addon) { instance_double(Registration::Addon, name: "addon1") } + let(:package) { instance_double(Registration::RemotePackage, name: "pkg1") } + + describe "#contents" do + it "includes a list of addons" do + expect(subject.contents.to_s).to include("Modules/extensions to register (1)") + end + + it "includes a list of packages" do + expect(subject.contents.to_s).to include("Selected packages (1)") + end + + context "when the list of addons is empty" do + subject { described_class.new([package], []) } + + it "does not include a list of addons" do + expect(subject.contents.to_s).to_not include("Modules") + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/registration/dialogs/online_search_test.rb new/yast2-registration-4.2.33/test/registration/dialogs/online_search_test.rb --- old/yast2-registration-4.2.30/test/registration/dialogs/online_search_test.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/test/registration/dialogs/online_search_test.rb 2020-02-06 12:13:26.000000000 +0100 @@ -26,7 +26,11 @@ describe "#selected_packages" do let(:search_widget) do - Registration::Widgets::PackageSearch.new + Registration::Widgets::PackageSearch.new(controller) + end + + let(:controller) do + Registration::Controllers::PackageSearch.new end let(:package) do @@ -36,7 +40,9 @@ before do allow(Registration::Widgets::PackageSearch).to receive(:new) .and_return(search_widget) - allow(search_widget).to receive(:selected_packages).and_return([package]) + allow(Registration::Controllers::PackageSearch).to receive(:new) + .and_return(controller) + allow(controller).to receive(:selected_packages).and_return([package]) allow(subject).to receive(:cwm_show).and_return(result) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/registration/widgets/package_search_test.rb new/yast2-registration-4.2.33/test/registration/widgets/package_search_test.rb --- old/yast2-registration-4.2.30/test/registration/widgets/package_search_test.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/test/registration/widgets/package_search_test.rb 2020-02-06 12:13:26.000000000 +0100 @@ -25,6 +25,12 @@ describe Registration::Widgets::PackageSearch do include_examples "CWM::CustomWidget" + subject { described_class.new(controller) } + + let(:controller) do + Registration::Controllers::PackageSearch.new + end + let(:packages_table) do instance_double( Registration::Widgets::RemotePackagesTable, value: package.id, @@ -52,36 +58,34 @@ ) end - let(:search) do - instance_double(Registration::PackageSearch, packages: [package]) - end - before do allow(Registration::Widgets::RemotePackagesTable).to receive(:new) .and_return(packages_table) allow(Registration::Widgets::RemotePackageDetails).to receive(:new) .and_return(package_details) - allow(subject).to receive(:search).and_return(search) + allow(controller).to receive(:search).and_return([package]) end describe "#handle" do + let(:text) { "gnome" } + let(:ignore_case) { true } + context "when the user asks for a package" do let(:event) { { "WidgetID" => "search_form_button" } } - let(:text) { "gnome" } let(:search_form) do - instance_double(Registration::Widgets::PackageSearchForm, text: text) + instance_double( + Registration::Widgets::PackageSearchForm, text: text, ignore_case: ignore_case + ) end before do allow(Registration::Widgets::PackageSearchForm).to receive(:new) .and_return(search_form) - allow(Registration::PackageSearch).to receive(:new).and_return(search) end it "searches for the package in SCC" do - expect(Registration::PackageSearch).to receive(:new) - .with(text: text).and_return(search) + expect(controller).to receive(:search).with(text, ignore_case) subject.handle(event) end @@ -105,125 +109,13 @@ context "when a package is selected for installation" do let(:event) { { "WidgetID" => "remote_packages_table", "EventReason" => "Activated" } } - context "and the package is already selected" do - let(:package) do - instance_double( - Registration::RemotePackage, id: 1, name: "gnome-desktop", addon: addon, - selected?: true, unselect!: nil, installed?: false - ) - end - - it "unselects the package" do - allow(Yast2::Popup).to receive(:show).and_return(:yes) - expect(package).to receive(:unselect!) - subject.handle(event) - end - - context "and the addon is still needed" do - let(:another_package) do - instance_double(Registration::RemotePackage, name: "eog", addon: addon) - end - - before do - allow(subject).to receive(:selected_packages).and_return([package, another_package]) - subject.handle(event) - end - - it "does not unselect the addon" do - expect(addon).to_not receive(:unselected) - subject.handle(event) - end - end - - context "and the addon is not needed anymore" do - before do - allow(Yast2::Popup).to receive(:show).and_return(unselect?) - end - - context "and the user agrees to unselect it" do - let(:unselect?) { :yes } - - it "unselects the addon" do - expect(addon).to receive(:unselected) - subject.handle(event) - end - end - - context "and the user wants to keep the addon" do - let(:unselect?) { :no } - - it "does not unselect the addon" do - expect(addon).to_not receive(:unselected) - subject.handle(event) - end - end - end - end - - context "and the addon is already registered" do - before do - allow(addon).to receive(:registered?).and_return(true) - end - - it "adds the package to the list of packages to install" do - subject.handle(event) - expect(subject.selected_packages).to eq([package]) - end - end - - context "when the addon is not registered" do - before do - allow(Yast2::Popup).to receive(:show).and_return(register?) - end - - let(:addon) do - pure_addon = load_yaml_fixture("pure_addons.yml").first - Registration::Addon.new(pure_addon) - end - - context "but the user accepts to register the addon" do - let(:register?) { :yes } - - it "adds the package to the list of packages to install" do - subject.handle(event) - expect(subject.selected_packages).to eq([package]) - end - - it "selects the addon for registration" do - expect(addon).to receive(:selected) - subject.handle(event) - end - end - - context "and the user refuses to register the addon" do - let(:register?) { :no } - - it "does not add the package to the list of packages to install" do - subject.handle(event) - expect(subject.selected_packages).to eq([]) - end - - it "does not select the addon for registration" do - expect(addon).to_not receive(:selected) - subject.handle(event) - end - end + before do + allow(subject).to receive(:packages).and_return([package]) end - context "when the addon is selected for registration" do - before do - allow(addon).to receive(:selected?).and_return(true) - end - - it "does not ask about registering the addon" do - expect(Yast2::Popup).to_not receive(:show) - subject.handle(event) - end - - it "adds the package to the list of packages to install" do - subject.handle(event) - expect(subject.selected_packages).to eq([package]) - end + it "toggles the selected package" do + expect(controller).to receive(:toggle_package).with(package) + subject.handle(event) end it "updates the table and the package details" do @@ -234,22 +126,12 @@ end end - context "when an already installed package is selected for installation" do - let(:event) { { "WidgetID" => "remote_packages_table", "EventReason" => "Activated" } } - let(:installed?) { true } + context "when the user selects a different package in the table" do + let(:event) { { "WidgetID" => "remote_packages_table", "EventReason" => "SelectionChanged" } } before do - allow(addon).to receive(:registered?).and_return(true) - end - - it "does not select the package" do - subject.handle(event) - expect(subject.selected_packages).to be_empty + allow(subject).to receive(:packages).and_return([package]) end - end - - context "when the user selects a different package in the table" do - let(:event) { { "WidgetID" => "remote_packages_table", "EventReason" => "SelectionChanged" } } it "updates the package details" do expect(package_details).to receive(:update).with(package) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.2.30/test/url_helpers_spec.rb new/yast2-registration-4.2.33/test/url_helpers_spec.rb --- old/yast2-registration-4.2.30/test/url_helpers_spec.rb 2020-01-29 15:33:17.000000000 +0100 +++ new/yast2-registration-4.2.33/test/url_helpers_spec.rb 2020-02-06 12:13:26.000000000 +0100 @@ -3,6 +3,7 @@ require_relative "spec_helper" describe "Registration::UrlHelpers" do + describe ".registration_url" do before do # reset the cache before each test @@ -212,6 +213,36 @@ end end end + + describe ".default_registration_url?" do + before do + allow(Registration::UrlHelpers).to receive(:registration_url).and_return(url) + end + + context "when the registration_url is nil" do + let(:url) { nil } + + it "returns true" do + expect(Registration::UrlHelpers.default_registration_url?).to eq(true) + end + end + + context "when the registration_url is the default one" do + let(:url) { SUSE::Connect::YaST::DEFAULT_URL } + + it "returns true" do + expect(Registration::UrlHelpers.default_registration_url?).to eq(true) + end + end + + context "when the registration_url is not nil nor the default one" do + let(:url) { "https://smt.example.net" } + + it "returns false" do + expect(Registration::UrlHelpers.default_registration_url?).to eq(false) + end + end + end describe ".service_url" do it "converts a SLP service to plain URL" do