-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from NetsoftHoldings/master
implement passing parameters to render_wizard and finish_wizard_path
- Loading branch information
Showing
11 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class UpdateParamsController < ApplicationController | ||
include Wicked::Wizard | ||
|
||
class Thing | ||
def save | ||
true | ||
end | ||
end | ||
|
||
steps :first, :second, :last_step | ||
|
||
def index | ||
|
||
end | ||
|
||
def show | ||
render_wizard(nil, {}, { one: 'two' }) | ||
end | ||
|
||
def update | ||
@thing = Thing.new | ||
render_wizard(@thing, { notice: "Thing was updated from step #{step}." }, { one: 'two' }) | ||
end | ||
|
||
private | ||
|
||
def finish_wizard_path(params) | ||
update_params_path(params) | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
test/dummy/app/views/update_params/_step_position.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% wizard_steps.each do |s| %> | ||
<%= s.inspect %> | ||
<%= I18n.t("wicked.#{s}") %> | ||
<p> | ||
<strong><u><%= s.inspect %></u></strong><br /> | ||
<%= current_step?(s) ? "#{s} step is the current step" : "nope" %><br /> | ||
<%= past_step?(s) ? "#{s} step is a past step" : "nope" %><br /> | ||
<%= future_step?(s) ? "#{s} step is a future step" : "nope" %><br /> | ||
<%= previous_step?(s) ? "#{s} step was the previous step" : "nope" %><br /> | ||
<%= next_step?(s) ? "#{s} step is the next step" : "nope" %><br /> | ||
</p> | ||
<% end %> | ||
<%= form_tag update_param_path(step, {one: 'two'}), :method => :put do %> | ||
<%= submit_tag "Next" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render 'step_position' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Index page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render 'step_position' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render 'step_position' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'test_helper' | ||
|
||
class UpdateParamsTest < ActiveSupport::IntegrationCase | ||
test 'on first' do | ||
step = :first | ||
visit(update_param_path(step)) | ||
|
||
click_button("Next") | ||
assert_equal page.current_path, update_param_path(:second) | ||
assert_has_content?("notice:Thing was updated from step first.") | ||
|
||
click_button("Next") | ||
assert_equal page.current_path, update_param_path(:last_step) | ||
assert_has_content?("notice:Thing was updated from step second.") | ||
|
||
click_button("Next") | ||
assert_equal page.current_url, update_params_url({host: 'www.example.com', one: 'two' }) | ||
assert_has_content?("notice:Thing was updated from step last_step.") | ||
end | ||
end |