wicked 1.0.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/check_changelog.yml +13 -0
- data/.gitignore +15 -0
- data/.travis.yml +12 -17
- data/Appraisals +11 -0
- data/CHANGELOG.md +40 -0
- data/CONTRIBUTING.md +19 -0
- data/Gemfile +3 -20
- data/README.md +148 -34
- data/Rakefile +2 -15
- data/gemfiles/rails_5.1.gemfile +12 -0
- data/gemfiles/rails_5.2.gemfile +12 -0
- data/gemfiles/rails_6.0.1.gemfile +12 -0
- data/lib/wicked/controller/concerns/action.rb +13 -0
- data/lib/wicked/controller/concerns/path.rb +13 -3
- data/lib/wicked/controller/concerns/render_redirect.rb +33 -23
- data/lib/wicked/controller/concerns/steps.rb +12 -17
- data/lib/wicked/version.rb +3 -0
- data/lib/wicked/wizard/translated.rb +3 -6
- data/lib/wicked/wizard.rb +19 -18
- data/{app/controllers → lib}/wicked/wizard_controller.rb +1 -2
- data/lib/wicked.rb +2 -1
- data/test/controllers/bar_controller_test.rb +3 -2
- data/test/controllers/updates_controller_test.rb +27 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -2
- data/test/dummy/app/controllers/dynamic_different_steps_controller.rb +18 -0
- data/test/dummy/app/controllers/dynamic_steps_controller.rb +1 -1
- data/test/dummy/app/controllers/jump_controller.rb +9 -2
- data/test/dummy/app/controllers/redirect_to_next_controller.rb +1 -1
- data/test/dummy/app/controllers/update_params_controller.rb +30 -0
- data/test/dummy/app/controllers/updates_controller.rb +30 -0
- data/test/dummy/app/views/bar/first.html.erb +3 -1
- data/test/dummy/app/views/bar/second.html.erb +2 -1
- data/test/dummy/app/views/dynamic_different_steps/first.html.erb +3 -0
- data/test/dummy/app/views/jump/last_step.html.erb +3 -1
- data/test/dummy/app/views/jump/second.html.erb +3 -1
- data/test/dummy/app/views/update_params/_step_position.html.erb +16 -0
- data/test/dummy/app/views/update_params/first.html.erb +1 -0
- data/test/dummy/app/views/update_params/index.html.erb +1 -0
- data/test/dummy/app/views/update_params/last_step.html.erb +1 -0
- data/test/dummy/app/views/update_params/second.html.erb +1 -0
- data/test/dummy/app/views/updates/_step_position.html.erb +16 -0
- data/test/dummy/app/views/updates/first.html.erb +1 -0
- data/test/dummy/app/views/updates/index.html.erb +1 -0
- data/test/dummy/app/views/updates/last_step.html.erb +1 -0
- data/test/dummy/app/views/updates/second.html.erb +1 -0
- data/test/dummy/config/application.rb +3 -0
- data/test/dummy/config/environments/development.rb +0 -1
- data/test/dummy/config/environments/test.rb +3 -1
- data/test/dummy/config/routes.rb +3 -0
- data/test/integration/dynamic_steps_test.rb +8 -1
- data/test/integration/helpers_test.rb +27 -0
- data/test/integration/jump_test.rb +16 -0
- data/test/integration/redirect_to_next_test.rb +1 -1
- data/test/integration/security_test.rb +0 -2
- data/test/integration/update_params_test.rb +20 -0
- data/test/integration/updates_test.rb +20 -0
- data/test/support/wicked_controller_test_case.rb +9 -0
- data/test/test_helper.rb +9 -9
- data/wicked.gemspec +22 -150
- metadata +146 -50
- data/.rvmrc +0 -19
- data/VERSION +0 -1
- /data/test/dummy/app/controllers/{steps_controller.rb → step_positions_controller.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ebda68c36a8e0e08aa54c850b91c176720d5fa4897482d0312182c2bee6a418f
|
4
|
+
data.tar.gz: f7a27e0b7baafe854a3891d0ec185a425f6d0e57694325dd2597ca9f7f94d85b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad278bb225e74a389efb8413290763b644625ff2bdc89213da99c7941b214abbdbfbc1e9e85c691a03196be064321f07d3c1222a2916c45bb6be3c425aee874
|
7
|
+
data.tar.gz: db3bdd321cc8902b9fa693e4884c567aa9fe474ad7fbe5cdd6f7452beec054ba9b21252441dabfd42e23adc94ee1e7fceac4bda07394d456c7cc36e65f50d82d
|
@@ -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
|
data/.gitignore
ADDED
data/.travis.yml
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
-
|
6
|
-
- jruby-19mode
|
3
|
+
- 2.5.8
|
4
|
+
- 2.6.6
|
5
|
+
- 2.7.1
|
7
6
|
|
8
|
-
|
9
|
-
- "RAILS_VERSION=3.0.7"
|
10
|
-
- "RAILS_VERSION=3.1.0"
|
11
|
-
- "RAILS_VERSION=3.2.0"
|
12
|
-
- "RAILS_VERSION=4.0.0"
|
13
|
-
- "RAILS_VERSION=4.1.0"
|
14
|
-
- "RAILS_VERSION=master"
|
7
|
+
sudo: false
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- env: "RAILS_VERSION=master"
|
21
|
-
- rvm: ruby-head
|
9
|
+
gemfile:
|
10
|
+
- gemfiles/rails_5.1.gemfile
|
11
|
+
- gemfiles/rails_5.2.gemfile
|
12
|
+
- gemfiles/rails_6.0.1.gemfile
|
22
13
|
|
14
|
+
jobs:
|
15
|
+
exclude:
|
16
|
+
- gemfile: gemfiles/rails_5.1.gemfile
|
17
|
+
rvm: 2.7.1
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
## 1.4.0
|
4
|
+
|
5
|
+
* Update readme to include `current_step?` (https://github.com/zombocom/wicked/pull/271)
|
6
|
+
* Add `*_url` versions of `wizard_path`, `next_wizard_path`, and `previous_wizard_path` (https://github.com/zombocom/wicked/pull/272)
|
7
|
+
|
8
|
+
## 1.3.4
|
9
|
+
|
10
|
+
* Remove arity check for AR objects (https://github.com/schneems/wicked/pull/257)
|
11
|
+
|
12
|
+
## 1.3.3
|
13
|
+
|
14
|
+
* Support being able to set a context in validation (https://github.com/schneems/wicked/pull/236)
|
15
|
+
|
16
|
+
## 1.3.2
|
17
|
+
|
18
|
+
* Support for params (#222)
|
19
|
+
|
20
|
+
## 1.3.1
|
21
|
+
|
22
|
+
* Docs and minor fixes
|
23
|
+
|
24
|
+
## 1.3.0
|
25
|
+
|
26
|
+
* [#201] Avoid Rails 5 deprecations.
|
27
|
+
|
28
|
+
## 1.2.1 (8/28/2015)
|
29
|
+
|
30
|
+
* [#186] Do not require use of ApplicationController with wicked.
|
31
|
+
|
32
|
+
## 1.1.1 (2/23/2015)
|
33
|
+
|
34
|
+
* [#159] Default wizard index actions now work when using `default_url_options`
|
35
|
+
|
36
|
+
## 1.1.0 (9/15/2014)
|
37
|
+
|
38
|
+
* [#136] `skip_step` and `jump_to` now take redirect options. You can use
|
39
|
+
this to effectively pass parameters to a redirect initiated by either of these method.
|
40
|
+
|
1
41
|
## 1.0.3 (4/25/2014)
|
2
42
|
|
3
43
|
* All `to_sym` have been removed. Symbol attacks are no longer possible.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
There are two main ways to contribute to this project.
|
4
|
+
|
5
|
+
## Content
|
6
|
+
|
7
|
+
* Write articles
|
8
|
+
* Recording screencasts
|
9
|
+
* Submit presentations
|
10
|
+
|
11
|
+
## Development
|
12
|
+
|
13
|
+
Using [CodeTriage](http://www.codetriage.com/schneems/wicked) as a volunteer, you'll receive an email each day with a link to an open issue that needs to be triaged in this project. You'll also receive instructions on how to triage issues.
|
14
|
+
|
15
|
+
1. Fork it! ( https://github.com/schneems/wicked/fork )
|
16
|
+
2. Create your feature branch: `git checkout -b my-new-feature`
|
17
|
+
3. Commit your changes: `git commit -am 'Add some feature'`
|
18
|
+
4. Push to the branch: `git push origin my-new-feature`
|
19
|
+
5. Create a new Pull Request :D
|
data/Gemfile
CHANGED
@@ -1,25 +1,8 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
rails = case rails_version
|
6
|
-
when "master"
|
7
|
-
{:github => "rails/rails"}
|
8
|
-
when "default"
|
9
|
-
">= 3.0.7"
|
10
|
-
else
|
11
|
-
"~> #{rails_version}"
|
12
|
-
end
|
13
|
-
|
14
|
-
gem "rails", rails
|
15
|
-
|
3
|
+
gemspec
|
16
4
|
|
17
5
|
group :development, :test do
|
18
|
-
gem
|
19
|
-
gem '
|
20
|
-
gem "capybara", "~> 1.1.2"
|
21
|
-
gem "launchy"
|
22
|
-
|
23
|
-
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
24
|
-
gem "activerecord-jdbcsqlite3-adapter", '>= 1.3.0.beta', :platform => :jruby
|
6
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
|
7
|
+
gem "activerecord-jdbcsqlite3-adapter", '~> 1.3.13', :platform => :jruby
|
25
8
|
end
|
data/README.md
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
# Step-By-Step Wizard Controllers
|
4
4
|
|
5
|
-
[![Build Status](https://
|
6
|
-
[![Code Climate](https://codeclimate.com/github/schneems/wicked.
|
5
|
+
[![Build Status](https://travis-ci.org/schneems/wicked.svg?branch=master)](https://travis-ci.org/schneems/wicked)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/schneems/wicked/badges/gpa.svg)](https://codeclimate.com/github/schneems/wicked)
|
7
|
+
[![Help Contribute to Open Source](https://www.codetriage.com/schneems/wicked/badges/users.svg)](https://www.codetriage.com/schneems/wicked)
|
8
|
+
|
7
9
|
|
8
10
|
Use wicked to make your Rails controllers into step-by-step wizards. To see Wicked in action check out the example [Rails app](https://github.com/schneems/wicked_example) or [watch the screencast](http://schneems.com/post/18437886598/wizard-ify-your-rails-controllers-with-wicked).
|
9
11
|
|
@@ -119,16 +121,23 @@ class AfterSignupController < ApplicationController
|
|
119
121
|
@user = current_user
|
120
122
|
case step
|
121
123
|
when :confirm_password
|
122
|
-
@user.update_attributes(
|
124
|
+
@user.update_attributes(user_params)
|
123
125
|
end
|
124
126
|
sign_in(@user, bypass: true) # needed for devise
|
125
127
|
render_wizard @user
|
126
128
|
end
|
129
|
+
|
130
|
+
private
|
131
|
+
def user_params
|
132
|
+
params.require(:user)
|
133
|
+
.permit(:email, :current_password) # ...
|
134
|
+
end
|
127
135
|
end
|
128
136
|
```
|
129
137
|
|
130
138
|
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.
|
131
139
|
|
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 `update_attributes` might work better.
|
132
141
|
|
133
142
|
To get to this update action, you simply need to submit a form that PUT's to the same url
|
134
143
|
|
@@ -165,34 +174,61 @@ Now you've got a fully functioning AfterSignup controller! If you have questions
|
|
165
174
|
|
166
175
|
## Quick Reference
|
167
176
|
|
168
|
-
View/URL Helpers
|
177
|
+
**View/URL Helpers:**
|
169
178
|
|
170
179
|
```ruby
|
171
|
-
wizard_path #
|
172
|
-
wizard_path(:specific_step) #
|
173
|
-
next_wizard_path #
|
174
|
-
previous_wizard_path #
|
180
|
+
wizard_path # relative url of the current step
|
181
|
+
wizard_path(:specific_step) # relative url of a :specific_step
|
182
|
+
next_wizard_path # relative url of the next step
|
183
|
+
previous_wizard_path # relative url of the previous step
|
175
184
|
|
176
|
-
#
|
185
|
+
wizard_url # fully qualified url of the current step
|
186
|
+
wizard_url(:specific_step) # fully qualified url of a :specific_step
|
187
|
+
next_wizard_url # fully qualified url of the next step
|
188
|
+
previous_wizard_url # fully qualified url of the previous step
|
189
|
+
|
190
|
+
# These only work while in a Wizard
|
177
191
|
# You can have multiple wizards in a project with multiple `wizard_path` calls
|
178
192
|
```
|
179
193
|
|
180
194
|
|
181
|
-
Controller Tidbits
|
195
|
+
**Controller Tidbits:**
|
182
196
|
|
183
197
|
```ruby
|
184
|
-
steps :first, :second
|
185
|
-
step
|
186
|
-
next_step
|
187
|
-
previous_step
|
188
|
-
skip_step
|
189
|
-
jump_to(:specific_step)
|
190
|
-
render_wizard
|
191
|
-
render_wizard(@user)
|
198
|
+
steps :first, :second # Sets the order of steps
|
199
|
+
step # Gets current step
|
200
|
+
next_step # Gets next step
|
201
|
+
previous_step # Gets previous step
|
202
|
+
skip_step # Tells render_wizard to skip to the next logical step
|
203
|
+
jump_to(:specific_step) # Jump to :specific_step
|
204
|
+
render_wizard # Renders the current step
|
205
|
+
render_wizard(@user) # Shows next_step if @user.save, otherwise renders
|
206
|
+
render_wizard(@user, context: :account_setup) # Shows next_step if @user.save(context: :account_setup), otherwise renders
|
207
|
+
wizard_steps # Gets ordered list of steps
|
208
|
+
current_step?(step) # is step the same as the current request's step
|
209
|
+
past_step?(step) # does step come before the current request's step in wizard_steps
|
210
|
+
future_step?(step) # does step come after the current request's step in wizard_steps
|
211
|
+
previous_step?(step) # is step immediately before the current request's step
|
212
|
+
next_step?(step) # is step immediately after the current request's step
|
213
|
+
```
|
214
|
+
|
215
|
+
**Redirect options**
|
216
|
+
|
217
|
+
Both `skip_step` and `jump_to` will cause a redirect.
|
218
|
+
|
219
|
+
```
|
220
|
+
skip_step(foo: "bar")
|
192
221
|
```
|
193
222
|
|
223
|
+
*Note that unlike you would do when making a call to Rails' `redirect_to`, you should not call `return` immediately after `skip_step` and `jump_to`, since the actual redirection is done in the render_wizard call.*
|
194
224
|
|
195
|
-
|
225
|
+
If you want to pass params to the step you are skipping to you can pass it into those:
|
226
|
+
|
227
|
+
```
|
228
|
+
jump_to(:specific_step, foo: "bar")
|
229
|
+
```
|
230
|
+
|
231
|
+
**Finally:**
|
196
232
|
|
197
233
|
Don't forget to create your named views
|
198
234
|
|
@@ -206,7 +242,7 @@ app/
|
|
206
242
|
```
|
207
243
|
|
208
244
|
|
209
|
-
|
245
|
+
## Finish Wizard Path
|
210
246
|
|
211
247
|
You can specify the url that your user goes to by over-riding the `finish_wizard_path` in your wizard controller.
|
212
248
|
|
@@ -217,18 +253,16 @@ def finish_wizard_path
|
|
217
253
|
end
|
218
254
|
```
|
219
255
|
|
220
|
-
|
221
256
|
### Testing with RSpec
|
222
257
|
|
223
258
|
```ruby
|
224
259
|
# Test find_friends block of show action
|
225
|
-
get :show, id: :find_friends
|
260
|
+
get :show, params: { id: :find_friends }
|
226
261
|
|
227
262
|
# Test find_friends block of update action
|
228
|
-
|
263
|
+
patch :update, params: {'id' => 'find_friends', "user" => { "id" => @user.id.to_s }}
|
229
264
|
```
|
230
265
|
|
231
|
-
|
232
266
|
### Internationalization of URLS (I18n)
|
233
267
|
|
234
268
|
If your site works in multiple languages, or if you just want more control over how your URLs look you can now use I18n with wicked. To do so you need to replace this:
|
@@ -262,7 +296,7 @@ es:
|
|
262
296
|
It would also be a good idea to create a english version under `config/locales/en.yml` or your english speaking friends will get errors. If your app already uses I18n you don't need to do anything else, if not you will need to make sure that you set the `I18n.locale` on each request you could do this somewhere like a before filter in your application_controller.rb
|
263
297
|
|
264
298
|
```ruby
|
265
|
-
|
299
|
+
before_action :set_locale
|
266
300
|
|
267
301
|
private
|
268
302
|
|
@@ -305,7 +339,6 @@ end
|
|
305
339
|
|
306
340
|
Instead you need to use `wizard_value` to get the "reverse translation" in your controller code like this:
|
307
341
|
|
308
|
-
|
309
342
|
```ruby
|
310
343
|
steps :confirm_password, :confirm_profile, :find_friends
|
311
344
|
|
@@ -347,8 +380,9 @@ Now you can change the values in the URLs to whatever you want without changing
|
|
347
380
|
```ruby
|
348
381
|
config.i18n.default_locale = :de
|
349
382
|
```
|
383
|
+
|
350
384
|
**Important:** Don't forget to use `wizard_value()` method to make
|
351
|
-
sure you are using the right
|
385
|
+
sure you are using the right canonical values of `step`,
|
352
386
|
`previous_step`, `next_step`, etc. If you are comparing them to non
|
353
387
|
wicked generate values.
|
354
388
|
|
@@ -356,11 +390,12 @@ Custom crafted wizard urls: just another way Wicked makes your app a little more
|
|
356
390
|
|
357
391
|
## Dynamic Step Names
|
358
392
|
|
359
|
-
If you wish to set the order of your steps dynamically you can do this
|
393
|
+
If you wish to set the order of your steps dynamically you can do this by manually calling and `self.steps = [# <some steps> ]` in a `before_action` method. Then call `before_action :setup_wizard` after so that wicked knows when it is safe to initializelike this:
|
360
394
|
|
361
395
|
```ruby
|
362
396
|
include Wicked::Wizard
|
363
|
-
|
397
|
+
before_action :set_steps
|
398
|
+
before_action :setup_wizard
|
364
399
|
|
365
400
|
# ...
|
366
401
|
|
@@ -374,6 +409,41 @@ def set_steps
|
|
374
409
|
end
|
375
410
|
```
|
376
411
|
|
412
|
+
NOTE: The order of the `before_action` matters, when `setup_wizard` is called it will validate the presence of `self.steps`, you must call your custom step setting code before this point.
|
413
|
+
|
414
|
+
## Send params to finish_wizard_path method
|
415
|
+
|
416
|
+
If you wish to send parameters to the `finish_wizard_path` method that can be done by adding to your controller the method with the params argument `def finish_wizard_path(params) ... end`.
|
417
|
+
|
418
|
+
In order to send the parameters to the method here is an example of the show method:
|
419
|
+
|
420
|
+
```ruby
|
421
|
+
steps :first_step, :second_step
|
422
|
+
|
423
|
+
def show
|
424
|
+
# ...
|
425
|
+
render_wizard(nil, {}, { hello: 'world' })
|
426
|
+
end
|
427
|
+
|
428
|
+
def update
|
429
|
+
# ...
|
430
|
+
render_wizard(@user, {}, { hello: 'world' })
|
431
|
+
end
|
432
|
+
|
433
|
+
def finish_wizard_path(params)
|
434
|
+
# here you can access params and that would be equal to { hello: 'world' }
|
435
|
+
end
|
436
|
+
```
|
437
|
+
|
438
|
+
The `wizard_path` and `next_wizard_path` methods also take parameters that can then be accessed or visible in the `show` and `update` actions of the controller. You can use the methods like so:
|
439
|
+
|
440
|
+
```ruby
|
441
|
+
next_wizard_path({ hello: 'world' })
|
442
|
+
wizard_path(nil, { hello: 'world' })
|
443
|
+
# the wizard_path with the step specified would look like this
|
444
|
+
wizard_path(:wicked_finish, wizard_id: @user.id, hello: 'world')
|
445
|
+
```
|
446
|
+
|
377
447
|
## Keywords
|
378
448
|
|
379
449
|
There are a few "magical" keywords that will take you to the first step,
|
@@ -389,15 +459,59 @@ Wicked::FINISH_STEP
|
|
389
459
|
```
|
390
460
|
|
391
461
|
You can build links using these constants
|
392
|
-
`after_signup_path(Wicked::
|
462
|
+
`after_signup_path(Wicked::FIRST_STEP)` which will redirect the user to
|
393
463
|
the first step you've specified. This might be useful for redirecting a
|
394
464
|
user to a step when you're not already in a Wicked controller. If you
|
395
|
-
change the
|
465
|
+
change the constants, they are expected to be strings (not symbols).
|
396
466
|
|
397
|
-
##
|
467
|
+
## Support
|
468
|
+
|
469
|
+
Most problems using this library are general problems using Ruby/Rails. If you cannot get something to work correctly please open up a question on [stack overflow](http://stackoverflow.com/). If you've not posted there before, provide a description of the problem you're having and usually some example code and a copy of your rails logs helps.
|
398
470
|
|
399
|
-
|
471
|
+
If you've found a bug, please open a ticket on the issue tracker with a small example app that reproduces the behavior.
|
472
|
+
|
473
|
+
## About
|
400
474
|
|
401
|
-
|
475
|
+
Made by [@schneems](http://twitter.com/schneems).
|
402
476
|
|
403
477
|
This project rocks and uses MIT-LICENSE.
|
478
|
+
|
479
|
+
## Compatibility
|
480
|
+
|
481
|
+
Refer to the Travis CI test matrix for test using your version of Ruby and Rails. If there is a newer Ruby or Rails you don't see on there, please add an entry to the Appraisals file, then run `$ appraisals install` and update the `.travis.yml` file and send me a pull request.
|
482
|
+
|
483
|
+
Note: Rails 3.0 support is only for Ruby 1.9.3 or JRuby, not Ruby 2.0.0 or newer.
|
484
|
+
|
485
|
+
## Running Gem Tests
|
486
|
+
|
487
|
+
First, install the development gems:
|
488
|
+
|
489
|
+
```
|
490
|
+
$ bundle install
|
491
|
+
```
|
492
|
+
|
493
|
+
Now that `appraisal` is installed, use it to set up all the gemfiles for the test matrix:
|
494
|
+
|
495
|
+
```
|
496
|
+
$ appraisal install
|
497
|
+
```
|
498
|
+
|
499
|
+
Then to run tests against all the appraisal gemfiles, use:
|
500
|
+
|
501
|
+
```
|
502
|
+
$ appraisal rake test
|
503
|
+
```
|
504
|
+
|
505
|
+
To run tests against one specific gemfile,
|
506
|
+
use
|
507
|
+
|
508
|
+
```
|
509
|
+
$ appraisal 4.1 rake test
|
510
|
+
```
|
511
|
+
|
512
|
+
Note that Rails 3.0 tests don't pass in Ruby 2.0.0 or newer, so during development it may be easier to disable this
|
513
|
+
gemfile if you are using a current version of Ruby.
|
514
|
+
|
515
|
+
## Contributing
|
516
|
+
|
517
|
+
See the [Contributing guide](https://github.com/schneems/wicked/blob/master/CONTRIBUTING.md).
|
data/Rakefile
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler'
|
4
4
|
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
|
5
7
|
begin
|
6
8
|
Bundler.setup(:default, :development, :test)
|
7
9
|
rescue Bundler::BundlerError => e
|
@@ -33,18 +35,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
33
35
|
end
|
34
36
|
|
35
37
|
|
36
|
-
require 'jeweler'
|
37
|
-
Jeweler::Tasks.new do |gem|
|
38
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
39
|
-
gem.name = "wicked"
|
40
|
-
gem.homepage = "http://github.com/schneems/wicked"
|
41
|
-
gem.license = "MIT"
|
42
|
-
gem.summary = %Q{Use Wicked to turn your controller into a wizard}
|
43
|
-
gem.description = %Q{Wicked is a Rails engine for producing easy wizard controllers}
|
44
|
-
gem.email = "richard.schneeman@gmail.com"
|
45
|
-
gem.authors = ["schneems"]
|
46
|
-
# dependencies defined in Gemfile
|
47
|
-
end
|
48
|
-
Jeweler::RubygemsDotOrgTasks.new
|
49
|
-
|
50
|
-
|
@@ -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", "~> 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.1"
|
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,13 @@
|
|
1
|
+
module Wicked::Controller::Concerns::Action
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
def self.extended(base)
|
6
|
+
%w{before skip_before prepend_before}.each do |action|
|
7
|
+
define_method "#{action}_action" do |*names, &blk|
|
8
|
+
send("#{action}_filter", *names, &blk)
|
9
|
+
end unless base.respond_to? "#{action}_action"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -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,8 +25,8 @@ module Wicked::Controller::Concerns::Path
|
|
18
25
|
params[:action]
|
19
26
|
end
|
20
27
|
|
21
|
-
|
22
28
|
def wizard_path(goto_step = nil, options = {})
|
29
|
+
options = options.respond_to?(:to_h) ? options.to_h : options
|
23
30
|
options = { :controller => wicked_controller,
|
24
31
|
:action => 'show',
|
25
32
|
:id => goto_step || params[:id],
|
@@ -27,5 +34,8 @@ module Wicked::Controller::Concerns::Path
|
|
27
34
|
}.merge options
|
28
35
|
url_for(options)
|
29
36
|
end
|
30
|
-
end
|
31
37
|
|
38
|
+
def wizard_url(goto_step = nil, options = {})
|
39
|
+
wizard_path(goto_step, options.merge(only_path: false))
|
40
|
+
end
|
41
|
+
end
|