wicked 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of wicked might be problematic. Click here for more details.
- data/CHANGELOG.md +20 -1
- data/README.md +20 -0
- data/VERSION +1 -1
- data/lib/wicked.rb +9 -1
- data/lib/wicked/controller/concerns/path.rb +1 -0
- data/lib/wicked/controller/concerns/render_redirect.rb +2 -2
- data/lib/wicked/controller/concerns/steps.rb +13 -3
- data/lib/wicked/wizard.rb +2 -2
- data/test/dummy/app/controllers/bar_controller.rb +1 -0
- data/test/dummy/app/controllers/string_steps_controller.rb +11 -0
- data/test/dummy/app/views/layouts/application.html.erb +2 -0
- data/test/dummy/app/views/string_steps/second.html.erb +1 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/integration/navigation_test.rb +10 -3
- data/test/integration/steps_test.rb +8 -0
- data/test/wicked_test.rb +11 -0
- data/wicked.gemspec +4 -2
- metadata +23 -21
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
+
## 0.6.0 (03/20/2013)
|
2
|
+
|
3
|
+
* Breaking change: hardcoded internal `finish` keyword changed to
|
4
|
+
`wicked_finish`. Can be modified by setting `Wicked::FINISH_STEP`.
|
5
|
+
Please use constants from now on instead of relying on the values of the
|
6
|
+
strings.
|
7
|
+
* [#56] raise error while using reserved keyword
|
8
|
+
* Keywords are now configurable as constants `Wicked::FIRST_STEP`,
|
9
|
+
`Wicked::LAST_STEP`, and `Wicked::FINISH_STEP`
|
10
|
+
|
11
|
+
## 0.5.0 (01/27/2013)
|
12
|
+
* [#51] bug fix: while using translations all wizard helpers now return values
|
13
|
+
in the same language (in whatever locale is being used). So if a user is
|
14
|
+
requesting a controller action in spanish, then `step` will be in
|
15
|
+
spanish and all the values inside of `steps` and `next_step` etc. will
|
16
|
+
be in spanish. To convert one of these values to a "canonical" wizard
|
17
|
+
value (that matches the names of your files) you can use
|
18
|
+
`wizard_value(step)` method.
|
19
|
+
|
1
20
|
## 0.4.0
|
2
|
-
* User
|
21
|
+
* User inputs no longer converted to symbol this mitigates risk of DoS
|
3
22
|
via symbol table or RAM (symbols are not garbage collected).
|
4
23
|
|
5
24
|
## 0.3.4
|
data/README.md
CHANGED
@@ -373,6 +373,26 @@ end
|
|
373
373
|
|
374
374
|
Note: Do not pass user submitted params directly into `self.steps` while using the custom or translated urls. The translator calls `to_sym` on steps provided, and if a user is allowed to submit arbitrary symbols, they could flood the take down your production app by filling up the symbol table. So, just don't do it.
|
375
375
|
|
376
|
+
## Keywords
|
377
|
+
|
378
|
+
There are a few "magical" keywords that will take you to the first step,
|
379
|
+
the last step, or the "final" action (the redirect that happens after
|
380
|
+
the last step). Prior to version 0.6.0 these were hardcoded strings. Now
|
381
|
+
they are constants which means you can access them or change them. They
|
382
|
+
are:
|
383
|
+
|
384
|
+
```ruby
|
385
|
+
Wicked::FIRST_STEP
|
386
|
+
Wicked::LAST_STEP
|
387
|
+
Wicked::FINISH_STEP
|
388
|
+
```
|
389
|
+
|
390
|
+
You can build links using these constants
|
391
|
+
`after_signup_path(Wicked::LAST_STEP)` which will redirect the user to
|
392
|
+
the first step you've specified. This might be useful for redirecting a
|
393
|
+
user to a step when you're not already in a Wicked controller. If you
|
394
|
+
change the step names, they are expected to be strings (not symbols).
|
395
|
+
|
376
396
|
## About
|
377
397
|
|
378
398
|
Please poke around the source code, if you see easier ways to get a Rails controller do do what I want, let me know.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/lib/wicked.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
module Wicked
|
2
|
+
FINISH_STEP = "wicked_finish"
|
3
|
+
FIRST_STEP = "wicked_first"
|
4
|
+
LAST_STEP = "wicked_last"
|
5
|
+
|
2
6
|
module Controller
|
3
7
|
module Concerns
|
4
8
|
end
|
@@ -7,9 +11,13 @@ module Wicked
|
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
14
|
+
class WickedError < StandardError; end
|
15
|
+
class WickedProtectedStepError < WickedError; end
|
16
|
+
|
10
17
|
require 'wicked/controller/concerns/render_redirect'
|
11
18
|
require 'wicked/controller/concerns/steps'
|
12
19
|
require 'wicked/controller/concerns/path'
|
13
20
|
require 'wicked/wizard'
|
14
21
|
require 'wicked/wizard/translated'
|
15
|
-
require 'wicked/engine'
|
22
|
+
require 'wicked/engine'
|
23
|
+
|
@@ -23,7 +23,7 @@ module Wicked::Controller::Concerns::RenderRedirect
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def render_step(the_step, options = {})
|
26
|
-
if the_step.nil? || the_step.to_s ==
|
26
|
+
if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP
|
27
27
|
redirect_to_finish_wizard options
|
28
28
|
else
|
29
29
|
render the_step, options
|
@@ -46,5 +46,5 @@ module Wicked::Controller::Concerns::RenderRedirect
|
|
46
46
|
def redirect_to_finish_wizard(options = nil)
|
47
47
|
redirect_to finish_wizard_path, options
|
48
48
|
end
|
49
|
-
|
50
49
|
end
|
50
|
+
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Wicked::Controller::Concerns::Steps
|
2
|
+
PROTECTED_STEPS = [Wicked::FINISH_STEP, Wicked::FIRST_STEP, Wicked::LAST_STEP]
|
3
|
+
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
4
6
|
def jump_to(goto_step)
|
@@ -47,10 +49,19 @@ module Wicked::Controller::Concerns::Steps
|
|
47
49
|
def steps(*args)
|
48
50
|
options = args.extract_options!
|
49
51
|
steps = args
|
52
|
+
check_protected!(steps)
|
50
53
|
prepend_before_filter(options) do
|
51
54
|
self.steps = steps
|
52
55
|
end
|
53
56
|
end
|
57
|
+
|
58
|
+
def check_protected!(wizard_steps)
|
59
|
+
string_steps = wizard_steps.map(&:to_s)
|
60
|
+
if protected_step = PROTECTED_STEPS.detect { |protected| string_steps.include?(protected) }
|
61
|
+
msg = "Protected step detected: '#{protected_step}' is used internally by Wicked please rename your step"
|
62
|
+
raise WickedProtectedStepError, msg
|
63
|
+
end
|
64
|
+
end
|
54
65
|
end
|
55
66
|
|
56
67
|
def steps=(wizard_steps)
|
@@ -76,7 +87,7 @@ module Wicked::Controller::Concerns::Steps
|
|
76
87
|
return @next_step if current_step.nil?
|
77
88
|
index = steps.index(current_step)
|
78
89
|
step = steps.at(index + 1) if index.present?
|
79
|
-
step ||=
|
90
|
+
step ||= Wicked::FINISH_STEP
|
80
91
|
step
|
81
92
|
end
|
82
93
|
|
@@ -94,6 +105,5 @@ module Wicked::Controller::Concerns::Steps
|
|
94
105
|
return false if current_step_index.nil? || steps.index(step_name).nil?
|
95
106
|
return true
|
96
107
|
end
|
97
|
-
|
98
|
-
|
99
108
|
end
|
109
|
+
|
data/lib/wicked/wizard.rb
CHANGED
@@ -34,8 +34,8 @@ module Wicked
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def check_redirect_to_first_last!(step)
|
37
|
-
redirect_to wizard_path(steps.first) if step.to_s ==
|
38
|
-
redirect_to wizard_path(steps.last) if step.to_s ==
|
37
|
+
redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
|
38
|
+
redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
|
39
39
|
end
|
40
40
|
|
41
41
|
def setup_step_from(the_step)
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'step_positions/step_position' %>
|
data/test/dummy/config/routes.rb
CHANGED
@@ -30,12 +30,12 @@ class IncludeNavigationTest < ActiveSupport::IntegrationCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
test 'pointer to first' do
|
33
|
-
visit(bar_path(
|
33
|
+
visit(bar_path(Wicked::FIRST_STEP))
|
34
34
|
assert has_content?('first')
|
35
35
|
end
|
36
36
|
|
37
37
|
test 'pointer to last' do
|
38
|
-
visit(bar_path(
|
38
|
+
visit(bar_path(Wicked::LAST_STEP))
|
39
39
|
assert has_content?('last_step')
|
40
40
|
end
|
41
41
|
|
@@ -47,10 +47,17 @@ class IncludeNavigationTest < ActiveSupport::IntegrationCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
test 'finish' do
|
50
|
-
step =
|
50
|
+
step = Wicked::FINISH_STEP
|
51
51
|
visit(bar_path(step))
|
52
52
|
assert has_content?('home')
|
53
53
|
end
|
54
|
+
|
55
|
+
test 'finish with flash' do
|
56
|
+
step = Wicked::FINISH_STEP
|
57
|
+
visit bar_path(step, :notice => 'yo')
|
58
|
+
assert has_content?('home')
|
59
|
+
assert has_content?('notice:yo')
|
60
|
+
end
|
54
61
|
end
|
55
62
|
|
56
63
|
|
@@ -23,6 +23,14 @@ class StepPositionsTest < ActiveSupport::IntegrationCase
|
|
23
23
|
assert has_content?('last_step step is the next step') # next_step?
|
24
24
|
end
|
25
25
|
|
26
|
+
test 'string-based steps' do
|
27
|
+
visit(string_step_path('second'))
|
28
|
+
assert has_content?('second step is the current step') # current_step?
|
29
|
+
assert has_content?('first step is a past step') # past_step?
|
30
|
+
assert has_content?('last_step step is a future step') # future_step?
|
31
|
+
assert has_content?('first step was the previous step') # previous_step?
|
32
|
+
assert has_content?('last_step step is the next step') # next_step?
|
33
|
+
end
|
26
34
|
end
|
27
35
|
|
28
36
|
# current_step?
|
data/test/wicked_test.rb
CHANGED
@@ -4,4 +4,15 @@ class WickedTest < ActiveSupport::TestCase
|
|
4
4
|
test "truth" do
|
5
5
|
assert_kind_of Module, Wicked
|
6
6
|
end
|
7
|
+
|
8
|
+
test "protected steps" do
|
9
|
+
error = assert_raise WickedProtectedStepError do
|
10
|
+
class ProtectedBadStepsController < ApplicationController
|
11
|
+
include Wicked::Wizard
|
12
|
+
|
13
|
+
steps :whatever, Wicked::FINISH_STEP
|
14
|
+
end
|
15
|
+
end
|
16
|
+
assert_equal "Protected step detected: '#{Wicked::FINISH_STEP}' is used internally by Wicked please rename your step", error.message
|
17
|
+
end
|
7
18
|
end
|
data/wicked.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wicked"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["schneems"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-03-20"
|
13
13
|
s.description = "Wicked is a Rails engine for producing easy wizard controllers"
|
14
14
|
s.email = "richard.schneeman@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
"test/dummy/app/controllers/nested/builder_controller.rb",
|
43
43
|
"test/dummy/app/controllers/pages_controller.rb",
|
44
44
|
"test/dummy/app/controllers/steps_controller.rb",
|
45
|
+
"test/dummy/app/controllers/string_steps_controller.rb",
|
45
46
|
"test/dummy/app/helpers/application_helper.rb",
|
46
47
|
"test/dummy/app/models/bar.rb",
|
47
48
|
"test/dummy/app/views/bar/first.html.erb",
|
@@ -63,6 +64,7 @@ Gem::Specification.new do |s|
|
|
63
64
|
"test/dummy/app/views/step_positions/first.html.erb",
|
64
65
|
"test/dummy/app/views/step_positions/last_step.html.erb",
|
65
66
|
"test/dummy/app/views/step_positions/second.html.erb",
|
67
|
+
"test/dummy/app/views/string_steps/second.html.erb",
|
66
68
|
"test/dummy/config.ru",
|
67
69
|
"test/dummy/config/application.rb",
|
68
70
|
"test/dummy/config/boot.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70158799315740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70158799315740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70158799315260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70158799315260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70158799314780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70158799314780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70158799314300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70158799314300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70158799313820 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70158799313820
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: capybara
|
71
|
-
requirement: &
|
71
|
+
requirement: &70158799313340 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.4.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70158799313340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: launchy
|
82
|
-
requirement: &
|
82
|
+
requirement: &70158799312860 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70158799312860
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: sqlite3
|
93
|
-
requirement: &
|
93
|
+
requirement: &70158799312380 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70158799312380
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: activerecord-jdbcsqlite3-adapter
|
104
|
-
requirement: &
|
104
|
+
requirement: &70158799311900 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70158799311900
|
113
113
|
description: Wicked is a Rails engine for producing easy wizard controllers
|
114
114
|
email: richard.schneeman@gmail.com
|
115
115
|
executables: []
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- test/dummy/app/controllers/nested/builder_controller.rb
|
144
144
|
- test/dummy/app/controllers/pages_controller.rb
|
145
145
|
- test/dummy/app/controllers/steps_controller.rb
|
146
|
+
- test/dummy/app/controllers/string_steps_controller.rb
|
146
147
|
- test/dummy/app/helpers/application_helper.rb
|
147
148
|
- test/dummy/app/models/bar.rb
|
148
149
|
- test/dummy/app/views/bar/first.html.erb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- test/dummy/app/views/step_positions/first.html.erb
|
165
166
|
- test/dummy/app/views/step_positions/last_step.html.erb
|
166
167
|
- test/dummy/app/views/step_positions/second.html.erb
|
168
|
+
- test/dummy/app/views/string_steps/second.html.erb
|
167
169
|
- test/dummy/config.ru
|
168
170
|
- test/dummy/config/application.rb
|
169
171
|
- test/dummy/config/boot.rb
|
@@ -218,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
220
|
version: '0'
|
219
221
|
segments:
|
220
222
|
- 0
|
221
|
-
hash:
|
223
|
+
hash: 2973292026559247990
|
222
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
225
|
none: false
|
224
226
|
requirements:
|