aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-01 19:22:16 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-01 19:22:16 +0000
commitdaf3e92a316c041b6b2bf331c8d2a51e710fe7bf (patch)
treeca492afaf76db59ec1ab99105c07b54ffb28cc6a /activerecord/test
parenta6fefad354d36f3e9a91f8582659ffcda1a35855 (diff)
downloadrails-daf3e92a316c041b6b2bf331c8d2a51e710fe7bf.tar.gz
rails-daf3e92a316c041b6b2bf331c8d2a51e710fe7bf.tar.bz2
rails-daf3e92a316c041b6b2bf331c8d2a51e710fe7bf.zip
Added a db2 adapter that only depends on the Ruby/DB2 bindings (http://raa.ruby-lang.org/project/ruby-db2/) #386 [Maik Schmidt]. Converted all the fixtures to YAML style ones.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@303 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/associations_test.rb2
-rwxr-xr-xactiverecord/test/base_test.rb6
-rw-r--r--activerecord/test/connections/native_db2/connection.rb24
-rw-r--r--activerecord/test/fixtures/companies.yml21
-rwxr-xr-xactiverecord/test/fixtures/companies/first_client6
-rwxr-xr-xactiverecord/test/fixtures/companies/first_firm4
-rwxr-xr-xactiverecord/test/fixtures/companies/second_client6
-rw-r--r--activerecord/test/fixtures/courses.yml7
-rw-r--r--activerecord/test/fixtures/courses/java2
-rw-r--r--activerecord/test/fixtures/courses/ruby2
-rw-r--r--activerecord/test/fixtures/customers.yml7
-rw-r--r--activerecord/test/fixtures/customers/david6
-rw-r--r--activerecord/test/fixtures/db_definitions/db2.sql112
-rw-r--r--activerecord/test/fixtures/db_definitions/db22.sql4
-rw-r--r--activerecord/test/fixtures/developers_projects.yml13
-rw-r--r--activerecord/test/fixtures/entrants.yml14
-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/movies.yml7
-rw-r--r--activerecord/test/fixtures/movies/first2
-rw-r--r--activerecord/test/fixtures/movies/second2
-rw-r--r--activerecord/test/fixtures/projects.yml7
-rw-r--r--activerecord/test/fixtures/projects/action_controller2
-rw-r--r--activerecord/test/fixtures/projects/active_record2
-rw-r--r--activerecord/test/fixtures/topics.yml21
-rwxr-xr-xactiverecord/test/fixtures/topics/first10
-rwxr-xr-xactiverecord/test/fixtures/topics/second8
28 files changed, 241 insertions, 65 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 5313485ec4..feccab09ec 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -519,7 +519,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
def test_removing_associations_on_destroy
Developer.find(1).destroy
- assert Developer.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = '1'").empty?
+ assert Developer.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty?
end
def test_additional_columns_from_join_table
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 8bbf98555d..1094430dbf 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -119,7 +119,7 @@ class BasicsTest < Test::Unit::TestCase
def test_update
topic = Topic.new
topic.title = "Another New Topic"
- topic.written_on = "2003-12-12 23:23"
+ topic.written_on = "2003-12-12 23:23:00"
topic.save
id = topic.id
assert_equal(id, topic.id)
@@ -162,7 +162,7 @@ class BasicsTest < Test::Unit::TestCase
def test_destroy
topic = Topic.new
topic.title = "Yet Another New Topic"
- topic.written_on = "2003-12-12 23:23"
+ topic.written_on = "2003-12-12 23:23:00"
topic.save
id = topic.id
topic.destroy
@@ -585,4 +585,4 @@ class BasicsTest < Test::Unit::TestCase
assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1) }
assert_nothing_raised { Reply.find(should_be_destroyed_reply.id) }
end
-end \ No newline at end of file
+end
diff --git a/activerecord/test/connections/native_db2/connection.rb b/activerecord/test/connections/native_db2/connection.rb
new file mode 100644
index 0000000000..47f323945a
--- /dev/null
+++ b/activerecord/test/connections/native_db2/connection.rb
@@ -0,0 +1,24 @@
+print "Using native DB2\n"
+require 'fixtures/course'
+require 'logger'
+
+ActiveRecord::Base.logger = Logger.new("debug.log")
+
+db1 = 'arunit'
+db2 = 'arunit2'
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "db2",
+ :host => "localhost",
+ :username => "arunit",
+ :password => "arunit",
+ :database => db1
+)
+
+Course.establish_connection(
+ :adapter => "db2",
+ :host => "localhost",
+ :username => "arunit2",
+ :password => "arunit2",
+ :database => db2
+)
diff --git a/activerecord/test/fixtures/companies.yml b/activerecord/test/fixtures/companies.yml
new file mode 100644
index 0000000000..9100cfd6ab
--- /dev/null
+++ b/activerecord/test/fixtures/companies.yml
@@ -0,0 +1,21 @@
+first_client:
+ id: 2
+ type: Client
+ firm_id: 1
+ client_of: 2
+ name: Summit
+ ruby_type: Client
+
+first_firm:
+ id: 1
+ type: Firm
+ name: 37signals
+ ruby_type: Firm
+
+second_client:
+ id: 3
+ type: Client
+ firm_id: 1
+ client_of: 1
+ name: Microsoft
+ ruby_type: Client
diff --git a/activerecord/test/fixtures/companies/first_client b/activerecord/test/fixtures/companies/first_client
deleted file mode 100755
index 800c694eeb..0000000000
--- a/activerecord/test/fixtures/companies/first_client
+++ /dev/null
@@ -1,6 +0,0 @@
-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
deleted file mode 100755
index 22d876dad1..0000000000
--- a/activerecord/test/fixtures/companies/first_firm
+++ /dev/null
@@ -1,4 +0,0 @@
-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
deleted file mode 100755
index 69f8adc49c..0000000000
--- a/activerecord/test/fixtures/companies/second_client
+++ /dev/null
@@ -1,6 +0,0 @@
-id => 3
-type => Client
-firm_id => 1
-client_of => 1
-name => Microsoft
-ruby_type => Client
diff --git a/activerecord/test/fixtures/courses.yml b/activerecord/test/fixtures/courses.yml
new file mode 100644
index 0000000000..d4c0e3cfb9
--- /dev/null
+++ b/activerecord/test/fixtures/courses.yml
@@ -0,0 +1,7 @@
+java:
+ id: 2
+ name: Java Development
+
+ruby:
+ id: 1
+ name: Ruby Development
diff --git a/activerecord/test/fixtures/courses/java b/activerecord/test/fixtures/courses/java
deleted file mode 100644
index 84b10d390b..0000000000
--- a/activerecord/test/fixtures/courses/java
+++ /dev/null
@@ -1,2 +0,0 @@
-id => 2
-name => Java Development
diff --git a/activerecord/test/fixtures/courses/ruby b/activerecord/test/fixtures/courses/ruby
deleted file mode 100644
index db42f96d27..0000000000
--- a/activerecord/test/fixtures/courses/ruby
+++ /dev/null
@@ -1,2 +0,0 @@
-id => 1
-name => Ruby Development
diff --git a/activerecord/test/fixtures/customers.yml b/activerecord/test/fixtures/customers.yml
new file mode 100644
index 0000000000..1a83a54a9c
--- /dev/null
+++ b/activerecord/test/fixtures/customers.yml
@@ -0,0 +1,7 @@
+david:
+ id: 1
+ name: David
+ balance: 50
+ address_street: Funny Street
+ address_city: Scary Town
+ address_country: Loony Land
diff --git a/activerecord/test/fixtures/customers/david b/activerecord/test/fixtures/customers/david
deleted file mode 100644
index 69b9c32376..0000000000
--- a/activerecord/test/fixtures/customers/david
+++ /dev/null
@@ -1,6 +0,0 @@
-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/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql
new file mode 100644
index 0000000000..7171bd3e16
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/db2.sql
@@ -0,0 +1,112 @@
+CREATE TABLE accounts (
+ id int generated by default as identity (start with +10000),
+ firm_id int default NULL,
+ credit_limit int default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE companies (
+ id int generated by default as identity (start with +10000),
+ 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,
+ rating int default 1,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE topics (
+ id int generated by default as identity (start with +10000),
+ title varchar(255) default NULL,
+ author_name varchar(255) default NULL,
+ author_email_address varchar(255) default NULL,
+ written_on timestamp default NULL,
+ bonus_time time default NULL,
+ last_read date default NULL,
+ content varchar(3000),
+ approved smallint 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 generated by default as identity (start with +10000),
+ name varchar(100) default NULL,
+ salary int default 70000,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE projects (
+ id int generated by default as identity (start with +10000),
+ name varchar(100) default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE developers_projects (
+ developer_id int NOT NULL,
+ project_id int NOT NULL,
+ joined_on date default NULL
+);
+
+CREATE TABLE customers (
+ id int generated by default as identity (start with +10000),
+ 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 generated by default as identity (start with +10000),
+ 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 generated by default as identity (start with +10000),
+ value int default NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE auto_id_tests (
+ auto_id int generated by default as identity (start with +10000),
+ 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 generated by default as identity (start with +10000),
+ references int NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE mixins (
+ id int generated by default as identity (start with +10000),
+ parent_id int default NULL,
+ pos int default NULL,
+ created_at timestamp default NULL,
+ updated_at timestamp default NULL,
+ lft int default NULL,
+ rgt int default NULL,
+ root_id int default NULL,
+ type varchar(40) default NULL,
+ PRIMARY KEY (id)
+);
+
diff --git a/activerecord/test/fixtures/db_definitions/db22.sql b/activerecord/test/fixtures/db_definitions/db22.sql
new file mode 100644
index 0000000000..dc4f9ed364
--- /dev/null
+++ b/activerecord/test/fixtures/db_definitions/db22.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/developers_projects.yml b/activerecord/test/fixtures/developers_projects.yml
new file mode 100644
index 0000000000..b1194a6f16
--- /dev/null
+++ b/activerecord/test/fixtures/developers_projects.yml
@@ -0,0 +1,13 @@
+david_action_controller:
+ developer_id: 1
+ project_id: 2
+ joined_on: 2004-10-10
+
+david_active_record:
+ developer_id: 1
+ project_id: 1
+ joined_on: 2004-10-10
+
+jamis_active_record:
+ developer_id: 2
+ project_id: 1
diff --git a/activerecord/test/fixtures/entrants.yml b/activerecord/test/fixtures/entrants.yml
new file mode 100644
index 0000000000..86f0108e52
--- /dev/null
+++ b/activerecord/test/fixtures/entrants.yml
@@ -0,0 +1,14 @@
+first:
+ id: 1
+ course_id: 1
+ name: Ruby Developer
+
+second:
+ id: 2
+ course_id: 1
+ name: Ruby Guru
+
+third:
+ id: 3
+ course_id: 2
+ name: Java Lover
diff --git a/activerecord/test/fixtures/entrants/first b/activerecord/test/fixtures/entrants/first
deleted file mode 100644
index e45cd6c1c2..0000000000
--- a/activerecord/test/fixtures/entrants/first
+++ /dev/null
@@ -1,3 +0,0 @@
-id => 1
-course_id => 1
-name => Ruby Developer
diff --git a/activerecord/test/fixtures/entrants/second b/activerecord/test/fixtures/entrants/second
deleted file mode 100644
index 38cd702476..0000000000
--- a/activerecord/test/fixtures/entrants/second
+++ /dev/null
@@ -1,3 +0,0 @@
-id => 2
-course_id => 1
-name => Ruby Guru
diff --git a/activerecord/test/fixtures/entrants/third b/activerecord/test/fixtures/entrants/third
deleted file mode 100644
index 594ac77af0..0000000000
--- a/activerecord/test/fixtures/entrants/third
+++ /dev/null
@@ -1,3 +0,0 @@
-id => 3
-course_id => 2
-name => Java Lover
diff --git a/activerecord/test/fixtures/movies.yml b/activerecord/test/fixtures/movies.yml
new file mode 100644
index 0000000000..2e9154fda8
--- /dev/null
+++ b/activerecord/test/fixtures/movies.yml
@@ -0,0 +1,7 @@
+first:
+ movieid: 1
+ name: Terminator
+
+second:
+ movieid: 2
+ name: Gladiator
diff --git a/activerecord/test/fixtures/movies/first b/activerecord/test/fixtures/movies/first
deleted file mode 100644
index 0feaeac7b0..0000000000
--- a/activerecord/test/fixtures/movies/first
+++ /dev/null
@@ -1,2 +0,0 @@
-movieid => 1
-name => Terminator
diff --git a/activerecord/test/fixtures/movies/second b/activerecord/test/fixtures/movies/second
deleted file mode 100644
index b3c506b7da..0000000000
--- a/activerecord/test/fixtures/movies/second
+++ /dev/null
@@ -1,2 +0,0 @@
-movieid => 2
-name => Gladiator
diff --git a/activerecord/test/fixtures/projects.yml b/activerecord/test/fixtures/projects.yml
new file mode 100644
index 0000000000..02800c7824
--- /dev/null
+++ b/activerecord/test/fixtures/projects.yml
@@ -0,0 +1,7 @@
+action_controller:
+ id: 2
+ name: Active Controller
+
+active_record:
+ id: 1
+ name: Active Record
diff --git a/activerecord/test/fixtures/projects/action_controller b/activerecord/test/fixtures/projects/action_controller
deleted file mode 100644
index b3f00ae727..0000000000
--- a/activerecord/test/fixtures/projects/action_controller
+++ /dev/null
@@ -1,2 +0,0 @@
-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
deleted file mode 100644
index 31131a7f30..0000000000
--- a/activerecord/test/fixtures/projects/active_record
+++ /dev/null
@@ -1,2 +0,0 @@
-id => 1
-name => Active Record \ No newline at end of file
diff --git a/activerecord/test/fixtures/topics.yml b/activerecord/test/fixtures/topics.yml
new file mode 100644
index 0000000000..5571bd914c
--- /dev/null
+++ b/activerecord/test/fixtures/topics.yml
@@ -0,0 +1,21 @@
+first:
+ id: 1
+ title: The First Topic
+ author_name: David
+ author_email_address: david@loudthinking.com
+ written_on: 2003-07-16 15:28:00
+ bonus_time: 12:13:14
+ last_read: 2004-04-15
+ content: Have a nice day
+ approved: 0
+ replies_count: 0
+
+second:
+ id: 2
+ title: The Second Topic's of the day
+ author_name: Mary
+ written_on: 2003-07-15 15:28:00
+ content: Have a great day!
+ approved: 1
+ replies_count: 2
+ parent_id: 1
diff --git a/activerecord/test/fixtures/topics/first b/activerecord/test/fixtures/topics/first
deleted file mode 100755
index 2e1a88563b..0000000000
--- a/activerecord/test/fixtures/topics/first
+++ /dev/null
@@ -1,10 +0,0 @@
-id => 1
-title => The First Topic
-author_name => David
-author_email_address => david@loudthinking.com
-written_on => 2003-07-16 15:28
-bonus_time => 12:13:14
-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
deleted file mode 100755
index f669b4fef4..0000000000
--- a/activerecord/test/fixtures/topics/second
+++ /dev/null
@@ -1,8 +0,0 @@
-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