Sha256: 7fa8755e67cf6619f8aaf6723d63e8718575ae0f35c893204f8a4dd517eabce9

Contents?: true

Size: 1.26 KB

Versions: 15

Compression:

Stored size: 1.26 KB

Contents

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

describe 'Given the results of Category.find_all_with_article_counters' do
  before(:each) { @cats = Category.find_all_with_article_counters }

  it "Categories should be sorted by category.position" do
    @cats.should == @cats.sort_by { |c| c.position }
  end

  it "Counts should be correct" do
    @cats.each do |cat|
      cat.article_counter.should == cat.published_articles.size
    end
  end
end

describe 'Given the fixtures' do
  it 'find gets the order right' do
    cats = Category.find(:all)
    cats.should == cats.sort_by { |c| c.position }
    Category.reorder(cats.reverse.collect { |c| c.id })
    Category.find(:all).should == cats.reverse
  end

  it 'can still override order in find' do
    cats = Category.find(:all, :order => 'name ASC')

    cats.should == cats.sort_by {|c| c.name}
    Category.find(:all).should_not == cats
  end

  it '.reorder_alpha puts categories in alphabetical order' do
    Category.find(:all).should_not == Category.find(:all, :order => :name)
    Category.reorder_alpha
    Category.find(:all).should == Category.find(:all, :order => :name)
  end

  it 'A category knows its url' do
    categories(:software).permalink_url.should ==
      'http://myblog.net/category/software'
  end
end


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
typo-5.4.4 spec/models/category_spec.rb
typo-5.4.3 spec/models/category_spec.rb
typo-5.4.2 spec/models/category_spec.rb
typo-5.4.1 spec/models/category_spec.rb
typo-5.4 spec/models/category_spec.rb
typo-5.0.3.98.1 spec/models/category_spec.rb
typo-5.0.3.98 spec/models/category_spec.rb
typo-5.1.1 spec/models/category_spec.rb
typo-5.1.2 spec/models/category_spec.rb
typo-5.1.3 spec/models/category_spec.rb
typo-5.1 spec/models/category_spec.rb
typo-5.1.98 spec/models/category_spec.rb
typo-5.2 spec/models/category_spec.rb
typo-5.2.98 spec/models/category_spec.rb
typo-5.3 spec/models/category_spec.rb