Sha256: a5ad0c5be65fd458d4b1e0e0aaaa348c03ab587a9f9d133ac50fdc50114b2148

Contents?: true

Size: 1.91 KB

Versions: 7

Compression:

Stored size: 1.91 KB

Contents

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

describe "included actions" do
  AllActions = [:index, :show, :new, :create, :edit, :update, :destroy]
  IncludedActions = [:new, :show]
  ExcludedActions = AllActions - IncludedActions
  
  setup = lambda {
    class ShipTypesController < ActionController::Base
      expose_many(:ship_types, :only => IncludedActions)
    end 
  }
  
  setup.call
  
  ActionController::Routing::Routes.draw do |map| 
    map.resources :ship_types
  end
  
  Object.remove_class(ShipTypesController)
  
  before(:each) do
    setup.call
    @controller = ShipTypesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end
  
  after(:each) do
    Object.remove_class(ShipTypesController)
  end

  IncludedActions.each do |action|
    it "should have action #{action}" do
      @controller.should respond_to(action)
    end
  end

  ExcludedActions.each do |action|
    it "should have not action #{action}" do
      @controller.should_not respond_to(action)
    end
  end
end

describe "excluded actions" do
  setup = lambda {
    class ShipTypesController < ActionController::Base
      expose_many(:ship_types, :except => ExcludedActions)
    end 
  }
  setup.call
  
  ActionController::Routing::Routes.draw do |map| 
    map.resources :ship_types
  end
  
  Object.remove_class(ShipTypesController)
  
  before(:each) do
    setup.call
    @controller = ShipTypesController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end
  
  after(:each) do
    Object.remove_class(ShipTypesController)
  end
  
  IncludedActions.each do |action|
    it "should have action #{action}" do
      @controller.should respond_to(action)
    end
  end
  
  ExcludedActions.each do |action|
    it "should have not action #{action}" do
      @controller.should_not respond_to(action)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
exposure-0.2.1 spec/configuration_spec.rb
exposure-0.2.0 spec/configuration_spec.rb
exposure-0.1.3 spec/configuration_spec.rb
exposure-0.1.2 spec/configuration_spec.rb
exposure-0.1.1 spec/configuration_spec.rb
exposure-0.1.0 spec/configuration_spec.rb
exposure-0.0.7 spec/configuration_spec.rb