Sha256: 275aa5accd6b3354eb9b70dbdf57857702f963232a96eb6148f881c4c3a83fe3

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

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

describe "nested builders", :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)
    @ship   = Factory.build(:ship)
    Pirate.stub!(:find).and_return(@pirate)
    @pirate.ships.stub!(:build).and_return(@ship)
    
    
    params = {:pirate_id => @pirate.id, :ship => Factory.attributes_for(:ship)}
    
    get(:new, params)
  end
  
  after(:each) do
    Object.remove_class(ShipsController)
  end
  
  it { should assign_to(:ship).with(@ship) }
  it { should assign_to(:resource).with(@ship) }
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exposure-0.1.1 spec/builders/nested_builder_spec.rb