wicked 1.3.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 483905a170cbf0f6edace70c1673ba2c6cbcbeb6df0765ce8f86f73c5cf884f7
4
- data.tar.gz: 6f9f288d5c14e26082666345d4e02191c62135743860bc4a15931fe2659132c9
3
+ metadata.gz: eb950926820837e2ebfd752237b01d22a38186c6073642f9c2c3fbf94da96fb3
4
+ data.tar.gz: 8eddcdf3391ac3d8e881c75624b431cafb54ccc956d488f6a1f975f02aff0c8d
5
5
  SHA512:
6
- metadata.gz: 5cf319e58176f0985c111a4513f29580d5a3aa4161da881781021c77b6131f72166f00a8d68638938158030948c1b4e97ddd0ce5a8e95cb76557eb801c29de81
7
- data.tar.gz: 6187eb1522ae0998571f21aa8580707445771f84a2d6d27d2aa3358c1508a9200e55f61050cb0be967580c305ec5e25a02be6c79f370d3b7b5f762ecb61d0c31
6
+ metadata.gz: b33ad97299a460547b255c6774c6961d0c6ee0d9721ca9db04dbc26b7e37b606aaddd7a8a93dda1e6bc60e2b3418ac103bbca53bd76815cf65796acaaabc32fe
7
+ data.tar.gz: 4d5c337fb136b16a2468ba1f456f77db7f73600280fa5966e5c9f4d95bf01932aa61fb0bc5651a13974d259513dc7d6e353287e8b1daaf3488a6db157a7f1016
@@ -0,0 +1,13 @@
1
+ name: Check Changelog
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, reopened, edited, synchronize]
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v1
11
+ - name: Check that CHANGELOG is touched
12
+ run: |
13
+ cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
@@ -0,0 +1,53 @@
1
+ name: CI
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ - '2.5'
15
+ - '2.6'
16
+ - '2.7'
17
+ - '3.0'
18
+ - '3.1'
19
+ # - 'head'
20
+ gemfile:
21
+ - gemfiles/rails_5.2.gemfile
22
+ - gemfiles/rails_6.0.gemfile
23
+ - gemfiles/rails_7.0.gemfile
24
+ # - gemfile: gemfiles/rails_head.gemfile
25
+ exclude:
26
+ - ruby: '2.5'
27
+ gemfile: gemfiles/rails_7.0.gemfile
28
+ - ruby: '2.6'
29
+ gemfile: gemfiles/rails_7.0.gemfile
30
+ - ruby: '2.7'
31
+ gemfile: gemfiles/rails_5.2.gemfile
32
+ - ruby: '3.0'
33
+ gemfile: gemfiles/rails_5.2.gemfile
34
+ - ruby: '3.0'
35
+ gemfile: gemfiles/rails_6.0.gemfile
36
+ - ruby: '3.1'
37
+ gemfile: gemfiles/rails_5.2.gemfile
38
+ - ruby: '3.1'
39
+ gemfile: gemfiles/rails_6.0.gemfile
40
+ steps:
41
+ - name: Checkout code
42
+ uses: actions/checkout@v3
43
+ - name: Set up Ruby
44
+ env:
45
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
50
+ - name: Run test
51
+ env:
52
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
53
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -6,6 +6,7 @@ test/dummy/log/*.log
6
6
  test/dummy/tmp/
7
7
  .DS_Store
8
8
  .rvmrc
9
+ .idea
9
10
 
10
11
  Gemfile.lock
11
12
  .ruby-version
data/Appraisals CHANGED
@@ -1,30 +1,11 @@
1
- appraise "3.1" do
2
- gem "rails", "~> 3.1.0"
3
- gemspec
1
+ appraise "rails-5.2" do
2
+ gem "rails", "~> 5.2"
4
3
  end
5
4
 
6
- appraise "3.2" do
7
- gem "rails", "~> 3.2.15"
8
- gemspec
5
+ appraise "rails-6.0" do
6
+ gem "rails", "~> 6.0"
9
7
  end
10
8
 
11
- appraise "4.0" do
12
- gem "rails", "~> 4.0.0"
13
- gemspec
14
- end
15
-
16
- appraise "4.1" do
17
- gem "rails", "~> 4.1.0"
18
- gemspec
19
- end
20
-
21
-
22
- appraise "4.2" do
23
- gem "rails", "~> 4.2"
24
- gemspec
25
- end
26
-
27
- appraise "5.0.beta2" do
28
- gem "rails", "~> 5.0.0.beta2"
29
- gemspec
9
+ appraise "rails-7.0" do
10
+ gem "rails", "~> 7.0"
30
11
  end
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- ## Master
1
+ ## Unreleased
2
+
3
+ ## 2.0.0
4
+
5
+ * Return `422` (`:unprocessable_entity`) when form submissions fails. Turbo requires an HTTP Status code between 400-499 or 500-599 when a FormSubmission request fails. This pull request makes wicked compatible with Turbo Drive (https://github.com/zombocom/wicked/pull/294)
6
+ * Pass the provided step when raising InvalidStepError errors (https://github.com/zombocom/wicked/pull/284)
7
+
8
+ ## 1.4.0
9
+
10
+ * Update readme to include `current_step?` (https://github.com/zombocom/wicked/pull/271)
11
+ * Add `*_url` versions of `wizard_path`, `next_wizard_path`, and `previous_wizard_path` (https://github.com/zombocom/wicked/pull/272)
2
12
 
3
13
  ## 1.3.4
4
14
 
data/Gemfile CHANGED
@@ -1,10 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
-
4
- # Put all runtime dependencies in wicked.gemspec
5
- # Put development requirements for different platforms here
6
- # Put more specific gem declarations in different gemfiles/*.gemfile files
7
- gemspec :path => ::File.expand_path("../.", __FILE__)
3
+ gemspec
8
4
 
9
5
  group :development, :test do
10
6
  gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- ![](http://cl.ly/image/3O2i1P061o3y/content.png)
1
+ ![](./wicked.png)
2
2
 
3
3
  # Step-By-Step Wizard Controllers
4
4
 
5
- [![Build Status](https://travis-ci.org/schneems/wicked.svg?branch=master)](https://travis-ci.org/schneems/wicked)
5
+ [![Build Status](https://github.com/zombocom/wicked/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/zombocom/wicked)
6
6
  [![Code Climate](https://codeclimate.com/github/schneems/wicked/badges/gpa.svg)](https://codeclimate.com/github/schneems/wicked)
7
7
  [![Help Contribute to Open Source](https://www.codetriage.com/schneems/wicked/badges/users.svg)](https://www.codetriage.com/schneems/wicked)
8
8
 
@@ -30,6 +30,7 @@ Then run `bundle install` and you're ready to start
30
30
  * [Show Current Wizard Progress to User](https://github.com/schneems/wicked/wiki/Show-Current-Wizard-Progress-to-User)
31
31
  * [Example App](https://github.com/schneems/wicked_example)
32
32
  * [Screencast](http://schneems.com/post/18437886598/wizard-ify-your-rails-controllers-with-wicked)
33
+ * [Devise Onboarding With Wicked by Deanin](https://www.youtube.com/watch?v=P-eYHvgT4KA)
33
34
  * [Watch Railscasts episode: #346 Wizard Forms with Wicked](http://railscasts.com/episodes/346-wizard-forms-with-wicked)
34
35
 
35
36
  ## How
@@ -121,17 +122,23 @@ class AfterSignupController < ApplicationController
121
122
  @user = current_user
122
123
  case step
123
124
  when :confirm_password
124
- @user.update_attributes(params[:user])
125
+ @user.update(user_params)
125
126
  end
126
127
  sign_in(@user, bypass: true) # needed for devise
127
128
  render_wizard @user
128
129
  end
130
+
131
+ private
132
+ def user_params
133
+ params.require(:user)
134
+ .permit(:email, :current_password) # ...
135
+ end
129
136
  end
130
137
  ```
131
138
 
132
139
  We're passing `render_wizard` our `@user` object here. If you pass an object into `render_wizard` it will show the next step if the object saves or re-render the previous view if it does not save.
133
140
 
134
- Note that `render_wizard` does attempt to save the passed object. This means that in the above example, the object will be saved twice. This will cause any callbacks to run twice also. If this is undesirable for your use case, then calling `assign_attributes` (which does not save the object) instead of `update_attributes` might work better.
141
+ Note that `render_wizard` does attempt to save the passed object. This means that in the above example, the object will be saved twice. This will cause any callbacks to run twice also. If this is undesirable for your use case, then calling `assign_attributes` (which does not save the object) instead of `update` might work better.
135
142
 
136
143
  To get to this update action, you simply need to submit a form that PUT's to the same url
137
144
 
@@ -171,12 +178,17 @@ Now you've got a fully functioning AfterSignup controller! If you have questions
171
178
  **View/URL Helpers:**
172
179
 
173
180
  ```ruby
174
- wizard_path # Grabs the current path in the wizard
175
- wizard_path(:specific_step) # Url of the :specific_step
176
- next_wizard_path # Url of the next step
177
- previous_wizard_path # Url of the previous step
181
+ wizard_path # relative url of the current step
182
+ wizard_path(:specific_step) # relative url of a :specific_step
183
+ next_wizard_path # relative url of the next step
184
+ previous_wizard_path # relative url of the previous step
185
+
186
+ wizard_url # fully qualified url of the current step
187
+ wizard_url(:specific_step) # fully qualified url of a :specific_step
188
+ next_wizard_url # fully qualified url of the next step
189
+ previous_wizard_url # fully qualified url of the previous step
178
190
 
179
- # These only work while in a Wizard, and are not absolute paths
191
+ # These only work while in a Wizard
180
192
  # You can have multiple wizards in a project with multiple `wizard_path` calls
181
193
  ```
182
194
 
@@ -194,6 +206,7 @@ render_wizard # Renders the current step
194
206
  render_wizard(@user) # Shows next_step if @user.save, otherwise renders
195
207
  render_wizard(@user, context: :account_setup) # Shows next_step if @user.save(context: :account_setup), otherwise renders
196
208
  wizard_steps # Gets ordered list of steps
209
+ current_step?(step) # is step the same as the current request's step
197
210
  past_step?(step) # does step come before the current request's step in wizard_steps
198
211
  future_step?(step) # does step come after the current request's step in wizard_steps
199
212
  previous_step?(step) # is step immediately before the current request's step
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.2"
6
+
7
+ group :development, :test do
8
+ gem "sqlite3", platform: [:ruby, :mswin, :mingw]
9
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
10
+ end
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0"
6
+
7
+ group :development, :test do
8
+ gem "sqlite3", platform: [:ruby, :mswin, :mingw]
9
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
10
+ end
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.0"
6
+
7
+ group :development, :test do
8
+ gem "sqlite3", platform: [:ruby, :mswin, :mingw]
9
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
10
+ end
11
+
12
+ gemspec path: "../"
@@ -1,15 +1,22 @@
1
1
  module Wicked::Controller::Concerns::Path
2
2
  extend ActiveSupport::Concern
3
3
 
4
-
5
4
  def next_wizard_path(options = {})
6
5
  wizard_path(@next_step, options)
7
6
  end
8
7
 
8
+ def next_wizard_url(options = {})
9
+ wizard_url(@next_step, options)
10
+ end
11
+
9
12
  def previous_wizard_path(options = {})
10
13
  wizard_path(@previous_step, options)
11
14
  end
12
15
 
16
+ def previous_wizard_url(options = {})
17
+ wizard_url(@previous_step, options)
18
+ end
19
+
13
20
  def wicked_controller
14
21
  params[:controller]
15
22
  end
@@ -18,7 +25,6 @@ module Wicked::Controller::Concerns::Path
18
25
  params[:action]
19
26
  end
20
27
 
21
-
22
28
  def wizard_path(goto_step = nil, options = {})
23
29
  options = options.respond_to?(:to_h) ? options.to_h : options
24
30
  options = { :controller => wicked_controller,
@@ -28,5 +34,8 @@ module Wicked::Controller::Concerns::Path
28
34
  }.merge options
29
35
  url_for(options)
30
36
  end
31
- end
32
37
 
38
+ def wizard_url(goto_step = nil, options = {})
39
+ wizard_path(goto_step, options.merge(only_path: false))
40
+ end
41
+ end
@@ -1,7 +1,6 @@
1
1
  module Wicked::Controller::Concerns::RenderRedirect
2
2
  extend ActiveSupport::Concern
3
3
 
4
-
5
4
  def render_wizard(resource = nil, options = {}, params = {})
6
5
  process_resource!(resource, options)
7
6
 
@@ -26,6 +25,8 @@ module Wicked::Controller::Concerns::RenderRedirect
26
25
  @skip_to ||= @next_step
27
26
  else
28
27
  @skip_to = nil
28
+ # Do not override user-provided status for render
29
+ options[:status] ||= :unprocessable_entity
29
30
  end
30
31
  end
31
32
 
@@ -83,7 +83,6 @@ module Wicked::Controller::Concerns::Steps
83
83
  step ||= steps.first
84
84
  end
85
85
 
86
-
87
86
  def next_step(current_step = nil)
88
87
  return @next_step if current_step.nil?
89
88
  index = steps.index(current_step)
@@ -91,18 +90,15 @@ module Wicked::Controller::Concerns::Steps
91
90
  step ||= Wicked::FINISH_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)
101
+ private def current_and_given_step_exists?(step_name)
105
102
  current_step_index.present? && steps.index(step_name).present?
106
103
  end
107
104
  end
108
-
@@ -1,3 +1,3 @@
1
1
  module Wicked
2
- VERSION = "1.3.4"
2
+ VERSION = "2.0.0"
3
3
  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
@@ -3,8 +3,12 @@ module Wicked
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  class InvalidStepError < RuntimeError
6
- def initialize
7
- super "The requested step did not match any steps defined for this controller."
6
+ attr_accessor :step
7
+
8
+ def initialize(step = nil)
9
+ self.step = step
10
+
11
+ super "The requested step did not match any steps defined for this controller: #{step.inspect}"
8
12
  end
9
13
  end
10
14
 
@@ -15,7 +19,6 @@ module Wicked
15
19
  end
16
20
 
17
21
  # Include the modules!!
18
-
19
22
  include Wicked::Controller::Concerns::Path
20
23
  include Wicked::Controller::Concerns::RenderRedirect
21
24
  include Wicked::Controller::Concerns::Steps
@@ -23,12 +26,12 @@ module Wicked
23
26
  included do
24
27
  include Wicked::Controller::Concerns::Action
25
28
  # Give our Views helper methods!
26
- helper_method :wizard_path, :next_wizard_path, :previous_wizard_path,
27
- :step, :wizard_steps, :current_step?,
28
- :past_step?, :future_step?, :previous_step?,
29
- :next_step?
29
+ helper_method :wizard_path, :wizard_url, :next_wizard_path, :next_wizard_url, :previous_wizard_path,
30
+ :previous_wizard_url, :step, :wizard_steps, :current_step?, :past_step?, :future_step?,
31
+ :next_step?, :previous_step?
32
+
30
33
  # Set @step and @next_step variables
31
- before_action :setup_wizard
34
+ before_action :initialize_wicked_variables, :setup_wizard
32
35
  end
33
36
 
34
37
  # forward to first step with whatever params are provided
@@ -41,43 +44,44 @@ module Wicked
41
44
  step_name
42
45
  end
43
46
 
44
- private
47
+ private def initialize_wicked_variables
48
+ @skip_to = nil
49
+ @wicked_redirect_params = nil
50
+ end
45
51
 
46
- def check_redirect_to_first_last!(step)
52
+ private def check_redirect_to_first_last!(step)
47
53
  redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
48
54
  redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
49
55
  end
50
56
 
51
- def setup_step_from(the_step)
57
+ private def setup_step_from(the_step)
52
58
  return if steps.nil?
53
59
 
54
60
  the_step ||= steps.first
55
61
  check_redirect_to_first_last!(the_step)
56
62
 
57
63
  valid_steps = steps + self.class::PROTECTED_STEPS
58
- the_step = valid_steps.detect { |stp| stp.to_s == the_step }
64
+ resolved_step = valid_steps.detect { |stp| stp.to_s == the_step }
59
65
 
60
- raise InvalidStepError if the_step.nil?
61
- the_step
66
+ raise InvalidStepError.new(the_step) if resolved_step.nil?
67
+ resolved_step
62
68
  end
63
69
 
64
- def check_steps!
70
+ private def check_steps!
65
71
  raise UndefinedStepsError if steps.nil?
66
72
  end
67
73
 
68
- def set_previous_next(step)
74
+ private def set_previous_next(step)
69
75
  @previous_step = previous_step(step)
70
76
  @next_step = next_step(step)
71
77
  end
72
78
 
73
- def setup_wizard
79
+ private def setup_wizard
74
80
  check_steps!
75
81
  return if params[:id].nil?
76
82
 
77
83
  @step = setup_step_from(params[:id])
78
84
  set_previous_next(@step)
79
85
  end
80
- public
81
86
  end
82
87
  end
83
-
@@ -35,4 +35,3 @@ class Wicked::WizardController < ApplicationController
35
35
  # render_wizard @user
36
36
  # end
37
37
  end
38
-
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ class StatusCodesControllerTest < WickedControllerTestCase
4
+ test 'returns successful status code for show' do
5
+ get :show, params: { id: 'good' }
6
+ assert_response(:success)
7
+ end
8
+
9
+ test 'returns correct status code for successfuly update' do
10
+ put :update, params: { id: 'good' }
11
+ assert_response(:redirect)
12
+ end
13
+
14
+ test 'returns correct status code for failed update' do
15
+ put :update, params: { id: 'bad' }
16
+ assert_response(:unprocessable_entity)
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ class StatusCodesController < ApplicationController
2
+ include Wicked::Wizard
3
+
4
+ class GoodThing
5
+ def save
6
+ true
7
+ end
8
+ end
9
+
10
+ class BadThing
11
+ def save
12
+ false
13
+ end
14
+ end
15
+
16
+ steps :good, :bad
17
+
18
+ def index; end
19
+
20
+ def show
21
+ render_wizard
22
+ end
23
+
24
+ def update
25
+ case step
26
+ when :good
27
+ @thing = GoodThing.new
28
+ when :bad
29
+ @thing = BadThing.new
30
+ end
31
+ render_wizard(@thing, notice: "Thing was updated from step #{step}.")
32
+ end
33
+
34
+ private
35
+
36
+ def finish_wizard_path
37
+ updates_path
38
+ end
39
+ 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 @@
1
+ bad step
@@ -0,0 +1 @@
1
+ good step
@@ -8,6 +8,7 @@ Dummy::Application.routes.draw do
8
8
  resources :string_steps
9
9
  resources :redirect_to_next
10
10
  resources :redirect_to_finish_flash
11
+ resources :status_codes
11
12
  resources :updates
12
13
  resources :update_params
13
14
 
@@ -5,13 +5,23 @@ class HelpersTest < ActiveSupport::IntegrationCase
5
5
  test 'next_wizard_path' do
6
6
  step = :first
7
7
  visit(bar_path(step))
8
+ assert has_link?('skip', href: '/bar/second')
8
9
  click_link 'skip'
9
10
  assert_has_content?('second')
10
11
  end
11
12
 
13
+ test 'next_wizard_url' do
14
+ step = :first
15
+ visit(bar_path(step))
16
+ assert has_link?('next url', href: 'http://www.example.com/bar/second')
17
+ click_link 'next url'
18
+ assert_has_content?('second')
19
+ end
20
+
12
21
  test 'wizard_path' do
13
22
  step = :first
14
23
  visit(bar_path(step))
24
+ assert has_link?('current', href: '/bar/first')
15
25
  click_link 'current'
16
26
  assert_has_content?(step.to_s)
17
27
  end
@@ -23,9 +33,26 @@ class HelpersTest < ActiveSupport::IntegrationCase
23
33
  assert_has_content?('last_step')
24
34
  end
25
35
 
36
+ test 'wizard_url' do
37
+ step = :first
38
+ visit(bar_path(step))
39
+ assert has_link?('current url', href: 'http://www.example.com/bar/first')
40
+ click_link 'current'
41
+ assert_has_content?(step.to_s)
42
+ end
43
+
26
44
  test 'previous_wizard_path' do
27
45
  step = :second
28
46
  visit(bar_path(step))
47
+ assert has_link?('previous', href: '/bar/first')
48
+ click_link 'previous'
49
+ assert_has_content?("first")
50
+ end
51
+
52
+ test 'previous_wizard_url' do
53
+ step = :second
54
+ visit(bar_path(step))
55
+ assert has_link?('previous url', href: 'http://www.example.com/bar/first')
29
56
  click_link 'previous'
30
57
  assert_has_content?("first")
31
58
  end
@@ -7,7 +7,6 @@ class SecurityTest < ActiveSupport::IntegrationCase
7
7
  assert_raise(Wicked::Wizard::InvalidStepError) do
8
8
  visit(bar_path(step))
9
9
  end
10
- refute has_content?('sqlite3')
11
10
  end
12
11
 
13
12
  # only works on *nix systems
@@ -18,6 +17,5 @@ class SecurityTest < ActiveSupport::IntegrationCase
18
17
  assert_raise(Wicked::Wizard::InvalidStepError) do
19
18
  visit(bar_path(step))
20
19
  end
21
- refute has_content?('aardvark')
22
20
  end
23
21
  end
data/test/test_helper.rb CHANGED
@@ -1,15 +1,10 @@
1
1
  # Configure Rails Envinronment
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
-
5
-
6
4
  ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
7
5
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
6
  require "rails/test_help"
9
7
 
10
-
11
-
12
-
13
8
  ActionMailer::Base.delivery_method = :test
14
9
  ActionMailer::Base.perform_deliveries = true
15
10
  ActionMailer::Base.default_url_options[:host] = "test.com"
@@ -21,10 +16,15 @@ require "capybara/rails"
21
16
  Capybara.default_driver = :rack_test
22
17
  Capybara.default_selector = :css
23
18
 
24
-
25
-
26
- # Run any available migration
27
- ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
19
+ # https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
20
+ migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
21
+ if ActiveRecord.version < Gem::Version.create("5.2.0")
22
+ ActiveRecord::Migrator.migrate(migrate_path)
23
+ elsif ActiveRecord.version < Gem::Version.create("6.0.0")
24
+ ActiveRecord::MigrationContext.new(migrate_path).migrate
25
+ else
26
+ ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
27
+ end
28
28
 
29
29
  # Load support files
30
30
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
data/wicked.png ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wicked
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -88,8 +88,9 @@ extensions: []
88
88
  extra_rdoc_files:
89
89
  - README.md
90
90
  files:
91
+ - ".github/workflows/check_changelog.yml"
92
+ - ".github/workflows/ci.yml"
91
93
  - ".gitignore"
92
- - ".travis.yml"
93
94
  - Appraisals
94
95
  - CHANGELOG.md
95
96
  - CONTRIBUTING.md
@@ -97,12 +98,9 @@ files:
97
98
  - MIT-LICENSE
98
99
  - README.md
99
100
  - Rakefile
100
- - gemfiles/3.1.gemfile
101
- - gemfiles/3.2.gemfile
102
- - gemfiles/4.0.gemfile
103
- - gemfiles/4.1.gemfile
104
- - gemfiles/4.2.gemfile
105
- - gemfiles/5.0.beta2.gemfile
101
+ - gemfiles/rails_5.2.gemfile
102
+ - gemfiles/rails_6.0.gemfile
103
+ - gemfiles/rails_7.0.gemfile
106
104
  - lib/wicked.rb
107
105
  - lib/wicked/controller/concerns/action.rb
108
106
  - lib/wicked/controller/concerns/path.rb
@@ -114,6 +112,7 @@ files:
114
112
  - lib/wicked/wizard/translated.rb
115
113
  - lib/wicked/wizard_controller.rb
116
114
  - test/controllers/bar_controller_test.rb
115
+ - test/controllers/status_codes_controller_test.rb
117
116
  - test/controllers/updates_controller_test.rb
118
117
  - test/dummy/Rakefile
119
118
  - test/dummy/app/controllers/application_controller.rb
@@ -126,6 +125,7 @@ files:
126
125
  - test/dummy/app/controllers/pages_controller.rb
127
126
  - test/dummy/app/controllers/redirect_to_finish_flash_controller.rb
128
127
  - test/dummy/app/controllers/redirect_to_next_controller.rb
128
+ - test/dummy/app/controllers/status_codes_controller.rb
129
129
  - test/dummy/app/controllers/step_positions_controller.rb
130
130
  - test/dummy/app/controllers/string_steps_controller.rb
131
131
  - test/dummy/app/controllers/update_params_controller.rb
@@ -153,6 +153,8 @@ files:
153
153
  - test/dummy/app/views/redirect_to_next/first.html.erb
154
154
  - test/dummy/app/views/redirect_to_next/last_step.html.erb
155
155
  - test/dummy/app/views/redirect_to_next/second.html.erb
156
+ - test/dummy/app/views/status_codes/bad.html.erb
157
+ - test/dummy/app/views/status_codes/good.html.erb
156
158
  - test/dummy/app/views/step_positions/_step_position.html.erb
157
159
  - test/dummy/app/views/step_positions/first.html.erb
158
160
  - test/dummy/app/views/step_positions/last_step.html.erb
@@ -213,11 +215,12 @@ files:
213
215
  - test/test_helper.rb
214
216
  - test/wicked_test.rb
215
217
  - wicked.gemspec
218
+ - wicked.png
216
219
  homepage: https://github.com/schneems/wicked
217
220
  licenses:
218
221
  - MIT
219
222
  metadata: {}
220
- post_install_message:
223
+ post_install_message:
221
224
  rdoc_options: []
222
225
  require_paths:
223
226
  - lib
@@ -232,12 +235,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
235
  - !ruby/object:Gem::Version
233
236
  version: '0'
234
237
  requirements: []
235
- rubygems_version: 3.0.3
236
- signing_key:
238
+ rubygems_version: 3.3.7
239
+ signing_key:
237
240
  specification_version: 4
238
241
  summary: Use Wicked to turn your controller into a wizard
239
242
  test_files:
240
243
  - test/controllers/bar_controller_test.rb
244
+ - test/controllers/status_codes_controller_test.rb
241
245
  - test/controllers/updates_controller_test.rb
242
246
  - test/dummy/Rakefile
243
247
  - test/dummy/app/controllers/application_controller.rb
@@ -250,6 +254,7 @@ test_files:
250
254
  - test/dummy/app/controllers/pages_controller.rb
251
255
  - test/dummy/app/controllers/redirect_to_finish_flash_controller.rb
252
256
  - test/dummy/app/controllers/redirect_to_next_controller.rb
257
+ - test/dummy/app/controllers/status_codes_controller.rb
253
258
  - test/dummy/app/controllers/step_positions_controller.rb
254
259
  - test/dummy/app/controllers/string_steps_controller.rb
255
260
  - test/dummy/app/controllers/update_params_controller.rb
@@ -277,6 +282,8 @@ test_files:
277
282
  - test/dummy/app/views/redirect_to_next/first.html.erb
278
283
  - test/dummy/app/views/redirect_to_next/last_step.html.erb
279
284
  - test/dummy/app/views/redirect_to_next/second.html.erb
285
+ - test/dummy/app/views/status_codes/bad.html.erb
286
+ - test/dummy/app/views/status_codes/good.html.erb
280
287
  - test/dummy/app/views/step_positions/_step_position.html.erb
281
288
  - test/dummy/app/views/step_positions/first.html.erb
282
289
  - test/dummy/app/views/step_positions/last_step.html.erb
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.1
6
- - 2.2.2
7
- - ruby-head
8
- - jruby-19mode
9
-
10
- sudo: false
11
-
12
- gemfile:
13
- - gemfiles/3.1.gemfile
14
- - gemfiles/3.2.gemfile
15
- - gemfiles/4.0.gemfile
16
- - gemfiles/4.1.gemfile
17
- - gemfiles/4.2.gemfile
18
- matrix:
19
- include:
20
- - gemfile: gemfiles/5.0.beta2.gemfile
21
- rvm: 2.2.2
22
- allow_failures:
23
- - gemfile: gemfiles/3.0.gemfile
24
- rvm: 2.0.0
25
- - gemfile: gemfiles/3.0.gemfile
26
- rvm: 2.1.1
27
- - rvm: ruby-head
28
-
data/gemfiles/3.1.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.1.0"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"
data/gemfiles/3.2.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.15"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"
data/gemfiles/4.0.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.0.0"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"
data/gemfiles/4.1.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.1.0"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"
data/gemfiles/4.2.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.2"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0.beta2"
6
-
7
- group :development, :test do
8
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
- end
11
-
12
- gemspec :path => "../"