wicked 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/CHANGELOG.md +6 -0
- data/VERSION +1 -1
- data/lib/wicked/controller/concerns/render_redirect.rb +1 -1
- data/lib/wicked/wizard.rb +27 -12
- data/lib/wicked/wizard/translated.rb +1 -3
- data/test/integration/navigation_test.rb +1 -1
- data/test/integration/security_test.rb +2 -2
- data/wicked.gemspec +2 -2
- metadata +3 -3
data/.rvmrc
CHANGED
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/wicked/wizard.rb
CHANGED
@@ -2,6 +2,18 @@ module Wicked
|
|
2
2
|
module Wizard
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
class InvalidStepError < RuntimeError
|
6
|
+
def initialize
|
7
|
+
super "The requested step did not match any steps defined for this controller."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class UndefinedStepsError < RuntimeError
|
12
|
+
def initialize
|
13
|
+
super "No step definitions have been supplied; if setting via `before_filter`, use `prepend_before_filter`"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
5
17
|
# Include the modules!!
|
6
18
|
include Wicked::Controller::Concerns::Path
|
7
19
|
include Wicked::Controller::Concerns::RenderRedirect
|
@@ -19,7 +31,7 @@ module Wicked
|
|
19
31
|
|
20
32
|
# forward to first step with whatever params are provided
|
21
33
|
def index
|
22
|
-
redirect_to wizard_path(steps.first
|
34
|
+
redirect_to "#{wizard_path(steps.first)}?#{request.query_parameters.to_query}"
|
23
35
|
end
|
24
36
|
|
25
37
|
# returns the canonical value for a step name, needed for translation support
|
@@ -29,25 +41,26 @@ module Wicked
|
|
29
41
|
|
30
42
|
private
|
31
43
|
|
32
|
-
def clean_params
|
33
|
-
params.except(:action, :controller)
|
34
|
-
end
|
35
|
-
|
36
44
|
def check_redirect_to_first_last!(step)
|
37
45
|
redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
|
38
46
|
redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
|
39
47
|
end
|
40
48
|
|
41
49
|
def setup_step_from(the_step)
|
42
|
-
|
50
|
+
return if steps.nil?
|
51
|
+
|
52
|
+
the_step ||= steps.first
|
43
53
|
check_redirect_to_first_last!(the_step)
|
44
|
-
|
45
|
-
|
54
|
+
|
55
|
+
valid_steps = steps + self.class::PROTECTED_STEPS
|
56
|
+
the_step = valid_steps.detect { |stp| stp.to_s == the_step }
|
57
|
+
|
58
|
+
raise InvalidStepError if the_step.nil?
|
59
|
+
the_step
|
46
60
|
end
|
47
61
|
|
48
|
-
def check_steps!
|
49
|
-
|
50
|
-
raise "Wicked Wizard steps expected but not yet set, if setting via `before_filter` use `prepend_before_filter`" if steps.nil?
|
62
|
+
def check_steps!
|
63
|
+
raise UndefinedStepsError if steps.nil?
|
51
64
|
end
|
52
65
|
|
53
66
|
def set_previous_next(step)
|
@@ -56,8 +69,10 @@ module Wicked
|
|
56
69
|
end
|
57
70
|
|
58
71
|
def setup_wizard
|
72
|
+
check_steps!
|
73
|
+
return if params[:id].nil?
|
74
|
+
|
59
75
|
@step = setup_step_from(params[:id])
|
60
|
-
check_steps!(@step)
|
61
76
|
set_previous_next(@step)
|
62
77
|
end
|
63
78
|
public
|
@@ -79,9 +79,7 @@ module Wicked
|
|
79
79
|
#
|
80
80
|
def setup_wizard_translated
|
81
81
|
self.steps = wizard_translations.keys # must come before setting previous/next steps
|
82
|
-
|
83
|
-
check_steps!(@step)
|
84
|
-
set_previous_next(@step)
|
82
|
+
setup_wizard
|
85
83
|
end
|
86
84
|
public
|
87
85
|
end
|
@@ -4,7 +4,7 @@ class SecurityTest < ActiveSupport::IntegrationCase
|
|
4
4
|
|
5
5
|
test 'does not show database.yml' do
|
6
6
|
step = "%2E%2F%2E%2E%2F%2E%2E%2Fconfig%2Fdatabase%2Eyml"
|
7
|
-
assert_raise
|
7
|
+
assert_raise(Wicked::Wizard::InvalidStepError) do
|
8
8
|
visit(bar_path(step))
|
9
9
|
end
|
10
10
|
refute has_content?('sqlite3')
|
@@ -15,7 +15,7 @@ class SecurityTest < ActiveSupport::IntegrationCase
|
|
15
15
|
root = '%2E%2F%2E' * 100 # root of system
|
16
16
|
step = root + '%2Fusr%2Fshare%2Fdict%2Fwords'
|
17
17
|
|
18
|
-
assert_raise
|
18
|
+
assert_raise(Wicked::Wizard::InvalidStepError) do
|
19
19
|
visit(bar_path(step))
|
20
20
|
end
|
21
21
|
refute has_content?('aardvark')
|
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 = "1.0.
|
8
|
+
s.version = "1.0.2"
|
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-10-
|
12
|
+
s.date = "2013-10-16"
|
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 = [
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -238,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: '0'
|
239
239
|
segments:
|
240
240
|
- 0
|
241
|
-
hash:
|
241
|
+
hash: 3158381855714249075
|
242
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
243
|
none: false
|
244
244
|
requirements:
|