aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-29 09:54:22 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-29 10:36:32 -0700
commit2cc4b7f2978b3e2dac490894b5d548c7f58c587e (patch)
tree185fdeb5a2d31c5982f390b686704614e87ad420 /activerecord/test
parent995ad3b3781c7a310daa11f728f2c5585c45c05d (diff)
downloadrails-2cc4b7f2978b3e2dac490894b5d548c7f58c587e.tar.gz
rails-2cc4b7f2978b3e2dac490894b5d548c7f58c587e.tar.bz2
rails-2cc4b7f2978b3e2dac490894b5d548c7f58c587e.zip
fisting test organization
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/dynamic_finder_match_test.rb51
-rw-r--r--activerecord/test/cases/finder_test.rb51
2 files changed, 50 insertions, 52 deletions
diff --git a/activerecord/test/cases/dynamic_finder_match_test.rb b/activerecord/test/cases/dynamic_finder_match_test.rb
index 64bf6cb508..e576870317 100644
--- a/activerecord/test/cases/dynamic_finder_match_test.rb
+++ b/activerecord/test/cases/dynamic_finder_match_test.rb
@@ -2,18 +2,67 @@ require "cases/helper"
module ActiveRecord
class DynamicFinderMatchTest < ActiveRecord::TestCase
+ def test_find_or_create_by
+ match = DynamicFinderMatch.match("find_or_create_by_age_and_sex_and_location")
+ assert_not_nil match
+ assert !match.finder?
+ assert match.instantiator?
+ assert_equal :first, match.finder
+ assert_equal :create, match.instantiator
+ assert_equal %w(age sex location), match.attribute_names
+ end
+
+ def test_find_or_initialize_by
+ match = DynamicFinderMatch.match("find_or_initialize_by_age_and_sex_and_location")
+ assert_not_nil match
+ assert !match.finder?
+ assert match.instantiator?
+ assert_equal :first, match.finder
+ assert_equal :new, match.instantiator
+ assert_equal %w(age sex location), match.attribute_names
+ end
+
+ def test_find_no_match
+ assert_nil DynamicFinderMatch.match("not_a_finder")
+ end
+
+ def find_by_bang
+ match = DynamicFinderMatch.match("find_by_age_and_sex_and_location!")
+ assert_not_nil match
+ assert match.finder?
+ assert match.bang?
+ assert_equal :first, match.finder
+ assert_equal %w(age sex location), match.attribute_names
+ end
+
def test_find_by
+ match = DynamicFinderMatch.match("find_by_age_and_sex_and_location")
+ assert_not_nil match
+ assert match.finder?
+ assert_equal :first, match.finder
+ assert_equal %w(age sex location), match.attribute_names
+ end
+
+ def test_find_by_with_symbol
m = DynamicFinderMatch.match(:find_by_foo)
assert_equal :first, m.finder
assert_equal %w{ foo }, m.attribute_names
end
- def test_find_all_by
+ def test_find_all_by_with_symbol
m = DynamicFinderMatch.match(:find_all_by_foo)
assert_equal :all, m.finder
assert_equal %w{ foo }, m.attribute_names
end
+ def test_find_all_by
+ match = DynamicFinderMatch.match("find_all_by_age_and_sex_and_location")
+ assert_not_nil match
+ assert match.finder?
+ assert_equal :all, match.finder
+ assert_equal %w(age sex location), match.attribute_names
+ end
+
def test_find_last_by
m = DynamicFinderMatch.match(:find_last_by_foo)
assert_equal :last, m.finder
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 4f3e43d77d..26b5096255 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -11,57 +11,6 @@ require 'models/project'
require 'models/developer'
require 'models/customer'
-class DynamicFinderMatchTest < ActiveRecord::TestCase
- def test_find_no_match
- assert_nil ActiveRecord::DynamicFinderMatch.match("not_a_finder")
- end
-
- def test_find_by
- match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location")
- assert_not_nil match
- assert match.finder?
- assert_equal :first, match.finder
- assert_equal %w(age sex location), match.attribute_names
- end
-
- def find_by_bang
- match = ActiveRecord::DynamicFinderMatch.match("find_by_age_and_sex_and_location!")
- assert_not_nil match
- assert match.finder?
- assert match.bang?
- assert_equal :first, match.finder
- assert_equal %w(age sex location), match.attribute_names
- end
-
- def test_find_all_by
- match = ActiveRecord::DynamicFinderMatch.match("find_all_by_age_and_sex_and_location")
- assert_not_nil match
- assert match.finder?
- assert_equal :all, match.finder
- assert_equal %w(age sex location), match.attribute_names
- end
-
- def test_find_or_initialize_by
- match = ActiveRecord::DynamicFinderMatch.match("find_or_initialize_by_age_and_sex_and_location")
- assert_not_nil match
- assert !match.finder?
- assert match.instantiator?
- assert_equal :first, match.finder
- assert_equal :new, match.instantiator
- assert_equal %w(age sex location), match.attribute_names
- end
-
- def test_find_or_create_by
- match = ActiveRecord::DynamicFinderMatch.match("find_or_create_by_age_and_sex_and_location")
- assert_not_nil match
- assert !match.finder?
- assert match.instantiator?
- assert_equal :first, match.finder
- assert_equal :create, match.instantiator
- assert_equal %w(age sex location), match.attribute_names
- end
-end
-
class FinderTest < ActiveRecord::TestCase
fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors, :customers, :categories, :categorizations