Sha256: 8a2936d7efa04321c4eb188e12b79b77db1c126842098a0a406c575e07914838

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

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

describe_with_render "Index as Blog" do

  before :all do
    load_defaults!
    reload_routes!
  end

  before do
    Admin::PostsController.reset_index_config!
    @post = Post.create(:title => "Hello World", :body => "This is the hello world post")
  end

  describe "displaying the index as posts" do

    context "when no configuration block given" do
      before do
        Admin::PostsController.index :as => :blog 
        get :index
      end      

      it "should have an h3 as the title" do
        response.should have_tag("h3", "Post #{@post.id}")
      end
      it "should generate a title link" do
        response.should have_tag("a", "Post #{@post.id}", :attributes => {
                                                            :href => "/admin/posts/#{@post.id}" })
      end
    end

    context "when a simple config given" do
      before do
        Admin::PostsController.index :as => :blog do |i|
          i.title :title
          i.content :body
        end
        get :index
      end
      it "should render the title" do
        response.should have_tag("h3", "Hello World")
      end
      it "should render the body as the content" do
        response.should have_tag("div", @post.body, :attributes => { :class => 'content' } )
      end
    end

    context "when blocks given as config" do
      before do
        Admin::PostsController.index :as => :blog do |i|
          i.title {|post| post.title }
          i.content {|post| simple_format post.body }
        end
        get :index
      end
      it "should render the title" do
        response.should have_tag("h3", "Hello World")
      end
      it "should render the body as the content" do
        response.should have_tag("div", @post.body, :attributes => { :class => 'content' } )
      end      
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-0.1.1 spec/integration/index_as_blog_spec.rb
activeadmin-0.1.0 spec/integration/index_as_blog_spec.rb