wicked 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +53 -0
- data/Appraisals +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +5 -4
- data/gemfiles/{rails_5.1.gemfile → rails_6.0.gemfile} +1 -1
- data/gemfiles/{rails_6.0.1.gemfile → rails_7.0.gemfile} +1 -1
- data/lib/wicked/controller/concerns/render_redirect.rb +2 -0
- data/lib/wicked/version.rb +1 -1
- data/lib/wicked/wizard.rb +9 -5
- data/test/controllers/status_codes_controller_test.rb +18 -0
- data/test/dummy/app/controllers/status_codes_controller.rb +39 -0
- data/test/dummy/app/views/status_codes/bad.html.erb +1 -0
- data/test/dummy/app/views/status_codes/good.html.erb +1 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/test_helper.rb +4 -4
- data/wicked.png +0 -0
- metadata +15 -6
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb950926820837e2ebfd752237b01d22a38186c6073642f9c2c3fbf94da96fb3
|
4
|
+
data.tar.gz: 8eddcdf3391ac3d8e881c75624b431cafb54ccc956d488f6a1f975f02aff0c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b33ad97299a460547b255c6774c6961d0c6ee0d9721ca9db04dbc26b7e37b606aaddd7a8a93dda1e6bc60e2b3418ac103bbca53bd76815cf65796acaaabc32fe
|
7
|
+
data.tar.gz: 4d5c337fb136b16a2468ba1f456f77db7f73600280fa5966e5c9f4d95bf01932aa61fb0bc5651a13974d259513dc7d6e353287e8b1daaf3488a6db157a7f1016
|
@@ -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/Appraisals
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
appraise "rails-5.
|
1
|
+
appraise "rails-5.2" do
|
2
2
|
gem "rails", "~> 5.2"
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise "rails-
|
6
|
-
gem "rails", "~>
|
5
|
+
appraise "rails-6.0" do
|
6
|
+
gem "rails", "~> 6.0"
|
7
7
|
end
|
8
8
|
|
9
|
-
appraise "rails-
|
10
|
-
gem "rails", "~>
|
9
|
+
appraise "rails-7.0" do
|
10
|
+
gem "rails", "~> 7.0"
|
11
11
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## Unreleased
|
2
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
|
+
|
3
8
|
## 1.4.0
|
4
9
|
|
5
10
|
* Update readme to include `current_step?` (https://github.com/zombocom/wicked/pull/271)
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
![](
|
1
|
+
![](./wicked.png)
|
2
2
|
|
3
3
|
# Step-By-Step Wizard Controllers
|
4
4
|
|
5
|
-
[![Build Status](https://
|
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,7 +122,7 @@ class AfterSignupController < ApplicationController
|
|
121
122
|
@user = current_user
|
122
123
|
case step
|
123
124
|
when :confirm_password
|
124
|
-
@user.
|
125
|
+
@user.update(user_params)
|
125
126
|
end
|
126
127
|
sign_in(@user, bypass: true) # needed for devise
|
127
128
|
render_wizard @user
|
@@ -137,7 +138,7 @@ end
|
|
137
138
|
|
138
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.
|
139
140
|
|
140
|
-
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 `
|
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.
|
141
142
|
|
142
143
|
To get to this update action, you simply need to submit a form that PUT's to the same url
|
143
144
|
|
data/lib/wicked/version.rb
CHANGED
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
|
-
|
7
|
-
|
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
|
|
@@ -57,10 +61,10 @@ module Wicked
|
|
57
61
|
check_redirect_to_first_last!(the_step)
|
58
62
|
|
59
63
|
valid_steps = steps + self.class::PROTECTED_STEPS
|
60
|
-
|
64
|
+
resolved_step = valid_steps.detect { |stp| stp.to_s == the_step }
|
61
65
|
|
62
|
-
raise InvalidStepError if
|
63
|
-
|
66
|
+
raise InvalidStepError.new(the_step) if resolved_step.nil?
|
67
|
+
resolved_step
|
64
68
|
end
|
65
69
|
|
66
70
|
private def check_steps!
|
@@ -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
|
@@ -0,0 +1 @@
|
|
1
|
+
bad step
|
@@ -0,0 +1 @@
|
|
1
|
+
good step
|
data/test/dummy/config/routes.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -18,12 +18,12 @@ Capybara.default_selector = :css
|
|
18
18
|
|
19
19
|
# https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
|
20
20
|
migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
|
21
|
-
if
|
22
|
-
ActiveRecord::
|
23
|
-
elsif
|
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
24
|
ActiveRecord::MigrationContext.new(migrate_path).migrate
|
25
25
|
else
|
26
|
-
ActiveRecord::
|
26
|
+
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
|
27
27
|
end
|
28
28
|
|
29
29
|
# Load support files
|
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -89,8 +89,8 @@ extra_rdoc_files:
|
|
89
89
|
- README.md
|
90
90
|
files:
|
91
91
|
- ".github/workflows/check_changelog.yml"
|
92
|
+
- ".github/workflows/ci.yml"
|
92
93
|
- ".gitignore"
|
93
|
-
- ".travis.yml"
|
94
94
|
- Appraisals
|
95
95
|
- CHANGELOG.md
|
96
96
|
- CONTRIBUTING.md
|
@@ -98,9 +98,9 @@ files:
|
|
98
98
|
- MIT-LICENSE
|
99
99
|
- README.md
|
100
100
|
- Rakefile
|
101
|
-
- gemfiles/rails_5.1.gemfile
|
102
101
|
- gemfiles/rails_5.2.gemfile
|
103
|
-
- gemfiles/rails_6.0.
|
102
|
+
- gemfiles/rails_6.0.gemfile
|
103
|
+
- gemfiles/rails_7.0.gemfile
|
104
104
|
- lib/wicked.rb
|
105
105
|
- lib/wicked/controller/concerns/action.rb
|
106
106
|
- lib/wicked/controller/concerns/path.rb
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/wicked/wizard/translated.rb
|
113
113
|
- lib/wicked/wizard_controller.rb
|
114
114
|
- test/controllers/bar_controller_test.rb
|
115
|
+
- test/controllers/status_codes_controller_test.rb
|
115
116
|
- test/controllers/updates_controller_test.rb
|
116
117
|
- test/dummy/Rakefile
|
117
118
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- test/dummy/app/controllers/pages_controller.rb
|
125
126
|
- test/dummy/app/controllers/redirect_to_finish_flash_controller.rb
|
126
127
|
- test/dummy/app/controllers/redirect_to_next_controller.rb
|
128
|
+
- test/dummy/app/controllers/status_codes_controller.rb
|
127
129
|
- test/dummy/app/controllers/step_positions_controller.rb
|
128
130
|
- test/dummy/app/controllers/string_steps_controller.rb
|
129
131
|
- test/dummy/app/controllers/update_params_controller.rb
|
@@ -151,6 +153,8 @@ files:
|
|
151
153
|
- test/dummy/app/views/redirect_to_next/first.html.erb
|
152
154
|
- test/dummy/app/views/redirect_to_next/last_step.html.erb
|
153
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
|
154
158
|
- test/dummy/app/views/step_positions/_step_position.html.erb
|
155
159
|
- test/dummy/app/views/step_positions/first.html.erb
|
156
160
|
- test/dummy/app/views/step_positions/last_step.html.erb
|
@@ -211,6 +215,7 @@ files:
|
|
211
215
|
- test/test_helper.rb
|
212
216
|
- test/wicked_test.rb
|
213
217
|
- wicked.gemspec
|
218
|
+
- wicked.png
|
214
219
|
homepage: https://github.com/schneems/wicked
|
215
220
|
licenses:
|
216
221
|
- MIT
|
@@ -230,12 +235,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
235
|
- !ruby/object:Gem::Version
|
231
236
|
version: '0'
|
232
237
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
238
|
+
rubygems_version: 3.3.7
|
234
239
|
signing_key:
|
235
240
|
specification_version: 4
|
236
241
|
summary: Use Wicked to turn your controller into a wizard
|
237
242
|
test_files:
|
238
243
|
- test/controllers/bar_controller_test.rb
|
244
|
+
- test/controllers/status_codes_controller_test.rb
|
239
245
|
- test/controllers/updates_controller_test.rb
|
240
246
|
- test/dummy/Rakefile
|
241
247
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -248,6 +254,7 @@ test_files:
|
|
248
254
|
- test/dummy/app/controllers/pages_controller.rb
|
249
255
|
- test/dummy/app/controllers/redirect_to_finish_flash_controller.rb
|
250
256
|
- test/dummy/app/controllers/redirect_to_next_controller.rb
|
257
|
+
- test/dummy/app/controllers/status_codes_controller.rb
|
251
258
|
- test/dummy/app/controllers/step_positions_controller.rb
|
252
259
|
- test/dummy/app/controllers/string_steps_controller.rb
|
253
260
|
- test/dummy/app/controllers/update_params_controller.rb
|
@@ -275,6 +282,8 @@ test_files:
|
|
275
282
|
- test/dummy/app/views/redirect_to_next/first.html.erb
|
276
283
|
- test/dummy/app/views/redirect_to_next/last_step.html.erb
|
277
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
|
278
287
|
- test/dummy/app/views/step_positions/_step_position.html.erb
|
279
288
|
- test/dummy/app/views/step_positions/first.html.erb
|
280
289
|
- test/dummy/app/views/step_positions/last_step.html.erb
|
data/.travis.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.5.8
|
4
|
-
- 2.6.6
|
5
|
-
- 2.7.1
|
6
|
-
|
7
|
-
sudo: false
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
- gemfiles/rails_5.1.gemfile
|
11
|
-
- gemfiles/rails_5.2.gemfile
|
12
|
-
- gemfiles/rails_6.0.1.gemfile
|
13
|
-
|
14
|
-
jobs:
|
15
|
-
exclude:
|
16
|
-
- gemfile: gemfiles/rails_5.1.gemfile
|
17
|
-
rvm: 2.7.1
|