wicked 0.1.2 → 0.1.3

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.

@@ -1,3 +1,7 @@
1
+ ## 0.1.3 (4/01/2012)
2
+
3
+ * previous_wizard_path introduced
4
+
1
5
  ## 0.1.2 (3/16/2012)
2
6
 
3
7
  * next_wizard_path takes options (thanks @Flink)
data/README.md CHANGED
@@ -53,7 +53,7 @@ You can also use the old way of inheriting from `Wicked::WizardController`.
53
53
 
54
54
  ```
55
55
 
56
- The wizard is set to call steps in order in the show action, you can specify custom logic in your show using a case statement like below. To send someone to the first step in this wizard we can direct them to `after_signup_path(:confirm_password)`.
56
+ The wizard is set to call steps in order in the show action, you can specify custom logic in your show using a case statement like below. To send someone to the first step in this wizard we can direct them to `after_signup_path(:confirm_password)`.
57
57
 
58
58
  ```ruby
59
59
  class AfterSignupController < ApplicationController
@@ -158,6 +158,7 @@ View/URL Helpers
158
158
  wizard_path # Grabs the current path in the wizard
159
159
  wizard_path(:specific_step) # Url of the :specific_step
160
160
  next_wizard_path # Url of the next step
161
+ previous_wizard_path # Url of the previous step
161
162
 
162
163
  # These only work while in a Wizard, and are not absolute paths
163
164
  # You can have multiple wizards in a project with multiple `wizard_path` calls
@@ -175,6 +176,17 @@ Controller Tidbits:
175
176
  render_wizard(@user) # Shows next_step if @user.save, otherwise renders current step
176
177
  ```
177
178
 
179
+ Testing with RSpec
180
+
181
+ ```ruby
182
+ # Test find_friends block of show action
183
+ get :show, :id => :find_friends
184
+
185
+ # Test find_friends block of update action
186
+ put :update, {'id' => 'find_friends', "user" => {"id"=>@user.id.to_s}}
187
+
188
+ ```
189
+
178
190
  Finally:
179
191
 
180
192
  Don't forget to create your named views
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -6,6 +6,10 @@ module Wicked::Controller::Concerns::Path
6
6
  wizard_path(@next_step, options)
7
7
  end
8
8
 
9
+ def previous_wizard_path(options = {})
10
+ wizard_path(@previous_step, options)
11
+ end
12
+
9
13
  def controller
10
14
  params[:controller]
11
15
  end
@@ -29,11 +29,20 @@ module Wicked::Controller::Concerns::Steps
29
29
  self.class.steps
30
30
  end
31
31
 
32
+ def previous_step(current_step = nil)
33
+ return @previous_step if current_step == nil
34
+ index = steps.index(current_step)
35
+ step = steps.at(index - 1) if index.present? && index != 0
36
+ step ||= nil
37
+ step
38
+ end
39
+
32
40
 
33
- def next_step(current_step)
41
+ def next_step(current_step = nil)
42
+ return @next_step if current_step == nil
34
43
  index = steps.index(current_step)
35
- step = steps.at(index + 1) if index.present?
36
- step ||= :finish
44
+ step = steps.at(index + 1) if index.present?
45
+ step ||= :finish
37
46
  step
38
47
  end
39
48
 
@@ -9,15 +9,16 @@ module Wicked
9
9
 
10
10
  included do
11
11
  # Give our Views helper methods!
12
- helper_method :wizard_path, :next_wizard_path
12
+ helper_method :wizard_path, :next_wizard_path, :previous_wizard_path
13
13
  # Set @step and @next_step variables
14
14
  before_filter :setup_wizard
15
15
  end
16
16
 
17
17
  private
18
18
  def setup_wizard
19
- @step = params[:id].try(:to_sym) || steps.first
20
- @next_step = next_step(@step)
19
+ @step = params[:id].try(:to_sym) || steps.first
20
+ @previous_step = previous_step(@step)
21
+ @next_step = next_step(@step)
21
22
  end
22
23
  public
23
24
  end
@@ -1 +1,3 @@
1
- second
1
+ second
2
+
3
+ <%= link_to 'previous', previous_wizard_path %>
@@ -6,21 +6,28 @@ class HelpersTest < ActiveSupport::IntegrationCase
6
6
  step = :first
7
7
  visit(bar_path(step))
8
8
  click_link 'skip'
9
- assert has_content?(:third)
9
+ assert has_content?('second')
10
10
  end
11
11
 
12
12
  test 'wizard_path' do
13
13
  step = :first
14
14
  visit(bar_path(step))
15
15
  click_link 'current'
16
- assert has_content?(step)
16
+ assert has_content?(step.to_s)
17
17
  end
18
18
 
19
19
  test 'wizard_path with symbol arg' do
20
20
  step = :first
21
21
  visit(bar_path(step))
22
22
  click_link 'last'
23
- assert has_content?(:last_step)
23
+ assert has_content?('last_step')
24
+ end
25
+
26
+ test 'previous_wizard_path' do
27
+ step = :second
28
+ visit(bar_path(step))
29
+ click_link 'previous'
30
+ assert has_content?("first")
24
31
  end
25
32
 
26
33
  end
@@ -5,19 +5,19 @@ class InheritNavigationTest < ActiveSupport::IntegrationCase
5
5
  test 'show first' do
6
6
  step = :first
7
7
  visit(foo_path(step))
8
- assert has_content?(step)
8
+ assert has_content?(step.to_s)
9
9
  end
10
10
 
11
11
  test 'show second' do
12
12
  step = :second
13
13
  visit(foo_path(step))
14
- assert has_content?(step)
14
+ assert has_content?(step.to_s)
15
15
  end
16
16
 
17
17
  test 'skip first' do
18
18
  step = :first
19
- visit(foo_path(step, :skip_step => 'true'))
20
- assert has_content?(:second)
19
+ visit(foo_path(step.to_s, :skip_step => 'true'))
20
+ assert has_content?('second')
21
21
  end
22
22
 
23
23
  test 'invalid step' do
@@ -41,19 +41,19 @@ class IncludeNavigationTest < ActiveSupport::IntegrationCase
41
41
  test 'show first' do
42
42
  step = :first
43
43
  visit(bar_path(step))
44
- assert has_content?(step)
44
+ assert has_content?(step.to_s)
45
45
  end
46
46
 
47
47
  test 'show second' do
48
48
  step = :second
49
49
  visit(bar_path(step))
50
- assert has_content?(step)
50
+ assert has_content?(step.to_s)
51
51
  end
52
52
 
53
53
  test 'skip first' do
54
54
  step = :first
55
55
  visit(bar_path(step, :skip_step => 'true'))
56
- assert has_content?(:second)
56
+ assert has_content?(:second.to_s)
57
57
  end
58
58
 
59
59
  test 'invalid step' do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wicked"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
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 = "2012-03-16"
12
+ s.date = "2012-04-01"
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: 0.1.2
4
+ version: 0.1.3
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: 2012-03-16 00:00:00.000000000Z
12
+ date: 2012-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70303085319860 !ruby/object:Gem::Requirement
16
+ requirement: &70359853035280 !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: *70303085319860
24
+ version_requirements: *70359853035280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70303085319260 !ruby/object:Gem::Requirement
27
+ requirement: &70359853033100 !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: *70303085319260
35
+ version_requirements: *70359853033100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70303085318660 !ruby/object:Gem::Requirement
38
+ requirement: &70359853030180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70303085318660
46
+ version_requirements: *70359853030180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70303085318040 !ruby/object:Gem::Requirement
49
+ requirement: &70359853028820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70303085318040
57
+ version_requirements: *70359853028820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &70303085317560 !ruby/object:Gem::Requirement
60
+ requirement: &70359853060960 !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: *70303085317560
68
+ version_requirements: *70359853060960
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &70303085317080 !ruby/object:Gem::Requirement
71
+ requirement: &70359853059300 !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: *70303085317080
79
+ version_requirements: *70359853059300
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70303085316500 !ruby/object:Gem::Requirement
82
+ requirement: &70359853058200 !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: *70303085316500
90
+ version_requirements: *70359853058200
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: launchy
93
- requirement: &70303085316000 !ruby/object:Gem::Requirement
93
+ requirement: &70359853056860 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70303085316000
101
+ version_requirements: *70359853056860
102
102
  description: Wicked is a Rails engine for producing easy wizard controllers
103
103
  email: richard.schneeman@gmail.com
104
104
  executables: []
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  segments:
184
184
  - 0
185
- hash: -2913474337156723270
185
+ hash: 192248127634563940
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  none: false
188
188
  requirements: