Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Active Record integration deprecation tests

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4962 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c3a52523ceaf4aab819c7c5da748d552f9cb3f99 1 parent 23d579b
@jeremy jeremy authored
View
6 actionpack/lib/action_controller/assertions/deprecated_assertions.rb
@@ -215,14 +215,14 @@ def glue_columns(columns)
end
def find_record_in_template(key = nil)
- assert_template_has(key)
+ assert_not_nil assigns(key)
record = @response.template_objects[key]
assert_not_nil(record)
assert_kind_of ActiveRecord::Base, record
return record
- end
+ end
end
end
-end
+end
View
37 actionpack/test/activerecord/active_record_assertions_test.rb
@@ -50,34 +50,43 @@ def setup
# 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)
+ assert_response :success
+
+ assert_deprecated_assertion { assert_invalid_record 'company' }
+ assert_deprecated_assertion { assert_invalid_column_on_record 'company', 'rating' }
+ assert_deprecated_assertion { assert_valid_column_on_record 'company', 'name' }
+ assert_deprecated_assertion { 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)
+ assert_response :success
+
+ assert_deprecated_assertion { assert_invalid_record 'company' }
+ assert_deprecated_assertion { assert_invalid_column_on_record 'company', 'rating' }
+ assert_deprecated_assertion { assert_invalid_column_on_record 'company', 'name' }
+ assert_deprecated_assertion { 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'
+ assert_response :success
+
+ assert_deprecated_assertion { 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'
+ assert_response :success
+
+ assert_deprecated_assertion { assert_invalid_record 'company' }
end
+
+ protected
+ def assert_deprecated_assertion(message = nil, &block)
+ assert_deprecated(/assert_.*from test_/, &block)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.