Skip to content

Commit

Permalink
Merge pull request #648 from ancorgs/fix_table
Browse files Browse the repository at this point in the history
Fix CWM::Table#value= for multiSelection
  • Loading branch information
ancorgs committed Nov 29, 2017
2 parents 2192340 + 0683514 commit 8d56330
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/cwm/src/lib/cwm/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def value
# @param id [Object, Array<Object>] selected id, if multiselection? is true
# it require array of ids to select
def value=(id)
Yast::UI.ChangeWidget(Id(widget_id), :SelectedItems, Array[id])
Yast::UI.ChangeWidget(Id(widget_id), :SelectedItems, Array(id))
end

# Replaces content of single cell
Expand Down
19 changes: 18 additions & 1 deletion library/cwm/test/table_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

require "cwm/rspec"
require "cwm/table"
Yast.import "UI"

describe CWM::Table do
class MyTable < CWM::Table
Expand All @@ -18,8 +19,24 @@ def items
]
end
end
subject { MyTable.new }
subject(:table) { MyTable.new }

include_examples "CWM::Table"
include_examples "CWM::CustomWidget"

describe "#value=" do
context "when called with a single id" do
it "passes an array with only that id to UI.ChangeWidget" do
expect(Yast::UI).to receive(:ChangeWidget).with(anything, anything, [:id])
table.value = :id
end
end

context "when called with an array of ids" do
it "passes the same array to UI.ChangeWidget" do
expect(Yast::UI).to receive(:ChangeWidget).with(anything, anything, [:id1, :id2])
table.value = [:id1, :id2]
end
end
end
end
7 changes: 7 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 29 09:10:59 UTC 2017 - ancor@suse.com

- Fixed a bug selecting rows programmatically for CWM::Table
(bsc#1070287).
- 4.0.20

-------------------------------------------------------------------
Tue Nov 28 11:44:30 UTC 2017 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.0.19
Version: 4.0.20
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0
Expand Down

0 comments on commit 8d56330

Please sign in to comment.