Skip to content

Commit

Permalink
Merge pull request #1235 from joseivanlopez/fix-cwm-dialog
Browse files Browse the repository at this point in the history
Fix CWM dialog
  • Loading branch information
joseivanlopez committed Jan 21, 2022
2 parents b38d907 + f006955 commit 6d7700d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
13 changes: 12 additions & 1 deletion library/cwm/src/lib/cwm/dialog.rb
Expand Up @@ -31,7 +31,18 @@ def initialize(*args, **kws); end

# A shortcut for `.new(*args).run`
def self.run(*args, **kws)
new(*args, **kws).run
# Argument delegation is handled differently since ruby 2.7:
#
# An empty Hash argument is automatically converted and absorbed into **kws, and the delegation
# call removes the empty keyword hash, so no argument is passed to target. In ruby 2.6 and before,
# an empty hash is passed:
#
# * Ruby 2.6 or before: run("foo") passes new("foo", {})
# * Ruby 2.7 or later: run("foo") passes new("foo")
#
# See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
dialog = kws.empty? ? new(*args) : new(*args, **kws)
dialog.run
end

# The entry point.
Expand Down
8 changes: 7 additions & 1 deletion library/cwm/test/dialog_test.rb
Expand Up @@ -32,12 +32,18 @@ def contents
allow(Yast::CWM).to receive(:show).and_return(:next)
end

it "pass all arguments to constructor" do
it "pass all given arguments to constructor" do
expect(TestCWMDialog).to receive(:new).with("test2", disable: :next).and_call_original

TestCWMDialog.run("test2", disable: :next)
end

it "does not past extra arguments to constructor" do
expect(TestCWMDialog).to receive(:new).with(no_args).and_call_original

TestCWMDialog.run
end

it "opens a dialog when needed, and calls CWM#show" do
expect(Yast::Wizard).to receive(:IsWizardDialog).and_return(false)
expect(Yast::Wizard).to receive(:CreateDialog)
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 21 12:51:45 UTC 2022 - José Iván López González <jlopez@suse.com>

- Fix CWM dialog: argument delegation is handled differently in
ruby 2.6 and before (bsc#1194984).
- 4.4.37

-------------------------------------------------------------------
Fri Jan 14 13:56:49 UTC 2022 - Ancor Gonzalez Sosa <ancor@suse.com>

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


Name: yast2
Version: 4.4.36
Version: 4.4.37

Release: 0
Summary: YaST2 Main Package
Expand Down

0 comments on commit 6d7700d

Please sign in to comment.