diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-09-08 15:38:51 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-09-08 15:38:51 -0300 |
commit | 670281c6b2e9b9e8c51a140f2a5f66b251f1b84b (patch) | |
tree | ab141872d72e010c8a0fe371d22a00914c97e1eb /activerecord/test | |
parent | 39e4e76d15233bb1cb0b778d920f54efe86bb4f0 (diff) | |
parent | 1a0f822037c408a392ffa7b6e1ecbe5951ab48db (diff) | |
download | rails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.tar.gz rails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.tar.bz2 rails-670281c6b2e9b9e8c51a140f2a5f66b251f1b84b.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/lib/active_record/associations.rb
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/habtm_join_table_test.rb | 16 | ||||
-rw-r--r-- | activerecord/test/cases/class_inheritable_attributes_test.rb | 32 | ||||
-rw-r--r-- | activerecord/test/fixtures/edges.yml | 3 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 2 |
4 files changed, 17 insertions, 36 deletions
diff --git a/activerecord/test/cases/associations/habtm_join_table_test.rb b/activerecord/test/cases/associations/habtm_join_table_test.rb index 745f169ad7..bf3e04c3eb 100644 --- a/activerecord/test/cases/associations/habtm_join_table_test.rb +++ b/activerecord/test/cases/associations/habtm_join_table_test.rb @@ -36,9 +36,21 @@ class HabtmJoinTableTest < ActiveRecord::TestCase uses_transaction :test_should_raise_exception_when_join_table_has_a_primary_key def test_should_raise_exception_when_join_table_has_a_primary_key if ActiveRecord::Base.connection.supports_primary_key? - assert_raise ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError do - MyReader.has_and_belongs_to_many :my_books + assert_raise ActiveRecord::ConfigurationError do + jaime = MyReader.create(:name=>"Jaime") + jaime.my_books << MyBook.create(:name=>'Great Expectations') end end end + + uses_transaction :test_should_cache_result_of_primary_key_check + def test_should_cache_result_of_primary_key_check + if ActiveRecord::Base.connection.supports_primary_key? + ActiveRecord::Base.connection.stubs(:primary_key).with('my_books_my_readers').returns(false).once + weaz = MyReader.create(:name=>'Weaz') + + weaz.my_books << MyBook.create(:name=>'Great Expectations') + weaz.my_books << MyBook.create(:name=>'Greater Expectations') + end + end end diff --git a/activerecord/test/cases/class_inheritable_attributes_test.rb b/activerecord/test/cases/class_inheritable_attributes_test.rb deleted file mode 100644 index abeb63c591..0000000000 --- a/activerecord/test/cases/class_inheritable_attributes_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'test/unit' -require "cases/helper" -require 'active_support/core_ext/class/inheritable_attributes' - -class A - include ClassInheritableAttributes -end - -class B < A - write_inheritable_array "first", [ :one, :two ] -end - -class C < A - write_inheritable_array "first", [ :three ] -end - -class D < B - write_inheritable_array "first", [ :four ] -end - - -class ClassInheritableAttributesTest < ActiveRecord::TestCase - def test_first_level - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - assert_equal [ :three ], C.read_inheritable_attribute("first") - end - - def test_second_level - assert_equal [ :one, :two, :four ], D.read_inheritable_attribute("first") - assert_equal [ :one, :two ], B.read_inheritable_attribute("first") - end -end diff --git a/activerecord/test/fixtures/edges.yml b/activerecord/test/fixtures/edges.yml index b804f7b6a6..c16c70dd2f 100644 --- a/activerecord/test/fixtures/edges.yml +++ b/activerecord/test/fixtures/edges.yml @@ -1,5 +1,6 @@ <% (1..4).each do |id| %> edge_<%= id %>: + id: <%= id %> source_id: <%= id %> sink_id: <%= id + 1 %> -<% end %> +<% end %>
\ No newline at end of file diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 5c12cb1a0c..9ab4cf6f43 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -159,7 +159,7 @@ ActiveRecord::Schema.define do t.integer :access_level, :default => 1 end - create_table :edges, :force => true, :id => false do |t| + create_table :edges, :force => true do |t| t.column :source_id, :integer, :null => false t.column :sink_id, :integer, :null => false end |