hat-trick 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -5
- data/app/assets/javascripts/hat-trick.js.coffee +254 -120
- data/app/views/hat_trick/_wizard_meta.html.erb +1 -1
- data/hat-trick.gemspec +3 -3
- data/lib/hat-trick.rb +1 -1
- data/lib/hat_trick/config.rb +17 -0
- data/lib/hat_trick/controller_helpers.rb +64 -0
- data/lib/hat_trick/controller_hooks.rb +20 -64
- data/lib/hat_trick/dsl.rb +86 -62
- data/lib/hat_trick/{rails_engine.rb → engine.rb} +1 -1
- data/lib/hat_trick/form_helper.rb +0 -4
- data/lib/hat_trick/model_methods.rb +30 -8
- data/lib/hat_trick/step_definition.rb +12 -12
- data/lib/hat_trick/version.rb +1 -1
- data/lib/hat_trick/wizard.rb +44 -27
- data/lib/hat_trick/wizard_definition.rb +2 -0
- data/lib/hat_trick/wizard_steps.rb +5 -2
- data/spec/lib/hat_trick/dsl_spec.rb +26 -0
- data/spec/lib/hat_trick/wizard_spec.rb +21 -19
- data/spec/spec_helper.rb +1 -9
- data/vendor/assets/javascripts/jquery.form.wizard.js +499 -438
- data/vendor/assets/javascripts/jquery.history.js +1 -0
- metadata +15 -12
- data/spec/lib/hat_trick/step_spec.rb +0 -9
- data/vendor/assets/javascripts/jquery.ba-bbq.js +0 -1137
@@ -12,30 +12,32 @@ describe HatTrick::Wizard do
|
|
12
12
|
HatTrick::Wizard.new(wiz_def)
|
13
13
|
}
|
14
14
|
|
15
|
+
let(:wizard) { subject }
|
16
|
+
|
15
17
|
before :each do
|
16
|
-
|
18
|
+
wizard.start
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "advancing steps" do
|
20
22
|
it "should go from step1 to step2" do
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
wizard.current_step.to_sym.should == :step1
|
24
|
+
wizard.advance_step
|
25
|
+
wizard.current_step.to_sym.should == :step2
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
describe "skipping steps" do
|
28
30
|
it "should skip step2 when requested" do
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
wizard.skip_step :step2
|
32
|
+
wizard.advance_step
|
33
|
+
wizard.current_step.to_sym.should == :step3
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should skip steps 2 & 3 when requested" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
wizard.skip_step :step2
|
38
|
+
wizard.skip_step :step3
|
39
|
+
wizard.advance_step
|
40
|
+
wizard.current_step.to_sym.should == :step4
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -46,19 +48,19 @@ describe HatTrick::Wizard do
|
|
46
48
|
|
47
49
|
describe "setting explicit next steps" do
|
48
50
|
it "should advance to the requested next step when one is set" do
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
wizard.steps.first.next_step = :step4
|
52
|
+
wizard.advance_step
|
53
|
+
wizard.current_step.to_sym.should == :step4
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
describe "#previously_visited_step" do
|
56
58
|
it "should return the most recently visited step" do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
wizard.steps[0].visited = true
|
60
|
+
wizard.steps[1].visited = true
|
61
|
+
wizard.steps[3].visited = true
|
62
|
+
wizard.current_step = :step5
|
63
|
+
wizard.previously_visited_step.to_sym.should == :step4
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= 'test'
|
2
2
|
require 'bundler/setup'
|
3
|
+
require 'rails'
|
3
4
|
require 'logger'
|
4
5
|
|
5
6
|
module Rails
|
@@ -10,15 +11,6 @@ module Rails
|
|
10
11
|
def self.logger
|
11
12
|
@logger ||= ::Logger.new(STDOUT).tap { |l| l.level = ::Logger::ERROR }
|
12
13
|
end
|
13
|
-
|
14
|
-
class Engine
|
15
|
-
def self.initializer(*args, &block); end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module ActionController
|
20
|
-
class Base
|
21
|
-
end
|
22
14
|
end
|
23
15
|
|
24
16
|
require File.expand_path('../../lib/hat-trick', __FILE__)
|