Sha256: 0701fa97b8373ea983c63d65bf30c43b4172417eefed351df9edea461d6dd31f

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

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

describe "nested finders", :type => :controller do
  setup = lambda {
    class ShipsController < ActionController::Base
      expose_many(:ships, :nested => [:pirates])
    end
    
    ActionController::Routing::Routes.draw do |map| 
      map.resources :pirates do |pirate|
        pirate.resources :ships
      end
    end
  }
  
  setup.call
  controller_name :ships
  Object.remove_class(ShipsController)

  before(:each) do
    setup.call
    @controller = ShipsController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    
    @pirate = Factory.create(:pirate_with_ships)
    Pirate.stub(:find => @pirate)
    
    get(:index, {:pirate_id => 1})
  end
  
  after(:each) do
    Object.remove_class(ShipsController)
  end
  
  it { should assign_to(:ships) }
  it { should assign_to(:resources) }
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exposure-0.1.0 spec/finders/nested_resources_finder_spec.rb
exposure-0.0.7 spec/finders/nested_resources_finder_spec.rb