@@ -8,82 +8,82 @@ def test_is_active_link_booleans_test
8
8
end
9
9
10
10
def test_is_active_link_symbol_inclusive
11
- request . fullpath = '/root'
11
+ set_fullpath ( '/root' )
12
12
assert is_active_link? ( '/root' , :inclusive )
13
13
14
- request . fullpath = '/root?param=test'
14
+ set_fullpath ( '/root?param=test' )
15
15
assert is_active_link? ( '/root' , :inclusive )
16
16
17
- request . fullpath = '/root/child/sub-child'
17
+ set_fullpath ( '/root/child/sub-child' )
18
18
assert is_active_link? ( '/root' , :inclusive )
19
19
20
- request . fullpath = '/other'
20
+ set_fullpath ( '/other' )
21
21
refute is_active_link? ( '/root' , :inclusive )
22
22
end
23
23
24
24
def test_is_active_link_symbol_inclusive_implied
25
- request . fullpath = '/root/child/sub-child'
25
+ set_fullpath ( '/root/child/sub-child' )
26
26
assert is_active_link? ( '/root' )
27
27
end
28
28
29
29
def test_is_active_link_symbol_inclusive_similar_path
30
- request . fullpath = '/root/abc'
30
+ set_fullpath ( '/root/abc' )
31
31
refute is_active_link? ( '/root/a' , :inclusive )
32
32
end
33
33
34
34
def test_is_active_link_symbol_inclusive_with_last_slash
35
- request . fullpath = '/root/abc'
35
+ set_fullpath ( '/root/abc' )
36
36
assert is_active_link? ( '/root/' )
37
37
end
38
38
39
39
def test_is_active_link_symbol_inclusive_with_last_slash_and_similar_path
40
- request . fullpath = '/root_path'
40
+ set_fullpath ( '/root_path' )
41
41
refute is_active_link? ( '/root/' )
42
42
end
43
43
44
44
def test_is_active_link_symbol_inclusive_with_link_params
45
- request . fullpath = '/root?param=test'
45
+ set_fullpath ( '/root?param=test' )
46
46
assert is_active_link? ( '/root?attr=example' )
47
47
end
48
48
49
49
def test_is_active_link_symbol_exclusive
50
- request . fullpath = '/root'
50
+ set_fullpath ( '/root' )
51
51
assert is_active_link? ( '/root' , :exclusive )
52
52
53
- request . fullpath = '/root?param=test'
53
+ set_fullpath ( '/root?param=test' )
54
54
assert is_active_link? ( '/root' , :exclusive )
55
55
56
- request . fullpath = '/root/child'
56
+ set_fullpath ( '/root/child' )
57
57
refute is_active_link? ( '/root' , :exclusive )
58
58
end
59
59
60
60
def test_is_active_link_symbol_exclusive_with_link_params
61
- request . fullpath = '/root?param=test'
61
+ set_fullpath ( '/root?param=test' )
62
62
assert is_active_link? ( '/root?attr=example' , :exclusive )
63
63
end
64
64
65
65
def test_is_active_link_symbol_exact
66
- request . fullpath = '/root?param=test'
66
+ set_fullpath ( '/root?param=test' )
67
67
assert is_active_link? ( '/root?param=test' , :exact )
68
68
69
- request . fullpath = '/root?param=test'
69
+ set_fullpath ( '/root?param=test' )
70
70
refute is_active_link? ( '/root?param=exact' , :exact )
71
71
72
- request . fullpath = '/root'
72
+ set_fullpath ( '/root' )
73
73
refute is_active_link? ( '/root?param=test' , :exact )
74
74
75
- request . fullpath = '/root?param=test'
75
+ set_fullpath ( '/root?param=test' )
76
76
refute is_active_link? ( '/root' , :exact )
77
77
end
78
78
79
79
def test_is_active_link_regex
80
- request . fullpath = '/root'
80
+ set_fullpath ( '/root' )
81
81
assert is_active_link? ( '/' , /^\/ root/ )
82
82
83
- request . fullpath = '/root/child'
83
+ set_fullpath ( '/root/child' )
84
84
assert is_active_link? ( '/' , /^\/ r/ )
85
85
86
- request . fullpath = '/other'
86
+ set_fullpath ( '/other' )
87
87
refute is_active_link? ( '/' , /^\/ r/ )
88
88
end
89
89
@@ -120,8 +120,16 @@ def test_is_active_link_hash
120
120
assert is_active_link? ( '/' , { :b => 2 } )
121
121
end
122
122
123
+ def test_is_active_link_with_memoization
124
+ set_fullpath ( '/' )
125
+ assert is_active_link? ( '/' , :exclusive )
126
+
127
+ set_fullpath ( '/other' , false )
128
+ assert is_active_link? ( '/' , :exclusive )
129
+ end
130
+
123
131
def test_active_link_to_class
124
- request . fullpath = '/root'
132
+ set_fullpath ( '/root' )
125
133
assert_equal 'active' , active_link_to_class ( '/root' )
126
134
assert_equal 'on' , active_link_to_class ( '/root' , :class_active => 'on' )
127
135
@@ -130,7 +138,7 @@ def test_active_link_to_class
130
138
end
131
139
132
140
def test_active_link_to
133
- request . fullpath = '/root'
141
+ set_fullpath ( '/root' )
134
142
link = active_link_to ( 'label' , '/root' )
135
143
assert_html link , 'a.active[href="/root"]' , 'label'
136
144
@@ -139,7 +147,7 @@ def test_active_link_to
139
147
end
140
148
141
149
def test_active_link_to_with_existing_class
142
- request . fullpath = '/root'
150
+ set_fullpath ( '/root' )
143
151
link = active_link_to ( 'label' , '/root' , :class => 'current' )
144
152
assert_html link , 'a.current.active[href="/root"]' , 'label'
145
153
@@ -148,7 +156,7 @@ def test_active_link_to_with_existing_class
148
156
end
149
157
150
158
def test_active_link_to_with_custom_classes
151
- request . fullpath = '/root'
159
+ set_fullpath ( '/root' )
152
160
link = active_link_to ( 'label' , '/root' , :class_active => 'on' )
153
161
assert_html link , 'a.on[href="/root"]' , 'label'
154
162
@@ -157,7 +165,7 @@ def test_active_link_to_with_custom_classes
157
165
end
158
166
159
167
def test_active_link_to_with_wrap_tag
160
- request . fullpath = '/root'
168
+ set_fullpath ( '/root' )
161
169
link = active_link_to ( 'label' , '/root' , :wrap_tag => :li )
162
170
assert_html link , 'li.active a.active[href="/root"]' , 'label'
163
171
@@ -169,21 +177,21 @@ def test_active_link_to_with_wrap_tag
169
177
end
170
178
171
179
def test_active_link_to_with_active_disable
172
- request . fullpath = '/root'
180
+ set_fullpath ( '/root' )
173
181
link = active_link_to ( 'label' , '/root' , :active_disable => true )
174
182
assert_html link , 'span.active' , 'label'
175
183
end
176
184
177
185
def test_should_not_modify_passed_params
178
- request . fullpath = '/root'
186
+ set_fullpath ( '/root' )
179
187
params = { :class => 'testing' , :active => :inclusive }
180
188
out = active_link_to 'label' , '/root' , params
181
189
assert_html out , 'a.testing.active[href="/root"]' , 'label'
182
190
assert_equal ( { :class => 'testing' , :active => :inclusive } ) , params
183
191
end
184
192
185
193
def test_no_empty_class_attribute
186
- request . fullpath = '/root'
194
+ set_fullpath ( '/root' )
187
195
link = active_link_to ( 'label' , '/root' , :wrap_tag => :li )
188
196
assert_html link , 'li.active a.active[href="/root"]' , 'label'
189
197
@@ -192,7 +200,7 @@ def test_no_empty_class_attribute
192
200
end
193
201
194
202
def test_active_link_to_with_url
195
- request . fullpath = '/root'
203
+ set_fullpath ( '/root' )
196
204
link = active_link_to ( 'label' , 'http://example.com/root' )
197
205
assert_html link , 'a.active[href="http://example.com/root"]' , 'label'
198
206
end
0 commit comments