activerecord 1.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2102 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +213 -0
- data/examples/performance.rb +172 -0
- data/examples/simple.rb +14 -0
- data/lib/active_record/aggregations.rb +180 -84
- data/lib/active_record/associations/alias_tracker.rb +76 -0
- data/lib/active_record/associations/association.rb +248 -0
- data/lib/active_record/associations/association_scope.rb +135 -0
- data/lib/active_record/associations/belongs_to_association.rb +92 -0
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +35 -0
- data/lib/active_record/associations/builder/association.rb +108 -0
- data/lib/active_record/associations/builder/belongs_to.rb +98 -0
- data/lib/active_record/associations/builder/collection_association.rb +89 -0
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +39 -0
- data/lib/active_record/associations/builder/has_many.rb +15 -0
- data/lib/active_record/associations/builder/has_one.rb +25 -0
- data/lib/active_record/associations/builder/singular_association.rb +32 -0
- data/lib/active_record/associations/collection_association.rb +608 -0
- data/lib/active_record/associations/collection_proxy.rb +986 -0
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +58 -39
- data/lib/active_record/associations/has_many_association.rb +116 -85
- data/lib/active_record/associations/has_many_through_association.rb +197 -0
- data/lib/active_record/associations/has_one_association.rb +102 -0
- data/lib/active_record/associations/has_one_through_association.rb +36 -0
- data/lib/active_record/associations/join_dependency/join_association.rb +174 -0
- data/lib/active_record/associations/join_dependency/join_base.rb +24 -0
- data/lib/active_record/associations/join_dependency/join_part.rb +78 -0
- data/lib/active_record/associations/join_dependency.rb +235 -0
- data/lib/active_record/associations/join_helper.rb +45 -0
- data/lib/active_record/associations/preloader/association.rb +121 -0
- data/lib/active_record/associations/preloader/belongs_to.rb +17 -0
- data/lib/active_record/associations/preloader/collection_association.rb +24 -0
- data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +60 -0
- data/lib/active_record/associations/preloader/has_many.rb +17 -0
- data/lib/active_record/associations/preloader/has_many_through.rb +19 -0
- data/lib/active_record/associations/preloader/has_one.rb +23 -0
- data/lib/active_record/associations/preloader/has_one_through.rb +9 -0
- data/lib/active_record/associations/preloader/singular_association.rb +21 -0
- data/lib/active_record/associations/preloader/through_association.rb +63 -0
- data/lib/active_record/associations/preloader.rb +178 -0
- data/lib/active_record/associations/singular_association.rb +64 -0
- data/lib/active_record/associations/through_association.rb +87 -0
- data/lib/active_record/associations.rb +1437 -431
- data/lib/active_record/attribute_assignment.rb +201 -0
- data/lib/active_record/attribute_methods/before_type_cast.rb +70 -0
- data/lib/active_record/attribute_methods/dirty.rb +118 -0
- data/lib/active_record/attribute_methods/primary_key.rb +122 -0
- data/lib/active_record/attribute_methods/query.rb +40 -0
- data/lib/active_record/attribute_methods/read.rb +107 -0
- data/lib/active_record/attribute_methods/serialization.rb +162 -0
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +59 -0
- data/lib/active_record/attribute_methods/write.rb +63 -0
- data/lib/active_record/attribute_methods.rb +393 -0
- data/lib/active_record/autosave_association.rb +426 -0
- data/lib/active_record/base.rb +268 -930
- data/lib/active_record/callbacks.rb +203 -230
- data/lib/active_record/coders/yaml_column.rb +38 -0
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +638 -0
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +67 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +390 -0
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +95 -0
- data/lib/active_record/connection_adapters/abstract/quoting.rb +129 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +501 -0
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +70 -0
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +873 -0
- data/lib/active_record/connection_adapters/abstract/transaction.rb +203 -0
- data/lib/active_record/connection_adapters/abstract_adapter.rb +389 -275
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +782 -0
- data/lib/active_record/connection_adapters/column.rb +318 -0
- data/lib/active_record/connection_adapters/connection_specification.rb +96 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +273 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +517 -90
- data/lib/active_record/connection_adapters/postgresql/array_parser.rb +97 -0
- data/lib/active_record/connection_adapters/postgresql/cast.rb +152 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +242 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +366 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +171 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +30 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +489 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +911 -138
- data/lib/active_record/connection_adapters/schema_cache.rb +129 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +624 -0
- data/lib/active_record/connection_adapters/statement_pool.rb +40 -0
- data/lib/active_record/connection_handling.rb +98 -0
- data/lib/active_record/core.rb +463 -0
- data/lib/active_record/counter_cache.rb +122 -0
- data/lib/active_record/dynamic_matchers.rb +131 -0
- data/lib/active_record/errors.rb +213 -0
- data/lib/active_record/explain.rb +38 -0
- data/lib/active_record/explain_registry.rb +30 -0
- data/lib/active_record/explain_subscriber.rb +29 -0
- data/lib/active_record/fixture_set/file.rb +55 -0
- data/lib/active_record/fixtures.rb +892 -138
- data/lib/active_record/inheritance.rb +200 -0
- data/lib/active_record/integration.rb +60 -0
- data/lib/active_record/locale/en.yml +47 -0
- data/lib/active_record/locking/optimistic.rb +181 -0
- data/lib/active_record/locking/pessimistic.rb +77 -0
- data/lib/active_record/log_subscriber.rb +82 -0
- data/lib/active_record/migration/command_recorder.rb +164 -0
- data/lib/active_record/migration/join_table.rb +15 -0
- data/lib/active_record/migration.rb +1015 -0
- data/lib/active_record/model_schema.rb +345 -0
- data/lib/active_record/nested_attributes.rb +546 -0
- data/lib/active_record/null_relation.rb +65 -0
- data/lib/active_record/persistence.rb +509 -0
- data/lib/active_record/query_cache.rb +56 -0
- data/lib/active_record/querying.rb +62 -0
- data/lib/active_record/railtie.rb +205 -0
- data/lib/active_record/railties/console_sandbox.rb +5 -0
- data/lib/active_record/railties/controller_runtime.rb +50 -0
- data/lib/active_record/railties/databases.rake +402 -0
- data/lib/active_record/railties/jdbcmysql_error.rb +16 -0
- data/lib/active_record/readonly_attributes.rb +30 -0
- data/lib/active_record/reflection.rb +544 -87
- data/lib/active_record/relation/batches.rb +93 -0
- data/lib/active_record/relation/calculations.rb +399 -0
- data/lib/active_record/relation/delegation.rb +125 -0
- data/lib/active_record/relation/finder_methods.rb +349 -0
- data/lib/active_record/relation/merger.rb +161 -0
- data/lib/active_record/relation/predicate_builder.rb +106 -0
- data/lib/active_record/relation/query_methods.rb +1044 -0
- data/lib/active_record/relation/spawn_methods.rb +73 -0
- data/lib/active_record/relation.rb +655 -0
- data/lib/active_record/result.rb +67 -0
- data/lib/active_record/runtime_registry.rb +17 -0
- data/lib/active_record/sanitization.rb +168 -0
- data/lib/active_record/schema.rb +65 -0
- data/lib/active_record/schema_dumper.rb +204 -0
- data/lib/active_record/schema_migration.rb +39 -0
- data/lib/active_record/scoping/default.rb +146 -0
- data/lib/active_record/scoping/named.rb +175 -0
- data/lib/active_record/scoping.rb +82 -0
- data/lib/active_record/serialization.rb +22 -0
- data/lib/active_record/serializers/xml_serializer.rb +197 -0
- data/lib/active_record/statement_cache.rb +26 -0
- data/lib/active_record/store.rb +156 -0
- data/lib/active_record/tasks/database_tasks.rb +203 -0
- data/lib/active_record/tasks/firebird_database_tasks.rb +56 -0
- data/lib/active_record/tasks/mysql_database_tasks.rb +143 -0
- data/lib/active_record/tasks/oracle_database_tasks.rb +45 -0
- data/lib/active_record/tasks/postgresql_database_tasks.rb +90 -0
- data/lib/active_record/tasks/sqlite_database_tasks.rb +51 -0
- data/lib/active_record/tasks/sqlserver_database_tasks.rb +48 -0
- data/lib/active_record/test_case.rb +96 -0
- data/lib/active_record/timestamp.rb +119 -0
- data/lib/active_record/transactions.rb +366 -69
- data/lib/active_record/translation.rb +22 -0
- data/lib/active_record/validations/associated.rb +49 -0
- data/lib/active_record/validations/presence.rb +65 -0
- data/lib/active_record/validations/uniqueness.rb +225 -0
- data/lib/active_record/validations.rb +64 -185
- data/lib/active_record/version.rb +11 -0
- data/lib/active_record.rb +149 -24
- data/lib/rails/generators/active_record/migration/migration_generator.rb +62 -0
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +19 -0
- data/lib/rails/generators/active_record/migration/templates/migration.rb +39 -0
- data/lib/rails/generators/active_record/model/model_generator.rb +48 -0
- data/lib/rails/generators/active_record/model/templates/model.rb +10 -0
- data/lib/rails/generators/active_record/model/templates/module.rb +7 -0
- data/lib/rails/generators/active_record.rb +23 -0
- metadata +261 -161
- data/CHANGELOG +0 -581
- data/README +0 -361
- data/RUNNING_UNIT_TESTS +0 -36
- data/dev-utils/eval_debugger.rb +0 -9
- data/examples/associations.png +0 -0
- data/examples/associations.rb +0 -87
- data/examples/shared_setup.rb +0 -15
- data/examples/validation.rb +0 -88
- data/install.rb +0 -60
- data/lib/active_record/associations/association_collection.rb +0 -70
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -107
- data/lib/active_record/deprecated_associations.rb +0 -70
- data/lib/active_record/observer.rb +0 -71
- data/lib/active_record/support/class_attribute_accessors.rb +0 -43
- data/lib/active_record/support/class_inheritable_attributes.rb +0 -37
- data/lib/active_record/support/clean_logger.rb +0 -10
- data/lib/active_record/support/inflector.rb +0 -70
- data/lib/active_record/vendor/mysql.rb +0 -1117
- data/lib/active_record/vendor/simple.rb +0 -702
- data/lib/active_record/wrappers/yaml_wrapper.rb +0 -15
- data/lib/active_record/wrappings.rb +0 -59
- data/rakefile +0 -122
- data/test/abstract_unit.rb +0 -16
- data/test/aggregations_test.rb +0 -34
- data/test/all.sh +0 -8
- data/test/associations_test.rb +0 -477
- data/test/base_test.rb +0 -513
- data/test/class_inheritable_attributes_test.rb +0 -33
- data/test/connections/native_mysql/connection.rb +0 -24
- data/test/connections/native_postgresql/connection.rb +0 -24
- data/test/connections/native_sqlite/connection.rb +0 -24
- data/test/deprecated_associations_test.rb +0 -336
- data/test/finder_test.rb +0 -67
- data/test/fixtures/accounts/signals37 +0 -3
- data/test/fixtures/accounts/unknown +0 -2
- data/test/fixtures/auto_id.rb +0 -4
- data/test/fixtures/column_name.rb +0 -3
- data/test/fixtures/companies/first_client +0 -6
- data/test/fixtures/companies/first_firm +0 -4
- data/test/fixtures/companies/second_client +0 -6
- data/test/fixtures/company.rb +0 -37
- data/test/fixtures/company_in_module.rb +0 -33
- data/test/fixtures/course.rb +0 -3
- data/test/fixtures/courses/java +0 -2
- data/test/fixtures/courses/ruby +0 -2
- data/test/fixtures/customer.rb +0 -30
- data/test/fixtures/customers/david +0 -6
- data/test/fixtures/db_definitions/mysql.sql +0 -96
- data/test/fixtures/db_definitions/mysql2.sql +0 -4
- data/test/fixtures/db_definitions/postgresql.sql +0 -113
- data/test/fixtures/db_definitions/postgresql2.sql +0 -4
- data/test/fixtures/db_definitions/sqlite.sql +0 -85
- data/test/fixtures/db_definitions/sqlite2.sql +0 -4
- data/test/fixtures/default.rb +0 -2
- data/test/fixtures/developer.rb +0 -8
- data/test/fixtures/developers/david +0 -2
- data/test/fixtures/developers/jamis +0 -2
- data/test/fixtures/developers_projects/david_action_controller +0 -2
- data/test/fixtures/developers_projects/david_active_record +0 -2
- data/test/fixtures/developers_projects/jamis_active_record +0 -2
- data/test/fixtures/entrant.rb +0 -3
- data/test/fixtures/entrants/first +0 -3
- data/test/fixtures/entrants/second +0 -3
- data/test/fixtures/entrants/third +0 -3
- data/test/fixtures/fixture_database.sqlite +0 -0
- data/test/fixtures/fixture_database_2.sqlite +0 -0
- data/test/fixtures/movie.rb +0 -5
- data/test/fixtures/movies/first +0 -2
- data/test/fixtures/movies/second +0 -2
- data/test/fixtures/project.rb +0 -3
- data/test/fixtures/projects/action_controller +0 -2
- data/test/fixtures/projects/active_record +0 -2
- data/test/fixtures/reply.rb +0 -21
- data/test/fixtures/subscriber.rb +0 -5
- data/test/fixtures/subscribers/first +0 -2
- data/test/fixtures/subscribers/second +0 -2
- data/test/fixtures/topic.rb +0 -20
- data/test/fixtures/topics/first +0 -9
- data/test/fixtures/topics/second +0 -8
- data/test/fixtures_test.rb +0 -20
- data/test/inflector_test.rb +0 -104
- data/test/inheritance_test.rb +0 -125
- data/test/lifecycle_test.rb +0 -110
- data/test/modules_test.rb +0 -21
- data/test/multiple_db_test.rb +0 -46
- data/test/pk_test.rb +0 -57
- data/test/reflection_test.rb +0 -78
- data/test/thread_safety_test.rb +0 -33
- data/test/transactions_test.rb +0 -83
- data/test/unconnected_test.rb +0 -24
- data/test/validations_test.rb +0 -126
@@ -1,113 +0,0 @@
|
|
1
|
-
SET search_path = public, pg_catalog;
|
2
|
-
|
3
|
-
CREATE TABLE accounts (
|
4
|
-
id serial,
|
5
|
-
firm_id integer,
|
6
|
-
credit_limit integer,
|
7
|
-
PRIMARY KEY (id)
|
8
|
-
);
|
9
|
-
SELECT setval('accounts_id_seq', 100);
|
10
|
-
|
11
|
-
CREATE TABLE companies (
|
12
|
-
id serial,
|
13
|
-
"type" character varying(50),
|
14
|
-
"ruby_type" character varying(50),
|
15
|
-
firm_id integer,
|
16
|
-
name character varying(50),
|
17
|
-
client_of integer,
|
18
|
-
rating integer default 1,
|
19
|
-
PRIMARY KEY (id)
|
20
|
-
);
|
21
|
-
SELECT setval('companies_id_seq', 100);
|
22
|
-
|
23
|
-
CREATE TABLE developers_projects (
|
24
|
-
developer_id integer NOT NULL,
|
25
|
-
project_id integer NOT NULL
|
26
|
-
);
|
27
|
-
|
28
|
-
CREATE TABLE developers (
|
29
|
-
id serial,
|
30
|
-
name character varying(100),
|
31
|
-
PRIMARY KEY (id)
|
32
|
-
);
|
33
|
-
SELECT setval('developers_id_seq', 100);
|
34
|
-
|
35
|
-
CREATE TABLE projects (
|
36
|
-
id serial,
|
37
|
-
name character varying(100),
|
38
|
-
PRIMARY KEY (id)
|
39
|
-
);
|
40
|
-
SELECT setval('projects_id_seq', 100);
|
41
|
-
|
42
|
-
CREATE TABLE topics (
|
43
|
-
id serial,
|
44
|
-
title character varying(255),
|
45
|
-
author_name character varying(255),
|
46
|
-
author_email_address character varying(255),
|
47
|
-
written_on timestamp without time zone,
|
48
|
-
last_read date,
|
49
|
-
content text,
|
50
|
-
replies_count integer default 0,
|
51
|
-
parent_id integer,
|
52
|
-
"type" character varying(50),
|
53
|
-
approved smallint DEFAULT 1,
|
54
|
-
PRIMARY KEY (id)
|
55
|
-
);
|
56
|
-
SELECT setval('topics_id_seq', 100);
|
57
|
-
|
58
|
-
CREATE TABLE customers (
|
59
|
-
id serial,
|
60
|
-
name character varying,
|
61
|
-
balance integer default 0,
|
62
|
-
address_street character varying,
|
63
|
-
address_city character varying,
|
64
|
-
address_country character varying,
|
65
|
-
PRIMARY KEY (id)
|
66
|
-
);
|
67
|
-
SELECT setval('customers_id_seq', 100);
|
68
|
-
|
69
|
-
CREATE TABLE movies (
|
70
|
-
movieid serial,
|
71
|
-
name text,
|
72
|
-
PRIMARY KEY (movieid)
|
73
|
-
);
|
74
|
-
|
75
|
-
CREATE TABLE subscribers (
|
76
|
-
nick text NOT NULL,
|
77
|
-
name text,
|
78
|
-
PRIMARY KEY (nick)
|
79
|
-
);
|
80
|
-
|
81
|
-
CREATE TABLE booleantests (
|
82
|
-
id serial,
|
83
|
-
value boolean,
|
84
|
-
PRIMARY KEY (id)
|
85
|
-
);
|
86
|
-
|
87
|
-
CREATE TABLE defaults (
|
88
|
-
id serial,
|
89
|
-
modified_date date default CURRENT_DATE,
|
90
|
-
fixed_date date default '2004-01-01',
|
91
|
-
modified_time timestamp default CURRENT_TIMESTAMP,
|
92
|
-
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
93
|
-
char1 char(1) default 'Y',
|
94
|
-
char2 character varying(50) default 'a varchar field',
|
95
|
-
char3 text default 'a text field'
|
96
|
-
);
|
97
|
-
|
98
|
-
CREATE TABLE auto_id_tests (
|
99
|
-
auto_id serial,
|
100
|
-
value integer,
|
101
|
-
PRIMARY KEY (auto_id)
|
102
|
-
);
|
103
|
-
|
104
|
-
CREATE TABLE entrants (
|
105
|
-
id serial,
|
106
|
-
name text,
|
107
|
-
course_id integer
|
108
|
-
);
|
109
|
-
|
110
|
-
CREATE TABLE colnametests (
|
111
|
-
id serial,
|
112
|
-
"references" integer NOT NULL
|
113
|
-
);
|
@@ -1,85 +0,0 @@
|
|
1
|
-
CREATE TABLE 'accounts' (
|
2
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
3
|
-
'firm_id' INTEGER DEFAULT NULL,
|
4
|
-
'credit_limit' INTEGER DEFAULT NULL
|
5
|
-
);
|
6
|
-
|
7
|
-
CREATE TABLE 'companies' (
|
8
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
9
|
-
'type' VARCHAR(255) DEFAULT NULL,
|
10
|
-
'ruby_type' VARCHAR(255) DEFAULT NULL,
|
11
|
-
'firm_id' INTEGER DEFAULT NULL,
|
12
|
-
'name' TEXT DEFAULT NULL,
|
13
|
-
'client_of' INTEGER DEFAULT NULL,
|
14
|
-
'rating' INTEGER DEFAULT 1
|
15
|
-
);
|
16
|
-
|
17
|
-
|
18
|
-
CREATE TABLE 'topics' (
|
19
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
20
|
-
'title' VARCHAR(255) DEFAULT NULL,
|
21
|
-
'author_name' VARCHAR(255) DEFAULT NULL,
|
22
|
-
'author_email_address' VARCHAR(255) DEFAULT NULL,
|
23
|
-
'written_on' DATETIME DEFAULT NULL,
|
24
|
-
'last_read' DATE DEFAULT NULL,
|
25
|
-
'content' TEXT,
|
26
|
-
'approved' INTEGER DEFAULT 1,
|
27
|
-
'replies_count' INTEGER DEFAULT 0,
|
28
|
-
'parent_id' INTEGER DEFAULT NULL,
|
29
|
-
'type' VARCHAR(255) DEFAULT NULL
|
30
|
-
);
|
31
|
-
|
32
|
-
CREATE TABLE 'developers' (
|
33
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
34
|
-
'name' TEXT DEFAULT NULL
|
35
|
-
);
|
36
|
-
|
37
|
-
CREATE TABLE 'projects' (
|
38
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
39
|
-
'name' TEXT DEFAULT NULL
|
40
|
-
);
|
41
|
-
|
42
|
-
CREATE TABLE 'developers_projects' (
|
43
|
-
'developer_id' INTEGER NOT NULL,
|
44
|
-
'project_id' INTEGER NOT NULL
|
45
|
-
);
|
46
|
-
|
47
|
-
CREATE TABLE 'customers' (
|
48
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
49
|
-
'name' VARCHAR(255) DEFAULT NULL,
|
50
|
-
'balance' INTEGER DEFAULT 0,
|
51
|
-
'address_street' TEXT DEFAULT NULL,
|
52
|
-
'address_city' TEXT DEFAULT NULL,
|
53
|
-
'address_country' TEXT DEFAULT NULL
|
54
|
-
);
|
55
|
-
|
56
|
-
CREATE TABLE 'movies' (
|
57
|
-
'movieid' INTEGER PRIMARY KEY NOT NULL,
|
58
|
-
'name' VARCHAR(255) DEFAULT NULL
|
59
|
-
);
|
60
|
-
|
61
|
-
CREATE TABLE subscribers (
|
62
|
-
'nick' VARCHAR(255) PRIMARY KEY NOT NULL,
|
63
|
-
'name' VARCHAR(255) DEFAULT NULL
|
64
|
-
);
|
65
|
-
|
66
|
-
CREATE TABLE 'booleantests' (
|
67
|
-
'id' INTEGER PRIMARY KEY NOT NULL,
|
68
|
-
'value' INTEGER DEFAULT NULL
|
69
|
-
);
|
70
|
-
|
71
|
-
CREATE TABLE 'auto_id_tests' (
|
72
|
-
'auto_id' INTEGER PRIMARY KEY NOT NULL,
|
73
|
-
'value' INTEGER DEFAULT NULL
|
74
|
-
);
|
75
|
-
|
76
|
-
CREATE TABLE 'entrants' (
|
77
|
-
'id' INTEGER NOT NULL PRIMARY KEY,
|
78
|
-
'name' VARCHAR(255) NOT NULL,
|
79
|
-
'course_id' INTEGER NOT NULL
|
80
|
-
);
|
81
|
-
|
82
|
-
CREATE TABLE 'colnametests' (
|
83
|
-
'id' INTEGER NOT NULL PRIMARY KEY,
|
84
|
-
'references' INTEGER NOT NULL
|
85
|
-
);
|
data/test/fixtures/default.rb
DELETED
data/test/fixtures/developer.rb
DELETED
data/test/fixtures/entrant.rb
DELETED
Binary file
|
Binary file
|
data/test/fixtures/movie.rb
DELETED
data/test/fixtures/movies/first
DELETED
data/test/fixtures/movies/second
DELETED
data/test/fixtures/project.rb
DELETED
data/test/fixtures/reply.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Reply < Topic
|
2
|
-
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
|
3
|
-
|
4
|
-
attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read
|
5
|
-
|
6
|
-
def validate
|
7
|
-
errors.add("title", "Empty") unless attribute_present? "title"
|
8
|
-
errors.add("content", "Empty") unless attribute_present? "content"
|
9
|
-
end
|
10
|
-
|
11
|
-
def validate_on_create
|
12
|
-
errors.add("title", "is Wrong Create") if attribute_present?("title") && title == "Wrong Create"
|
13
|
-
if attribute_present?("title") && attribute_present?("content") && content == "Mismatch"
|
14
|
-
errors.add("title", "is Content Mismatch")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def validate_on_update
|
19
|
-
errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update"
|
20
|
-
end
|
21
|
-
end
|
data/test/fixtures/subscriber.rb
DELETED
data/test/fixtures/topic.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class Topic < ActiveRecord::Base
|
2
|
-
has_many :replies, :foreign_key => "parent_id"
|
3
|
-
serialize :content
|
4
|
-
|
5
|
-
before_create :default_written_on
|
6
|
-
before_destroy :destroy_children #'self.class.delete_all "parent_id = #{id}"'
|
7
|
-
|
8
|
-
def parent
|
9
|
-
self.class.find(parent_id)
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
def default_written_on
|
14
|
-
self.written_on = Time.now unless attribute_present?("written_on")
|
15
|
-
end
|
16
|
-
|
17
|
-
def destroy_children
|
18
|
-
self.class.delete_all "parent_id = #{id}"
|
19
|
-
end
|
20
|
-
end
|
data/test/fixtures/topics/first
DELETED
data/test/fixtures/topics/second
DELETED
data/test/fixtures_test.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
|
3
|
-
class FixturesTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@fixtures = create_fixtures("topics")
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_attributes
|
9
|
-
assert_equal("The First Topic", @fixtures["first"]["title"])
|
10
|
-
assert_nil(@fixtures["second"]["author_email_address"])
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_inserts
|
14
|
-
firstRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
|
15
|
-
assert_equal("The First Topic", firstRow["title"])
|
16
|
-
|
17
|
-
secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'")
|
18
|
-
assert_nil(secondRow["author_email_address"])
|
19
|
-
end
|
20
|
-
end
|
data/test/inflector_test.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
|
3
|
-
class InflectorTest < Test::Unit::TestCase
|
4
|
-
SingularToPlural = {
|
5
|
-
"search" => "searches",
|
6
|
-
"switch" => "switches",
|
7
|
-
"fix" => "fixes",
|
8
|
-
"box" => "boxes",
|
9
|
-
"process" => "processes",
|
10
|
-
"address" => "addresses",
|
11
|
-
"case" => "cases",
|
12
|
-
"stack" => "stacks",
|
13
|
-
|
14
|
-
"category" => "categories",
|
15
|
-
"query" => "queries",
|
16
|
-
"ability" => "abilities",
|
17
|
-
"agency" => "agencies",
|
18
|
-
|
19
|
-
"wife" => "wives",
|
20
|
-
"safe" => "saves",
|
21
|
-
"half" => "halves",
|
22
|
-
|
23
|
-
"salesperson" => "salespeople",
|
24
|
-
"person" => "people",
|
25
|
-
|
26
|
-
"spokesman" => "spokesmen",
|
27
|
-
"man" => "men",
|
28
|
-
"woman" => "women",
|
29
|
-
|
30
|
-
"basis" => "bases",
|
31
|
-
"diagnosis" => "diagnoses",
|
32
|
-
|
33
|
-
"datum" => "data",
|
34
|
-
"medium" => "media",
|
35
|
-
|
36
|
-
"node_child" => "node_children",
|
37
|
-
"child" => "children",
|
38
|
-
|
39
|
-
"experience" => "experiences",
|
40
|
-
"day" => "days",
|
41
|
-
|
42
|
-
"comment" => "comments",
|
43
|
-
"foobar" => "foobars"
|
44
|
-
}
|
45
|
-
|
46
|
-
CamelToUnderscore = {
|
47
|
-
"Product" => "product",
|
48
|
-
"SpecialGuest" => "special_guest",
|
49
|
-
"AbstractApplicationController" => "abstract_application_controller"
|
50
|
-
}
|
51
|
-
|
52
|
-
ClassNameToForeignKeyWithUnderscore = {
|
53
|
-
"Person" => "person_id",
|
54
|
-
"MyApplication::Billing::Account" => "account_id"
|
55
|
-
}
|
56
|
-
|
57
|
-
ClassNameToForeignKeyWithoutUnderscore = {
|
58
|
-
"Person" => "personid",
|
59
|
-
"MyApplication::Billing::Account" => "accountid"
|
60
|
-
}
|
61
|
-
|
62
|
-
def test_pluralize
|
63
|
-
SingularToPlural.each do |singular, plural|
|
64
|
-
assert_equal(plural, Inflector.pluralize(singular))
|
65
|
-
end
|
66
|
-
|
67
|
-
assert_equal("plurals", Inflector.pluralize("plurals"))
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_singularize
|
71
|
-
SingularToPlural.each do |singular, plural|
|
72
|
-
assert_equal(singular, Inflector.singularize(plural))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_camelize
|
77
|
-
CamelToUnderscore.each do |camel, underscore|
|
78
|
-
assert_equal(camel, Inflector.camelize(underscore))
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_underscore
|
83
|
-
CamelToUnderscore.each do |camel, underscore|
|
84
|
-
assert_equal(underscore, Inflector.underscore(camel))
|
85
|
-
end
|
86
|
-
|
87
|
-
assert_equal "html_tidy", Inflector.underscore("HTMLTidy")
|
88
|
-
assert_equal "html_tidy_generator", Inflector.underscore("HTMLTidyGenerator")
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_demodulize
|
92
|
-
assert_equal "Account", Inflector.demodulize("MyApplication::Billing::Account")
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_foreign_key
|
96
|
-
ClassNameToForeignKeyWithUnderscore.each do |klass, foreign_key|
|
97
|
-
assert_equal(foreign_key, Inflector.foreign_key(klass))
|
98
|
-
end
|
99
|
-
|
100
|
-
ClassNameToForeignKeyWithoutUnderscore.each do |klass, foreign_key|
|
101
|
-
assert_equal(foreign_key, Inflector.foreign_key(klass, false))
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
data/test/inheritance_test.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'abstract_unit'
|
2
|
-
require 'fixtures/company'
|
3
|
-
|
4
|
-
|
5
|
-
class InheritanceTest < Test::Unit::TestCase
|
6
|
-
def setup
|
7
|
-
@company_fixtures = create_fixtures "companies"
|
8
|
-
end
|
9
|
-
|
10
|
-
def switch_to_alt_inheritance_column
|
11
|
-
# we don't want misleading test results, so get rid of the values in the type column
|
12
|
-
Company.find_all(nil, "id").each do |c|
|
13
|
-
c['type'] = nil
|
14
|
-
c.save
|
15
|
-
end
|
16
|
-
|
17
|
-
def Company.inheritance_column() "ruby_type" end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_inheritance_find
|
21
|
-
assert Company.find(1).kind_of?(Firm), "37signals should be a firm"
|
22
|
-
assert Firm.find(1).kind_of?(Firm), "37signals should be a firm"
|
23
|
-
assert Company.find(2).kind_of?(Client), "Summit should be a client"
|
24
|
-
assert Client.find(2).kind_of?(Client), "Summit should be a client"
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_alt_inheritance_find
|
28
|
-
switch_to_alt_inheritance_column
|
29
|
-
test_inheritance_find
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_inheritance_find_all
|
33
|
-
companies = Company.find_all(nil, "id")
|
34
|
-
assert companies[0].kind_of?(Firm), "37signals should be a firm"
|
35
|
-
assert companies[1].kind_of?(Client), "Summit should be a client"
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_alt_inheritance_find_all
|
39
|
-
switch_to_alt_inheritance_column
|
40
|
-
test_inheritance_find_all
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_inheritance_save
|
44
|
-
firm = Firm.new
|
45
|
-
firm.name = "Next Angle"
|
46
|
-
firm.save
|
47
|
-
|
48
|
-
next_angle = Company.find(firm.id)
|
49
|
-
assert next_angle.kind_of?(Firm), "Next Angle should be a firm"
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_alt_inheritance_save
|
53
|
-
switch_to_alt_inheritance_column
|
54
|
-
test_inheritance_save
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_inheritance_condition
|
58
|
-
assert_equal 3, Company.find_all.length
|
59
|
-
assert_equal 1, Firm.find_all.length
|
60
|
-
assert_equal 2, Client.find_all.length
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_alt_inheritance_condition
|
64
|
-
switch_to_alt_inheritance_column
|
65
|
-
test_inheritance_condition
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_finding_incorrect_type_data
|
69
|
-
assert_raises(ActiveRecord::RecordNotFound) { Firm.find(2) }
|
70
|
-
assert_nothing_raised { Firm.find(1) }
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_alt_finding_incorrect_type_data
|
74
|
-
switch_to_alt_inheritance_column
|
75
|
-
test_finding_incorrect_type_data
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_update_all_within_inheritance
|
79
|
-
Client.update_all "name = 'I am a client'"
|
80
|
-
assert_equal "I am a client", Client.find_all.first.name
|
81
|
-
assert_equal "37signals", Firm.find_all.first.name
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_alt_update_all_within_inheritance
|
85
|
-
switch_to_alt_inheritance_column
|
86
|
-
test_update_all_within_inheritance
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_destroy_all_within_inheritance
|
90
|
-
Client.destroy_all
|
91
|
-
assert_equal 0, Client.find_all.length
|
92
|
-
assert_equal 1, Firm.find_all.length
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_alt_destroy_all_within_inheritance
|
96
|
-
switch_to_alt_inheritance_column
|
97
|
-
test_destroy_all_within_inheritance
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_find_first_within_inheritance
|
101
|
-
assert_kind_of Firm, Company.find_first("name = '37signals'")
|
102
|
-
assert_kind_of Firm, Firm.find_first("name = '37signals'")
|
103
|
-
assert_nil Client.find_first("name = '37signals'")
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_alt_find_first_within_inheritance
|
107
|
-
switch_to_alt_inheritance_column
|
108
|
-
test_find_first_within_inheritance
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_complex_inheritance
|
112
|
-
very_special_client = VerySpecialClient.create("name" => "veryspecial")
|
113
|
-
assert_equal very_special_client, VerySpecialClient.find_first("name = 'veryspecial'")
|
114
|
-
assert_equal very_special_client, SpecialClient.find_first("name = 'veryspecial'")
|
115
|
-
assert_equal very_special_client, Company.find_first("name = 'veryspecial'")
|
116
|
-
assert_equal very_special_client, Client.find_first("name = 'veryspecial'")
|
117
|
-
assert_equal 1, Client.find_all("name = 'Summit'").size
|
118
|
-
assert_equal very_special_client, Client.find(very_special_client.id)
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_alt_complex_inheritance
|
122
|
-
switch_to_alt_inheritance_column
|
123
|
-
test_complex_inheritance
|
124
|
-
end
|
125
|
-
end
|