Sha256: 774344a37e9fdd8dc9054143acf60ac2cb4af5677de2ed5998070653752105c6

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe Sunrise::ManagerController do
  #render_views
  
  describe "#current_ability" do
    before(:each) { @ability = controller.send(:current_ability) }
    
    it "should have namespace sunrise" do
      @ability.context.should == :sunrise
    end
    
    it "should be a guest user" do
      @ability.user.should be_new_record
    end
  end
  
  describe "admin" do
    login_admin
    
    context "index" do
      before(:all) do
        @root = FactoryGirl.create(:structure_main)
        @page = FactoryGirl.create(:structure_page, :parent => @root)
      end
      
      it "should respond successfully" do
        get :index, :model_name => "structures"
        
        assigns(:records).should include(@root)
        assigns(:records).should_not include(@page)
        
        response.should render_template('index')
      end
      
      it "should render 404 page" do
        lambda {
          get :index, :model_name => "wrong"
        }.should raise_error ActionController::RoutingError
      end

      it "should not destroy root structure" do
        @root.kind.should == ::StructureType.main.id
        
        controller.should_not_receive(:destroy)
        delete :destroy, :model_name => "structures", :id => @root.id
      end
    end

    context "posts" do
      before(:all) do
        @post = FactoryGirl.create(:post)
      end

      it "should respond successfully" do
        get :index, :model_name => "posts"
        
        assigns(:records).should include(@post)
        
        response.should render_template('index')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-cms-0.5.3 spec/controllers/sunrise/manager_controller_spec.rb
sunrise-cms-0.5.2 spec/controllers/sunrise/manager_controller_spec.rb
sunrise-cms-0.5.1 spec/controllers/sunrise/manager_controller_spec.rb