Sha256: 833551e3f75b8f7fcf6966240f21db72de67754494c90c270fbe0c654e9b6e7b

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

require File.expand_path('../../../../../helper', __FILE__)
require File.join(Zen::FIXTURES, 'package/categories/helper/category_frontend')

describe 'Ramaze::Helper::CategoryFrontend' do
  behaves_like :capybara

  extend Ramaze::Helper::CategoryFrontend

  category_group = ::Categories::Model::CategoryGroup.create(
    :name => 'Spec group'
  )

  category1 = ::Categories::Model::Category.create(
    :name              => 'Spec category',
    :category_group_id => category_group.id
  )

  category2 = ::Categories::Model::Category.create(
    :name              => 'Spec category 2',
    :category_group_id => category_group.id
  )

  it 'Retrieve categories for a group ID' do
    categories = get_categories(category_group.id).all

    categories.length.should   == 2
    categories[0].name.should  == category1.name
  end

  it 'Retrieve categories for a group slug' do
    categories = get_categories(category_group.name).all

    categories.length.should   == 2
    categories[0].name.should  == category1.name
  end

  it 'Limit the amount of results' do
    categories = get_categories(category_group.id, :limit => 1).all

    categories.length.should  == 1
    categories[0].name.should == category1.name
  end

  it 'Retrieve and paginate two categories' do
    visit('/spec-category-frontend')

    page.has_selector?('p').should          == true
    page.find('p:first-child').text.should  == category1.name
    page.has_selector?('.pager').should     == true

    visit('/spec-category-frontend?page=2')

    page.has_selector?('p').should          == true
    page.find('p:first-child').text.should  == category2.name
    page.has_selector?('.pager').should     == true
  end

  category1.destroy
  category2.destroy
  category_group.destroy
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.4.3 spec/zen/package/categories/helper/category_frontend.rb
zen-0.4.2 spec/zen/package/categories/helper/category_frontend.rb
zen-0.4.1 spec/zen/package/categories/helper/category_frontend.rb
zen-0.4 spec/zen/package/categories/helper/category_frontend.rb