diff options
author | Michael Koziarski <michael@koziarski.com> | 2006-02-09 09:17:40 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2006-02-09 09:17:40 +0000 |
commit | d49a5fcb4cfe90824337dc3756bae7161cea768b (patch) | |
tree | 48af0b2f4c9301be8e0816e5ac759516862db2ef /actionpack/test/activerecord/active_record_assertions_test.rb | |
parent | 803b9a41af46210da842afdba032c34109514942 (diff) | |
download | rails-d49a5fcb4cfe90824337dc3756bae7161cea768b.tar.gz rails-d49a5fcb4cfe90824337dc3756bae7161cea768b.tar.bz2 rails-d49a5fcb4cfe90824337dc3756bae7161cea768b.zip |
* Fix pagination problems when using include
* Introduce Unit Tests for pagination
* Allow count to work with :include by using count distinct.
[Kevin Clark & Jeremy Hopple]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3553 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/activerecord/active_record_assertions_test.rb')
-rw-r--r-- | actionpack/test/activerecord/active_record_assertions_test.rb | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/actionpack/test/activerecord/active_record_assertions_test.rb b/actionpack/test/activerecord/active_record_assertions_test.rb new file mode 100644 index 0000000000..f5661d19cc --- /dev/null +++ b/actionpack/test/activerecord/active_record_assertions_test.rb @@ -0,0 +1,84 @@ +require "#{File.dirname(__FILE__)}/../active_record_unit" +require 'fixtures/company' + +class ActiveRecordAssertionsController < ActionController::Base + self.template_root = "#{File.dirname(__FILE__)}/../fixtures/" + + # fail with 1 bad column + def nasty_columns_1 + @company = Company.new + @company.name = "B" + @company.rating = 2 + render :inline => "snicker...." + end + + # fail with 2 bad columns + def nasty_columns_2 + @company = Company.new + @company.name = "" + @company.rating = 2 + render :inline => "double snicker...." + end + + # this will pass validation + def good_company + @company = Company.new + @company.name = "A" + @company.rating = 69 + render :inline => "Goodness Gracious!" + end + + # this will fail validation + def bad_company + @company = Company.new + render :inline => "Who's Bad?" + end + + # the safety dance...... + def rescue_action(e) raise; end +end + +class ActiveRecordAssertionsControllerTest < ActiveRecordTestCase + fixtures :companies + + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @controller = ActiveRecordAssertionsController.new + super + end + + # test for 1 bad apple column + def test_some_invalid_columns + process :nasty_columns_1 + assert_success + assert_invalid_record 'company' + assert_invalid_column_on_record 'company', 'rating' + assert_valid_column_on_record 'company', 'name' + assert_valid_column_on_record 'company', %w(name id) + end + + # test for 2 bad apples columns + def test_all_invalid_columns + process :nasty_columns_2 + assert_success + assert_invalid_record 'company' + assert_invalid_column_on_record 'company', 'rating' + assert_invalid_column_on_record 'company', 'name' + assert_invalid_column_on_record 'company', %w(name rating) + end + + # ensure we have no problems with an ActiveRecord + def test_valid_record + process :good_company + assert_success + assert_valid_record 'company' + end + + # ensure we have problems with an ActiveRecord + def test_invalid_record + process :bad_company + assert_success + assert_invalid_record 'company' + end +end
\ No newline at end of file |