diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-08-04 23:36:05 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-08-04 23:36:05 -0500 |
commit | f8d3c72c39ad209abca7f3613f91fb3a03805261 (patch) | |
tree | 2d6f5b67e3212b59be1f00391eeb64ebf5b40548 /activerecord/test | |
parent | 64eecdd131c93d7d6c8ef9c6a7ae6b9d76c72a8b (diff) | |
download | rails-f8d3c72c39ad209abca7f3613f91fb3a03805261.tar.gz rails-f8d3c72c39ad209abca7f3613f91fb3a03805261.tar.bz2 rails-f8d3c72c39ad209abca7f3613f91fb3a03805261.zip |
Extract generic attribute method generation to AMo
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 47 | ||||
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 2 |
2 files changed, 1 insertions, 48 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index a5f4a67200..ab8768ea3e 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -16,53 +16,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase ActiveRecord::Base.send(:attribute_method_matchers).concat(@old_matchers) end - def test_match_attribute_method_query_returns_default_match_data - topic = @target.new(:title => 'Budget') - assert_not_nil match = topic.match_attribute_method?('title=') - assert_equal '', match.prefix - assert_equal 'title', match.base - assert_equal '=', match.suffix - end - - def test_match_attribute_method_query_returns_match_data_for_prefixes - topic = @target.new(:title => 'Budget') - %w(default_ title_).each do |prefix| - @target.class_eval "def #{prefix}attribute(*args) args end" - @target.attribute_method_prefix prefix - - assert_not_nil match = topic.match_attribute_method?("#{prefix}title") - assert_equal prefix, match.prefix - assert_equal 'title', match.base - assert_equal '', match.suffix - end - end - - def test_match_attribute_method_query_returns_match_data_for_suffixes - topic = @target.new(:title => 'Budget') - %w(_default _title_default it! _candidate= _maybe?).each do |suffix| - @target.class_eval "def attribute#{suffix}(*args) args end" - @target.attribute_method_suffix suffix - - assert_not_nil match = topic.match_attribute_method?("title#{suffix}") - assert_equal '', match.prefix - assert_equal 'title', match.base - assert_equal suffix, match.suffix - end - end - - def test_match_attribute_method_query_returns_match_data_for_affixes - topic = @target.new(:title => 'Budget') - [['mark_', '_for_update'], ['reset_', '!'], ['default_', '_value?']].each do |prefix, suffix| - @target.class_eval "def #{prefix}attribute#{suffix}(*args) args end" - @target.attribute_method_affix({ :prefix => prefix, :suffix => suffix }) - - assert_not_nil match = topic.match_attribute_method?("#{prefix}title#{suffix}") - assert_equal prefix, match.prefix - assert_equal 'title', match.base - assert_equal suffix, match.suffix - end - end - def test_undeclared_attribute_method_does_not_affect_respond_to_and_method_missing topic = @target.new(:title => 'Budget') assert topic.respond_to?('title') diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 55ef0d45eb..893fc34c36 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -251,7 +251,7 @@ class FinderTest < ActiveRecord::TestCase def test_find_only_some_columns topic = Topic.find(1, :select => "author_name") - assert_raise(ActiveRecord::MissingAttributeError) {topic.title} + assert_raise(ActiveModel::MissingAttributeError) {topic.title} assert_equal "David", topic.author_name assert !topic.attribute_present?("title") #assert !topic.respond_to?("title") |