From eb95be4cf1132d285daeaedd5da329a44b23f236 Mon Sep 17 00:00:00 2001 From: Dan Croak Date: Tue, 7 Jul 2009 20:46:21 -0400 Subject: [PATCH] upgrading coulda --- vendor/plugins/coulda/features/step_definitions/migration_steps.rb | 38 +++++++++++++++++++++++++++----------- vendor/plugins/coulda/features/step_definitions/model_steps.rb | 18 ------------------ vendor/plugins/coulda/generators/model/templates/migration.rb | 6 ++++-- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/vendor/plugins/coulda/features/step_definitions/migration_steps.rb b/vendor/plugins/coulda/features/step_definitions/migration_steps.rb index c9a3eeb..24d6881 100644 --- a/vendor/plugins/coulda/features/step_definitions/migration_steps.rb +++ b/vendor/plugins/coulda/features/step_definitions/migration_steps.rb @@ -1,14 +1,30 @@ Then /^the paperclip migration should add "(.*)" columns to the "(.*)"$/ do |attr, table| - up = " add_column :#{table}, :#{attr}_file_name, :string\n" << - " add_column :#{table}, :#{attr}_content_type, :string\n" << - " add_column :#{table}, :#{attr}_file_size, :integer\n" << - " add_column :#{table}, :#{attr}_updated_at, :datetime" - down = " remove_column :#{table}, :#{attr}_file_name\n" << - " remove_column :#{table}, :#{attr}_content_type\n" << - " remove_column :#{table}, :#{attr}_file_size\n" << - " remove_column :#{table}, :#{attr}_updated_at" - assert_generated_migration(table) do |body| - assert body.include?(up), body.inspect - assert body.include?(down), body.inspect + assert_generated_migration(table) do + " add_column :#{table}, :#{attr}_file_name, :string, :default => \"\"\n" << + " add_column :#{table}, :#{attr}_content_type, :string, :default => \"\"\n" << + " add_column :#{table}, :#{attr}_file_size, :integer, :default => \"\"\n" << + " add_column :#{table}, :#{attr}_updated_at, :datetime, :default => \"\"" + end + assert_generated_migration(table) do + " remove_column :#{table}, :#{attr}_file_name\n" << + " remove_column :#{table}, :#{attr}_content_type\n" << + " remove_column :#{table}, :#{attr}_file_size\n" << + " remove_column :#{table}, :#{attr}_updated_at" + end +end + +Then /^the "(.*)" table should have db index on "(.*)"$/ do |table, foreign_key| + assert_generated_migration(table) do + "add_index :#{table}, :#{foreign_key}" + end +end + +Then /^the "(.*)" table should have paperclip columns for "(.*)"$/ do |table, attr| + assert_generated_migration(table) do + " table.string :#{attr}_file_name, :default => \"\"\n" << + " table.string :#{attr}_content_type, :default => \"\"\n" << + " table.integer :#{attr}_file_size\n" << + " table.datetime :#{attr}_updated_at" end end + diff --git a/vendor/plugins/coulda/features/step_definitions/model_steps.rb b/vendor/plugins/coulda/features/step_definitions/model_steps.rb index c726d1f..343275d 100644 --- a/vendor/plugins/coulda/features/step_definitions/model_steps.rb +++ b/vendor/plugins/coulda/features/step_definitions/model_steps.rb @@ -80,21 +80,3 @@ Then /^the "(.*)" unit test should have "(.*)" macro$/ do |model, macro| end end -# MIGRATION - -Then /^the "(.*)" table should have db index on "(.*)"$/ do |table, foreign_key| - assert_generated_migration(table) do - "add_index :#{table}, :#{foreign_key}" - end -end - -Then /^the "(.*)" table should have paperclip columns for "(.*)"$/ do |table, attr| - assert_generated_migration(table) do - " table.string :#{attr}_file_name\n" << - " table.string :#{attr}_content_type\n" << - " table.integer :#{attr}_file_size\n" << - " table.datetime :#{attr}_updated_at" - end -end - - diff --git a/vendor/plugins/coulda/generators/model/templates/migration.rb b/vendor/plugins/coulda/generators/model/templates/migration.rb index a114dca..2530587 100644 --- a/vendor/plugins/coulda/generators/model/templates/migration.rb +++ b/vendor/plugins/coulda/generators/model/templates/migration.rb @@ -3,10 +3,12 @@ class <%= migration_name %> < ActiveRecord::Migration create_table :<%= table_name %> do |table| <% attributes.each do |attribute| -%> <% if attribute.type == :paperclip -%> - table.string :<%= attribute.name %>_file_name - table.string :<%= attribute.name %>_content_type + table.string :<%= attribute.name %>_file_name, :default => "" + table.string :<%= attribute.name %>_content_type, :default => "" table.integer :<%= attribute.name %>_file_size table.datetime :<%= attribute.name %>_updated_at +<% elsif attribute.type == :string -%> + table.string :<%= attribute.name %>, :default => "" <% else -%> table.<%= attribute.type %> :<%= attribute.name %> <% end -%> -- libgit2 0.21.2