Sha256: e5557e4fabbf6a26401fe286bc38290bfeca45dee1beec9b13a3e9c4cbcc16a0

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require 'spec_helper'

describe ThingsController, :type => :controller do
  before(:all) do
    User.delete_all
    Entity.delete_all

    @admin = User.create! :admin => true

    @entity1 = Entity.create! :name => 'entity 1'
    @entity2 = Entity.create! :name => 'entity 2'

    @thing1 = Thing.create! :name => 'thing 1', :entity_id => @entity1.id
    @thing2 = Thing.create! :name => 'thing 2', :entity_id => @entity1.id
    @thing3 = Thing.create! :name => 'thing 3', :entity_id => @entity2.id
  end

  it "loads entity resource and assigns to @entity" do
    User.mock @admin
    get :index, :entity_id => @entity1.id

    assigns(:entity).id.should == @entity1.id
  end

  it "loads thing resources through @entity and assigns to @things" do
    User.mock @admin
    get :index, :entity_id => @entity1.id

    assigns(:things).should have(2).items
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heimdallr-resource-1.2.0 spec/controllers/things_controller_spec.rb