diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 11 | ||||
-rw-r--r-- | activerecord/test/models/joke.rb | 4 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 4 |
3 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 68adeff882..1fa5d2ac5f 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -20,6 +20,7 @@ require 'models/warehouse_thing' require 'models/parrot' require 'models/loose_person' require 'models/edge' +require 'models/joke' require 'rexml/document' require 'active_support/core_ext/exception' @@ -1156,6 +1157,16 @@ class BasicsTest < ActiveRecord::TestCase assert_equal "bar", k.table_name end + def test_switching_between_table_name + assert_difference("GoodJoke.count") do + Joke.set_table_name "cold_jokes" + Joke.create + + Joke.set_table_name "funny_jokes" + Joke.create + end + end + def test_quoted_table_name_after_set_table_name klass = Class.new(ActiveRecord::Base) diff --git a/activerecord/test/models/joke.rb b/activerecord/test/models/joke.rb index 3978abc2ba..d7f01e59e6 100644 --- a/activerecord/test/models/joke.rb +++ b/activerecord/test/models/joke.rb @@ -1,3 +1,7 @@ class Joke < ActiveRecord::Base set_table_name 'funny_jokes' end + +class GoodJoke < ActiveRecord::Base + set_table_name 'funny_jokes' +end diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 665a4fe914..b1763ff431 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -229,6 +229,10 @@ ActiveRecord::Schema.define do t.string :name end + create_table :cold_jokes, :force => true do |t| + t.string :name + end + create_table :goofy_string_id, :force => true, :id => false do |t| t.string :id, :null => false t.string :info |