Skip to content

Commit

Permalink
Revert "Merge pull request #4114 from alexeymuranov/my_fix_for_prefix…
Browse files Browse the repository at this point in the history
…_suffix_fixtures_test"

This reverts commit f8e484d, reversing
changes made to fa5adfb.

Reason: broke the postgres tests.
  • Loading branch information
jonleighton committed Dec 22, 2011
1 parent f8e484d commit 91681c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 78 deletions.
59 changes: 23 additions & 36 deletions activerecord/test/cases/fixtures_test.rb
@@ -1,32 +1,31 @@
require 'cases/helper' require "cases/helper"
require 'models/admin' require 'models/post'
require 'models/admin/account'
require 'models/admin/user'
require 'models/binary' require 'models/binary'
require 'models/book' require 'models/topic'
require 'models/category'
require 'models/company'
require 'models/computer' require 'models/computer'
require 'models/course'
require 'models/developer' require 'models/developer'
require 'models/company'
require 'models/task'
require 'models/reply'
require 'models/joke' require 'models/joke'
require 'models/matey' require 'models/course'
require 'models/category'
require 'models/parrot' require 'models/parrot'
require 'models/pirate' 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/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' require 'tempfile'


class FixturesTest < ActiveRecord::TestCase class FixturesTest < ActiveRecord::TestCase
self.use_instantiated_fixtures = true self.use_instantiated_fixtures = true
self.use_transactional_fixtures = false 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 :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights


FIXTURES = %w( accounts binaries companies customers FIXTURES = %w( accounts binaries companies customers
Expand Down Expand Up @@ -94,7 +93,7 @@ def test_inserts_with_pre_and_suffix
# Reset cache to make finds on the new table work # Reset cache to make finds on the new table work
ActiveRecord::Fixtures.reset_cache 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 :title, :string
t.column :author_name, :string t.column :author_name, :string
t.column :author_email_address, :string t.column :author_email_address, :string
Expand All @@ -116,35 +115,23 @@ def test_inserts_with_pre_and_suffix
ActiveRecord::Base.table_name_prefix = 'prefix_' ActiveRecord::Base.table_name_prefix = 'prefix_'
ActiveRecord::Base.table_name_suffix = '_suffix' ActiveRecord::Base.table_name_suffix = '_suffix'


other_topic_klass = Class.new(ActiveRecord::Base) do topics = create_fixtures("topics")
def self.name
"OtherTopic"
end
end


topics = create_fixtures("other_topics") first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'")

# 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'")
assert_equal("The First Topic", first_row["title"]) 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_nil(second_row["author_email_address"])


assert_equal "prefix_other_topics_suffix", ActiveRecord::Fixtures::all_loaded_fixtures["other_topics"].table_name # This checks for a caching problem which causes a bug in the fixtures
# This assertion should be the last in the list, because calling # class-level configuration helper.
# other_topic_klass.table_name sets a class-level instance variable assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
assert_equal "prefix_other_topics_suffix", other_topic_klass.table_name

ensure ensure
# Restore prefix/suffix to its previous values # Restore prefix/suffix to its previous values
ActiveRecord::Base.table_name_prefix = old_prefix ActiveRecord::Base.table_name_prefix = old_prefix
ActiveRecord::Base.table_name_suffix = old_suffix 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
end end


Expand Down
42 changes: 0 additions & 42 deletions activerecord/test/fixtures/other_topics.yml

This file was deleted.

0 comments on commit 91681c2

Please sign in to comment.