Skip to content

Commit

Permalink
Add also hspacing to CWM::RadioButtons
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Mar 23, 2017
1 parent 9690358 commit 0fc3787
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
10 changes: 8 additions & 2 deletions library/cwm/src/lib/cwm/widget.rb
Expand Up @@ -614,16 +614,22 @@ def value=(val)
end

# See AbstractWidget#cwm_definition
# In addition to the base definition, this honors a possible
# `vspacing` method
# In addition to the base definition, this honors possible
# `vspacing` and `hspacing` methods
#
# @example defining additional space between the options
# def vspacing
# 1
# end
#
# @example defining some margin at both sides of the list of options
# def hspacing
# 3
# end
def cwm_definition
additional = {}
additional["vspacing"] = vspacing if respond_to?(:vspacing)
additional["hspacing"] = hspacing if respond_to?(:hspacing)

super.merge(additional)
end
Expand Down
31 changes: 24 additions & 7 deletions library/cwm/test/widgets_test.rb
Expand Up @@ -226,29 +226,46 @@ def items
end
end

class TestSpacedRadioButtons < TestRadioButtons
def vspacing
2
end

def hspacing
3
end
end

describe "#cwm_definition" do
context "if #vspacing is not defined" do
context "if #vspacing and #hspacing are not defined" do
subject { TestRadioButtons.new }

it "does not include the vspacing key" do
expect(subject.cwm_definition.keys).to_not include("vspacing")
end
end

context "if #vspacing is defined" do
class TestSpacedRadioButtons < TestRadioButtons
def vspacing
2
end
it "does not include the hspacing key" do
expect(subject.cwm_definition.keys).to_not include("hspacing")
end
end

context "if #vspacing is defined" do
subject { TestSpacedRadioButtons.new }

it "sets vspacing based on the method result" do
expect(subject.cwm_definition.keys).to include("vspacing")
expect(subject.cwm_definition["vspacing"]).to eq 2
end
end

context "if #hspacing is defined" do
subject { TestSpacedRadioButtons.new }

it "sets hspacing based on the method result" do
expect(subject.cwm_definition.keys).to include("hspacing")
expect(subject.cwm_definition["hspacing"]).to eq 3
end
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions package/yast2.changes
@@ -1,8 +1,8 @@
-------------------------------------------------------------------
Wed Mar 22 15:37:51 UTC 2017 - ancor@suse.com

- Added an option to CWM::RadioButtons to set extra space between
the options (related to poo#14936 and bsc#1025415).
- Added options to CWM::RadioButtons to set some extra spaces
(related to poo#14936 and bsc#1025415).
- 3.2.20

-------------------------------------------------------------------
Expand Down

0 comments on commit 0fc3787

Please sign in to comment.