aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-05-11 21:26:53 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-05-11 21:26:53 +0000
commite105e599e706780905d4c348394da989de3b200f (patch)
treeecff04b0f168d2b1c6cb84083234601dd8bbfcae /activerecord/test
parent19ed709b09e7d942dadb285150a7b41225a2236f (diff)
downloadrails-e105e599e706780905d4c348394da989de3b200f.tar.gz
rails-e105e599e706780905d4c348394da989de3b200f.tar.bz2
rails-e105e599e706780905d4c348394da989de3b200f.zip
Sexy dumper now has its groove on (closes #8281) [Chris Wanstrath]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/schema_dumper_test.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/schema_dumper_test.rb
index 576c2cebc3..d18b99d561 100644
--- a/activerecord/test/schema_dumper_test.rb
+++ b/activerecord/test/schema_dumper_test.rb
@@ -32,11 +32,27 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
return assert(true) if matches.empty?
assert_equal 1, matches.map{ |match| match.offset(0).first }.uniq.length
end
+
+ def column_definition_lines(output = standard_dump)
+ output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) }
+ end
+
+ def test_types_line_up
+ column_definition_lines.each do |column_set|
+ next if column_set.empty?
+
+ lengths = column_set.map do |column|
+ if match = column.match(/t\.(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)\s+"/)
+ match[0].length
+ end
+ end
+
+ assert_equal 1, lengths.uniq.length
+ end
+ end
def test_arguments_line_up
- output = standard_dump
- output.scan(/^( *)create_table.*?\n(.*?)^\1end/m).map{ |m| m.last.split(/\n/) }.each do |column_set|
- assert_line_up(column_set, /:(?:integer|decimal|float|datetime|timestamp|time|date|text|binary|string|boolean)/, true)
+ column_definition_lines.each do |column_set|
assert_line_up(column_set, /:default => /)
assert_line_up(column_set, /:limit => /)
assert_line_up(column_set, /:null => /)
@@ -92,7 +108,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables)
if current_adapter?(:MysqlAdapter)
def test_schema_dump_should_not_add_default_value_for_mysql_text_field
output = standard_dump
- assert_match %r{t.column "body",\s+:text,\s+:null => false$}, output
+ assert_match %r{t.text\s+"body",\s+:null => false$}, output
end
end