diff options
author | Xavier Noria <fxn@hashref.com> | 2011-01-12 21:19:10 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-01-12 21:19:10 +0100 |
commit | 8b293e99ff2da0b5a60ff7bc5cde7bda9a2f715e (patch) | |
tree | 68afb497f317dab1652defe0f96bd20051b572cf /activerecord/test/cases/associations/association_proxy_test.rb | |
parent | 5bc98c9510a369a22b856cbe952d640f3825bb5c (diff) | |
parent | 31293ba9d33f5b5f62ee760a548b4f5438183f22 (diff) | |
download | rails-8b293e99ff2da0b5a60ff7bc5cde7bda9a2f715e.tar.gz rails-8b293e99ff2da0b5a60ff7bc5cde7bda9a2f715e.tar.bz2 rails-8b293e99ff2da0b5a60ff7bc5cde7bda9a2f715e.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activerecord/test/cases/associations/association_proxy_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/association_proxy_test.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/association_proxy_test.rb b/activerecord/test/cases/associations/association_proxy_test.rb new file mode 100644 index 0000000000..55d8da4c4e --- /dev/null +++ b/activerecord/test/cases/associations/association_proxy_test.rb @@ -0,0 +1,52 @@ +require "cases/helper" + +module ActiveRecord + module Associations + class AsssociationProxyTest < ActiveRecord::TestCase + class FakeOwner + attr_accessor :new_record + alias :new_record? :new_record + + def initialize + @new_record = false + end + end + + class FakeReflection < Struct.new(:options, :klass) + def initialize options = {}, klass = nil + super + end + + def check_validity! + true + end + end + + class FakeTarget + end + + class FakeTargetProxy < AssociationProxy + def association_scope + true + end + + def find_target + FakeTarget.new + end + end + + def test_method_missing_error + reflection = FakeReflection.new({}, Object.new) + owner = FakeOwner.new + proxy = FakeTargetProxy.new(owner, reflection) + + exception = assert_raises(NoMethodError) do + proxy.omg + end + + assert_match('omg', exception.message) + assert_match(FakeTarget.name, exception.message) + end + end + end +end |