Sha256: 4d54193c7a6c7d23fd4defd34132e86d5e07391cfac90b7e9184c869d728e898

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

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

describe Admin::PageAttachmentsController do
  dataset :users, :assets

  before :each do
    ActionController::Routing::Routes.reload
    login_as :designer
  end
  
  it "should be a ResourceController" do
    controller.should be_kind_of(Admin::ResourceController)
  end

  it "should handle PageAttachments" do
    controller.class.model_class.should == PageAttachment
    controller.send(:model_symbol).should == :page_attachment
  end

  describe "create" do
    before do
      pending
      post :create, :format => :js, :page_id => page_id(:pictured), :page_attachment => {:asset_id => asset_id(:document)}
    end

    it "should attach the asset to the page" do
      assets(:document).attached_to?(pages(:pictured)).should be_true
    end

    it "should render the attached-asset list" do
      response.should be_success
      response.should render_template('admin/page_attachments/_attachment_list')
    end
  end

  describe "destroy" do
    before do
      delete :destroy, :format => :js, :page_id => page_id(:pictured), :id => page_attachment_id(:tester_attachment)
    end

    it "should render the attached-asset list" do
      response.should be_success
      response.should render_template('admin/page_attachments/_attachment_list')
    end

    it "should detach the asset from the page" do
      assets(:tester).attached_to?(pages(:pictured)).should be_false
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-1.0.0.rc1 vendor/extensions/assets/spec/controllers/admin/page_attachment_controller_spec.rb