diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-03-06 10:48:17 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-03-06 10:51:57 +0100 |
commit | eac3349285718e2a145c1e85e1fdb7bf96fc5bd1 (patch) | |
tree | d0f68fef3c824ee26ea3ab615a5b21e7c36db4a4 /activerecord/test/cases | |
parent | 90c10500bec897c99f33bfc71e7481a002a34db2 (diff) | |
download | rails-eac3349285718e2a145c1e85e1fdb7bf96fc5bd1.tar.gz rails-eac3349285718e2a145c1e85e1fdb7bf96fc5bd1.tar.bz2 rails-eac3349285718e2a145c1e85e1fdb7bf96fc5bd1.zip |
tests, remove side effects on `Joke` during `base_test.rb`.
prompted by #19221.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 993350ebd6..5016dcea43 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require "cases/helper" require 'active_support/concurrency/latch' @@ -1008,54 +1009,58 @@ class BasicsTest < ActiveRecord::TestCase end def test_switching_between_table_name + k = Class.new(Joke) + assert_difference("GoodJoke.count") do - Joke.table_name = "cold_jokes" - Joke.create + k.table_name = "cold_jokes" + k.create - Joke.table_name = "funny_jokes" - Joke.create + k.table_name = "funny_jokes" + k.create end end def test_clear_cash_when_setting_table_name - Joke.table_name = "cold_jokes" - before_columns = Joke.columns - before_seq = Joke.sequence_name + k = Class.new(Joke) + k.table_name = "cold_jokes" + before_columns = k.columns + before_seq = k.sequence_name - Joke.table_name = "funny_jokes" - after_columns = Joke.columns - after_seq = Joke.sequence_name + k.table_name = "funny_jokes" + after_columns = k.columns + after_seq = k.sequence_name assert_not_equal before_columns, after_columns assert_not_equal before_seq, after_seq unless before_seq.nil? && after_seq.nil? end def test_dont_clear_sequence_name_when_setting_explicitly - Joke.sequence_name = "black_jokes_seq" - Joke.table_name = "cold_jokes" - before_seq = Joke.sequence_name + k = Class.new(Joke) + k.sequence_name = "black_jokes_seq" + k.table_name = "cold_jokes" + before_seq = k.sequence_name - Joke.table_name = "funny_jokes" - after_seq = Joke.sequence_name + k.table_name = "funny_jokes" + after_seq = k.sequence_name assert_equal before_seq, after_seq unless before_seq.nil? && after_seq.nil? - ensure - Joke.reset_sequence_name end def test_dont_clear_inheritance_column_when_setting_explicitly - Joke.inheritance_column = "my_type" - before_inherit = Joke.inheritance_column + k = Class.new(Joke) + k.inheritance_column = "my_type" + before_inherit = k.inheritance_column - Joke.reset_column_information - after_inherit = Joke.inheritance_column + k.reset_column_information + after_inherit = k.inheritance_column assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank? end def test_set_table_name_symbol_converted_to_string - Joke.table_name = :cold_jokes - assert_equal 'cold_jokes', Joke.table_name + k = Class.new(Joke) + k.table_name = :cold_jokes + assert_equal 'cold_jokes', k.table_name end def test_quoted_table_name_after_set_table_name |