Skip to content

Commit

Permalink
Merge 1f9404a into 0b9bc68
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 26, 2020
2 parents 0b9bc68 + 1f9404a commit a0f55c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 66 deletions.
19 changes: 0 additions & 19 deletions library/cwm/src/lib/cwm/common_widgets.rb
Expand Up @@ -184,25 +184,6 @@ class ComboBox < AbstractWidget
include ValueBasedWidget
include ItemsSelection
abstract_method :label

alias_method :orig_value=, :value=

# Sets the current value
#
# If the given value is not in the list of items but the widget is editable,
# the item is added to the list.
#
# @param val [Object] Value to assign to the widget
def value=(val)
change_items([[val, val]] + items) if editable? && !items.map(&:first).include?(val)
self.orig_value = val
end

private

def editable?
respond_to?(:opt) && opt.include?(:editable)
end
end

# Widget representing selection box to select value.
Expand Down
46 changes: 0 additions & 46 deletions library/cwm/test/common_widgets_test.rb
Expand Up @@ -110,49 +110,3 @@ def hspacing
end
end
end

describe CWM::ComboBox do
class MountPointSelector < CWM::ComboBox
def label
""
end

def opt
[:editable]
end

def items
[["/", "/ (root)"]]
end
end

class SelectorWithoutOpt < CWM::ComboBox
def label
""
end

def items
[["/", "/ (root)"]]
end
end

describe "#value=" do
describe "when the widget is editable" do
subject { MountPointSelector.new }

it "adds the given value to the list of items" do
expect(subject).to receive(:change_items).with([["/srv", "/srv"], ["/", "/ (root)"]])
subject.value = "/srv"
end
end

describe "when the widget is not editable" do
subject { SelectorWithoutOpt.new }

it "does not add the given value to the list of items" do
expect(subject).to_not receive(:change_items)
subject.value = "/srv"
end
end
end
end
8 changes: 8 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Nov 26 13:35:52 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- CWM ComboBox: an editable ComboBox will not alter the list of
items when the current value is not part of the list as it uses
the original list which could be already modified (bsc#1177137)
- 4.3.43

-------------------------------------------------------------------
Tue Nov 24 22:03:19 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

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


Name: yast2
Version: 4.3.42
Version: 4.3.43
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit a0f55c6

Please sign in to comment.