aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-11-24 01:04:44 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-11-24 01:04:44 +0000
commitdb045dbbf60b53dbe013ef25554fd013baf88134 (patch)
tree257830e3c76458c8ff3d1329de83f32b23926028 /activerecord/test/fixtures
downloadrails-db045dbbf60b53dbe013ef25554fd013baf88134.tar.gz
rails-db045dbbf60b53dbe013ef25554fd013baf88134.tar.bz2
rails-db045dbbf60b53dbe013ef25554fd013baf88134.zip
Initial
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures')
-rw-r--r--activerecord/test/fixtures/accounts.yml8
-rw-r--r--activerecord/test/fixtures/auto_id.rb4
-rw-r--r--activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char1
-rw-r--r--activerecord/test/fixtures/bad_fixtures/attr_with_spaces1
-rw-r--r--activerecord/test/fixtures/bad_fixtures/blank_line3
-rw-r--r--activerecord/test/fixtures/bad_fixtures/duplicate_attributes3
-rw-r--r--activerecord/test/fixtures/bad_fixtures/missing_value1
-rw-r--r--activerecord/test/fixtures/column_name.rb3
-rwxr-xr-xactiverecord/test/fixtures/companies/first_client6
-rwxr-xr-xactiverecord/test/fixtures/companies/first_firm4
-rwxr-xr-xactiverecord/test/fixtures/companies/second_client6
-rwxr-xr-xactiverecord/test/fixtures/company.rb37
-rw-r--r--activerecord/test/fixtures/company_in_module.rb47
-rw-r--r--activerecord/test/fixtures/course.rb3
-rw-r--r--activerecord/test/fixtures/courses/java2
-rw-r--r--activerecord/test/fixtures/courses/ruby2
-rw-r--r--activerecord/test/fixtures/customer.rb30
-rw-r--r--activerecord/test/fixtures/customers/david6
-rwxr-xr-xactiverecord/test/fixtures/db_definitions/mysql.sql97
-rw-r--r--activerecord/test/fixtures/db_definitions/mysql2.sql4
-rw-r--r--activerecord/test/fixtures/db_definitions/postgresql.sql114
-rw-r--r--activerecord/test/fixtures/db_definitions/postgresql2.sql4
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlite.sql86
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlite2.sql4
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlserver.sql96
-rw-r--r--activerecord/test/fixtures/db_definitions/sqlserver2.sql4
-rw-r--r--activerecord/test/fixtures/default.rb2
-rw-r--r--activerecord/test/fixtures/developer.rb8
-rw-r--r--activerecord/test/fixtures/developers.yml13
-rw-r--r--activerecord/test/fixtures/developers_projects/david_action_controller3
-rw-r--r--activerecord/test/fixtures/developers_projects/david_active_record3
-rw-r--r--activerecord/test/fixtures/developers_projects/jamis_active_record2
-rw-r--r--activerecord/test/fixtures/entrant.rb3
-rw-r--r--activerecord/test/fixtures/entrants/first3
-rw-r--r--activerecord/test/fixtures/entrants/second3
-rw-r--r--activerecord/test/fixtures/entrants/third3
-rw-r--r--activerecord/test/fixtures/movie.rb5
-rw-r--r--activerecord/test/fixtures/movies/first2
-rw-r--r--activerecord/test/fixtures/movies/second2
-rw-r--r--activerecord/test/fixtures/project.rb4
-rw-r--r--activerecord/test/fixtures/projects/action_controller2
-rw-r--r--activerecord/test/fixtures/projects/active_record2
-rwxr-xr-xactiverecord/test/fixtures/reply.rb21
-rw-r--r--activerecord/test/fixtures/subscriber.rb5
-rw-r--r--activerecord/test/fixtures/subscribers/first2
-rw-r--r--activerecord/test/fixtures/subscribers/second2
-rwxr-xr-xactiverecord/test/fixtures/topic.rb20
-rwxr-xr-xactiverecord/test/fixtures/topics/first9
-rwxr-xr-xactiverecord/test/fixtures/topics/second8
49 files changed, 703 insertions, 0 deletions
diff --git a/activerecord/test/fixtures/accounts.yml b/activerecord/test/fixtures/accounts.yml
new file mode 100644
index 0000000000..21a0aab52a
--- /dev/null
+++ b/activerecord/test/fixtures/accounts.yml
@@ -0,0 +1,8 @@
+signals37:
+ id: 1
+ firm_id: 1
+ credit_limit: 50
+
+unknown:
+ id: 2
+ credit_limit: 50
diff --git a/activerecord/test/fixtures/auto_id.rb b/activerecord/test/fixtures/auto_id.rb
new file mode 100644
index 0000000000..d720e2be5e
--- /dev/null
+++ b/activerecord/test/fixtures/auto_id.rb
@@ -0,0 +1,4 @@
+class AutoId < ActiveRecord::Base
+ def self.table_name () "auto_id_tests" end
+ def self.primary_key () "auto_id" end
+end
diff --git a/activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char b/activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char
new file mode 100644
index 0000000000..ef27947f27
--- /dev/null
+++ b/activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char
@@ -0,0 +1 @@
+1b => 1
diff --git a/activerecord/test/fixtures/bad_fixtures/attr_with_spaces b/activerecord/test/fixtures/bad_fixtures/attr_with_spaces
new file mode 100644
index 0000000000..46fd6f2fe9
--- /dev/null
+++ b/activerecord/test/fixtures/bad_fixtures/attr_with_spaces
@@ -0,0 +1 @@
+a b => 1
diff --git a/activerecord/test/fixtures/bad_fixtures/blank_line b/activerecord/test/fixtures/bad_fixtures/blank_line
new file mode 100644
index 0000000000..3ea1f71743
--- /dev/null
+++ b/activerecord/test/fixtures/bad_fixtures/blank_line
@@ -0,0 +1,3 @@
+a => 1
+
+b => 2
diff --git a/activerecord/test/fixtures/bad_fixtures/duplicate_attributes b/activerecord/test/fixtures/bad_fixtures/duplicate_attributes
new file mode 100644
index 0000000000..cc0236f26f
--- /dev/null
+++ b/activerecord/test/fixtures/bad_fixtures/duplicate_attributes
@@ -0,0 +1,3 @@
+a => 1
+b => 2
+a => 3
diff --git a/activerecord/test/fixtures/bad_fixtures/missing_value b/activerecord/test/fixtures/bad_fixtures/missing_value
new file mode 100644
index 0000000000..fb59ec33e8
--- /dev/null
+++ b/activerecord/test/fixtures/bad_fixtures/missing_value
@@ -0,0 +1 @@
+a =>
diff --git a/activerecord/test/fixtures/column_name.rb b/activerecord/test/fixtures/column_name.rb
new file mode 100644
index 0000000000..ec07205a3a
--- /dev/null
+++ b/activerecord/test/fixtures/column_name.rb
@@ -0,0 +1,3 @@
+class ColumnName < ActiveRecord::Base
+ def self.table_name () "colnametests" end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/companies/first_client b/activerecord/test/fixtures/companies/first_client
new file mode 100755
index 0000000000..800c694eeb
--- /dev/null
+++ b/activerecord/test/fixtures/companies/first_client
@@ -0,0 +1,6 @@
+id => 2
+type => Client
+firm_id => 1
+client_of => 2
+name => Summit
+ruby_type => Client
diff --git a/activerecord/test/fixtures/companies/first_firm b/activerecord/test/fixtures/companies/first_firm
new file mode 100755
index 0000000000..22d876dad1
--- /dev/null
+++ b/activerecord/test/fixtures/companies/first_firm
@@ -0,0 +1,4 @@
+id => 1
+type => Firm
+name => 37signals
+ruby_type => Firm
diff --git a/activerecord/test/fixtures/companies/second_client b/activerecord/test/fixtures/companies/second_client
new file mode 100755
index 0000000000..69f8adc49c
--- /dev/null
+++ b/activerecord/test/fixtures/companies/second_client
@@ -0,0 +1,6 @@
+id => 3
+type => Client
+firm_id => 1
+client_of => 1
+name => Microsoft
+ruby_type => Client
diff --git a/activerecord/test/fixtures/company.rb b/activerecord/test/fixtures/company.rb
new file mode 100755
index 0000000000..b5ee055948
--- /dev/null
+++ b/activerecord/test/fixtures/company.rb
@@ -0,0 +1,37 @@
+class Company < ActiveRecord::Base
+ attr_protected :rating
+end
+
+
+class Firm < Company
+ has_many :clients, :order => "id", :dependent => true
+ has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
+ has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
+ has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
+ has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
+
+ has_one :account, :dependent => true
+end
+
+class Client < Company
+ belongs_to :firm, :foreign_key => "client_of"
+ belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id"
+ belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
+ belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => "1 = 1"
+end
+
+
+class SpecialClient < Client
+end
+
+class VerySpecialClient < SpecialClient
+end
+
+class Account < ActiveRecord::Base
+ belongs_to :firm
+
+ protected
+ def validate
+ errors.add_on_empty "credit_limit"
+ end
+end
diff --git a/activerecord/test/fixtures/company_in_module.rb b/activerecord/test/fixtures/company_in_module.rb
new file mode 100644
index 0000000000..a484ed5eaf
--- /dev/null
+++ b/activerecord/test/fixtures/company_in_module.rb
@@ -0,0 +1,47 @@
+module MyApplication
+ module Business
+ class Company < ActiveRecord::Base
+ attr_protected :rating
+ end
+
+ class Firm < Company
+ has_many :clients, :order => "id", :dependent => true
+ has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
+ has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
+ has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
+ has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
+
+ has_one :account, :dependent => true
+ end
+
+ class Client < Company
+ belongs_to :firm, :foreign_key => "client_of"
+ belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
+ end
+
+ class Developer < ActiveRecord::Base
+ has_and_belongs_to_many :projects
+
+ protected
+ def validate
+ errors.add_on_boundry_breaking("name", 3..20)
+ end
+ end
+
+ class Project < ActiveRecord::Base
+ has_and_belongs_to_many :developers
+ end
+
+ end
+
+ module Billing
+ class Account < ActiveRecord::Base
+ belongs_to :firm, :class_name => "MyApplication::Business::Firm"
+
+ protected
+ def validate
+ errors.add_on_empty "credit_limit"
+ end
+ end
+ end
+end
diff --git a/activerecord/test/fixtures/course.rb b/activerecord/test/fixtures/course.rb
new file mode 100644
index 0000000000..8a40fa740d
--- /dev/null
+++ b/activerecord/test/fixtures/course.rb
@@ -0,0 +1,3 @@
+class Course < ActiveRecord::Base
+ has_many :entrants
+end
diff --git a/activerecord/test/fixtures/courses/java b/activerecord/test/fixtures/courses/java
new file mode 100644
index 0000000000..84b10d390b
--- /dev/null
+++ b/activerecord/test/fixtures/courses/java
@@ -0,0 +1,2 @@
+id => 2
+name => Java Development
diff --git a/activerecord/test/fixtures/courses/ruby b/activerecord/test/fixtures/courses/ruby
new file mode 100644
index 0000000000..db42f96d27
--- /dev/null
+++ b/activerecord/test/fixtures/courses/ruby
@@ -0,0 +1,2 @@
+id => 1
+name => Ruby Development
diff --git a/activerecord/test/fixtures/customer.rb b/activerecord/test/fixtures/customer.rb
new file mode 100644
index 0000000000..5275a5209d
--- /dev/null
+++ b/activerecord/test/fixtures/customer.rb
@@ -0,0 +1,30 @@
+class Customer < ActiveRecord::Base
+ composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ]
+ composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
+end
+
+class Address
+ attr_reader :street, :city, :country
+
+ def initialize(street, city, country)
+ @street, @city, @country = street, city, country
+ end
+
+ def close_to?(other_address)
+ city == other_address.city && country == other_address.country
+ end
+end
+
+class Money
+ attr_reader :amount, :currency
+
+ EXCHANGE_RATES = { "USD_TO_DKK" => 6, "DKK_TO_USD" => 0.6 }
+
+ def initialize(amount, currency = "USD")
+ @amount, @currency = amount, currency
+ end
+
+ def exchange_to(other_currency)
+ Money.new((amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor, other_currency)
+ end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/customers/david b/activerecord/test/fixtures/customers/david
new file mode 100644
index 0000000000..69b9c32376
--- /dev/null
+++ b/activerecord/test/fixtures/customers/david
@@ -0,0 +1,6 @@
+id => 1
+name => David
+balance => 50
+address_street => Funny Street
+address_city => Scary Town
+address_country => Loony Land \ No newline at end of file
diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql
new file mode 100755
index 0000000000..766c0ec71f
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/mysql.sql
@@ -0,0 +1,97 @@
+CREATE TABLE `accounts` (
+ `id` int(11) NOT NULL auto_increment,
+ `firm_id` int(11) default NULL,
+ `credit_limit` int(5) default NULL,
+ PRIMARY KEY (`id`)
+) TYPE=InnoDB;
+
+CREATE TABLE `companies` (
+ `id` int(11) NOT NULL auto_increment,
+ `type` varchar(50) default NULL,
+ `ruby_type` varchar(50) default NULL,
+ `firm_id` int(11) default NULL,
+ `name` varchar(50) default NULL,
+ `client_of` int(11) default NULL,
+ `rating` int(11) default NULL default 1,
+ PRIMARY KEY (`id`)
+) TYPE=InnoDB;
+
+
+CREATE TABLE `topics` (
+ `id` int(11) NOT NULL auto_increment,
+ `title` varchar(255) default NULL,
+ `author_name` varchar(255) default NULL,
+ `author_email_address` varchar(255) default NULL,
+ `written_on` datetime default NULL,
+ `last_read` date default NULL,
+ `content` text,
+ `approved` tinyint(1) default 1,
+ `replies_count` int(11) default 0,
+ `parent_id` int(11) default NULL,
+ `type` varchar(50) default NULL,
+ PRIMARY KEY (`id`)
+) TYPE=InnoDB;
+
+CREATE TABLE `developers` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(100) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `projects` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(100) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `developers_projects` (
+ `developer_id` int(11) NOT NULL,
+ `project_id` int(11) NOT NULL,
+ `joined_on` date default NULL
+);
+
+CREATE TABLE `customers` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(100) default NULL,
+ `balance` int(6) default 0,
+ `address_street` varchar(100) default NULL,
+ `address_city` varchar(100) default NULL,
+ `address_country` varchar(100) default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `movies` (
+ `movieid` int(11) NOT NULL auto_increment,
+ `name` varchar(100) default NULL,
+ PRIMARY KEY (`movieid`)
+);
+
+CREATE TABLE `subscribers` (
+ `nick` varchar(100) NOT NULL,
+ `name` varchar(100) default NULL,
+ PRIMARY KEY (`nick`)
+);
+
+CREATE TABLE `booleantests` (
+ `id` int(11) NOT NULL auto_increment,
+ `value` integer default NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `auto_id_tests` (
+ `auto_id` int(11) NOT NULL auto_increment,
+ `value` integer default NULL,
+ PRIMARY KEY (`auto_id`)
+);
+
+CREATE TABLE `entrants` (
+ `id` INTEGER NOT NULL PRIMARY KEY,
+ `name` VARCHAR(255) NOT NULL,
+ `course_id` INTEGER NOT NULL
+);
+
+CREATE TABLE `colnametests` (
+ `id` int(11) NOT NULL auto_increment,
+ `references` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+);
diff --git a/activerecord/test/fixtures/db_definitions/mysql2.sql b/activerecord/test/fixtures/db_definitions/mysql2.sql
new file mode 100644
index 0000000000..0a16a0a2f9
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/mysql2.sql
@@ -0,0 +1,4 @@
+CREATE TABLE `courses` (
+ `id` INTEGER NOT NULL PRIMARY KEY,
+ `name` VARCHAR(255) NOT NULL
+);
diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql
new file mode 100644
index 0000000000..e83356627b
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/postgresql.sql
@@ -0,0 +1,114 @@
+SET search_path = public, pg_catalog;
+
+CREATE TABLE accounts (
+ id serial,
+ firm_id integer,
+ credit_limit integer,
+ PRIMARY KEY (id)
+);
+SELECT setval('accounts_id_seq', 100);
+
+CREATE TABLE companies (
+ id serial,
+ "type" character varying(50),
+ "ruby_type" character varying(50),
+ firm_id integer,
+ name character varying(50),
+ client_of integer,
+ rating integer default 1,
+ PRIMARY KEY (id)
+);
+SELECT setval('companies_id_seq', 100);
+
+CREATE TABLE developers_projects (
+ developer_id integer NOT NULL,
+ project_id integer NOT NULL,
+ joined_on date
+);
+
+CREATE TABLE developers (
+ id serial,
+ name character varying(100),
+ PRIMARY KEY (id)
+);
+SELECT setval('developers_id_seq', 100);
+
+CREATE TABLE projects (
+ id serial,
+ name character varying(100),
+ PRIMARY KEY (id)
+);
+SELECT setval('projects_id_seq', 100);
+
+CREATE TABLE topics (
+ id serial,
+ title character varying(255),
+ author_name character varying(255),
+ author_email_address character varying(255),
+ written_on timestamp without time zone,
+ last_read date,
+ content text,
+ replies_count integer default 0,
+ parent_id integer,
+ "type" character varying(50),
+ approved smallint DEFAULT 1,
+ PRIMARY KEY (id)
+);
+SELECT setval('topics_id_seq', 100);
+
+CREATE TABLE customers (
+ id serial,
+ name character varying,
+ balance integer default 0,
+ address_street character varying,
+ address_city character varying,
+ address_country character varying,
+ PRIMARY KEY (id)
+);
+SELECT setval('customers_id_seq', 100);
+
+CREATE TABLE movies (
+ movieid serial,
+ name text,
+ PRIMARY KEY (movieid)
+);
+
+CREATE TABLE subscribers (
+ nick text NOT NULL,
+ name text,
+ PRIMARY KEY (nick)
+);
+
+CREATE TABLE booleantests (
+ id serial,
+ value boolean,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE defaults (
+ id serial,
+ modified_date date default CURRENT_DATE,
+ fixed_date date default '2004-01-01',
+ modified_time timestamp default CURRENT_TIMESTAMP,
+ fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
+ char1 char(1) default 'Y',
+ char2 character varying(50) default 'a varchar field',
+ char3 text default 'a text field'
+);
+
+CREATE TABLE auto_id_tests (
+ auto_id serial,
+ value integer,
+ PRIMARY KEY (auto_id)
+);
+
+CREATE TABLE entrants (
+ id serial,
+ name text,
+ course_id integer
+);
+
+CREATE TABLE colnametests (
+ id serial,
+ "references" integer NOT NULL
+);
diff --git a/activerecord/test/fixtures/db_definitions/postgresql2.sql b/activerecord/test/fixtures/db_definitions/postgresql2.sql
new file mode 100644
index 0000000000..b58a45eff7
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/postgresql2.sql
@@ -0,0 +1,4 @@
+CREATE TABLE courses (
+ id serial,
+ name text
+); \ No newline at end of file
diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql
new file mode 100644
index 0000000000..cb617305dc
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/sqlite.sql
@@ -0,0 +1,86 @@
+CREATE TABLE 'accounts' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'firm_id' INTEGER DEFAULT NULL,
+ 'credit_limit' INTEGER DEFAULT NULL
+);
+
+CREATE TABLE 'companies' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'type' VARCHAR(255) DEFAULT NULL,
+ 'ruby_type' VARCHAR(255) DEFAULT NULL,
+ 'firm_id' INTEGER DEFAULT NULL,
+ 'name' TEXT DEFAULT NULL,
+ 'client_of' INTEGER DEFAULT NULL,
+ 'rating' INTEGER DEFAULT 1
+);
+
+
+CREATE TABLE 'topics' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'title' VARCHAR(255) DEFAULT NULL,
+ 'author_name' VARCHAR(255) DEFAULT NULL,
+ 'author_email_address' VARCHAR(255) DEFAULT NULL,
+ 'written_on' DATETIME DEFAULT NULL,
+ 'last_read' DATE DEFAULT NULL,
+ 'content' TEXT,
+ 'approved' INTEGER DEFAULT 1,
+ 'replies_count' INTEGER DEFAULT 0,
+ 'parent_id' INTEGER DEFAULT NULL,
+ 'type' VARCHAR(255) DEFAULT NULL
+);
+
+CREATE TABLE 'developers' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL
+);
+
+CREATE TABLE 'projects' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL
+);
+
+CREATE TABLE 'developers_projects' (
+ 'developer_id' INTEGER NOT NULL,
+ 'project_id' INTEGER NOT NULL,
+ 'joined_on' DATE DEFAULT NULL
+);
+
+CREATE TABLE 'customers' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' VARCHAR(255) DEFAULT NULL,
+ 'balance' INTEGER DEFAULT 0,
+ 'address_street' TEXT DEFAULT NULL,
+ 'address_city' TEXT DEFAULT NULL,
+ 'address_country' TEXT DEFAULT NULL
+);
+
+CREATE TABLE 'movies' (
+ 'movieid' INTEGER PRIMARY KEY NOT NULL,
+ 'name' VARCHAR(255) DEFAULT NULL
+);
+
+CREATE TABLE subscribers (
+ 'nick' VARCHAR(255) PRIMARY KEY NOT NULL,
+ 'name' VARCHAR(255) DEFAULT NULL
+);
+
+CREATE TABLE 'booleantests' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'value' INTEGER DEFAULT NULL
+);
+
+CREATE TABLE 'auto_id_tests' (
+ 'auto_id' INTEGER PRIMARY KEY NOT NULL,
+ 'value' INTEGER DEFAULT NULL
+);
+
+CREATE TABLE 'entrants' (
+ 'id' INTEGER NOT NULL PRIMARY KEY,
+ 'name' VARCHAR(255) NOT NULL,
+ 'course_id' INTEGER NOT NULL
+);
+
+CREATE TABLE 'colnametests' (
+ 'id' INTEGER NOT NULL PRIMARY KEY,
+ 'references' INTEGER NOT NULL
+);
diff --git a/activerecord/test/fixtures/db_definitions/sqlite2.sql b/activerecord/test/fixtures/db_definitions/sqlite2.sql
new file mode 100644
index 0000000000..19b123968a
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/sqlite2.sql
@@ -0,0 +1,4 @@
+CREATE TABLE 'courses' (
+ 'id' INTEGER NOT NULL PRIMARY KEY,
+ 'name' VARCHAR(255) NOT NULL
+);
diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql
new file mode 100644
index 0000000000..0ae9780273
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql
@@ -0,0 +1,96 @@
+CREATE TABLE accounts (
+ id int NOT NULL IDENTITY(1, 1),
+ firm_id int default NULL,
+ credit_limit int default NULL,
+ PRIMARY KEY (id)
+)
+
+CREATE TABLE companies (
+ id int NOT NULL IDENTITY(1, 1),
+ type varchar(50) default NULL,
+ ruby_type varchar(50) default NULL,
+ firm_id int default NULL,
+ name varchar(50) default NULL,
+ client_of int default NULL,
+ companies_count int default 0,
+ rating int default 1,
+ PRIMARY KEY (id)
+)
+
+CREATE TABLE topics (
+ id int NOT NULL IDENTITY(1, 1),
+ title varchar(255) default NULL,
+ author_name varchar(255) default NULL,
+ author_email_address varchar(255) default NULL,
+ written_on datetime default NULL,
+ last_read datetime default NULL,
+ content text,
+ approved tinyint default 1,
+ replies_count int default 0,
+ parent_id int default NULL,
+ type varchar(50) default NULL,
+ PRIMARY KEY (id)
+)
+
+CREATE TABLE developers (
+ id int NOT NULL IDENTITY(1, 1),
+ name varchar(100) default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE projects (
+ id int NOT NULL IDENTITY(1, 1),
+ name varchar(100) default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE developers_projects (
+ developer_id int NOT NULL,
+ project_id int NOT NULL
+);
+
+CREATE TABLE customers (
+ id int NOT NULL IDENTITY(1, 1),
+ name varchar(100) default NULL,
+ balance int default 0,
+ address_street varchar(100) default NULL,
+ address_city varchar(100) default NULL,
+ address_country varchar(100) default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE movies (
+ movieid int NOT NULL IDENTITY(1, 1),
+ name varchar(100) default NULL,
+ PRIMARY KEY (movieid)
+);
+
+CREATE TABLE subscribers (
+ nick varchar(100) NOT NULL,
+ name varchar(100) default NULL,
+ PRIMARY KEY (nick)
+);
+
+CREATE TABLE booleantests (
+ id int NOT NULL IDENTITY(1, 1),
+ value integer default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE auto_id_tests (
+ auto_id int NOT NULL IDENTITY(1, 1),
+ value int default NULL,
+ PRIMARY KEY (auto_id)
+);
+
+CREATE TABLE entrants (
+ id int NOT NULL PRIMARY KEY,
+ name varchar(255) NOT NULL,
+ course_id int NOT NULL
+);
+
+CREATE TABLE colnametests (
+ id int NOT NULL IDENTITY(1, 1),
+ [references] int NOT NULL,
+ PRIMARY KEY (id)
+); \ No newline at end of file
diff --git a/activerecord/test/fixtures/db_definitions/sqlserver2.sql b/activerecord/test/fixtures/db_definitions/sqlserver2.sql
new file mode 100644
index 0000000000..dc4f9ed364
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/sqlserver2.sql
@@ -0,0 +1,4 @@
+CREATE TABLE courses (
+ id int NOT NULL PRIMARY KEY,
+ name varchar(255) NOT NULL
+);
diff --git a/activerecord/test/fixtures/default.rb b/activerecord/test/fixtures/default.rb
new file mode 100644
index 0000000000..887e9cc999
--- /dev/null
+++ b/activerecord/test/fixtures/default.rb
@@ -0,0 +1,2 @@
+class Default < ActiveRecord::Base
+end
diff --git a/activerecord/test/fixtures/developer.rb b/activerecord/test/fixtures/developer.rb
new file mode 100644
index 0000000000..737fc3824b
--- /dev/null
+++ b/activerecord/test/fixtures/developer.rb
@@ -0,0 +1,8 @@
+class Developer < ActiveRecord::Base
+ has_and_belongs_to_many :projects
+
+ protected
+ def validate
+ errors.add_on_boundry_breaking("name", 3..20)
+ end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/developers.yml b/activerecord/test/fixtures/developers.yml
new file mode 100644
index 0000000000..733455f789
--- /dev/null
+++ b/activerecord/test/fixtures/developers.yml
@@ -0,0 +1,13 @@
+david:
+ id: 1
+ name: David
+
+jamis:
+ id: 2
+ name: Jamis
+
+<% for digit in 3..10 %>
+dev_<%= digit %>:
+ id: <%= digit %>
+ name: fixture_<%= digit %>
+<% end %> \ No newline at end of file
diff --git a/activerecord/test/fixtures/developers_projects/david_action_controller b/activerecord/test/fixtures/developers_projects/david_action_controller
new file mode 100644
index 0000000000..e6e9d0e59b
--- /dev/null
+++ b/activerecord/test/fixtures/developers_projects/david_action_controller
@@ -0,0 +1,3 @@
+developer_id => 1
+project_id => 2
+joined_on => 2004-10-10 \ No newline at end of file
diff --git a/activerecord/test/fixtures/developers_projects/david_active_record b/activerecord/test/fixtures/developers_projects/david_active_record
new file mode 100644
index 0000000000..2ef474c10d
--- /dev/null
+++ b/activerecord/test/fixtures/developers_projects/david_active_record
@@ -0,0 +1,3 @@
+developer_id => 1
+project_id => 1
+joined_on => 2004-10-10 \ No newline at end of file
diff --git a/activerecord/test/fixtures/developers_projects/jamis_active_record b/activerecord/test/fixtures/developers_projects/jamis_active_record
new file mode 100644
index 0000000000..91beb80797
--- /dev/null
+++ b/activerecord/test/fixtures/developers_projects/jamis_active_record
@@ -0,0 +1,2 @@
+developer_id => 2
+project_id => 1 \ No newline at end of file
diff --git a/activerecord/test/fixtures/entrant.rb b/activerecord/test/fixtures/entrant.rb
new file mode 100644
index 0000000000..4682ce48c8
--- /dev/null
+++ b/activerecord/test/fixtures/entrant.rb
@@ -0,0 +1,3 @@
+class Entrant < ActiveRecord::Base
+ belongs_to :course
+end
diff --git a/activerecord/test/fixtures/entrants/first b/activerecord/test/fixtures/entrants/first
new file mode 100644
index 0000000000..e45cd6c1c2
--- /dev/null
+++ b/activerecord/test/fixtures/entrants/first
@@ -0,0 +1,3 @@
+id => 1
+course_id => 1
+name => Ruby Developer
diff --git a/activerecord/test/fixtures/entrants/second b/activerecord/test/fixtures/entrants/second
new file mode 100644
index 0000000000..38cd702476
--- /dev/null
+++ b/activerecord/test/fixtures/entrants/second
@@ -0,0 +1,3 @@
+id => 2
+course_id => 1
+name => Ruby Guru
diff --git a/activerecord/test/fixtures/entrants/third b/activerecord/test/fixtures/entrants/third
new file mode 100644
index 0000000000..594ac77af0
--- /dev/null
+++ b/activerecord/test/fixtures/entrants/third
@@ -0,0 +1,3 @@
+id => 3
+course_id => 2
+name => Java Lover
diff --git a/activerecord/test/fixtures/movie.rb b/activerecord/test/fixtures/movie.rb
new file mode 100644
index 0000000000..6384b4c801
--- /dev/null
+++ b/activerecord/test/fixtures/movie.rb
@@ -0,0 +1,5 @@
+class Movie < ActiveRecord::Base
+ def self.primary_key
+ "movieid"
+ end
+end
diff --git a/activerecord/test/fixtures/movies/first b/activerecord/test/fixtures/movies/first
new file mode 100644
index 0000000000..0feaeac7b0
--- /dev/null
+++ b/activerecord/test/fixtures/movies/first
@@ -0,0 +1,2 @@
+movieid => 1
+name => Terminator
diff --git a/activerecord/test/fixtures/movies/second b/activerecord/test/fixtures/movies/second
new file mode 100644
index 0000000000..b3c506b7da
--- /dev/null
+++ b/activerecord/test/fixtures/movies/second
@@ -0,0 +1,2 @@
+movieid => 2
+name => Gladiator
diff --git a/activerecord/test/fixtures/project.rb b/activerecord/test/fixtures/project.rb
new file mode 100644
index 0000000000..1ccf39d7cf
--- /dev/null
+++ b/activerecord/test/fixtures/project.rb
@@ -0,0 +1,4 @@
+class Project < ActiveRecord::Base
+ has_and_belongs_to_many :developers, :uniq => true
+ has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/projects/action_controller b/activerecord/test/fixtures/projects/action_controller
new file mode 100644
index 0000000000..b3f00ae727
--- /dev/null
+++ b/activerecord/test/fixtures/projects/action_controller
@@ -0,0 +1,2 @@
+id => 2
+name => Active Controller \ No newline at end of file
diff --git a/activerecord/test/fixtures/projects/active_record b/activerecord/test/fixtures/projects/active_record
new file mode 100644
index 0000000000..31131a7f30
--- /dev/null
+++ b/activerecord/test/fixtures/projects/active_record
@@ -0,0 +1,2 @@
+id => 1
+name => Active Record \ No newline at end of file
diff --git a/activerecord/test/fixtures/reply.rb b/activerecord/test/fixtures/reply.rb
new file mode 100755
index 0000000000..51dfe21d2d
--- /dev/null
+++ b/activerecord/test/fixtures/reply.rb
@@ -0,0 +1,21 @@
+class Reply < Topic
+ belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
+
+ attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read
+
+ def validate
+ errors.add("title", "Empty") unless attribute_present? "title"
+ errors.add("content", "Empty") unless attribute_present? "content"
+ end
+
+ def validate_on_create
+ errors.add("title", "is Wrong Create") if attribute_present?("title") && title == "Wrong Create"
+ if attribute_present?("title") && attribute_present?("content") && content == "Mismatch"
+ errors.add("title", "is Content Mismatch")
+ end
+ end
+
+ def validate_on_update
+ errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update"
+ end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/subscriber.rb b/activerecord/test/fixtures/subscriber.rb
new file mode 100644
index 0000000000..3f1ade0d83
--- /dev/null
+++ b/activerecord/test/fixtures/subscriber.rb
@@ -0,0 +1,5 @@
+class Subscriber < ActiveRecord::Base
+ def self.primary_key
+ "nick"
+ end
+end
diff --git a/activerecord/test/fixtures/subscribers/first b/activerecord/test/fixtures/subscribers/first
new file mode 100644
index 0000000000..5287e26e4d
--- /dev/null
+++ b/activerecord/test/fixtures/subscribers/first
@@ -0,0 +1,2 @@
+nick => alterself
+name => Luke Holden
diff --git a/activerecord/test/fixtures/subscribers/second b/activerecord/test/fixtures/subscribers/second
new file mode 100644
index 0000000000..2345e4475a
--- /dev/null
+++ b/activerecord/test/fixtures/subscribers/second
@@ -0,0 +1,2 @@
+nick => webster132
+name => David Heinemeier Hansson
diff --git a/activerecord/test/fixtures/topic.rb b/activerecord/test/fixtures/topic.rb
new file mode 100755
index 0000000000..55c94e9e88
--- /dev/null
+++ b/activerecord/test/fixtures/topic.rb
@@ -0,0 +1,20 @@
+class Topic < ActiveRecord::Base
+ has_many :replies, :foreign_key => "parent_id"
+ serialize :content
+
+ before_create :default_written_on
+ before_destroy :destroy_children #'self.class.delete_all "parent_id = #{id}"'
+
+ def parent
+ self.class.find(parent_id)
+ end
+
+ protected
+ def default_written_on
+ self.written_on = Time.now unless attribute_present?("written_on")
+ end
+
+ def destroy_children
+ self.class.delete_all "parent_id = #{id}"
+ end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/topics/first b/activerecord/test/fixtures/topics/first
new file mode 100755
index 0000000000..9972a578c8
--- /dev/null
+++ b/activerecord/test/fixtures/topics/first
@@ -0,0 +1,9 @@
+id => 1
+title => The First Topic
+author_name => David
+author_email_address => david@loudthinking.com
+written_on => 2003-07-16 15:28
+last_read => 2004-04-15
+content => Have a nice day
+approved => 0
+replies_count => 0 \ No newline at end of file
diff --git a/activerecord/test/fixtures/topics/second b/activerecord/test/fixtures/topics/second
new file mode 100755
index 0000000000..f669b4fef4
--- /dev/null
+++ b/activerecord/test/fixtures/topics/second
@@ -0,0 +1,8 @@
+id => 2
+title => The Second Topic's of the day
+author_name => Mary
+written_on => 2003-07-15 15:28
+content => Have a great day!
+approved => 1
+replies_count => 2
+parent_id => 1 \ No newline at end of file