stateful_link 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/stateful_link/helper.rb +2 -1
- data/lib/stateful_link/version.rb +1 -1
- data/spec/helpers/stateful_link_spec.rb +16 -0
- metadata +3 -27
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stateful_link (0.0.
|
4
|
+
stateful_link (0.0.8)
|
5
5
|
rails (>= 3)
|
6
6
|
|
7
7
|
GEM
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
rake (>= 0.8.7)
|
57
57
|
i18n (0.5.0)
|
58
58
|
json_pure (1.5.1)
|
59
|
-
mail (2.2.
|
59
|
+
mail (2.2.19)
|
60
60
|
activesupport (>= 2.3.6)
|
61
61
|
i18n (>= 0.4.0)
|
62
62
|
mime-types (~> 1.16)
|
data/lib/stateful_link/helper.rb
CHANGED
@@ -20,7 +20,8 @@ module StatefulLink
|
|
20
20
|
options = args.extract_options!
|
21
21
|
active = args.first
|
22
22
|
chosen = args.second
|
23
|
-
state = options[:state]
|
23
|
+
state = options[:state]
|
24
|
+
state = proc { action_state(active, chosen) } if state.nil?
|
24
25
|
state = state.is_a?(Proc) ? instance_exec(&state) : state
|
25
26
|
state = :active if state == true
|
26
27
|
state = :inactive if state == false
|
@@ -45,5 +45,21 @@ describe StatefulLink::Helper do
|
|
45
45
|
:chosen => "3",
|
46
46
|
:state => proc { false }
|
47
47
|
).should == "2"
|
48
|
+
|
49
|
+
helper.stub(:action_state) { :chosen }
|
50
|
+
|
51
|
+
helper.stateful_link_to(
|
52
|
+
:active => "1",
|
53
|
+
:inactive => "2",
|
54
|
+
:chosen => "3",
|
55
|
+
:state => false
|
56
|
+
).should == "2"
|
57
|
+
|
58
|
+
helper.stateful_link_to(
|
59
|
+
:active => "1",
|
60
|
+
:inactive => "2",
|
61
|
+
:chosen => "3",
|
62
|
+
:state => true
|
63
|
+
).should == "1"
|
48
64
|
end
|
49
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stateful_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
5
|
+
version: 0.0.9
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Victor Sokolov
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-05-03 00:00:00 +04:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,9 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 3
|
32
24
|
version: "3"
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -40,10 +32,6 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ~>
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 11
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 4
|
47
35
|
version: "2.4"
|
48
36
|
type: :development
|
49
37
|
version_requirements: *id002
|
@@ -55,9 +43,6 @@ dependencies:
|
|
55
43
|
requirements:
|
56
44
|
- - ">="
|
57
45
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
|
-
segments:
|
60
|
-
- 0
|
61
46
|
version: "0"
|
62
47
|
type: :development
|
63
48
|
version_requirements: *id003
|
@@ -69,9 +54,6 @@ dependencies:
|
|
69
54
|
requirements:
|
70
55
|
- - ">="
|
71
56
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 3
|
73
|
-
segments:
|
74
|
-
- 0
|
75
57
|
version: "0"
|
76
58
|
type: :development
|
77
59
|
version_requirements: *id004
|
@@ -145,23 +127,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
127
|
requirements:
|
146
128
|
- - ">="
|
147
129
|
- !ruby/object:Gem::Version
|
148
|
-
hash: 3
|
149
|
-
segments:
|
150
|
-
- 0
|
151
130
|
version: "0"
|
152
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
132
|
none: false
|
154
133
|
requirements:
|
155
134
|
- - ">="
|
156
135
|
- !ruby/object:Gem::Version
|
157
|
-
hash: 3
|
158
|
-
segments:
|
159
|
-
- 0
|
160
136
|
version: "0"
|
161
137
|
requirements: []
|
162
138
|
|
163
139
|
rubyforge_project:
|
164
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.5.3
|
165
141
|
signing_key:
|
166
142
|
specification_version: 3
|
167
143
|
summary: Helper to generate stateful navigation links.
|