diff options
Diffstat (limited to 'activerecord/test')
19 files changed, 74 insertions, 2 deletions
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 4418b8d9e6..53ef4a5e86 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -11,6 +11,7 @@ require 'fixtures/column_name' require 'fixtures/subscriber' require 'fixtures/keyboard' require 'fixtures/post' +require 'fixtures/minimalistic' class Category < ActiveRecord::Base; end class Smarts < ActiveRecord::Base; end @@ -64,7 +65,7 @@ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base end class BasicsTest < Test::Unit::TestCase - fixtures :topics, :companies, :developers, :projects, :computers, :accounts + fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics def test_table_exists assert !NonExistentTable.table_exists? @@ -184,6 +185,15 @@ class BasicsTest < Test::Unit::TestCase assert_nil topic.title end + def test_save_for_record_with_only_primary_key + minimalistic = Minimalistic.new + assert_nothing_raised { minimalistic.save } + end + + def test_save_for_record_with_only_primary_key_that_is_provided + assert_nothing_raised { Minimalistic.create!(:id => 2) } + end + def test_hashes_not_mangled new_topic = { :title => "New Topic" } new_topic_values = { :title => "AnotherTopic" } @@ -240,6 +250,11 @@ class BasicsTest < Test::Unit::TestCase topicReloaded.send :write_attribute, 'does_not_exist', 'test' assert_nothing_raised { topicReloaded.save } end + + def test_update_for_record_with_only_primary_key + minimalistic = minimalistics(:first) + assert_nothing_raised { minimalistic.save } + end def test_write_attribute topic = Topic.new diff --git a/activerecord/test/fixtures/db_definitions/db2.drop.sql b/activerecord/test/fixtures/db_definitions/db2.drop.sql index 9837def303..286066ea20 100644 --- a/activerecord/test/fixtures/db_definitions/db2.drop.sql +++ b/activerecord/test/fixtures/db_definitions/db2.drop.sql @@ -30,3 +30,4 @@ DROP TABLE keyboards; DROP TABLE legacy_things; DROP TABLE numeric_data; DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/fixtures/db_definitions/db2.sql b/activerecord/test/fixtures/db_definitions/db2.sql index 750e74a0c3..6e088bd8ed 100644 --- a/activerecord/test/fixtures/db_definitions/db2.sql +++ b/activerecord/test/fixtures/db_definitions/db2.sql @@ -229,3 +229,7 @@ CREATE TABLE mixed_case_monkeys ( monkeyID INT NOT NULL PRIMARY KEY, fleaCount INT ); + +CREATE TABLE minimalistics ( + id INT NOT NULL PRIMARY KEY +); diff --git a/activerecord/test/fixtures/db_definitions/firebird.drop.sql b/activerecord/test/fixtures/db_definitions/firebird.drop.sql index 69aa093150..378843bf9b 100644 --- a/activerecord/test/fixtures/db_definitions/firebird.drop.sql +++ b/activerecord/test/fixtures/db_definitions/firebird.drop.sql @@ -31,6 +31,7 @@ DROP TABLE defaults; DROP TABLE legacy_things; DROP TABLE numeric_data; DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; DROP DOMAIN D_BOOLEAN; @@ -60,4 +61,5 @@ DROP GENERATOR keyboards_seq; DROP GENERATOR defaults_seq; DROP GENERATOR legacy_things_seq; DROP GENERATOR numeric_data_seq; -DROP GENERATOR mixed_case_monkeys_seq;
\ No newline at end of file +DROP GENERATOR mixed_case_monkeys_seq; +DROP GENERATOR minimalistics_seq; diff --git a/activerecord/test/fixtures/db_definitions/firebird.sql b/activerecord/test/fixtures/db_definitions/firebird.sql index 779701c354..9ed6453ff7 100644 --- a/activerecord/test/fixtures/db_definitions/firebird.sql +++ b/activerecord/test/fixtures/db_definitions/firebird.sql @@ -302,3 +302,9 @@ CREATE TABLE mixed_case_monkeys ( ); CREATE GENERATOR mixed_case_monkeys_seq; SET GENERATOR mixed_case_monkeys_seq TO 10000; + +CREATE TABLE minimalistics ( + id BIGINT NOT NULL +); +CREATE GENERATOR minimalistics_seq; +SET GENERATOR minimalistics_seq TO 10000; diff --git a/activerecord/test/fixtures/db_definitions/frontbase.drop.sql b/activerecord/test/fixtures/db_definitions/frontbase.drop.sql index 1c87fdf7ed..58ec56bd4f 100644 --- a/activerecord/test/fixtures/db_definitions/frontbase.drop.sql +++ b/activerecord/test/fixtures/db_definitions/frontbase.drop.sql @@ -30,3 +30,4 @@ DROP TABLE keyboards CASCADE; DROP TABLE legacy_things CASCADE; DROP TABLE numeric_data CASCADE; DROP TABLE mixed_case_monkeys CASCADE; +DROP TABLE minimalistics CASCADE; diff --git a/activerecord/test/fixtures/db_definitions/frontbase.sql b/activerecord/test/fixtures/db_definitions/frontbase.sql index 798b0204d2..83441798b4 100644 --- a/activerecord/test/fixtures/db_definitions/frontbase.sql +++ b/activerecord/test/fixtures/db_definitions/frontbase.sql @@ -266,3 +266,8 @@ CREATE TABLE mixed_case_monkeys ( "fleaCount" integer ); SET UNIQUE FOR mixed_case_monkeys("monkeyID"); + +CREATE TABLE minimalistics ( + "id" integer NOT NULL +); +SET UNIQUE FOR minimalistics("id"); diff --git a/activerecord/test/fixtures/db_definitions/mysql.drop.sql b/activerecord/test/fixtures/db_definitions/mysql.drop.sql index f269b3a3b7..419cdaa52c 100644 --- a/activerecord/test/fixtures/db_definitions/mysql.drop.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.drop.sql @@ -30,3 +30,4 @@ DROP TABLE keyboards; DROP TABLE legacy_things; DROP TABLE numeric_data; DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/fixtures/db_definitions/mysql.sql b/activerecord/test/fixtures/db_definitions/mysql.sql index 1450d20890..a2195a4f5a 100755 --- a/activerecord/test/fixtures/db_definitions/mysql.sql +++ b/activerecord/test/fixtures/db_definitions/mysql.sql @@ -232,3 +232,7 @@ CREATE TABLE mixed_case_monkeys ( `fleaCount` int(11), PRIMARY KEY (`monkeyID`) ) TYPE=InnoDB; + +CREATE TABLE `minimalistics` ( + `id` INTEGER NOT NULL auto_increment PRIMARY KEY +); diff --git a/activerecord/test/fixtures/db_definitions/openbase.sql b/activerecord/test/fixtures/db_definitions/openbase.sql index a177d1688b..ec0029b0f6 100644 --- a/activerecord/test/fixtures/db_definitions/openbase.sql +++ b/activerecord/test/fixtures/db_definitions/openbase.sql @@ -309,3 +309,10 @@ CREATE TABLE mixed_case_monkeys ( go CREATE PRIMARY KEY mixed_case_monkeys (monkeyID) go + +CREATE TABLE minimalistics ( + id INTEGER NOT NULL DEFAULT _rowid +); +go +CREATE PRIMARY KEY minimalistics (id) +go diff --git a/activerecord/test/fixtures/db_definitions/oracle.drop.sql b/activerecord/test/fixtures/db_definitions/oracle.drop.sql index 910b118e05..21f40ed8d0 100644 --- a/activerecord/test/fixtures/db_definitions/oracle.drop.sql +++ b/activerecord/test/fixtures/db_definitions/oracle.drop.sql @@ -31,6 +31,7 @@ drop table keyboards; drop table legacy_things; drop table numeric_data; drop table mixed_case_monkeys; +drop table minimalistics; drop sequence accounts_seq; drop sequence funny_jokes_seq; @@ -63,3 +64,4 @@ drop sequence keyboards_seq; drop sequence legacy_things_seq; drop sequence numeric_data_seq; drop sequence mixed_case_monkeys_seq; +drop sequence minimalistics_seq; diff --git a/activerecord/test/fixtures/db_definitions/oracle.sql b/activerecord/test/fixtures/db_definitions/oracle.sql index f84a86a655..22ca0baa8d 100644 --- a/activerecord/test/fixtures/db_definitions/oracle.sql +++ b/activerecord/test/fixtures/db_definitions/oracle.sql @@ -323,3 +323,8 @@ CREATE TABLE mixed_case_monkeys ( "fleaCount" INTEGER ); create sequence mixed_case_monkeys_seq minvalue 10000; + +CREATE TABLE minimalistics ( + id INTEGER NOT NULL PRIMARY KEY +); +create sequence minimalistics_seq minvalue 10000; diff --git a/activerecord/test/fixtures/db_definitions/postgresql.sql b/activerecord/test/fixtures/db_definitions/postgresql.sql index bbe54599d8..3b929e338c 100644 --- a/activerecord/test/fixtures/db_definitions/postgresql.sql +++ b/activerecord/test/fixtures/db_definitions/postgresql.sql @@ -285,3 +285,7 @@ CREATE TABLE postgresql_oids ( id SERIAL PRIMARY KEY, obj_id OID ); + +CREATE TABLE minimalistics ( + id serial primary key +); diff --git a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql index f269b3a3b7..419cdaa52c 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.drop.sql @@ -30,3 +30,4 @@ DROP TABLE keyboards; DROP TABLE legacy_things; DROP TABLE numeric_data; DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/fixtures/db_definitions/sqlite.sql b/activerecord/test/fixtures/db_definitions/sqlite.sql index 973639f177..2e19dd2533 100644 --- a/activerecord/test/fixtures/db_definitions/sqlite.sql +++ b/activerecord/test/fixtures/db_definitions/sqlite.sql @@ -213,3 +213,7 @@ CREATE TABLE mixed_case_monkeys ( 'monkeyID' INTEGER NOT NULL PRIMARY KEY, 'fleaCount' INTEGER ); + +CREATE TABLE minimalistics ( + 'id' INTEGER NOT NULL PRIMARY KEY +); diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql index c415d223f5..a886aa3efb 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql @@ -32,3 +32,4 @@ DROP TABLE legacy_things; DROP TABLE numeric_data; DROP TABLE [order]; DROP TABLE mixed_case_monkeys; +DROP TABLE minimalistics; diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index 3cec4e4a16..81b79bfe5c 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -241,3 +241,7 @@ CREATE TABLE mixed_case_monkeys ( [monkeyID] int NOT NULL IDENTITY(1, 1), [fleaCount] int default NULL ); + +CREATE TABLE minimalistics ( + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY +); diff --git a/activerecord/test/fixtures/db_definitions/sybase.drop.sql b/activerecord/test/fixtures/db_definitions/sybase.drop.sql index 9d85221610..ebb91931fb 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.drop.sql @@ -30,5 +30,6 @@ DROP TABLE keyboards DROP TABLE legacy_things DROP TABLE numeric_data DROP TABLE mixed_case_monkeys +DROP TABLE minimalistics DROP TABLE schema_info go diff --git a/activerecord/test/fixtures/db_definitions/sybase.sql b/activerecord/test/fixtures/db_definitions/sybase.sql index 6c42c66031..9f0cb3ebe2 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.sql @@ -215,4 +215,8 @@ CREATE TABLE mixed_case_monkeys ( [fleaCount] numeric(9,0) ); +CREATE TABLE minimalistics ( + id numeric(9,0) IDENTITY PRIMARY KEY +); + go |