Ticket #1732: active_record_bug.diff
| File active_record_bug.diff, 4.7 kB (added by david, 3 years ago) |
|---|
-
activerecord/test/associations_test.rb
old new 5 5 require 'fixtures/topic' 6 6 require 'fixtures/reply' 7 7 require 'fixtures/computer' 8 require 'fixtures/graphnode' 8 9 9 10 # Can't declare new classes in test case methods, so tests before that 10 11 bad_collection_keys = false … … 801 802 802 803 803 804 class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase 804 fixtures :accounts, :companies, :developers, :projects, :developers_projects 805 fixtures :accounts, :companies, :developers, :projects, :developers_projects, :graphnodes, :graphnode_links 805 806 806 807 def test_has_and_belongs_to_many 807 808 david = Developer.find(1) … … 829 830 assert_equal 2, action_controller.developers(true).size 830 831 end 831 832 833 def test_finder_sql_cache 834 shared_node = graphnodes(:shared_subchild) 835 child_one = graphnodes(:child_one) 836 child_two = graphnodes(:child_two) 837 838 assert_equal 2, shared_node.parent_nodes.size 839 assert_equal child_one, shared_node.parent_nodes.first 840 assert_equal 1, child_one.parent_nodes.size 841 end 842 832 843 def test_adding_type_mismatch 833 844 jamis = Developer.find(2) 834 845 assert_raise(ActiveRecord::AssociationTypeMismatch) { jamis.projects << nil } -
activerecord/test/fixtures/graphnodes.yml
old new 1 root_node: 2 id: 1 3 name: Root Node 4 child_one: 5 id: 2 6 name: Child One 7 child_two: 8 id: 3 9 name: Child Two 10 subchild_one: 11 id: 4 12 name: Subchild One 13 subchild_two: 14 id: 5 15 name: Subchild Two 16 shared_subchild: 17 id: 6 18 name: Shared Subchild 19 subsubchild: 20 id: 7 21 name: Sub-sub child -
activerecord/test/fixtures/db_definitions/mysql.sql
old new 180 180 181 181 FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`) 182 182 ) TYPE=InnoDB; 183 184 CREATE TABLE `graphnodes` ( 185 `id` INTEGER NOT NULL auto_increment, 186 `name` VARCHAR(255) NOT NULL, 187 PRIMARY KEY (`id`) 188 ) TYPE=InnoDB; 189 190 CREATE TABLE `graphnode_links` ( 191 `parent_node_id` INTEGER NOT NULL, 192 `child_node_id` INTEGER NOT NULL, 193 PRIMARY KEY (`parent_node_id`,`child_node_id`), 194 CONSTRAINT `FK_child_node` FOREIGN KEY (`child_node_id`) REFERENCES `graphnodes` (`id`), 195 CONSTRAINT `FK_parent_node` FOREIGN KEY (`parent_node_id`) REFERENCES `graphnodes` (`id`) 196 ) TYPE=InnoDB; 197 -
activerecord/test/fixtures/db_definitions/mysql.drop.sql
old new 21 21 DROP TABLE authors; 22 22 DROP TABLE categories; 23 23 DROP TABLE categories_posts; 24 DROP TABLE graphnodes; 25 DROP TABLE graphnode_links; -
activerecord/test/fixtures/graphnode_links.yml
old new 1 link_one: 2 parent_node_id: 1 3 child_node_id: 2 4 link_two: 5 parent_node_id: 1 6 child_node_id: 3 7 link_three: 8 parent_node_id: 2 9 child_node_id: 4 10 link_four: 11 parent_node_id: 2 12 child_node_id: 5 13 link_five: 14 parent_node_id: 2 15 child_node_id: 6 16 link_six: 17 parent_node_id: 3 18 child_node_id: 6 19 link_seven: 20 parent_node_id: 6 21 child_node_id: 7 -
activerecord/test/fixtures/graphnode.rb
old new 1 class Graphnode < ActiveRecord::Base 2 has_and_belongs_to_many :parent_nodes, 3 :class_name => 'Graphnode', 4 :finder_sql => 'SELECT n.* FROM graphnodes n, graphnode_links l ' + 5 ' WHERE n.id = l.parent_node_id ' + 6 ' AND l.child_node_id = #{id}' 7 8 has_and_belongs_to_many :child_nodes, 9 :class_name => 'Graphnode', 10 :finder_sql => 'SELECT n.* FROM graphnodes n, graphnode_links l ' + 11 ' WHERE n.id = l.child_node_id ' + 12 ' AND l.parent_node_id = #{id}' 13 end