actionpack 1.4.0 → 1.5.0

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 (84) hide show
  1. data/CHANGELOG +66 -0
  2. data/README +94 -64
  3. data/install.rb +1 -20
  4. data/lib/action_controller.rb +15 -7
  5. data/lib/action_controller/assertions/action_pack_assertions.rb +56 -3
  6. data/lib/action_controller/base.rb +137 -64
  7. data/lib/action_controller/caching.rb +11 -11
  8. data/lib/action_controller/cgi_ext/cgi_ext.rb +2 -2
  9. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +4 -4
  10. data/lib/action_controller/cgi_process.rb +9 -1
  11. data/lib/action_controller/components.rb +73 -0
  12. data/lib/action_controller/cookies.rb +1 -1
  13. data/lib/action_controller/dependencies.rb +6 -1
  14. data/lib/action_controller/filters.rb +1 -1
  15. data/lib/action_controller/flash.rb +3 -3
  16. data/lib/action_controller/helpers.rb +17 -21
  17. data/lib/action_controller/layout.rb +2 -2
  18. data/lib/action_controller/request.rb +16 -6
  19. data/lib/action_controller/rescue.rb +15 -3
  20. data/lib/action_controller/routing.rb +304 -0
  21. data/lib/action_controller/scaffolding.rb +10 -12
  22. data/lib/action_controller/session/active_record_store.rb +4 -7
  23. data/lib/action_controller/session/mem_cache_store.rb +2 -2
  24. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +9 -1
  25. data/lib/action_controller/templates/rescues/diagnostics.rhtml +1 -1
  26. data/lib/action_controller/templates/rescues/routing_error.rhtml +8 -0
  27. data/lib/action_controller/test_process.rb +29 -7
  28. data/lib/action_controller/url_rewriter.rb +28 -112
  29. data/lib/action_view.rb +1 -1
  30. data/lib/action_view/base.rb +44 -17
  31. data/lib/action_view/helpers/active_record_helper.rb +1 -1
  32. data/lib/action_view/helpers/asset_tag_helper.rb +59 -0
  33. data/lib/action_view/helpers/date_helper.rb +24 -13
  34. data/lib/action_view/helpers/form_helper.rb +6 -1
  35. data/lib/action_view/helpers/form_options_helper.rb +87 -9
  36. data/lib/action_view/helpers/form_tag_helper.rb +80 -0
  37. data/lib/action_view/helpers/tag_helper.rb +0 -23
  38. data/lib/action_view/helpers/text_helper.rb +26 -1
  39. data/lib/action_view/helpers/url_helper.rb +29 -35
  40. data/lib/action_view/partials.rb +2 -2
  41. data/lib/action_view/vendor/builder/xmlbase.rb +3 -3
  42. data/rakefile +5 -2
  43. data/test/abstract_unit.rb +3 -1
  44. data/test/controller/action_pack_assertions_test.rb +29 -1
  45. data/test/controller/active_record_assertions_test.rb +109 -101
  46. data/test/controller/base_tests.rb +72 -0
  47. data/test/controller/components_test.rb +74 -0
  48. data/test/controller/cookie_test.rb +0 -9
  49. data/test/controller/custom_handler_test.rb +33 -0
  50. data/test/controller/filters_test.rb +36 -0
  51. data/test/controller/helper_test.rb +27 -10
  52. data/test/controller/redirect_test.rb +23 -31
  53. data/test/controller/render_test.rb +81 -66
  54. data/test/controller/request_test.rb +22 -0
  55. data/test/controller/routing_tests.rb +490 -0
  56. data/test/controller/{url_test.rb → url_obsolete.rb} +24 -14
  57. data/test/controller/url_obsolete.rb.rej +747 -0
  58. data/test/fixtures/fun/games/hello_world.rhtml +1 -0
  59. data/test/fixtures/helpers/fun/games_helper.rb +3 -0
  60. data/test/template/asset_tag_helper_test.rb +45 -0
  61. data/test/template/form_options_helper_test.rb +161 -1
  62. data/test/template/form_tag_helper_test.rb +22 -0
  63. data/test/template/text_helper_test.rb +7 -0
  64. data/test/template/url_helper_test.rb +5 -2
  65. data/test/template/url_helper_test.rb.rej +105 -0
  66. metadata +32 -27
  67. data/lib/action_controller/support/binding_of_caller.rb +0 -83
  68. data/lib/action_controller/support/breakpoint.rb +0 -518
  69. data/lib/action_controller/support/class_attribute_accessors.rb +0 -57
  70. data/lib/action_controller/support/class_inheritable_attributes.rb +0 -117
  71. data/lib/action_controller/support/clean_logger.rb +0 -10
  72. data/lib/action_controller/support/core_ext.rb +0 -1
  73. data/lib/action_controller/support/core_ext/hash.rb +0 -5
  74. data/lib/action_controller/support/core_ext/hash/keys.rb +0 -35
  75. data/lib/action_controller/support/core_ext/numeric.rb +0 -7
  76. data/lib/action_controller/support/core_ext/numeric/bytes.rb +0 -33
  77. data/lib/action_controller/support/core_ext/numeric/time.rb +0 -59
  78. data/lib/action_controller/support/core_ext/object_and_class.rb +0 -24
  79. data/lib/action_controller/support/core_ext/string.rb +0 -5
  80. data/lib/action_controller/support/core_ext/string/inflections.rb +0 -45
  81. data/lib/action_controller/support/dependencies.rb +0 -63
  82. data/lib/action_controller/support/inflector.rb +0 -84
  83. data/lib/action_controller/support/misc.rb +0 -8
  84. data/lib/action_controller/support/module_attribute_accessors.rb +0 -57
@@ -16,6 +16,9 @@ module ActionView
16
16
  # get a link tag that just points without consideration. If nil is passed as a name, the link itself will become the name.
17
17
  # The html_options have a special feature for creating javascript confirm alerts where if you pass :confirm => 'Are you sure?',
18
18
  # the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not.
19
+ #
20
+ # Example:
21
+ # link_to "Delete this page", { :action => "destroy", :id => @page.id }, :confirm => "Are you sure?"
19
22
  def link_to(name, options = {}, html_options = {}, *parameters_for_method_reference)
20
23
  convert_confirm_option_to_javascript!(html_options) unless html_options.nil?
21
24
  if options.is_a?(String)
@@ -28,21 +31,25 @@ module ActionView
28
31
  end
29
32
  end
30
33
 
31
- # Creates a link tag to the image residing at the +src+ using an URL created by the set of +options+. See the valid options in
34
+ # Creates a link tag on the image residing at the +src+ using an URL created by the set of +options+. See the valid options in
32
35
  # link:classes/ActionController/Base.html#M000021. It's also possible to pass a string instead of an options hash to
33
36
  # get a link tag that just points without consideration. The <tt>html_options</tt> works jointly for the image and ahref tag by
34
37
  # letting the following special values enter the options on the image and the rest goes to the ahref:
35
38
  #
36
- # * <tt>alt</tt> - If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension)
37
- # * <tt>size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45"
38
- # * <tt>border</tt> - Is set to 0 by default
39
- # * <tt>align</tt> - Sets the alignment, no special features
39
+ # * <tt>:alt</tt> - If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension)
40
+ # * <tt>:size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45"
41
+ # * <tt>:border</tt> - Is set to 0 by default
42
+ # * <tt>:align</tt> - Sets the alignment, no special features
40
43
  #
41
44
  # The +src+ can be supplied as a...
42
45
  # * full path, like "/my_images/image.gif"
43
46
  # * file name, like "rss.gif", that gets expanded to "/images/rss.gif"
44
47
  # * file name without extension, like "logo", that gets expanded to "/images/logo.png"
45
- def link_to_image(src, options = {}, html_options = {}, *parameters_for_method_reference)
48
+ #
49
+ # Examples:
50
+ # link_image_to "logo", { :controller => "home" }, :alt => "Homepage", :size => "45x80"
51
+ # link_image_to "delete", { :action => "destroy" }, :size => "10x10", :confirm => "Are you sure?", "class" => "admin"
52
+ def link_image_to(src, options = {}, html_options = {}, *parameters_for_method_reference)
46
53
  image_options = { "src" => src.include?("/") ? src : "/images/#{src}" }
47
54
  image_options["src"] = image_options["src"] + ".png" unless image_options["src"].include?(".")
48
55
 
@@ -73,19 +80,19 @@ module ActionView
73
80
  link_to(tag("img", image_options), options, html_options, *parameters_for_method_reference)
74
81
  end
75
82
 
83
+ alias_method :link_to_image, :link_image_to # deprecated name
84
+
76
85
  # Creates a link tag of the given +name+ using an URL created by the set of +options+, unless the current
77
- # controller, action, and id are the same as the link's, in which case only the name is returned (or the
86
+ # request uri is the same as the link's, in which case only the name is returned (or the
78
87
  # given block is yielded, if one exists). This is useful for creating link bars where you don't want to link
79
88
  # to the page currently being viewed.
80
89
  def link_to_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference)
81
- assume_current_url_options!(options)
82
-
83
- if destination_equal_to_current(options)
90
+ if current_page?(options)
84
91
  block_given? ?
85
92
  yield(name, options, html_options, *parameters_for_method_reference) :
86
93
  html_escape(name)
87
94
  else
88
- link_to name, options, html_options, *parameters_for_method_reference
95
+ link_to(name, options, html_options, *parameters_for_method_reference)
89
96
  end
90
97
  end
91
98
 
@@ -93,11 +100,12 @@ module ActionView
93
100
  # link unless +name+ is specified. Additional HTML options, such as class or id, can be passed in the <tt>html_options</tt> hash.
94
101
  #
95
102
  # You can also make it difficult for spiders to harvest email address by obfuscating them.
96
- # Examples:
97
- # * mail_to "me@domain.com", "My email", :encode => "javascript"
98
- # => <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>
99
- # * mail_to "me@domain.com", "My email", :encode => "hex"
100
- # => <a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>
103
+ # Examples:
104
+ # mail_to "me@domain.com", "My email", :encode => "javascript" # =>
105
+ # <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>
106
+ #
107
+ # mail_to "me@domain.com", "My email", :encode => "hex" # =>
108
+ # <a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>
101
109
  def mail_to(email_address, name = nil, html_options = {})
102
110
  encode = html_options[:encode]
103
111
  html_options.delete(:encode)
@@ -122,26 +130,12 @@ module ActionView
122
130
  end
123
131
  end
124
132
 
125
- private
126
- def destination_equal_to_current(options)
127
- params_without_location = @params.reject { |key, value| %w( controller action id ).include?(key) }
128
-
129
- options[:action].to_s == @params['action'].to_s &&
130
- options[:id].to_s == @params['id'].to_s &&
131
- options[:controller].to_s == @params['controller'].to_s &&
132
- (options.has_key?(:params) ? params_without_location == options[:params] : true)
133
- end
133
+ # Returns true if the current page uri is generated by the options passed (in url_for format).
134
+ def current_page?(options)
135
+ url_for(options) == @request.request_uri
136
+ end
134
137
 
135
- def assume_current_url_options!(options)
136
- if options[:controller].nil?
137
- options[:controller] = @params['controller']
138
- if options[:action].nil?
139
- options[:action] = @params['action']
140
- if options[:id].nil? then options[:id] ||= @params['id'] end
141
- end
142
- end
143
- end
144
-
138
+ private
145
139
  def convert_confirm_option_to_javascript!(html_options)
146
140
  if html_options.include?(:confirm)
147
141
  html_options["onclick"] = "return confirm('#{html_options[:confirm]}');"
@@ -12,7 +12,7 @@ module ActionView
12
12
  #
13
13
  # == Rendering a collection of partials
14
14
  #
15
- # The example of partial use describes a familar pattern where a template needs to iterate over an array and render a sub
15
+ # The example of partial use describes a familiar pattern where a template needs to iterate over an array and render a sub
16
16
  # template for each of the elements. This pattern has been implemented as a single method that accepts an array and renders
17
17
  # a partial by the same name as the elements contained within. So the three-lined example in "Using partials" can be rewritten
18
18
  # with a single line:
@@ -60,7 +60,7 @@ module ActionView
60
60
  if partial_path.include?('/')
61
61
  return File.dirname(partial_path), File.basename(partial_path)
62
62
  else
63
- return controller.send(:controller_name), partial_path
63
+ return controller.class.controller_path, partial_path
64
64
  end
65
65
  end
66
66
 
@@ -76,7 +76,7 @@ module Builder #:nodoc:
76
76
  end
77
77
 
78
78
  # Append text to the output target. Escape any markup. May be
79
- # used within the markup brakets as:
79
+ # used within the markup brackets as:
80
80
  #
81
81
  # builder.p { br; text! "HI" } #=> <p><br/>HI</p>
82
82
  def text!(text)
@@ -84,7 +84,7 @@ module Builder #:nodoc:
84
84
  end
85
85
 
86
86
  # Append text to the output target without escaping any markup.
87
- # May be used within the markup brakets as:
87
+ # May be used within the markup brackets as:
88
88
  #
89
89
  # builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p>
90
90
  #
@@ -94,7 +94,7 @@ module Builder #:nodoc:
94
94
  #
95
95
  # It is also useful for stacking builder objects. Builders only
96
96
  # use <tt><<</tt> to append to the target, so by supporting this
97
- # method/operation builders can use oother builders as their
97
+ # method/operation builders can use other builders as their
98
98
  # targets.
99
99
  def <<(text)
100
100
  _text(text)
data/rakefile CHANGED
@@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
10
10
  PKG_NAME = 'actionpack'
11
- PKG_VERSION = '1.4.0' + PKG_BUILD
11
+ PKG_VERSION = '1.5.0' + PKG_BUILD
12
12
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
13
 
14
14
  desc "Default Task"
@@ -47,7 +47,7 @@ spec = Gem::Specification.new do |s|
47
47
  s.name = PKG_NAME
48
48
  s.version = PKG_VERSION
49
49
  s.summary = "Web-flow and rendering framework putting the VC in MVC."
50
- s.description = %q{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.}
50
+ s.description = %q{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.} #'
51
51
 
52
52
  s.author = "David Heinemeier Hansson"
53
53
  s.email = "david@loudthinking.com"
@@ -56,6 +56,9 @@ spec = Gem::Specification.new do |s|
56
56
 
57
57
  s.has_rdoc = true
58
58
  s.requirements << 'none'
59
+
60
+ s.add_dependency('activesupport', '= 1.0.0' + PKG_BUILD)
61
+
59
62
  s.require_path = 'lib'
60
63
  s.autorequire = 'action_controller'
61
64
 
@@ -1,4 +1,5 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
2
3
 
3
4
  require 'test/unit'
4
5
  require 'action_controller'
@@ -6,4 +7,5 @@ require 'action_controller'
6
7
  require 'action_controller/test_process'
7
8
 
8
9
  ActionController::Base.logger = nil
9
- ActionController::Base.ignore_missing_templates = true
10
+ ActionController::Base.ignore_missing_templates = true
11
+ ActionController::Routing::Routes.reload
@@ -15,6 +15,10 @@ class ActionPackAssertionsController < ActionController::Base
15
15
  # a redirect to an internal location
16
16
  def redirect_internal() redirect_to "nothing"; end
17
17
 
18
+ def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params => { "panda" => "fun" }; end
19
+
20
+ def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end
21
+
18
22
  # a redirect to an external location
19
23
  def redirect_external() redirect_to_url "http://www.rubyonrails.org"; end
20
24
 
@@ -195,7 +199,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
195
199
  assert_success
196
200
  end
197
201
 
198
- # -- standard request/reponse object testing --------------------------------
202
+ # -- standard request/response object testing --------------------------------
199
203
 
200
204
  # ensure our session is working properly
201
205
  def test_session_objects
@@ -333,6 +337,13 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
333
337
  assert_equal "Mr. David", @response.body
334
338
  end
335
339
 
340
+ def test_assert_template_xpath_match_no_matches
341
+ process :hello_xml_world
342
+ assert_raises Test::Unit::AssertionFailedError do
343
+ assert_template_xpath_match('/no/such/node/in/document')
344
+ end
345
+ end
346
+
336
347
  def test_simple_one_element_xpath_match
337
348
  process :hello_xml_world
338
349
  assert_template_xpath_match('//title', "Hello World")
@@ -342,6 +353,23 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
342
353
  process :hello_xml_world
343
354
  assert_template_xpath_match('//p', %w( abes monks wiseguys ))
344
355
  end
356
+
357
+ def test_follow_redirect
358
+ process :redirect_to_action
359
+ assert_redirected_to :action => "flash_me"
360
+
361
+ follow_redirect
362
+ assert_equal 1, @request.parameters["id"]
363
+
364
+ assert "Inconceivable!", @response.body
365
+ end
366
+
367
+ def test_follow_redirect_outside_current_action
368
+ process :redirect_to_controller
369
+ assert_redirected_to :controller => "elsewhere", :action => "flash_me"
370
+
371
+ assert_raises(RuntimeError, "Can't follow redirects outside of current controller (elsewhere)") { follow_redirect }
372
+ end
345
373
  end
346
374
 
347
375
  class ActionPackHeaderTest < Test::Unit::TestCase
@@ -1,120 +1,128 @@
1
1
  path_to_ar = File.dirname(__FILE__) + '/../../../activerecord'
2
2
 
3
3
  if Object.const_defined?("ActiveRecord") || File.exist?(path_to_ar)
4
- # This test is very different than the others. It requires ActiveRecord to
5
- # run. There's a bunch of stuff we are assuming here:
6
- #
7
- # 1. activerecord exists as a sibling directory to actionpack
8
- # (i.e., actionpack/../activerecord)
9
- # 2. you've created the appropriate database to run the active_record unit tests
10
- # 3. you set the appropriate database connection below
11
-
12
- driver_to_use = 'native_sqlite'
13
-
14
- $: << path_to_ar + '/lib/'
15
- $: << path_to_ar + '/test/'
16
- require 'active_record' unless Object.const_defined?("ActiveRecord")
17
- require "connections/#{driver_to_use}/connection"
18
- require 'fixtures/company'
19
-
20
- # -----------------------------------------------------------------------------
21
-
22
- # add some validation rules to trip up the assertions
23
- class Company
24
- protected
25
- def validate
26
- errors.add_on_empty('name')
27
- errors.add('rating', 'rating should not be 2') if rating == 2
28
- errors.add_to_base('oh oh') if rating == 3
29
- end
30
- end
4
+
5
+ # This test is very different than the others. It requires ActiveRecord to
6
+ # run. There's a bunch of stuff we are assuming here:
7
+ #
8
+ # 1. activerecord exists as a sibling directory to actionpack
9
+ # (i.e., actionpack/../activerecord)
10
+ # 2. you've created the appropriate database to run the active_record unit tests
11
+ # 3. you set the appropriate database connection below
31
12
 
32
- # -----------------------------------------------------------------------------
13
+ begin
33
14
 
34
- require File.dirname(__FILE__) + '/../abstract_unit'
15
+ driver_to_use = 'native_sqlite'
35
16
 
36
- # a controller class to handle the AR assertions
37
- class ActiveRecordAssertionsController < ActionController::Base
38
- # fail with 1 bad column
39
- def nasty_columns_1
40
- @company = Company.new
41
- @company.name = "B"
42
- @company.rating = 2
43
- render_text "snicker...."
44
- end
17
+ $: << path_to_ar + '/lib/'
18
+ $: << path_to_ar + '/test/'
19
+ require 'active_record' unless Object.const_defined?("ActiveRecord")
20
+ require "connections/#{driver_to_use}/connection"
21
+ require 'fixtures/company'
22
+
23
+ # -----------------------------------------------------------------------------
24
+
25
+ # add some validation rules to trip up the assertions
26
+ class Company
27
+ protected
28
+ def validate
29
+ errors.add_on_empty('name')
30
+ errors.add('rating', 'rating should not be 2') if rating == 2
31
+ errors.add_to_base('oh oh') if rating == 3
32
+ end
33
+ end
34
+
35
+ # -----------------------------------------------------------------------------
36
+
37
+ require File.dirname(__FILE__) + '/../abstract_unit'
38
+
39
+ # a controller class to handle the AR assertions
40
+ class ActiveRecordAssertionsController < ActionController::Base
41
+ # fail with 1 bad column
42
+ def nasty_columns_1
43
+ @company = Company.new
44
+ @company.name = "B"
45
+ @company.rating = 2
46
+ render_text "snicker...."
47
+ end
45
48
 
46
- # fail with 2 bad column
47
- def nasty_columns_2
48
- @company = Company.new
49
- @company.name = ""
50
- @company.rating = 2
51
- render_text "double snicker...."
52
- end
49
+ # fail with 2 bad column
50
+ def nasty_columns_2
51
+ @company = Company.new
52
+ @company.name = ""
53
+ @company.rating = 2
54
+ render_text "double snicker...."
55
+ end
53
56
 
54
- # this will pass validation
55
- def good_company
56
- @company = Company.new
57
- @company.name = "A"
58
- @company.rating = 69
59
- render_text "Goodness Gracious!"
60
- end
57
+ # this will pass validation
58
+ def good_company
59
+ @company = Company.new
60
+ @company.name = "A"
61
+ @company.rating = 69
62
+ render_text "Goodness Gracious!"
63
+ end
61
64
 
62
- # this will fail validation
63
- def bad_company
64
- @company = Company.new
65
- render_text "Who's Bad?"
66
- end
65
+ # this will fail validation
66
+ def bad_company
67
+ @company = Company.new
68
+ render_text "Who's Bad?"
69
+ end
67
70
 
68
- # the safety dance......
69
- def rescue_action(e) raise; end
70
- end
71
+ # the safety dance......
72
+ def rescue_action(e) raise; end
73
+ end
71
74
 
72
- # -----------------------------------------------------------------------------
75
+ # -----------------------------------------------------------------------------
73
76
 
74
- ActiveRecordAssertionsController.template_root = File.dirname(__FILE__) + "/../fixtures/"
77
+ ActiveRecordAssertionsController.template_root = File.dirname(__FILE__) + "/../fixtures/"
75
78
 
76
- # The test case to try the AR assertions
77
- class ActiveRecordAssertionsControllerTest < Test::Unit::TestCase
78
- # set it up
79
- def setup
80
- @request = ActionController::TestRequest.new
81
- @response = ActionController::TestResponse.new
82
- @controller = ActiveRecordAssertionsController.new
83
- end
79
+ # The test case to try the AR assertions
80
+ class ActiveRecordAssertionsControllerTest < Test::Unit::TestCase
81
+ # set it up
82
+ def setup
83
+ @request = ActionController::TestRequest.new
84
+ @response = ActionController::TestResponse.new
85
+ @controller = ActiveRecordAssertionsController.new
86
+ end
84
87
 
85
- # test for 1 bad apple column
86
- def test_some_invalid_columns
87
- process :nasty_columns_1
88
- assert_success
89
- assert_invalid_record 'company'
90
- assert_invalid_column_on_record 'company', 'rating'
91
- assert_valid_column_on_record 'company', 'name'
92
- assert_valid_column_on_record 'company', ['name','id']
93
- end
88
+ # test for 1 bad apple column
89
+ def test_some_invalid_columns
90
+ process :nasty_columns_1
91
+ assert_success
92
+ assert_invalid_record 'company'
93
+ assert_invalid_column_on_record 'company', 'rating'
94
+ assert_valid_column_on_record 'company', 'name'
95
+ assert_valid_column_on_record 'company', ['name','id']
96
+ end
94
97
 
95
- # test for 2 bad apples columns
96
- def test_all_invalid_columns
97
- process :nasty_columns_2
98
- assert_success
99
- assert_invalid_record 'company'
100
- assert_invalid_column_on_record 'company', 'rating'
101
- assert_invalid_column_on_record 'company', 'name'
102
- assert_invalid_column_on_record 'company', ['name','rating']
103
- end
98
+ # test for 2 bad apples columns
99
+ def test_all_invalid_columns
100
+ process :nasty_columns_2
101
+ assert_success
102
+ assert_invalid_record 'company'
103
+ assert_invalid_column_on_record 'company', 'rating'
104
+ assert_invalid_column_on_record 'company', 'name'
105
+ assert_invalid_column_on_record 'company', ['name','rating']
106
+ end
104
107
 
105
- # ensure we have no problems with an ActiveRecord
106
- def test_valid_record
107
- process :good_company
108
- assert_success
109
- assert_valid_record 'company'
110
- end
108
+ # ensure we have no problems with an ActiveRecord
109
+ def test_valid_record
110
+ process :good_company
111
+ assert_success
112
+ assert_valid_record 'company'
113
+ end
111
114
 
112
- # ensure we have problems with an ActiveRecord
113
- def test_invalid_record
114
- process :bad_company
115
- assert_success
116
- assert_invalid_record 'company'
115
+ # ensure we have problems with an ActiveRecord
116
+ def test_invalid_record
117
+ process :bad_company
118
+ assert_success
119
+ assert_invalid_record 'company'
120
+ end
121
+ end
122
+
123
+ rescue SqliteError => e
124
+ puts "Skipping active record based tests"
125
+ puts e.message
117
126
  end
118
- end
119
127
 
120
- end
128
+ end