Sha256: c8317430b811b96a16eaec3db70fac98f09dab31557254773be5e7166466b8de

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'spec/spec_helper'

describe Shop::CategoriesController do
  before(:each) do
    @shop_category = Object.new
    stub(@shop_category).handle { 'a' }
    stub(@shop_category).layout.stub!.name { 'Layout' }
    stub(@shop_category).name { 'Bob' }
    @shop_categories = []
  end
  
  describe 'index' do
    it 'should expose categories list' do
      mock(ShopCategory).search(nil).returns(@shop_categories)
      get :index
      
      response.should be_success
      assigns(:shop_categories).should === @shop_categories
    end
  end
  
  describe '#show' do
    it 'should expose category' do
      mock(ShopCategory).find(:first, :conditions => { :handle => @shop_category.handle}) { @shop_category }
      
      get :show, :handle => @shop_category.handle
      
      response.should be_success
      assigns(:shop_category).should === @shop_category
      assigns(:title).should === 'Bob'
      assigns(:radiant_layout).should === 'Layout'
    end
    
    it 'should return 404 if product empty' do
      mock(ShopCategory).find(:first, :conditions => { :handle => @shop_category.handle}) { false }
      get :show, :handle => @shop_category.handle
      
      response.should render_template('site/not_found')
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-shop-extension-0.10.0 spec/controllers/shop/categories_controller_spec.rb
radiant-shop-extension-0.9.3 spec/controllers/shop/categories_controller_spec.rb
radiant-shop-extension-0.9.2 spec/controllers/shop/categories_controller_spec.rb