actionpack 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

@@ -46,7 +46,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
46
46
  )
47
47
  end
48
48
 
49
-
49
+
50
50
  def test_collection_options_with_preselected_value
51
51
  @posts = [
52
52
  Post.new("<Abe> went home", "<Abe>", "To a little house", "shh!"),
@@ -75,14 +75,14 @@ class FormOptionsHelperTest < Test::Unit::TestCase
75
75
 
76
76
  def test_array_options_for_select
77
77
  assert_equal(
78
- "<option>&lt;Denmark&gt;</option>\n<option>USA</option>\n<option>Sweden</option>",
78
+ "<option>&lt;Denmark&gt;</option>\n<option>USA</option>\n<option>Sweden</option>",
79
79
  options_for_select([ "<Denmark>", "USA", "Sweden" ])
80
80
  )
81
81
  end
82
82
 
83
83
  def test_array_options_for_select_with_selection
84
84
  assert_equal(
85
- "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option>Sweden</option>",
85
+ "<option>Denmark</option>\n<option selected=\"selected\">&lt;USA&gt;</option>\n<option>Sweden</option>",
86
86
  options_for_select([ "Denmark", "<USA>", "Sweden" ], "<USA>")
87
87
  )
88
88
  end
@@ -96,21 +96,21 @@ class FormOptionsHelperTest < Test::Unit::TestCase
96
96
 
97
97
  def test_hash_options_for_select
98
98
  assert_equal(
99
- "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
99
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
100
100
  options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
101
101
  )
102
102
  end
103
103
 
104
104
  def test_hash_options_for_select_with_selection
105
105
  assert_equal(
106
- "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
106
+ "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
107
107
  options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
108
108
  )
109
109
  end
110
110
 
111
111
  def test_hash_options_for_select_with_selection
112
112
  assert_equal(
113
- "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
113
+ "<option value=\"&lt;Kroner&gt;\" selected=\"selected\">&lt;DKR&gt;</option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
114
114
  options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
115
115
  )
116
116
  end
@@ -197,7 +197,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
197
197
  @post = Post.new
198
198
  @post.category = "<mus>"
199
199
  assert_equal(
200
- "<select id=\"post_category\" name=\"post[category]\"><option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
200
+ "<select id=\"post_category\" name=\"post[category]\"><option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
201
201
  select("post", "category", %w( abe <mus> hest))
202
202
  )
203
203
  end
@@ -206,7 +206,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
206
206
  @post = Post.new
207
207
  @post.category = "<mus>"
208
208
  assert_equal(
209
- "<select id=\"post_category\" name=\"post[category]\"><option></option>\n<option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
209
+ "<select id=\"post_category\" name=\"post[category]\"><option></option>\n<option>abe</option>\n<option selected=\"selected\">&lt;mus&gt;</option>\n<option>hest</option></select>",
210
210
  select("post", "category", %w( abe <mus> hest), :include_blank => true)
211
211
  )
212
212
  end
@@ -222,7 +222,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
222
222
  @post.author_name = "Babe"
223
223
 
224
224
  assert_equal(
225
- "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
225
+ "<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
226
226
  collection_select("post", "author_name", @posts, "author_name", "author_name")
227
227
  )
228
228
  end
@@ -238,7 +238,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
238
238
  @post.author_name = "Babe"
239
239
 
240
240
  assert_equal(
241
- "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
241
+ "<select id=\"post_author_name\" name=\"post[author_name]\" style=\"width: 200px\"><option></option>\n<option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
242
242
  collection_select("post", "author_name", @posts, "author_name", "author_name", { :include_blank => true }, "style" => "width: 200px")
243
243
  )
244
244
  end
@@ -291,6 +291,8 @@ class FormOptionsHelperTest < Test::Unit::TestCase
291
291
  "<option value=\"E\">E</option>" +
292
292
  "</select>",
293
293
  html
294
+ assert_equal html, time_zone_select("firm", "time_zone", nil, {},
295
+ :style => "color: red")
294
296
  end
295
297
 
296
298
  def test_time_zone_select_with_blank_and_style
@@ -306,6 +308,8 @@ class FormOptionsHelperTest < Test::Unit::TestCase
306
308
  "<option value=\"E\">E</option>" +
307
309
  "</select>",
308
310
  html
311
+ assert_equal html, time_zone_select("firm", "time_zone", nil,
312
+ { :include_blank => true }, :style => "color: red")
309
313
  end
310
314
 
311
315
  def test_time_zone_select_with_priority_zones
@@ -11,12 +11,13 @@ class FormTagHelperTest < Test::Unit::TestCase
11
11
  %(hidden_field_tag "id", 3) => %(<input id="id" name="id" type="hidden" value="3" />),
12
12
  %(password_field_tag) => %(<input id="password" name="password" type="password" value="" />),
13
13
  %(text_area_tag("body", "hello world", :size => "20x40")) => %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>),
14
+ %(text_area_tag("body", "hello world", "size" => "20x40")) => %(<textarea cols="20" id="body" name="body" rows="40">hello world</textarea>),
14
15
  %(check_box_tag("admin")) => %(<input id="admin" name="admin" type="checkbox" value="1" />),
15
16
  %(radio_button_tag("people", "david")) => %(<input id="people" name="people" type="radio" value="david" />),
16
17
  %(select_tag("people", "<option>david</option>")) => %(<select id="people" name="people"><option>david</option></select>),
17
18
  }
18
19
 
19
20
  def test_tags
20
- MethodToTag.each { |method, tag| assert_equal(eval(method), tag) }
21
+ MethodToTag.each { |method, tag| assert_equal(tag, eval(method)) }
21
22
  end
22
- end
23
+ end
@@ -8,23 +8,26 @@ class TagHelperTest < Test::Unit::TestCase
8
8
 
9
9
  def test_tag
10
10
  assert_equal "<p class=\"show\" />", tag("p", "class" => "show")
11
+ assert_equal tag("p", "class" => "show"), tag("p", :class => "show")
11
12
  end
12
-
13
+
13
14
  def test_content_tag
14
15
  assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create")
16
+ assert_equal content_tag("a", "Create", "href" => "create"),
17
+ content_tag("a", "Create", :href => "create")
15
18
  end
16
19
 
17
20
  def test_mail_to_with_javascript
18
- assert_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript")
21
+ assert_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript")
19
22
  end
20
23
 
21
24
  def test_mail_to_with_hex
22
- assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex")
25
+ assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex")
23
26
  end
24
27
 
25
28
  def test_mail_to
26
- assert_equal "<a href=\"mailto:me@domain.com\">My email</a>", mail_to("me@domain.com", "My email")
29
+ assert_equal "<a href=\"mailto:me@domain.com\">My email</a>", mail_to("me@domain.com", "My email")
27
30
  end
28
31
 
29
32
  # FIXME: Test form tag
30
- end
33
+ end
@@ -8,11 +8,11 @@ class TextHelperTest < Test::Unit::TestCase
8
8
  assert_equal "Hello World!", truncate("Hello World!", 12)
9
9
  assert_equal "Hello Worl...", truncate("Hello World!!", 12)
10
10
  end
11
-
11
+
12
12
  def test_strip_links
13
13
  assert_equal "on my mind", strip_links("<a href='almost'>on my mind</a>")
14
14
  end
15
-
15
+
16
16
  def test_highlighter
17
17
  assert_equal(
18
18
  "This is a <strong class=\"highlight\">beautiful</strong> morning",
@@ -29,7 +29,7 @@ class TextHelperTest < Test::Unit::TestCase
29
29
  highlight("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\1</b>')
30
30
  )
31
31
  end
32
-
32
+
33
33
  def test_highlighter_with_regexp
34
34
  assert_equal(
35
35
  "This is a <strong class=\"highlight\">beautiful!</strong> morning",
@@ -46,7 +46,7 @@ class TextHelperTest < Test::Unit::TestCase
46
46
  highlight("This is a beautiful? morning", "beautiful? morning")
47
47
  )
48
48
  end
49
-
49
+
50
50
  def test_excerpt
51
51
  assert_equal("...is a beautiful morni...", excerpt("This is a beautiful morning", "beautiful", 5))
52
52
  assert_equal("This is a...", excerpt("This is a beautiful morning", "this", 5))
@@ -54,16 +54,16 @@ class TextHelperTest < Test::Unit::TestCase
54
54
  assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", 5))
55
55
  assert_nil excerpt("This is a beautiful morning", "day")
56
56
  end
57
-
57
+
58
58
  def test_pluralization
59
59
  assert_equal("1 count", pluralize(1, "count"))
60
60
  assert_equal("2 counts", pluralize(2, "count"))
61
61
  end
62
-
62
+
63
63
  def test_auto_linking
64
64
  assert_equal %(hello <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>), auto_link("hello david@loudthinking.com", :email_addresses)
65
65
  assert_equal %(Go to <a href="http://www.rubyonrails.com">http://www.rubyonrails.com</a>), auto_link("Go to http://www.rubyonrails.com", :urls)
66
66
  assert_equal %(Go to http://www.rubyonrails.com), auto_link("Go to http://www.rubyonrails.com", :email_addresses)
67
67
  assert_equal %(Go to <a href="http://www.rubyonrails.com">http://www.rubyonrails.com</a> and say hello to <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>), auto_link("Go to http://www.rubyonrails.com and say hello to david@loudthinking.com")
68
68
  end
69
- end
69
+ end
@@ -11,7 +11,7 @@ class UrlHelperTest < Test::Unit::TestCase
11
11
  def setup
12
12
  @controller = Class.new do
13
13
  def url_for(options, *parameters_for_method_reference)
14
- "http://www.world.com"
14
+ "http://www.example.com"
15
15
  end
16
16
  end
17
17
  @controller = @controller.new
@@ -19,35 +19,66 @@ class UrlHelperTest < Test::Unit::TestCase
19
19
 
20
20
  # todo: missing test cases
21
21
  def test_link_tag_with_straight_url
22
- assert_equal "<a href=\"http://www.world.com\">Hello</a>", link_to("Hello", "http://www.world.com")
22
+ assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com")
23
23
  end
24
-
24
+
25
25
  def test_link_tag_with_javascript_confirm
26
26
  assert_equal(
27
- "<a href=\"http://www.world.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",
28
- link_to("Hello", "http://www.world.com", :confirm => "Are you sure?")
27
+ "<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",
28
+ link_to("Hello", "http://www.example.com", :confirm => "Are you sure?")
29
+ )
30
+ assert_equal(
31
+ "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure, can you?');\">Hello</a>",
32
+ link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure, can you?")
29
33
  )
30
34
  end
31
-
32
- def test_link_to_image
35
+
36
+ def test_link_image_to
33
37
  assert_equal(
34
- "<a href=\"http://www.world.com\"><img alt=\"Rss\" border=\"0\" height=\"45\" src=\"/images/rss.png\" width=\"30\" /></a>",
35
- link_to_image("rss", "http://www.world.com", "size" => "30x45")
38
+ "<a href=\"http://www.example.com\"><img alt=\"Rss\" border=\"0\" height=\"45\" src=\"/images/rss.png\" width=\"30\" /></a>",
39
+ link_image_to("rss", "http://www.example.com", "size" => "30x45", "border" => "0")
36
40
  )
37
41
 
38
42
  assert_equal(
39
- "<a class=\"admin\" href=\"http://www.world.com\"><img alt=\"Feed\" border=\"0\" height=\"45\" src=\"/images/rss.gif\" width=\"30\" /></a>",
40
- link_to_image("rss.gif", "http://www.world.com", "size" => "30x45", "alt" => "Feed", "class" => "admin")
43
+ "<a class=\"admin\" href=\"http://www.example.com\"><img alt=\"Feed\" height=\"45\" src=\"/images/rss.gif\" width=\"30\" /></a>",
44
+ link_image_to("rss.gif", "http://www.example.com", "size" => "30x45", "alt" => "Feed", "class" => "admin")
41
45
  )
46
+
47
+ assert_equal link_image_to("rss", "http://www.example.com", "size" => "30x45"),
48
+ link_image_to("rss", "http://www.example.com", :size => "30x45")
49
+ assert_equal link_image_to("rss.gif", "http://www.example.com", "size" => "30x45", "alt" => "Feed", "class" => "admin"),
50
+ link_image_to("rss.gif", "http://www.example.com", :size => "30x45", :alt => "Feed", :class => "admin")
51
+ end
52
+
53
+ def test_link_to_unless
54
+ assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog")
55
+ assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog")
56
+ assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1)
57
+ assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name, options, html_options, *parameters_for_method_reference|
58
+ "<strong>#{name}</strong>"
59
+ }
60
+ assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name|
61
+ "<strong>#{name}</strong>"
62
+ }
63
+ assert_equal "test", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) {
64
+ "test"
65
+ }
42
66
  end
43
67
 
68
+ def test_link_to_if
69
+ assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog")
70
+ assert "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog")
71
+ assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1)
72
+ end
73
+
74
+
44
75
  def test_link_unless_current
45
- @request = RequestMock.new("http://www.world.com")
76
+ @request = RequestMock.new("http://www.example.com")
46
77
  assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog")
47
- @request = RequestMock.new("http://www.notworld.com")
48
- assert "<a href=\"http://www.world.com\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog")
78
+ @request = RequestMock.new("http://www.example.org")
79
+ assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless_current("Listing", :action => "list", :controller => "weblog")
49
80
 
50
- @request = RequestMock.new("http://www.world.com")
81
+ @request = RequestMock.new("http://www.example.com")
51
82
  assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog", :id => 1)
52
83
  end
53
84
 
@@ -55,12 +86,14 @@ class UrlHelperTest < Test::Unit::TestCase
55
86
  assert_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com")
56
87
  assert_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson")
57
88
  assert_equal(
58
- "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>",
89
+ "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>",
59
90
  mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin")
60
91
  )
92
+ assert_equal mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin"),
93
+ mail_to("david@loudthinking.com", "David Heinemeier Hansson", :class => "admin")
61
94
  end
62
-
95
+
63
96
  def test_link_with_nil_html_options
64
- assert_equal "<a href=\"http://www.world.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil)
97
+ assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil)
65
98
  end
66
99
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.4
2
+ rubygems_version: 0.8.6
3
3
  specification_version: 1
4
4
  name: actionpack
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.5.0
7
- date: 2005-02-24
6
+ version: 1.5.1
7
+ date: 2005-03-07
8
8
  summary: Web-flow and rendering framework putting the VC in MVC.
9
9
  require_paths:
10
10
  - lib
@@ -161,7 +161,6 @@ files:
161
161
  - test/template/tag_helper_test.rb
162
162
  - test/template/text_helper_test.rb
163
163
  - test/template/url_helper_test.rb
164
- - test/template/url_helper_test.rb.rej
165
164
  - examples/address_book
166
165
  - examples/address_book_controller.cgi
167
166
  - examples/address_book_controller.fcgi
@@ -193,5 +192,5 @@ dependencies:
193
192
  -
194
193
  - "="
195
194
  - !ruby/object:Gem::Version
196
- version: 1.0.0
195
+ version: 1.0.1
197
196
  version:
@@ -1,105 +0,0 @@
1
- ***************
2
- *** 11,17 ****
3
- def setup
4
- @controller = Class.new do
5
- def url_for(options, *parameters_for_method_reference)
6
- - &#34;http://www.world.com&#34;
7
- end
8
- end
9
- @controller = @controller.new
10
- --- 11,17 ----
11
- def setup
12
- @controller = Class.new do
13
- def url_for(options, *parameters_for_method_reference)
14
- + &#34;http://www.example.com&#34;
15
- end
16
- end
17
- @controller = @controller.new
18
- ***************
19
- *** 19,53 ****
20
-
21
- # todo: missing test cases
22
- def test_link_tag_with_straight_url
23
- - assert_equal &#34;&lt;a href=\&#34;http://www.world.com\&#34;&gt;Hello&lt;/a&gt;&#34;, link_to(&#34;Hello&#34;, &#34;http://www.world.com&#34;)
24
- end
25
-
26
- def test_link_tag_with_javascript_confirm
27
- assert_equal(
28
- - &#34;&lt;a href=\&#34;http://www.world.com\&#34; onclick=\&#34;return confirm('Are you sure?');\&#34;&gt;Hello&lt;/a&gt;&#34;,
29
- - link_to(&#34;Hello&#34;, &#34;http://www.world.com&#34;, :confirm =&gt; &#34;Are you sure?&#34;)
30
- )
31
- end
32
-
33
- def test_link_to_image
34
- assert_equal(
35
- - &#34;&lt;a href=\&#34;http://www.world.com\&#34;&gt;&lt;img alt=\&#34;Rss\&#34; border=\&#34;0\&#34; height=\&#34;45\&#34; src=\&#34;/images/rss.png\&#34; width=\&#34;30\&#34; /&gt;&lt;/a&gt;&#34;,
36
- - link_to_image(&#34;rss&#34;, &#34;http://www.world.com&#34;, &#34;size&#34; =&gt; &#34;30x45&#34;)
37
- )
38
-
39
- assert_equal(
40
- - &#34;&lt;a class=\&#34;admin\&#34; href=\&#34;http://www.world.com\&#34;&gt;&lt;img alt=\&#34;Feed\&#34; border=\&#34;0\&#34; height=\&#34;45\&#34; src=\&#34;/images/rss.gif\&#34; width=\&#34;30\&#34; /&gt;&lt;/a&gt;&#34;,
41
- - link_to_image(&#34;rss.gif&#34;, &#34;http://www.world.com&#34;, &#34;size&#34; =&gt; &#34;30x45&#34;, &#34;alt&#34; =&gt; &#34;Feed&#34;, &#34;class&#34; =&gt; &#34;admin&#34;)
42
- )
43
- end
44
-
45
- def test_link_unless_current
46
- - @request = RequestMock.new(&#34;http://www.world.com&#34;)
47
- assert_equal &#34;Showing&#34;, link_to_unless_current(&#34;Showing&#34;, :action =&gt; &#34;show&#34;, :controller =&gt; &#34;weblog&#34;)
48
- - @request = RequestMock.new(&#34;http://www.notworld.com&#34;)
49
- - assert &#34;&lt;a href=\&#34;http://www.world.com\&#34;&gt;Listing&lt;/a&gt;&#34;, link_to_unless_current(&#34;Listing&#34;, :action =&gt; &#34;list&#34;, :controller =&gt; &#34;weblog&#34;)
50
-
51
- - @request = RequestMock.new(&#34;http://www.world.com&#34;)
52
- assert_equal &#34;Showing&#34;, link_to_unless_current(&#34;Showing&#34;, :action =&gt; &#34;show&#34;, :controller =&gt; &#34;weblog&#34;, :id =&gt; 1)
53
- end
54
-
55
- --- 19,53 ----
56
-
57
- # todo: missing test cases
58
- def test_link_tag_with_straight_url
59
- + assert_equal &#34;&lt;a href=\&#34;http://www.example.com\&#34;&gt;Hello&lt;/a&gt;&#34;, link_to(&#34;Hello&#34;, &#34;http://www.example.com&#34;)
60
- end
61
-
62
- def test_link_tag_with_javascript_confirm
63
- assert_equal(
64
- + &#34;&lt;a href=\&#34;http://www.example.com\&#34; onclick=\&#34;return confirm('Are you sure?');\&#34;&gt;Hello&lt;/a&gt;&#34;,
65
- + link_to(&#34;Hello&#34;, &#34;http://www.example.com&#34;, :confirm =&gt; &#34;Are you sure?&#34;)
66
- )
67
- end
68
-
69
- def test_link_to_image
70
- assert_equal(
71
- + &#34;&lt;a href=\&#34;http://www.example.com\&#34;&gt;&lt;img alt=\&#34;Rss\&#34; border=\&#34;1\&#34; height=\&#34;45\&#34; src=\&#34;/images/rss.png\&#34; width=\&#34;30\&#34; /&gt;&lt;/a&gt;&#34;,
72
- + link_to_image(&#34;rss&#34;, &#34;http://www.example.com&#34;, &#34;size&#34; =&gt; &#34;30x45&#34;, &#34;border&#34; =&gt; 1)
73
- )
74
-
75
- assert_equal(
76
- + &#34;&lt;a class=\&#34;admin\&#34; href=\&#34;http://www.example.com\&#34;&gt;&lt;img alt=\&#34;Feed\&#34; height=\&#34;45\&#34; src=\&#34;/images/rss.gif\&#34; width=\&#34;30\&#34; /&gt;&lt;/a&gt;&#34;,
77
- + link_to_image(&#34;rss.gif&#34;, &#34;http://www.example.com&#34;, &#34;size&#34; =&gt; &#34;30x45&#34;, &#34;alt&#34; =&gt; &#34;Feed&#34;, &#34;class&#34; =&gt; &#34;admin&#34;)
78
- )
79
- end
80
-
81
- def test_link_unless_current
82
- + @request = RequestMock.new(&#34;http://www.example.com&#34;)
83
- assert_equal &#34;Showing&#34;, link_to_unless_current(&#34;Showing&#34;, :action =&gt; &#34;show&#34;, :controller =&gt; &#34;weblog&#34;)
84
- + @request = RequestMock.new(&#34;http://www.example.org&#34;)
85
- + assert &#34;&lt;a href=\&#34;http://www.example.com\&#34;&gt;Listing&lt;/a&gt;&#34;, link_to_unless_current(&#34;Listing&#34;, :action =&gt; &#34;list&#34;, :controller =&gt; &#34;weblog&#34;)
86
-
87
- + @request = RequestMock.new(&#34;http://www.example.com&#34;)
88
- assert_equal &#34;Showing&#34;, link_to_unless_current(&#34;Showing&#34;, :action =&gt; &#34;show&#34;, :controller =&gt; &#34;weblog&#34;, :id =&gt; 1)
89
- end
90
-
91
- ***************
92
- *** 61,66 ****
93
- end
94
-
95
- def test_link_with_nil_html_options
96
- - assert_equal &#34;&lt;a href=\&#34;http://www.world.com\&#34;&gt;Hello&lt;/a&gt;&#34;, link_to(&#34;Hello&#34;, {:action =&gt; 'myaction'}, nil)
97
- end
98
- end
99
- --- 61,66 ----
100
- end
101
-
102
- def test_link_with_nil_html_options
103
- + assert_equal &#34;&lt;a href=\&#34;http://www.example.com\&#34;&gt;Hello&lt;/a&gt;&#34;, link_to(&#34;Hello&#34;, {:action =&gt; 'myaction'}, nil)
104
- end
105
- end