wizardz 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -66,7 +66,7 @@ module Wizardz
66
66
  @valid_states.each do |state|
67
67
  results[state] = @pages[state].page_data if @pages[state].respond_to?(:page_data)
68
68
  end
69
- results[:states] = @valid_states
69
+ results[:valid_states] = @valid_states
70
70
  results[:unprocessed] = @unprocessed.clone
71
71
  results[:unprocessed].delete(@state)
72
72
  results
@@ -1,3 +1,4 @@
1
+ #require 'ruby-debug'
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
3
 
3
4
  class TestClassWiz < Wizardz::Page
@@ -14,6 +15,11 @@ end
14
15
  class StateRedefWiz < Wizardz::Wizard
15
16
  end
16
17
 
18
+ class ValidStates < Wizardz::Wizard
19
+ STATES = [{:id => :first_state, :class => Wizardz::Page::First},
20
+ {:id => :test_class_wiz, :class => TestClassWiz}]
21
+ end
22
+
17
23
  describe "Wizard" do
18
24
 
19
25
  it "has minimum of 0 parameters on creation" do
@@ -81,14 +87,14 @@ describe "Wizard" do
81
87
  wiz = StateRedefWiz.new()
82
88
  wiz.save_data.should == {:first_state=>{},
83
89
  :unprocessed=>[:second_state],
84
- :states=>[:first_state, :second_state]}
90
+ :valid_states=>[:first_state, :second_state]}
85
91
  end
86
92
 
87
93
  it 'returns the data_object to save from default values' do
88
94
  wiz = StateRedefWiz.new({:first_state => {:value => 'test'}})
89
95
  wiz.save_data.should == {:first_state=>{:value=>"test"},
90
96
  :unprocessed=>[:second_state],
91
- :states=>[:first_state, :second_state]}
97
+ :valid_states=>[:first_state, :second_state]}
92
98
  end
93
99
 
94
100
  it 'returns the view partial for the wizard' do
@@ -164,6 +170,25 @@ describe "Wizard" do
164
170
  wiz.update(1)
165
171
  end
166
172
  end
173
+
174
+ context "data save and load" do
175
+ before(:each) do
176
+ @page = Wizardz::Page::First.new({},false)
177
+ Wizardz::Page::First.should_receive(:new).with({},nil).twice.and_return(@page)
178
+ @wiz = ValidStates.new
179
+ end
180
+
181
+ it "should correctly reload valid states" do
182
+ @wiz.valid_states.should == [:first_state, :test_class_wiz]
183
+ @page.should_receive(:get_valid_states).with([:first_state, :test_class_wiz]).and_return([:first_state])
184
+ @wiz.update({:first => {:value => 'aaa'}},'next')
185
+ data = @wiz.save_data
186
+ load_wiz = ValidStates.new(data)
187
+ load_wiz.valid_states.should == [:first_state]
188
+ end
189
+
190
+ end
191
+
167
192
  # it 'return true for the first_look? value (indicates if page should be validated)' do
168
193
  # wiz = Wizardz::Wizard.new({:unprocessed => [:first_state]})
169
194
  # wiz.first_look?.should be_true
data/wizardz.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wizardz}
8
- s.version = "1.3.0"
8
+ s.version = "1.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Henry"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wizardz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 0
10
- version: 1.3.0
9
+ - 1
10
+ version: 1.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Henry