actionpack 2.0.2 → 2.0.4

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.

Files changed (74) hide show
  1. data/CHANGELOG +45 -0
  2. data/Rakefile +5 -3
  3. data/lib/action_controller.rb +0 -0
  4. data/lib/action_controller/assertions/response_assertions.rb +6 -2
  5. data/lib/action_controller/assertions/routing_assertions.rb +5 -2
  6. data/lib/action_controller/base.rb +4 -3
  7. data/lib/action_controller/cgi_ext/cookie.rb +1 -1
  8. data/lib/action_controller/filters.rb +5 -3
  9. data/lib/action_controller/http_authentication.rb +2 -4
  10. data/lib/action_controller/integration.rb +3 -2
  11. data/lib/action_controller/layout.rb +14 -15
  12. data/lib/action_controller/mime_type.rb +4 -1
  13. data/lib/action_controller/polymorphic_routes.rb +90 -15
  14. data/lib/action_controller/record_identifier.rb +4 -4
  15. data/lib/action_controller/request.rb +29 -14
  16. data/lib/action_controller/request_forgery_protection.rb +41 -34
  17. data/lib/action_controller/request_profiler.rb +16 -6
  18. data/lib/action_controller/response.rb +0 -0
  19. data/lib/action_controller/routing.rb +3 -3
  20. data/lib/action_controller/session/active_record_store.rb +7 -8
  21. data/lib/action_controller/session/cookie_store.rb +2 -3
  22. data/lib/action_controller/templates/rescues/_trace.erb +5 -5
  23. data/lib/action_controller/test_case.rb +24 -4
  24. data/lib/action_controller/test_process.rb +3 -3
  25. data/lib/action_controller/url_rewriter.rb +29 -28
  26. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +2 -2
  27. data/lib/action_controller/verification.rb +73 -57
  28. data/lib/action_pack/version.rb +1 -1
  29. data/lib/action_view/base.rb +24 -6
  30. data/lib/action_view/helpers/active_record_helper.rb +1 -1
  31. data/lib/action_view/helpers/asset_tag_helper.rb +12 -6
  32. data/lib/action_view/helpers/atom_feed_helper.rb +21 -17
  33. data/lib/action_view/helpers/date_helper.rb +6 -6
  34. data/lib/action_view/helpers/form_helper.rb +3 -2
  35. data/lib/action_view/helpers/form_options_helper.rb +12 -1
  36. data/lib/action_view/helpers/form_tag_helper.rb +18 -0
  37. data/lib/action_view/helpers/number_helper.rb +1 -1
  38. data/lib/action_view/helpers/prototype_helper.rb +1 -1
  39. data/lib/action_view/helpers/text_helper.rb +1 -1
  40. data/lib/action_view/helpers/url_helper.rb +5 -9
  41. data/lib/action_view/template_error.rb +11 -4
  42. data/test/activerecord/active_record_store_test.rb +1 -1
  43. data/test/activerecord/fixtures_test.rb +24 -0
  44. data/test/controller/action_pack_assertions_test.rb +37 -2
  45. data/test/controller/base_test.rb +4 -1
  46. data/test/controller/cgi_test.rb +4 -3
  47. data/test/controller/filters_test.rb +4 -7
  48. data/test/controller/html-scanner/sanitizer_test.rb +7 -1
  49. data/test/controller/integration_test.rb +0 -1
  50. data/test/controller/mime_type_test.rb +5 -0
  51. data/test/controller/new_render_test.rb +25 -2
  52. data/test/controller/polymorphic_routes_test.rb +106 -75
  53. data/test/controller/redirect_test.rb +11 -0
  54. data/test/controller/render_test.rb +19 -0
  55. data/test/controller/request_forgery_protection_test.rb +9 -0
  56. data/test/controller/request_test.rb +33 -5
  57. data/test/controller/routing_test.rb +4 -4
  58. data/test/controller/session/cookie_store_test.rb +0 -0
  59. data/test/controller/test_test.rb +43 -1
  60. data/test/controller/url_rewriter_test.rb +34 -4
  61. data/test/fixtures/layouts/block_with_layout.erb +3 -0
  62. data/test/fixtures/layouts/partial_with_layout.erb +3 -0
  63. data/test/template/asset_tag_helper_test.rb +17 -13
  64. data/test/template/atom_feed_helper_test.rb +52 -2
  65. data/test/template/compiled_templates_test.rb +5 -1
  66. data/test/template/date_helper_test.rb +1 -1
  67. data/test/template/deprecate_ivars_test.rb +51 -0
  68. data/test/template/form_options_helper_test.rb +29 -0
  69. data/test/template/form_tag_helper_test.rb +18 -0
  70. data/test/template/number_helper_test.rb +1 -0
  71. data/test/template/text_helper_test.rb +32 -14
  72. data/test/template/url_helper_test.rb +1 -1
  73. data/test/testing_sandbox.rb +8 -4
  74. metadata +9 -4
@@ -64,8 +64,12 @@ class CompiledTemplateTests < Test::Unit::TestCase
64
64
 
65
65
  def test_mtime
66
66
  t1 = Time.now
67
+
67
68
  test_compile_source_single_method
68
- assert (t1..Time.now).include?(ct.mtime('doubling method', [:a]))
69
+ mtime = ct.mtime('doubling method', [:a])
70
+
71
+ assert mtime < Time.now
72
+ assert mtime > t1
69
73
  end
70
74
 
71
75
  uses_mocha 'test_compile_time' do
@@ -1395,7 +1395,7 @@ class DateHelperTest < Test::Unit::TestCase
1395
1395
 
1396
1396
  expected = %{<select id="post_updated_at_1i" name="post[updated_at(1i)]">\n}
1397
1397
  expected << %(<option value=""></option>\n)
1398
- 2002.upto(2012) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
1398
+ (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(<option value="#{i}">#{i}</option>\n) }
1399
1399
  expected << "</select>\n"
1400
1400
  expected << %{<select id="post_updated_at_2i" name="post[updated_at(2i)]">\n}
1401
1401
  expected << %(<option value=""></option>\n)
@@ -0,0 +1,51 @@
1
+ require File.dirname(__FILE__) + '/../abstract_unit'
2
+
3
+ class DeprecateIvars < ActionController::Base
4
+ def use_logger
5
+ render :inline => "<%= logger.class -%>"
6
+ end
7
+
8
+ def use_old_logger
9
+ render :inline => "<%= @logger.class -%>"
10
+ end
11
+
12
+ def use_action_name
13
+ render :inline => "<%= action_name -%>"
14
+ end
15
+
16
+ def use_old_action_name
17
+ render :inline => "<%= @action_name -%>"
18
+ end
19
+ end
20
+
21
+ class DeprecateIvarsTest < Test::Unit::TestCase
22
+ def setup
23
+ @request = ActionController::TestRequest.new
24
+ @response = ActionController::TestResponse.new
25
+
26
+ @controller = DeprecateIvars.new
27
+ @controller.logger = Logger.new(nil)
28
+
29
+ @request.host = "rubyonrails.com"
30
+ end
31
+
32
+ def test_logger
33
+ assert_not_deprecated { get :use_logger }
34
+ assert_equal "Logger", @response.body
35
+ end
36
+
37
+ def test_deprecated_logger
38
+ assert_deprecated { get :use_old_logger }
39
+ assert_equal "Logger", @response.body
40
+ end
41
+
42
+ def test_action_name
43
+ assert_not_deprecated { get :use_action_name }
44
+ assert_equal "use_action_name", @response.body
45
+ end
46
+
47
+ def test_deprecated_action_name
48
+ assert_deprecated { get :use_old_action_name }
49
+ assert_equal "use_old_action_name", @response.body
50
+ end
51
+ end
@@ -109,6 +109,7 @@ class FormOptionsHelperTest < Test::Unit::TestCase
109
109
  )
110
110
  end
111
111
 
112
+ # FIXME: fails on Ruby 1.9, probably in html-scanner
112
113
  def test_hash_options_for_select
113
114
  assert_dom_equal(
114
115
  "<option value=\"&lt;Kroner&gt;\">&lt;DKR&gt;</option>\n<option value=\"Dollar\">$</option>",
@@ -1293,4 +1294,32 @@ COUNTRIES
1293
1294
  "</select>",
1294
1295
  html
1295
1296
  end
1297
+
1298
+ def test_time_zone_select_with_default_time_zone_and_nil_value
1299
+ @firm = Firm.new()
1300
+ @firm.time_zone = nil
1301
+ html = time_zone_select( "firm", "time_zone", nil, :default => 'B' )
1302
+ assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" +
1303
+ "<option value=\"A\">A</option>\n" +
1304
+ "<option value=\"B\" selected=\"selected\">B</option>\n" +
1305
+ "<option value=\"C\">C</option>\n" +
1306
+ "<option value=\"D\">D</option>\n" +
1307
+ "<option value=\"E\">E</option>" +
1308
+ "</select>",
1309
+ html
1310
+ end
1311
+
1312
+ def test_time_zone_select_with_default_time_zone_and_value
1313
+ @firm = Firm.new('D')
1314
+ html = time_zone_select( "firm", "time_zone", nil, :default => 'B' )
1315
+ assert_dom_equal "<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" +
1316
+ "<option value=\"A\">A</option>\n" +
1317
+ "<option value=\"B\">B</option>\n" +
1318
+ "<option value=\"C\">C</option>\n" +
1319
+ "<option value=\"D\" selected=\"selected\">D</option>\n" +
1320
+ "<option value=\"E\">E</option>" +
1321
+ "</select>",
1322
+ html
1323
+ end
1324
+
1296
1325
  end
@@ -188,6 +188,24 @@ class FormTagHelperTest < Test::Unit::TestCase
188
188
  assert_dom_equal expected, actual
189
189
  end
190
190
 
191
+ def test_label_tag_without_text
192
+ actual = label_tag "title"
193
+ expected = %(<label for="title">Title</label>)
194
+ assert_dom_equal expected, actual
195
+ end
196
+
197
+ def test_label_tag_with_text
198
+ actual = label_tag "title", "My Title"
199
+ expected = %(<label for="title">My Title</label>)
200
+ assert_dom_equal expected, actual
201
+ end
202
+
203
+ def test_label_tag_class_string
204
+ actual = label_tag "title", "My Title", "class" => "small_label"
205
+ expected = %(<label for="title" class="small_label">My Title</label>)
206
+ assert_dom_equal expected, actual
207
+ end
208
+
191
209
  def test_boolean_optios
192
210
  assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes")
193
211
  assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil)
@@ -87,6 +87,7 @@ class NumberHelperTest < Test::Unit::TestCase
87
87
  assert_equal '1.01 KB', number_to_human_size(1.0100.kilobytes, 4)
88
88
  assert_equal '10 KB', number_to_human_size(10.000.kilobytes, 4)
89
89
  assert_equal '1 Byte', number_to_human_size(1.1)
90
+ assert_equal '10 Bytes', number_to_human_size(10)
90
91
  assert_nil number_to_human_size('x')
91
92
  assert_nil number_to_human_size(nil)
92
93
  end
@@ -1,5 +1,5 @@
1
- require "#{File.dirname(__FILE__)}/../abstract_unit"
2
- require "#{File.dirname(__FILE__)}/../testing_sandbox"
1
+ require 'abstract_unit'
2
+ require 'testing_sandbox'
3
3
 
4
4
  class TextHelperTest < Test::Unit::TestCase
5
5
  include ActionView::Helpers::TextHelper
@@ -36,16 +36,26 @@ class TextHelperTest < Test::Unit::TestCase
36
36
  assert_equal str[0...27] + "...", truncate(str)
37
37
  end
38
38
 
39
- def test_truncate_multibyte
40
- with_kcode 'none' do
41
- assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
39
+ if RUBY_VERSION < '1.9.0'
40
+ def test_truncate_multibyte
41
+ with_kcode 'none' do
42
+ assert_equal "\354\225\210\353\205\225\355...", truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
43
+ end
44
+ with_kcode 'u' do
45
+ assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...",
46
+ truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244", 10)
47
+ end
42
48
  end
43
- with_kcode 'u' do
44
- assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...",
45
- truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244", 10)
49
+ else
50
+ def test_truncate_multibyte
51
+ assert_equal "\354\225\210\353\205\225\355...",
52
+ truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
53
+
54
+ assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".force_encoding('UTF-8'),
55
+ truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".force_encoding('UTF-8'), 10)
46
56
  end
47
57
  end
48
-
58
+
49
59
  def test_highlighter
50
60
  assert_equal(
51
61
  "This is a <strong class=\"highlight\">beautiful</strong> morning",
@@ -103,15 +113,22 @@ class TextHelperTest < Test::Unit::TestCase
103
113
  assert_equal('...is a beautiful? morn...', excerpt('This is a beautiful? morning', 'beautiful', 5))
104
114
  end
105
115
 
106
- def test_excerpt_with_utf8
107
- with_kcode('u') do
108
- assert_equal("...fficiency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
116
+ if RUBY_VERSION < '1.9'
117
+ def test_excerpt_with_utf8
118
+ with_kcode('u') do
119
+ assert_equal("...fficiency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
120
+ end
121
+ with_kcode('none') do
122
+ assert_equal("...\203ciency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
123
+ end
109
124
  end
110
- with_kcode('none') do
125
+ else
126
+ def test_excerpt_with_utf8
127
+ assert_equal("...fficiency could not be h...".force_encoding('UTF-8'), excerpt("That's why efficiency could not be helped".force_encoding('UTF-8'), 'could', 8))
111
128
  assert_equal("...\203ciency could not be h...", excerpt("That's why efficiency could not be helped", 'could', 8))
112
129
  end
113
130
  end
114
-
131
+
115
132
  def test_word_wrap
116
133
  assert_equal("my very very\nvery long\nstring", word_wrap("my very very very long string", 15))
117
134
  end
@@ -158,6 +175,7 @@ class TextHelperTest < Test::Unit::TestCase
158
175
  http://www.rubyonrails.com/~minam/contact;new?with=query&string=params
159
176
  http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
160
177
  http://www.mail-archive.com/rails@lists.rubyonrails.org/
178
+ http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1
161
179
  )
162
180
 
163
181
  urls.each do |url|
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/../abstract_unit"
1
+ require 'abstract_unit'
2
2
 
3
3
  RequestMock = Struct.new("Request", :request_uri, :protocol, :host_with_port, :env)
4
4
 
@@ -1,11 +1,15 @@
1
1
  module TestingSandbox
2
2
  # Temporarily replaces KCODE for the block
3
3
  def with_kcode(kcode)
4
- old_kcode, $KCODE = $KCODE, kcode
5
- begin
4
+ if RUBY_VERSION < '1.9'
5
+ old_kcode, $KCODE = $KCODE, kcode
6
+ begin
7
+ yield
8
+ ensure
9
+ $KCODE = old_kcode
10
+ end
11
+ else
6
12
  yield
7
- ensure
8
- $KCODE = old_kcode
9
13
  end
10
14
  end
11
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,17 +9,18 @@ autorequire: action_controller
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-16 00:00:00 -06:00
12
+ date: 2008-09-03 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
21
  - - "="
21
22
  - !ruby/object:Gem::Version
22
- version: 2.0.2
23
+ version: 2.0.4
23
24
  version:
24
25
  description: Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.
25
26
  email: david@loudthinking.com
@@ -157,6 +158,7 @@ files:
157
158
  - test/active_record_unit.rb
158
159
  - test/activerecord
159
160
  - test/activerecord/active_record_store_test.rb
161
+ - test/activerecord/fixtures_test.rb
160
162
  - test/activerecord/render_partial_with_record_identification_test.rb
161
163
  - test/controller
162
164
  - test/controller/action_pack_assertions_test.rb
@@ -262,7 +264,9 @@ files:
262
264
  - test/fixtures/layout_tests/views
263
265
  - test/fixtures/layout_tests/views/hello.rhtml
264
266
  - test/fixtures/layouts
267
+ - test/fixtures/layouts/block_with_layout.erb
265
268
  - test/fixtures/layouts/builder.builder
269
+ - test/fixtures/layouts/partial_with_layout.erb
266
270
  - test/fixtures/layouts/standard.erb
267
271
  - test/fixtures/layouts/talk_from_action.erb
268
272
  - test/fixtures/layouts/yield.erb
@@ -380,6 +384,7 @@ files:
380
384
  - test/template/benchmark_helper_test.rb
381
385
  - test/template/compiled_templates_test.rb
382
386
  - test/template/date_helper_test.rb
387
+ - test/template/deprecate_ivars_test.rb
383
388
  - test/template/erb_util_test.rb
384
389
  - test/template/form_helper_test.rb
385
390
  - test/template/form_options_helper_test.rb
@@ -415,7 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
420
  requirements:
416
421
  - none
417
422
  rubyforge_project: actionpack
418
- rubygems_version: 0.9.5
423
+ rubygems_version: 1.2.0
419
424
  signing_key:
420
425
  specification_version: 2
421
426
  summary: Web-flow and rendering framework putting the VC in MVC.