2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

Merge branch 'refactor-category' of git://github.com/goshakkk/discourse

Conflicts:
	app/models/category.rb
This commit is contained in:
Robin Ward 2013-03-08 10:49:25 -05:00
commit b8fd734d0e
2 changed files with 36 additions and 52 deletions

View file

@ -3,7 +3,6 @@
require 'spec_helper'
describe Category do
it { should validate_presence_of :user_id }
it { should validate_presence_of :name }
@ -20,13 +19,11 @@ describe Category do
it { should have_many :featured_topics }
describe "uncategorized name" do
let(:category) { Fabricate.build(:category, name: SiteSetting.uncategorized_name) }
it "is invalid to create a category with the reserved name" do
category.should_not be_valid
end
end
describe "short name" do
@ -39,11 +36,9 @@ describe Category do
it 'has one topic' do
Topic.where(category_id: category.id).count.should == 1
end
end
describe 'caching' do
it "invalidates the site cache on creation" do
Site.expects(:invalidate_cache).once
Fabricate(:category)
@ -63,17 +58,14 @@ describe Category do
end
describe 'non-english characters' do
let(:category) { Fabricate(:category, name: "電車男") }
it "creates a blank slug, this is OK." do
category.slug.should be_blank
end
end
describe 'after create' do
before do
@category = Fabricate(:category)
@topic = @category.topic
@ -119,10 +111,7 @@ describe Category do
@category.topic_url.should be_present
end
describe "trying to change the category topic's category" do
before do
@new_cat = Fabricate(:category, name: '2nd Category', user: @category.user)
@topic.change_category(@new_cat.name)
@ -145,7 +134,6 @@ describe Category do
end
describe 'destroy' do
before do
@category = Fabricate(:category)
@category_id = @category.id
@ -160,17 +148,14 @@ describe Category do
it 'deletes the forum topic' do
Topic.exists?(id: @topic_id).should be_false
end
end
describe 'update_stats' do
before do
@category = Fabricate(:category)
end
context 'with regular topics' do
before do
@category.topics << Fabricate(:topic, user: @category.user)
Category.update_stats
@ -188,11 +173,9 @@ describe Category do
it 'updates topics_year' do
@category.topics_year.should == 1
end
end
context 'with deleted topics' do
before do
@category.topics << Fabricate(:deleted_topic,
user: @category.user)
@ -211,9 +194,6 @@ describe Category do
it 'does not count deleted topics for topics_year' do
@category.topics_year.should == 0
end
end
end
end