require File.dirname(__FILE__) + '/spec_helper'

describe Category do
  before(:all) do
    @original_entry_count = Category.all.count
  end

  context "on creating a new category with blank slug" do
    before do
      @cat = Category.new({"title"=>"foo", "description"=>"bar", "slug"=>""})
      @cat.save
    end
    after { @cat.destroy }

    subject { Category }
    it { should have(@original_entry_count + 1).item }
  end

  context "on creating 2 new categories with blank slug" do
    before do
      @cat1 = Category.new({"title"=>"foo", "description"=>"bar", "slug"=>""})
      @cat2 = Category.new({"title"=>"bar", "description"=>"buz", "slug"=>""})
      @cat1.save
      @cat2.save
    end

    after do
      @cat1.destroy
      @cat2.destroy
    end

    subject { Category }
    it { should have(@original_entry_count + 2).item }
  end
end

require File.dirname(__FILE__) + '/spec_helper'

describe Category do
  after do
    Category.destroy
  end

  context "on creating a new category with blank slug" do
    before do
      Category.new({"title"=>"foo", "description"=>"bar", "slug"=>""}).save
    end
    subject { Category }
    it { should have(1).item }
  end

  context "on creating 2 new categories with blank slug" do
    before do
      Category.new({"title"=>"foo", "description"=>"bar", "slug"=>""}).save
      Category.new({"title"=>"bar", "description"=>"buz", "slug"=>""}).save
    end
    subject { Category }
    it { should have(2).item }
  end
end

Revert "Fix Category spec not to delete existing category entries"
Revert "Fix Category spec not to delete existing category entries"

This reverts commit dd3223ca9319060349db0dbd9d50af2a737c1c47.
