From 21b19db5a30fcb6db83f4ac9302cc94c6320a0db Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Mon, 1 Aug 2011 11:27:28 -0700 Subject: refactor engine testing scenario Engine is now tested standalone by leveraging a dummy rails app Enable Guard for speedy testing Move factories to the more standard location `spec/factories/*` Update README with a Testing section Rename migrations to contain datetimestamps for their version to fix migration order issues when migrating the dummy application --- db/migrate/1_create_blog_structure.rb | 54 ---------------------- db/migrate/20110803223522_create_blog_structure.rb | 54 ++++++++++++++++++++++ .../20110803223523_add_user_id_to_blog_posts.rb | 7 +++ ...20110803223524_acts_as_taggable_on_migration.rb | 28 +++++++++++ .../20110803223525_create_seo_meta_for_blog.rb | 25 ++++++++++ db/migrate/20110803223526_add_cached_slugs.rb | 6 +++ ...803223527_add_custom_url_field_to_blog_posts.rb | 5 ++ ...223528_add_custom_teaser_field_to_blog_posts.rb | 6 +++ ...803223529_add_primary_key_to_categorizations.rb | 14 ++++++ db/migrate/2_add_user_id_to_blog_posts.rb | 7 --- db/migrate/3_acts_as_taggable_on_migration.rb | 28 ----------- db/migrate/4_create_seo_meta_for_blog.rb | 25 ---------- db/migrate/5_add_cached_slugs.rb | 6 --- db/migrate/6_add_custom_url_field_to_blog_posts.rb | 5 -- .../7_add_custom_teaser_field_to_blog_posts.rb | 6 --- db/migrate/8_add_primary_key_to_categorizations.rb | 14 ------ 16 files changed, 145 insertions(+), 145 deletions(-) delete mode 100644 db/migrate/1_create_blog_structure.rb create mode 100644 db/migrate/20110803223522_create_blog_structure.rb create mode 100644 db/migrate/20110803223523_add_user_id_to_blog_posts.rb create mode 100644 db/migrate/20110803223524_acts_as_taggable_on_migration.rb create mode 100644 db/migrate/20110803223525_create_seo_meta_for_blog.rb create mode 100644 db/migrate/20110803223526_add_cached_slugs.rb create mode 100644 db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb create mode 100644 db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb create mode 100644 db/migrate/20110803223529_add_primary_key_to_categorizations.rb delete mode 100644 db/migrate/2_add_user_id_to_blog_posts.rb delete mode 100644 db/migrate/3_acts_as_taggable_on_migration.rb delete mode 100644 db/migrate/4_create_seo_meta_for_blog.rb delete mode 100644 db/migrate/5_add_cached_slugs.rb delete mode 100644 db/migrate/6_add_custom_url_field_to_blog_posts.rb delete mode 100644 db/migrate/7_add_custom_teaser_field_to_blog_posts.rb delete mode 100644 db/migrate/8_add_primary_key_to_categorizations.rb (limited to 'db/migrate') diff --git a/db/migrate/1_create_blog_structure.rb b/db/migrate/1_create_blog_structure.rb deleted file mode 100644 index 612584e..0000000 --- a/db/migrate/1_create_blog_structure.rb +++ /dev/null @@ -1,54 +0,0 @@ -class CreateBlogStructure < ActiveRecord::Migration - - def up - create_table Refinery::BlogPost.table_name, :id => true do |t| - t.string :title - t.text :body - t.boolean :draft - t.datetime :published_at - t.timestamps - end - - add_index Refinery::BlogPost.table_name, :id - - create_table Refinery::BlogComment.table_name, :id => true do |t| - t.integer :blog_post_id - t.boolean :spam - t.string :name - t.string :email - t.text :body - t.string :state - t.timestamps - end - - add_index Refinery::BlogComment.table_name, :id - - create_table Refinery::BlogCategory.table_name, :id => true do |t| - t.string :title - t.timestamps - end - - add_index Refinery::BlogCategory.table_name, :id - - create_table Refinery::Categorization.table_name, :id => true do |t| - t.integer :blog_category_id - t.integer :blog_post_id - end - - add_index Refinery::Categorization.table_name, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp' - - load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s) - end - - def down - Refinery::UserPlugin.destroy_all({:name => "refinerycms_blog"}) - - Refinery::Page.delete_all({:link_url => "/blog"}) - - drop_table Refinery::BlogPost.table_name - drop_table Refinery::BlogComment.table_name - drop_table Refinery::Category.table_name - drop_table Refinery::Categorization.table_name - end - -end diff --git a/db/migrate/20110803223522_create_blog_structure.rb b/db/migrate/20110803223522_create_blog_structure.rb new file mode 100644 index 0000000..f6f5b2d --- /dev/null +++ b/db/migrate/20110803223522_create_blog_structure.rb @@ -0,0 +1,54 @@ +class CreateBlogStructure < ActiveRecord::Migration + + def up + create_table Refinery::BlogPost.table_name, :id => true do |t| + t.string :title + t.text :body + t.boolean :draft + t.datetime :published_at + t.timestamps + end + + add_index Refinery::BlogPost.table_name, :id + + create_table Refinery::BlogComment.table_name, :id => true do |t| + t.integer :blog_post_id + t.boolean :spam + t.string :name + t.string :email + t.text :body + t.string :state + t.timestamps + end + + add_index Refinery::BlogComment.table_name, :id + + create_table Refinery::BlogCategory.table_name, :id => true do |t| + t.string :title + t.timestamps + end + + add_index Refinery::BlogCategory.table_name, :id + + create_table Refinery::Categorization.table_name, :id => true do |t| + t.integer :blog_category_id + t.integer :blog_post_id + end + + add_index Refinery::Categorization.table_name, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp' + + load(File.expand_path('../../seeds/refinerycms_blog.rb', __FILE__)) + end + + def down + Refinery::UserPlugin.destroy_all({:name => "refinerycms_blog"}) + + Refinery::Page.delete_all({:link_url => "/blog"}) + + drop_table Refinery::BlogPost.table_name + drop_table Refinery::BlogComment.table_name + drop_table Refinery::Category.table_name + drop_table Refinery::Categorization.table_name + end + +end diff --git a/db/migrate/20110803223523_add_user_id_to_blog_posts.rb b/db/migrate/20110803223523_add_user_id_to_blog_posts.rb new file mode 100644 index 0000000..5be3224 --- /dev/null +++ b/db/migrate/20110803223523_add_user_id_to_blog_posts.rb @@ -0,0 +1,7 @@ +class AddUserIdToBlogPosts < ActiveRecord::Migration + + def change + add_column Refinery::BlogPost.table_name, :user_id, :integer + end + +end \ No newline at end of file diff --git a/db/migrate/20110803223524_acts_as_taggable_on_migration.rb b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb new file mode 100644 index 0000000..812daf4 --- /dev/null +++ b/db/migrate/20110803223524_acts_as_taggable_on_migration.rb @@ -0,0 +1,28 @@ +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def up + create_table :tags do |t| + t.string :name + end + + create_table :taggings do |t| + t.references :tag + + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, :polymorphic => true + t.references :tagger, :polymorphic => true + + t.string :context + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def down + drop_table :taggings + drop_table :tags + end +end diff --git a/db/migrate/20110803223525_create_seo_meta_for_blog.rb b/db/migrate/20110803223525_create_seo_meta_for_blog.rb new file mode 100644 index 0000000..b1c3c31 --- /dev/null +++ b/db/migrate/20110803223525_create_seo_meta_for_blog.rb @@ -0,0 +1,25 @@ +class CreateSeoMetaForBlog < ActiveRecord::Migration + + def up + unless ::SeoMetum.table_exists? + create_table ::SeoMetum.table_name do |t| + t.integer :seo_meta_id + t.string :seo_meta_type + + t.string :browser_title + t.string :meta_keywords + t.text :meta_description + + t.timestamps + end + + add_index ::SeoMetum.table_name, :id + add_index ::SeoMetum.table_name, [:seo_meta_id, :seo_meta_type] + end + end + + def down + # can't drop the table because someone else might be using it. + end + +end diff --git a/db/migrate/20110803223526_add_cached_slugs.rb b/db/migrate/20110803223526_add_cached_slugs.rb new file mode 100644 index 0000000..9e39586 --- /dev/null +++ b/db/migrate/20110803223526_add_cached_slugs.rb @@ -0,0 +1,6 @@ +class AddCachedSlugs < ActiveRecord::Migration + def change + add_column Refinery::BlogCategory.table_name, :cached_slug, :string + add_column Refinery::BlogPost.table_name, :cached_slug, :string + end +end diff --git a/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb b/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb new file mode 100644 index 0000000..22b49a4 --- /dev/null +++ b/db/migrate/20110803223527_add_custom_url_field_to_blog_posts.rb @@ -0,0 +1,5 @@ +class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration + def change + add_column Refinery::BlogPost.table_name, :custom_url, :string + end +end diff --git a/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb b/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb new file mode 100644 index 0000000..9c50b97 --- /dev/null +++ b/db/migrate/20110803223528_add_custom_teaser_field_to_blog_posts.rb @@ -0,0 +1,6 @@ +class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration + def change + add_column Refinery::BlogPost.table_name, :custom_teaser, :text + end +end + diff --git a/db/migrate/20110803223529_add_primary_key_to_categorizations.rb b/db/migrate/20110803223529_add_primary_key_to_categorizations.rb new file mode 100644 index 0000000..5bbfcf3 --- /dev/null +++ b/db/migrate/20110803223529_add_primary_key_to_categorizations.rb @@ -0,0 +1,14 @@ +class AddPrimaryKeyToCategorizations < ActiveRecord::Migration + def up + unless Refinery::Categorization.column_names.include?("id") + add_column Refinery::Categorization.table_name, :id, :primary_key + end + end + + def down + if Refinery::Categorization.column_names.include?("id") + remove_column Refinery::Categorization.table_name, :id + end + end +end + diff --git a/db/migrate/2_add_user_id_to_blog_posts.rb b/db/migrate/2_add_user_id_to_blog_posts.rb deleted file mode 100644 index 5be3224..0000000 --- a/db/migrate/2_add_user_id_to_blog_posts.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddUserIdToBlogPosts < ActiveRecord::Migration - - def change - add_column Refinery::BlogPost.table_name, :user_id, :integer - end - -end \ No newline at end of file diff --git a/db/migrate/3_acts_as_taggable_on_migration.rb b/db/migrate/3_acts_as_taggable_on_migration.rb deleted file mode 100644 index 812daf4..0000000 --- a/db/migrate/3_acts_as_taggable_on_migration.rb +++ /dev/null @@ -1,28 +0,0 @@ -class ActsAsTaggableOnMigration < ActiveRecord::Migration - def up - create_table :tags do |t| - t.string :name - end - - create_table :taggings do |t| - t.references :tag - - # You should make sure that the column created is - # long enough to store the required class names. - t.references :taggable, :polymorphic => true - t.references :tagger, :polymorphic => true - - t.string :context - - t.datetime :created_at - end - - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type, :context] - end - - def down - drop_table :taggings - drop_table :tags - end -end diff --git a/db/migrate/4_create_seo_meta_for_blog.rb b/db/migrate/4_create_seo_meta_for_blog.rb deleted file mode 100644 index b1c3c31..0000000 --- a/db/migrate/4_create_seo_meta_for_blog.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateSeoMetaForBlog < ActiveRecord::Migration - - def up - unless ::SeoMetum.table_exists? - create_table ::SeoMetum.table_name do |t| - t.integer :seo_meta_id - t.string :seo_meta_type - - t.string :browser_title - t.string :meta_keywords - t.text :meta_description - - t.timestamps - end - - add_index ::SeoMetum.table_name, :id - add_index ::SeoMetum.table_name, [:seo_meta_id, :seo_meta_type] - end - end - - def down - # can't drop the table because someone else might be using it. - end - -end diff --git a/db/migrate/5_add_cached_slugs.rb b/db/migrate/5_add_cached_slugs.rb deleted file mode 100644 index 9e39586..0000000 --- a/db/migrate/5_add_cached_slugs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCachedSlugs < ActiveRecord::Migration - def change - add_column Refinery::BlogCategory.table_name, :cached_slug, :string - add_column Refinery::BlogPost.table_name, :cached_slug, :string - end -end diff --git a/db/migrate/6_add_custom_url_field_to_blog_posts.rb b/db/migrate/6_add_custom_url_field_to_blog_posts.rb deleted file mode 100644 index 22b49a4..0000000 --- a/db/migrate/6_add_custom_url_field_to_blog_posts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration - def change - add_column Refinery::BlogPost.table_name, :custom_url, :string - end -end diff --git a/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb b/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb deleted file mode 100644 index 9c50b97..0000000 --- a/db/migrate/7_add_custom_teaser_field_to_blog_posts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration - def change - add_column Refinery::BlogPost.table_name, :custom_teaser, :text - end -end - diff --git a/db/migrate/8_add_primary_key_to_categorizations.rb b/db/migrate/8_add_primary_key_to_categorizations.rb deleted file mode 100644 index 5bbfcf3..0000000 --- a/db/migrate/8_add_primary_key_to_categorizations.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddPrimaryKeyToCategorizations < ActiveRecord::Migration - def up - unless Refinery::Categorization.column_names.include?("id") - add_column Refinery::Categorization.table_name, :id, :primary_key - end - end - - def down - if Refinery::Categorization.column_names.include?("id") - remove_column Refinery::Categorization.table_name, :id - end - end -end - -- cgit v1.2.3