diff --git a/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb b/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb new file mode 100644 index 00000000000..28426a572b6 --- /dev/null +++ b/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb @@ -0,0 +1,11 @@ +class AddDefaultsToCategoryPostsAndTopicsFields < ActiveRecord::Migration + def change + change_column_default :categories, :posts_week, 0 + change_column_default :categories, :posts_month, 0 + change_column_default :categories, :posts_year, 0 + + change_column_default :categories, :topics_week, 0 + change_column_default :categories, :topics_month, 0 + change_column_default :categories, :topics_year, 0 + end +end diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb index b11dc5db111..11f9e32cab8 100644 --- a/spec/models/category_spec.rb +++ b/spec/models/category_spec.rb @@ -206,6 +206,14 @@ describe Category do @topic.posts.count.should == 1 @category.topic_url.should be_present + + @category.posts_week.should == 0 + @category.posts_month.should == 0 + @category.posts_year.should == 0 + + @category.topics_week.should == 0 + @category.topics_month.should == 0 + @category.topics_year.should == 0 end it "should not set its description topic to auto-close" do