diff options
Diffstat (limited to 'activerecord/test/fixtures')
-rw-r--r-- | activerecord/test/fixtures/categories.yml | 7 | ||||
-rw-r--r-- | activerecord/test/fixtures/categories_posts.yml | 8 | ||||
-rw-r--r-- | activerecord/test/fixtures/category.rb | 2 | ||||
-rw-r--r-- | activerecord/test/fixtures/comment.rb | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/comments.yml | 44 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/db2.sql | 3 | ||||
-rwxr-xr-x | activerecord/test/fixtures/db_definitions/mysql.sql | 1 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/oci.sql | 3 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/postgresql.sql | 3 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/sqlite.sql | 3 | ||||
-rw-r--r-- | activerecord/test/fixtures/db_definitions/sqlserver.sql | 3 | ||||
-rw-r--r-- | activerecord/test/fixtures/post.rb | 10 | ||||
-rw-r--r-- | activerecord/test/fixtures/posts.yml | 21 |
13 files changed, 103 insertions, 9 deletions
diff --git a/activerecord/test/fixtures/categories.yml b/activerecord/test/fixtures/categories.yml index 2ce34d6f9f..b0770a093d 100644 --- a/activerecord/test/fixtures/categories.yml +++ b/activerecord/test/fixtures/categories.yml @@ -1,7 +1,14 @@ general: id: 1 name: General + type: Category technology: id: 2 name: Technology + type: Category + +sti_test: + id: 3 + name: Special category + type: SpecialCategory diff --git a/activerecord/test/fixtures/categories_posts.yml b/activerecord/test/fixtures/categories_posts.yml index 04eeb8f46c..0d77d8c05f 100644 --- a/activerecord/test/fixtures/categories_posts.yml +++ b/activerecord/test/fixtures/categories_posts.yml @@ -9,3 +9,11 @@ technology_welcome: general_thinking: category_id: 1 post_id: 2 + +general_sti_habtm: + category_id: 1 + post_id: 6 + +sti_test_sti_habtm: + category_id: 3 + post_id: 6 diff --git a/activerecord/test/fixtures/category.rb b/activerecord/test/fixtures/category.rb index 751413c0db..822defa03e 100644 --- a/activerecord/test/fixtures/category.rb +++ b/activerecord/test/fixtures/category.rb @@ -1,3 +1,5 @@ class Category < ActiveRecord::Base has_and_belongs_to_many :posts end + +class SpecialCategory < Category; end; diff --git a/activerecord/test/fixtures/comment.rb b/activerecord/test/fixtures/comment.rb index b59819864d..982cbc6a7a 100644 --- a/activerecord/test/fixtures/comment.rb +++ b/activerecord/test/fixtures/comment.rb @@ -2,4 +2,6 @@ class Comment < ActiveRecord::Base belongs_to :post end -class SpecialComment < Comment; end;
\ No newline at end of file +class SpecialComment < Comment; end; + +class VerySpecialComment < Comment; end; diff --git a/activerecord/test/fixtures/comments.yml b/activerecord/test/fixtures/comments.yml index 9c442cf794..bfe61068e1 100644 --- a/activerecord/test/fixtures/comments.yml +++ b/activerecord/test/fixtures/comments.yml @@ -14,4 +14,46 @@ does_it_hurt: id: 3 post_id: 2 body: Don't think too hard - type: SpecialComment
\ No newline at end of file + type: SpecialComment + +eager_sti_on_associations_comment: + id: 4 + post_id: 4 + body: Normal type + type: Comment + +eager_sti_on_associations_vs_comment: + id: 5 + post_id: 4 + body: Very Special type + type: VerySpecialComment + +eager_sti_on_associations_s_comment1: + id: 6 + post_id: 4 + body: Special type + type: SpecialComment + +eager_sti_on_associations_s_comment2: + id: 7 + post_id: 4 + body: Special type 2 + type: SpecialComment + +eager_sti_on_associations_comment: + id: 8 + post_id: 4 + body: Normal type + type: Comment + +check_eager_sti_on_associations: + id: 9 + post_id: 5 + body: Normal type + type: Comment + +check_eager_sti_on_associations2: + id: 10 + post_id: 5 + body: Special Type + type: SpecialComment diff --git a/activerecord/test/fixtures/db_definitions/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql index bd1696d546..40faf53269 100644 --- a/activerecord/test/fixtures/db_definitions/db2.sql +++ b/activerecord/test/fixtures/db_definitions/db2.sql @@ -160,7 +160,8 @@ CREATE TABLE tasks ( CREATE TABLE categories ( id int generated by default as identity (start with +10000), - name varchar(255) NOT NULL + name varchar(255) NOT NULL, + type varchar(40) default NULL ); CREATE TABLE categories_posts ( diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index 6fa1a38615..cb589bec6f 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -162,6 +162,7 @@ CREATE TABLE `tasks` ( CREATE TABLE `categories` ( `id` int(11) NOT NULL auto_increment, `name` VARCHAR(255) NOT NULL, + `type` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`) ) TYPE=InnoDB; diff --git a/activerecord/test/fixtures/db_definitions/oci.sql b/activerecord/test/fixtures/db_definitions/oci.sql index be6872a26a..0170215c41 100644 --- a/activerecord/test/fixtures/db_definitions/oci.sql +++ b/activerecord/test/fixtures/db_definitions/oci.sql @@ -198,7 +198,8 @@ create table tasks ( create table categories ( id integer not null primary key, - name varchar(255) default null + name varchar(255) default null, + type varchar(255) default null ); create table categories_posts ( diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index 60623e5a48..aec5bd64c3 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -177,7 +177,8 @@ CREATE TABLE tasks ( CREATE TABLE categories ( id serial, - name varchar(255) + name varchar(255), + type varchar(255) ); CREATE TABLE categories_posts ( diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql index 08a515e67b..1e3b4769f2 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.sql @@ -147,7 +147,8 @@ CREATE TABLE 'tasks' ( CREATE TABLE 'categories' ( 'id' INTEGER NOT NULL PRIMARY KEY, - 'name' VARCHAR(255) NOT NULL + 'name' VARCHAR(255) NOT NULL, + 'type' VARCHAR(255) DEFAULT NULL ); CREATE TABLE 'categories_posts' ( diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index 1177b37035..2280bc80ea 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -147,7 +147,8 @@ CREATE TABLE tasks ( CREATE TABLE categories ( id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, - name varchar(255) + name varchar(255), + type varchar(255) default NULL ); CREATE TABLE categories_posts ( diff --git a/activerecord/test/fixtures/post.rb b/activerecord/test/fixtures/post.rb index bac0857e5f..e347d94fb8 100644 --- a/activerecord/test/fixtures/post.rb +++ b/activerecord/test/fixtures/post.rb @@ -1,8 +1,14 @@ class Post < ActiveRecord::Base belongs_to :author has_many :comments, :order => "body" + has_one :very_special_comment, :class_name => "VerySpecialComment" + has_many :special_comments, :class_name => "SpecialComment" has_and_belongs_to_many :categories + has_and_belongs_to_many :special_categories, :join_table => "categories_posts" end -class SpecialPost < Post -end
\ No newline at end of file +class SpecialPost < Post; end; + +class StiPost < Post + has_one :special_comment, :class_name => "SpecialComment" +end diff --git a/activerecord/test/fixtures/posts.yml b/activerecord/test/fixtures/posts.yml index decd14b70e..190993dcdd 100644 --- a/activerecord/test/fixtures/posts.yml +++ b/activerecord/test/fixtures/posts.yml @@ -18,3 +18,24 @@ authorless: title: I don't have any comments body: I just don't want to type: Post + +sti_comments: + id: 4 + author_id: 1 + title: sti comments + body: hello + type: Post + +sti_post_and_comments: + id: 5 + author_id: 1 + title: sti me + body: hello + type: StiPost + +sti_habtm: + id: 6 + author_id: 1 + title: habtm sti test + body: hello + type: Post |