aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-12-22 17:04:01 +0000
committerJon Leighton <j@jonathanleighton.com>2011-12-22 17:04:01 +0000
commit91681c281b0693d376342e3cc1ebeb86449ef197 (patch)
tree46f8ff88edb62bed653215fe1ba6e8d635d5c0bb /activerecord/test
parentf8e484d0f71114675ed04e987914d3f2815cb868 (diff)
downloadrails-91681c281b0693d376342e3cc1ebeb86449ef197.tar.gz
rails-91681c281b0693d376342e3cc1ebeb86449ef197.tar.bz2
rails-91681c281b0693d376342e3cc1ebeb86449ef197.zip
Revert "Merge pull request #4114 from alexeymuranov/my_fix_for_prefix_suffix_fixtures_test"
This reverts commit f8e484d0f71114675ed04e987914d3f2815cb868, reversing changes made to fa5adfb1e884bf21a7071ade634a820e37ac4db4. Reason: broke the postgres tests.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/fixtures_test.rb59
-rw-r--r--activerecord/test/fixtures/other_topics.yml42
2 files changed, 23 insertions, 78 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 83b4365477..99dd74c561 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -1,32 +1,31 @@
-require 'cases/helper'
-require 'models/admin'
-require 'models/admin/account'
-require 'models/admin/user'
+require "cases/helper"
+require 'models/post'
require 'models/binary'
-require 'models/book'
-require 'models/category'
-require 'models/company'
+require 'models/topic'
require 'models/computer'
-require 'models/course'
require 'models/developer'
+require 'models/company'
+require 'models/task'
+require 'models/reply'
require 'models/joke'
-require 'models/matey'
+require 'models/course'
+require 'models/category'
require 'models/parrot'
require 'models/pirate'
-require 'models/post'
-require 'models/reply'
-require 'models/ship'
-require 'models/task'
-require 'models/topic'
-require 'models/traffic_light'
require 'models/treasure'
+require 'models/traffic_light'
+require 'models/matey'
+require 'models/ship'
+require 'models/book'
+require 'models/admin'
+require 'models/admin/account'
+require 'models/admin/user'
require 'tempfile'
class FixturesTest < ActiveRecord::TestCase
self.use_instantiated_fixtures = true
self.use_transactional_fixtures = false
- # other_topics fixture should not be included here
fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights
FIXTURES = %w( accounts binaries companies customers
@@ -94,7 +93,7 @@ class FixturesTest < ActiveRecord::TestCase
# Reset cache to make finds on the new table work
ActiveRecord::Fixtures.reset_cache
- ActiveRecord::Base.connection.create_table :prefix_other_topics_suffix do |t|
+ ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t|
t.column :title, :string
t.column :author_name, :string
t.column :author_email_address, :string
@@ -116,35 +115,23 @@ class FixturesTest < ActiveRecord::TestCase
ActiveRecord::Base.table_name_prefix = 'prefix_'
ActiveRecord::Base.table_name_suffix = '_suffix'
- other_topic_klass = Class.new(ActiveRecord::Base) do
- def self.name
- "OtherTopic"
- end
- end
+ topics = create_fixtures("topics")
- topics = create_fixtures("other_topics")
-
- # This checks for a caching problem which causes a bug in the fixtures
- # class-level configuration helper.
- assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
-
- first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'David'")
+ first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'")
assert_equal("The First Topic", first_row["title"])
- second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'Mary'")
+ second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
assert_nil(second_row["author_email_address"])
- assert_equal "prefix_other_topics_suffix", ActiveRecord::Fixtures::all_loaded_fixtures["other_topics"].table_name
- # This assertion should be the last in the list, because calling
- # other_topic_klass.table_name sets a class-level instance variable
- assert_equal "prefix_other_topics_suffix", other_topic_klass.table_name
-
+ # This checks for a caching problem which causes a bug in the fixtures
+ # class-level configuration helper.
+ assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
ensure
# Restore prefix/suffix to its previous values
ActiveRecord::Base.table_name_prefix = old_prefix
ActiveRecord::Base.table_name_suffix = old_suffix
- ActiveRecord::Base.connection.drop_table :prefix_other_topics_suffix rescue nil
+ ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil
end
end
diff --git a/activerecord/test/fixtures/other_topics.yml b/activerecord/test/fixtures/other_topics.yml
deleted file mode 100644
index 93f48aedc4..0000000000
--- a/activerecord/test/fixtures/other_topics.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-first:
- id: 1
- title: The First Topic
- author_name: David
- author_email_address: david@loudthinking.com
- written_on: 2003-07-16t15:28:11.2233+01:00
- last_read: 2004-04-15
- bonus_time: 2005-01-30t15:28:00.00+01:00
- content: Have a nice day
- approved: false
- replies_count: 1
-
-second:
- id: 2
- title: The Second Topic of the day
- author_name: Mary
- written_on: 2004-07-15t15:28:00.0099+01:00
- content: Have a nice day
- approved: true
- replies_count: 0
- parent_id: 1
- type: Reply
-
-third:
- id: 3
- title: The Third Topic of the day
- author_name: Carl
- written_on: 2005-07-15t15:28:00.0099+01:00
- content: I'm a troll
- approved: true
- replies_count: 1
-
-fourth:
- id: 4
- title: The Fourth Topic of the day
- author_name: Carl
- written_on: 2006-07-15t15:28:00.0099+01:00
- content: Why not?
- approved: true
- type: Reply
- parent_id: 3
-