wicked 1.0.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/check_changelog.yml +13 -0
  3. data/.gitignore +15 -0
  4. data/.travis.yml +12 -17
  5. data/Appraisals +11 -0
  6. data/CHANGELOG.md +40 -0
  7. data/CONTRIBUTING.md +19 -0
  8. data/Gemfile +3 -20
  9. data/README.md +148 -34
  10. data/Rakefile +2 -15
  11. data/gemfiles/rails_5.1.gemfile +12 -0
  12. data/gemfiles/rails_5.2.gemfile +12 -0
  13. data/gemfiles/rails_6.0.1.gemfile +12 -0
  14. data/lib/wicked/controller/concerns/action.rb +13 -0
  15. data/lib/wicked/controller/concerns/path.rb +13 -3
  16. data/lib/wicked/controller/concerns/render_redirect.rb +33 -23
  17. data/lib/wicked/controller/concerns/steps.rb +12 -17
  18. data/lib/wicked/version.rb +3 -0
  19. data/lib/wicked/wizard/translated.rb +3 -6
  20. data/lib/wicked/wizard.rb +19 -18
  21. data/{app/controllers → lib}/wicked/wizard_controller.rb +1 -2
  22. data/lib/wicked.rb +2 -1
  23. data/test/controllers/bar_controller_test.rb +3 -2
  24. data/test/controllers/updates_controller_test.rb +27 -0
  25. data/test/dummy/app/controllers/application_controller.rb +5 -2
  26. data/test/dummy/app/controllers/dynamic_different_steps_controller.rb +18 -0
  27. data/test/dummy/app/controllers/dynamic_steps_controller.rb +1 -1
  28. data/test/dummy/app/controllers/jump_controller.rb +9 -2
  29. data/test/dummy/app/controllers/redirect_to_next_controller.rb +1 -1
  30. data/test/dummy/app/controllers/update_params_controller.rb +30 -0
  31. data/test/dummy/app/controllers/updates_controller.rb +30 -0
  32. data/test/dummy/app/views/bar/first.html.erb +3 -1
  33. data/test/dummy/app/views/bar/second.html.erb +2 -1
  34. data/test/dummy/app/views/dynamic_different_steps/first.html.erb +3 -0
  35. data/test/dummy/app/views/jump/last_step.html.erb +3 -1
  36. data/test/dummy/app/views/jump/second.html.erb +3 -1
  37. data/test/dummy/app/views/update_params/_step_position.html.erb +16 -0
  38. data/test/dummy/app/views/update_params/first.html.erb +1 -0
  39. data/test/dummy/app/views/update_params/index.html.erb +1 -0
  40. data/test/dummy/app/views/update_params/last_step.html.erb +1 -0
  41. data/test/dummy/app/views/update_params/second.html.erb +1 -0
  42. data/test/dummy/app/views/updates/_step_position.html.erb +16 -0
  43. data/test/dummy/app/views/updates/first.html.erb +1 -0
  44. data/test/dummy/app/views/updates/index.html.erb +1 -0
  45. data/test/dummy/app/views/updates/last_step.html.erb +1 -0
  46. data/test/dummy/app/views/updates/second.html.erb +1 -0
  47. data/test/dummy/config/application.rb +3 -0
  48. data/test/dummy/config/environments/development.rb +0 -1
  49. data/test/dummy/config/environments/test.rb +3 -1
  50. data/test/dummy/config/routes.rb +3 -0
  51. data/test/integration/dynamic_steps_test.rb +8 -1
  52. data/test/integration/helpers_test.rb +27 -0
  53. data/test/integration/jump_test.rb +16 -0
  54. data/test/integration/redirect_to_next_test.rb +1 -1
  55. data/test/integration/security_test.rb +0 -2
  56. data/test/integration/update_params_test.rb +20 -0
  57. data/test/integration/updates_test.rb +20 -0
  58. data/test/support/wicked_controller_test_case.rb +9 -0
  59. data/test/test_helper.rb +9 -9
  60. data/wicked.gemspec +22 -150
  61. metadata +146 -50
  62. data/.rvmrc +0 -19
  63. data/VERSION +0 -1
  64. /data/test/dummy/app/controllers/{steps_controller.rb → step_positions_controller.rb} +0 -0
@@ -1,51 +1,61 @@
1
1
  module Wicked::Controller::Concerns::RenderRedirect
2
2
  extend ActiveSupport::Concern
3
3
 
4
-
5
- def render_wizard(resource = nil, options = {})
6
- process_resource!(resource)
4
+ def render_wizard(resource = nil, options = {}, params = {})
5
+ process_resource!(resource, options)
7
6
 
8
7
  if @skip_to
9
- redirect_to wizard_path(@skip_to), options
8
+ url_params = (@wicked_redirect_params || {}).merge(params)
9
+ redirect_to wizard_path(@skip_to, url_params), options
10
10
  else
11
- render_step wizard_value(step), options
11
+ render_step(wizard_value(step), options, params)
12
12
  end
13
13
  end
14
14
 
15
- def process_resource!(resource)
16
- if resource
17
- if resource.save
18
- @skip_to ||= @next_step
19
- else
20
- @skip_to = nil
21
- end
15
+ def process_resource!(resource, options = {})
16
+ return unless resource
17
+
18
+ if options[:context]
19
+ did_save = resource.save(context: options[:context])
20
+ else
21
+ did_save = resource.save
22
+ end
23
+
24
+ if did_save
25
+ @skip_to ||= @next_step
26
+ else
27
+ @skip_to = nil
22
28
  end
23
29
  end
24
30
 
25
- def render_step(the_step, options = {})
31
+ def render_step(the_step, options = {}, params = {})
26
32
  if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP
27
- redirect_to_finish_wizard options
33
+ redirect_to_finish_wizard options, params
28
34
  else
29
35
  render the_step, options
30
36
  end
31
37
  end
32
38
 
33
- def redirect_to_next(next_step, options = {})
39
+ def redirect_to_next(next_step, options = {}, params = {})
34
40
  if next_step.nil?
35
- redirect_to_finish_wizard(options)
41
+ redirect_to_finish_wizard(options, params)
36
42
  else
37
- redirect_to wizard_path(next_step), options
43
+ redirect_to wizard_path(next_step, params), options
38
44
  end
39
45
  end
40
46
 
41
47
  # TODO redirect to resource if one is passed to render_wizard
42
- def finish_wizard_path
43
- '/'
48
+ def finish_wizard_path(params = {})
49
+ url = '/'
50
+ url = "#{url}?#{params.to_query}" unless params.blank?
51
+ url
44
52
  end
45
53
 
46
- def redirect_to_finish_wizard(options = {})
47
- Rails.logger.debug("Wizard has finished, redirecting to finish_wizard_path: #{finish_wizard_path.inspect}")
48
- redirect_to finish_wizard_path, options
54
+ def redirect_to_finish_wizard(options = {}, params = {})
55
+ wicked_final_redirect_path = method(:finish_wizard_path).arity == 1 ? finish_wizard_path(params) : finish_wizard_path
56
+ Rails.logger.debug("Wizard has finished, redirecting to finish_wizard_path: #{wicked_final_redirect_path.inspect}")
57
+ # flash.keep is required for Rails 3 where a flash message is lost on a second redirect.
58
+ flash.keep
59
+ redirect_to wicked_final_redirect_path, options
49
60
  end
50
61
  end
51
-
@@ -3,12 +3,14 @@ module Wicked::Controller::Concerns::Steps
3
3
 
4
4
  extend ActiveSupport::Concern
5
5
 
6
- def jump_to(goto_step)
7
- @skip_to = goto_step
6
+ def jump_to(goto_step, options = {})
7
+ @skip_to = goto_step
8
+ @wicked_redirect_params = options
8
9
  end
9
10
 
10
- def skip_step
11
- @skip_to = @next_step
11
+ def skip_step(options = {})
12
+ @skip_to = @next_step
13
+ @wicked_redirect_params = options
12
14
  end
13
15
 
14
16
  def step
@@ -50,8 +52,8 @@ module Wicked::Controller::Concerns::Steps
50
52
  options = args.extract_options!
51
53
  steps = args
52
54
  check_protected!(steps)
53
- prepend_before_filter(options) do
54
- self.steps = steps
55
+ prepend_before_action(options) do
56
+ self.steps = steps.dup
55
57
  end
56
58
  end
57
59
 
@@ -79,31 +81,24 @@ module Wicked::Controller::Concerns::Steps
79
81
  index = steps.index(current_step)
80
82
  step = steps.at(index - 1) if index.present? && index != 0
81
83
  step ||= steps.first
82
- step
83
84
  end
84
85
 
85
-
86
86
  def next_step(current_step = nil)
87
87
  return @next_step if current_step.nil?
88
88
  index = steps.index(current_step)
89
89
  step = steps.at(index + 1) if index.present?
90
90
  step ||= Wicked::FINISH_STEP
91
- step
92
91
  end
93
92
 
94
- private
95
-
96
- def step_index_for(step_name)
93
+ private def step_index_for(step_name)
97
94
  steps.index(step_name)
98
95
  end
99
96
 
100
- def current_step_index
97
+ private def current_step_index
101
98
  step_index_for(step)
102
99
  end
103
100
 
104
- def current_and_given_step_exists?(step_name)
105
- return false if current_step_index.nil? || steps.index(step_name).nil?
106
- return true
101
+ private def current_and_given_step_exists?(step_name)
102
+ current_step_index.present? && steps.index(step_name).present?
107
103
  end
108
104
  end
109
-
@@ -0,0 +1,3 @@
1
+ module Wicked
2
+ VERSION = "1.4.0"
3
+ end
@@ -5,8 +5,8 @@ module Wicked
5
5
  include Wicked::Wizard
6
6
 
7
7
  included do
8
- skip_before_filter :setup_wizard
9
- before_filter :setup_wizard_translated
8
+ skip_before_action :setup_wizard
9
+ before_action :setup_wizard_translated
10
10
 
11
11
  helper_method :wizard_translate, :wizard_value
12
12
  end
@@ -57,7 +57,6 @@ module Wicked
57
57
  end
58
58
 
59
59
 
60
- private
61
60
  # sets up a translated wizard controller
62
61
  # translations are expected under the 'wicked' namespace
63
62
  #
@@ -74,12 +73,10 @@ module Wicked
74
73
  #
75
74
  # steps "wicked.first", "wicked.second"
76
75
  #
77
- def setup_wizard_translated
76
+ private def setup_wizard_translated
78
77
  self.steps = wizard_translations.keys # must come before setting previous/next steps
79
78
  setup_wizard
80
79
  end
81
- public
82
80
  end
83
81
  end
84
82
  end
85
-
data/lib/wicked/wizard.rb CHANGED
@@ -10,7 +10,7 @@ module Wicked
10
10
 
11
11
  class UndefinedStepsError < RuntimeError
12
12
  def initialize
13
- super "No step definitions have been supplied; if setting via `before_filter`, use `prepend_before_filter`"
13
+ super "No step definitions have been supplied; if setting via `before_action`, use `prepend_before_action`"
14
14
  end
15
15
  end
16
16
 
@@ -20,19 +20,19 @@ module Wicked
20
20
  include Wicked::Controller::Concerns::Steps
21
21
 
22
22
  included do
23
+ include Wicked::Controller::Concerns::Action
23
24
  # Give our Views helper methods!
24
- helper_method :wizard_path, :next_wizard_path, :previous_wizard_path,
25
- :step, :wizard_steps, :current_step?,
26
- :past_step?, :future_step?, :previous_step?,
27
- :next_step?
25
+ helper_method :wizard_path, :wizard_url, :next_wizard_path, :next_wizard_url, :previous_wizard_path,
26
+ :previous_wizard_url, :step, :wizard_steps, :current_step?, :past_step?, :future_step?,
27
+ :next_step?, :previous_step?
28
+
28
29
  # Set @step and @next_step variables
29
- before_filter :setup_wizard
30
+ before_action :initialize_wicked_variables, :setup_wizard
30
31
  end
31
32
 
32
33
  # forward to first step with whatever params are provided
33
34
  def index
34
- query_string = "?#{request.query_parameters.to_query}" if request.query_parameters.any?
35
- redirect_to "#{ wizard_path(steps.first) }#{ query_string || '' }"
35
+ redirect_to wizard_path(steps.first, request.query_parameters)
36
36
  end
37
37
 
38
38
  # returns the canonical value for a step name, needed for translation support
@@ -40,14 +40,17 @@ module Wicked
40
40
  step_name
41
41
  end
42
42
 
43
- private
43
+ private def initialize_wicked_variables
44
+ @skip_to = nil
45
+ @wicked_redirect_params = nil
46
+ end
44
47
 
45
- def check_redirect_to_first_last!(step)
48
+ private def check_redirect_to_first_last!(step)
46
49
  redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
47
50
  redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
48
51
  end
49
52
 
50
- def setup_step_from(the_step)
53
+ private def setup_step_from(the_step)
51
54
  return if steps.nil?
52
55
 
53
56
  the_step ||= steps.first
@@ -60,23 +63,21 @@ module Wicked
60
63
  the_step
61
64
  end
62
65
 
63
- def check_steps!
66
+ private def check_steps!
64
67
  raise UndefinedStepsError if steps.nil?
65
68
  end
66
69
 
67
- def set_previous_next(step)
68
- @previous_step = previous_step(@step)
69
- @next_step = next_step(@step)
70
+ private def set_previous_next(step)
71
+ @previous_step = previous_step(step)
72
+ @next_step = next_step(step)
70
73
  end
71
74
 
72
- def setup_wizard
75
+ private def setup_wizard
73
76
  check_steps!
74
77
  return if params[:id].nil?
75
78
 
76
79
  @step = setup_step_from(params[:id])
77
80
  set_previous_next(@step)
78
81
  end
79
- public
80
82
  end
81
83
  end
82
-
@@ -32,7 +32,6 @@ class Wicked::WizardController < ApplicationController
32
32
  # @user.update_attributes(params[:user])
33
33
  # end
34
34
  # sign_in(@user, :bypass => true) # needed for devise
35
- # render_wizard
35
+ # render_wizard @user
36
36
  # end
37
37
  end
38
-
data/lib/wicked.rb CHANGED
@@ -13,6 +13,7 @@ module Wicked
13
13
  end
14
14
  module Wizard
15
15
  end
16
+ autoload :WizardController, "wicked/wizard_controller"
16
17
  end
17
18
 
18
19
  class WickedError < StandardError; end
@@ -21,7 +22,7 @@ class WickedProtectedStepError < WickedError; end
21
22
  require 'wicked/controller/concerns/render_redirect'
22
23
  require 'wicked/controller/concerns/steps'
23
24
  require 'wicked/controller/concerns/path'
25
+ require 'wicked/controller/concerns/action'
24
26
  require 'wicked/wizard'
25
27
  require 'wicked/wizard/translated'
26
28
  require 'wicked/engine'
27
-
@@ -1,13 +1,14 @@
1
1
  require 'test_helper'
2
2
 
3
- class BarControllerTest < ActionController::TestCase
3
+ class BarControllerTest < WickedControllerTestCase
4
+
4
5
  test 'index redirects to the first step' do
5
6
  get :index
6
7
  assert_redirected_to bar_path(:first)
7
8
  end
8
9
 
9
10
  test 'index redirects to the first step, preserving query args' do
10
- get :index, :some => 'arguments', :were => 'passed'
11
+ get :index, params: { :some => 'arguments', :were => 'passed' }
11
12
  assert_redirected_to bar_path(:first, :some => 'arguments', :were => 'passed')
12
13
  end
13
14
  end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ class UpdatesControllerTest < WickedControllerTestCase
4
+ test 'redirect from first step to second step' do
5
+ put :update, params: {:id => 'first'}
6
+ assert_redirected_to update_path(:second)
7
+ assert_equal 'Thing was updated from step first.', flash[:notice]
8
+ end
9
+
10
+ test 'redirect from second step to final step' do
11
+ put :update, params: {:id => 'second'}
12
+ assert_redirected_to update_path(:last_step)
13
+ assert_equal 'Thing was updated from step second.', flash[:notice]
14
+ end
15
+
16
+ test 'redirect from last_step to root path' do
17
+ put :update, params: {:id => 'last_step'}
18
+ assert_redirected_to update_path(:wicked_finish)
19
+ assert_equal 'Thing was updated from step last_step.', flash[:notice]
20
+ end
21
+
22
+ test 'redirect from wicked_finish to root path' do
23
+ get :show, params: {:id => Wicked::FINISH_STEP}, flash: {:notice => "flash from last_step"}
24
+ assert_redirected_to updates_path
25
+ assert_equal 'flash from last_step', flash[:notice]
26
+ end
27
+ end
@@ -1,7 +1,10 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
- before_filter :pull_out_locale
4
-
3
+ if respond_to? :before_action
4
+ before_action :pull_out_locale
5
+ else
6
+ before_filter :pull_out_locale
7
+ end
5
8
 
6
9
  def pull_out_locale
7
10
  I18n.locale = params[:locale] if params[:locale].present?
@@ -0,0 +1,18 @@
1
+ class DynamicDifferentStepsController < ApplicationController
2
+ include Wicked::Wizard
3
+
4
+ before_action :set_steps
5
+ before_action :setup_wizard
6
+
7
+ def show
8
+ render_wizard
9
+ end
10
+
11
+
12
+ private
13
+ def set_steps
14
+ self.steps = if params[:steps]
15
+ params[:steps]
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,6 @@
1
1
  class DynamicStepsController < ApplicationController
2
2
  include Wicked::Wizard
3
- prepend_before_filter :set_steps
3
+ prepend_before_action :set_steps
4
4
 
5
5
  def show
6
6
  render_wizard
@@ -5,8 +5,8 @@ class JumpController < ApplicationController
5
5
  steps :first, :second, :last_step
6
6
 
7
7
  def show
8
- skip_step if params[:skip_step]
9
- jump_to :last_step if params[:jump_to]
8
+ skip_step(skip_step_options) if params[:skip_step]
9
+ jump_to :last_step, skip_step_options if params[:jump_to]
10
10
  if params[:resource]
11
11
  value = params[:resource][:save] == 'true'
12
12
  @bar = Bar.new(value)
@@ -19,4 +19,11 @@ class JumpController < ApplicationController
19
19
  def update
20
20
  end
21
21
 
22
+ private
23
+
24
+ def skip_step_options
25
+ options = params[:skip_step_options]
26
+ options.permit! if options.respond_to? :permitted?
27
+ options
28
+ end
22
29
  end
@@ -17,4 +17,4 @@ class RedirectToNextController < ApplicationController
17
17
  def update
18
18
  end
19
19
 
20
- end
20
+ end
@@ -0,0 +1,30 @@
1
+ class UpdateParamsController < ApplicationController
2
+ include Wicked::Wizard
3
+
4
+ class Thing
5
+ def save
6
+ true
7
+ end
8
+ end
9
+
10
+ steps :first, :second, :last_step
11
+
12
+ def index
13
+
14
+ end
15
+
16
+ def show
17
+ render_wizard(nil, {}, { one: 'two' })
18
+ end
19
+
20
+ def update
21
+ @thing = Thing.new
22
+ render_wizard(@thing, { notice: "Thing was updated from step #{step}." }, { one: 'two' })
23
+ end
24
+
25
+ private
26
+
27
+ def finish_wizard_path(params)
28
+ update_params_path(params)
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ class UpdatesController < ApplicationController
2
+ include Wicked::Wizard
3
+
4
+ class Thing
5
+ def save
6
+ true
7
+ end
8
+ end
9
+
10
+ steps :first, :second, :last_step
11
+
12
+ def index
13
+
14
+ end
15
+
16
+ def show
17
+ render_wizard
18
+ end
19
+
20
+ def update
21
+ @thing = Thing.new
22
+ render_wizard(@thing, notice: "Thing was updated from step #{step}.")
23
+ end
24
+
25
+ private
26
+
27
+ def finish_wizard_path
28
+ updates_path
29
+ end
30
+ end
@@ -4,4 +4,6 @@ first
4
4
  <%= "params[:foo] #{params[:foo]}" %>
5
5
  <%= link_to 'last', wizard_path(:last_step) %>
6
6
  <%= link_to 'current', wizard_path %>
7
- <%= link_to 'skip', next_wizard_path %>
7
+ <%= link_to 'current url', wizard_url %>
8
+ <%= link_to 'skip', next_wizard_path %>
9
+ <%= link_to 'next url', next_wizard_url %>
@@ -1,3 +1,4 @@
1
1
  second
2
2
 
3
- <%= link_to 'previous', previous_wizard_path %>
3
+ <%= link_to 'previous', previous_wizard_path %>
4
+ <%= link_to 'previous url', previous_wizard_url %>
@@ -0,0 +1,3 @@
1
+ <%= step.inspect %>
2
+ <br />
3
+ <%= wizard_steps.inspect %>
@@ -1 +1,3 @@
1
- last_step
1
+ last_step
2
+
3
+ <%= params.inspect %>
@@ -1 +1,3 @@
1
- second
1
+ second
2
+
3
+ <%= params.inspect %>
@@ -0,0 +1,16 @@
1
+ <% wizard_steps.each do |s| %>
2
+ <%= s.inspect %>
3
+ <%= I18n.t("wicked.#{s}") %>
4
+ <p>
5
+ <strong><u><%= s.inspect %></u></strong><br />
6
+ <%= current_step?(s) ? "#{s} step is the current step" : "nope" %><br />
7
+ <%= past_step?(s) ? "#{s} step is a past step" : "nope" %><br />
8
+ <%= future_step?(s) ? "#{s} step is a future step" : "nope" %><br />
9
+ <%= previous_step?(s) ? "#{s} step was the previous step" : "nope" %><br />
10
+ <%= next_step?(s) ? "#{s} step is the next step" : "nope" %><br />
11
+ </p>
12
+ <% end %>
13
+
14
+ <%= form_tag update_param_path(step, {one: 'two'}), :method => :put do %>
15
+ <%= submit_tag "Next" %>
16
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -0,0 +1 @@
1
+ Index page.
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -0,0 +1,16 @@
1
+ <% wizard_steps.each do |s| %>
2
+ <%= s.inspect %>
3
+ <%= I18n.t("wicked.#{s}") %>
4
+ <p>
5
+ <strong><u><%= s.inspect %></u></strong><br />
6
+ <%= current_step?(s) ? "#{s} step is the current step" : "nope" %><br />
7
+ <%= past_step?(s) ? "#{s} step is a past step" : "nope" %><br />
8
+ <%= future_step?(s) ? "#{s} step is a future step" : "nope" %><br />
9
+ <%= previous_step?(s) ? "#{s} step was the previous step" : "nope" %><br />
10
+ <%= next_step?(s) ? "#{s} step is the next step" : "nope" %><br />
11
+ </p>
12
+ <% end %>
13
+
14
+ <%= form_tag update_path(step, {one: 'two'}), :method => :put do %>
15
+ <%= submit_tag "Next" %>
16
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -0,0 +1 @@
1
+ Index page.
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -0,0 +1 @@
1
+ <%= render 'step_position' %>
@@ -41,5 +41,8 @@ module Dummy
41
41
 
42
42
  # Configure sensitive parameters which will be filtered from the log file.
43
43
  config.filter_parameters += [:password]
44
+
45
+ config.eager_load = false
46
+ config.secret_key_base = 'foo'
44
47
  end
45
48
  end
@@ -11,7 +11,6 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
14
  config.action_controller.perform_caching = false
16
15
 
17
16
  # Don't care if the mailer can't send
@@ -8,7 +8,7 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
11
+ config.whiny_nils = true if Rails::VERSION::MAJOR == 3
12
12
 
13
13
  # Show full error reports and disable caching
14
14
  config.consider_all_requests_local = true
@@ -32,4 +32,6 @@ Dummy::Application.configure do
32
32
 
33
33
  # Print deprecation notices to the stderr
34
34
  config.active_support.deprecation = :stderr
35
+
36
+ config.active_support.test_order = :sorted
35
37
  end
@@ -4,9 +4,12 @@ Dummy::Application.routes.draw do
4
4
  resources :jump
5
5
  resources :step_positions
6
6
  resources :dynamic_steps
7
+ resources :dynamic_different_steps
7
8
  resources :string_steps
8
9
  resources :redirect_to_next
9
10
  resources :redirect_to_finish_flash
11
+ resources :updates
12
+ resources :update_params
10
13
 
11
14
  resources :nested do
12
15
  resources :builder, :controller => 'nested/builder'
@@ -1,10 +1,17 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class DynamicStepsTest < ActiveSupport::IntegrationCase
4
- test 'set dynamic steps from params' do
4
+ test 'set dynamic steps from params using prepend' do
5
5
  steps = ['first', 'second']
6
6
  visit dynamic_steps_path(:steps => steps)
7
7
  assert_has_content?(steps.first.inspect)
8
8
  assert_has_content?(steps.inspect)
9
9
  end
10
+
11
+ test 'set dynamic steps from params without using' do
12
+ steps = ['first', 'second']
13
+ visit dynamic_different_steps_path(:steps => steps)
14
+ assert_has_content?(steps.first.inspect)
15
+ assert_has_content?(steps.inspect)
16
+ end
10
17
  end