aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/pk_test.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-06-10 14:58:02 +0000
committerJamis Buck <jamis@37signals.com>2005-06-10 14:58:02 +0000
commit2c0fa3208859aed2c1fd0ce54c8d5215d11d0c75 (patch)
treeb65523d2f9c2d0b79bc0b65157e966ee36ebd1a2 /activerecord/test/pk_test.rb
parent7f9ffb2ebf1a0230368f54a6372cb7196c90177e (diff)
downloadrails-2c0fa3208859aed2c1fd0ce54c8d5215d11d0c75.tar.gz
rails-2c0fa3208859aed2c1fd0ce54c8d5215d11d0c75.tar.bz2
rails-2c0fa3208859aed2c1fd0ce54c8d5215d11d0c75.zip
Do not use instantiated fixtures (in general) in tests. Also, support the use of transactional fixtures by setting the AR_TX_FIXTURES environment variable to "yes".
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/pk_test.rb')
-rw-r--r--activerecord/test/pk_test.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/activerecord/test/pk_test.rb b/activerecord/test/pk_test.rb
index aefaebde6e..6c70988a26 100644
--- a/activerecord/test/pk_test.rb
+++ b/activerecord/test/pk_test.rb
@@ -4,17 +4,13 @@ require 'fixtures/subscriber'
require 'fixtures/movie'
class PrimaryKeysTest < Test::Unit::TestCase
- def setup
- @topics = create_fixtures "topics"
- @subscribers = create_fixtures "subscribers"
- @movies = create_fixtures "movies"
- end
+ fixtures :topics, :subscribers, :movies
def test_integer_key
topic = Topic.find(1)
- assert_equal(@topics["first"]["author_name"], topic.author_name)
+ assert_equal(topics(:first).author_name, topic.author_name)
topic = Topic.find(2)
- assert_equal(@topics["second"]["author_name"], topic.author_name)
+ assert_equal(topics(:second).author_name, topic.author_name)
topic = Topic.new
topic.title = "New Topic"
@@ -27,10 +23,10 @@ class PrimaryKeysTest < Test::Unit::TestCase
end
def test_string_key
- subscriber = Subscriber.find(@subscribers["first"]["nick"])
- assert_equal(@subscribers["first"]["name"], subscriber.name)
- subscriber = Subscriber.find(@subscribers["second"]["nick"])
- assert_equal(@subscribers["second"]["name"], subscriber.name)
+ subscriber = Subscriber.find(subscribers(:first).nick)
+ assert_equal(subscribers(:first).name, subscriber.name)
+ subscriber = Subscriber.find(subscribers(:second).nick)
+ assert_equal(subscribers(:second).name, subscriber.name)
subscriber = Subscriber.new
subscriber.id = "jdoe"
@@ -43,7 +39,7 @@ class PrimaryKeysTest < Test::Unit::TestCase
end
def test_find_with_more_than_one_string_key
- assert_equal 2, Subscriber.find(@subscribers["first"]["nick"], @subscribers["second"]["nick"]).length
+ assert_equal 2, Subscriber.find(subscribers(:first).nick, subscribers(:second).nick).length
end
def test_primary_key_prefix