Skip to content

Commit

Permalink
Add default next handler to CWM::Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Sep 5, 2018
1 parent 4d494a0 commit 5d6a1cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/cwm/src/lib/cwm/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def disable_buttons
[]
end

# Handler when the next button is used
#
# If returns false, then it does not go next.
#
# @return [Boolean]
def next_handler
true
end

# Handler when the back button is used
#
# If returns false, then it does not go back.
Expand Down Expand Up @@ -116,6 +125,7 @@ def cwm_show
next_button: next_button,
skip_store_for: skip_store_for,
disable_buttons: disable_buttons,
next_handler: proc { next_handler },
back_handler: proc { back_handler },
abort_handler: proc { abort_handler }
)
Expand Down
10 changes: 10 additions & 0 deletions library/cwm/test/dialog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def contents
expect(subject.class.run).to eq(:launch)
end

it "passes the next handler to CWM#show" do
expect(Yast::CWM).to receive(:show) do |_content, options|
expect(options).to include(:next_handler)
# Checking the default handler is passed (simply returns true)
expect(options[:next_handler].call).to eq(true)
end

subject.class.run
end

it "passes the back handler to CWM#show" do
expect(Yast::CWM).to receive(:show) do |_content, options|
expect(options).to include(:back_handler)
Expand Down

0 comments on commit 5d6a1cf

Please sign in to comment.