Sha256: ef4f40cc50d725e08d51a6b82b26ad5e7d1b43134651776fb27c60f99881d0e0

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe Spud::Admin::ApplicationController do
  
  
  before :each do
    activate_authlogic
    @user = FactoryGirl.create(:spud_user)
    @session = SpudUserSession.create(@user)
  end
  
  describe :require_admin_user do
    controller(Spud::Admin::ApplicationController) do
      def index
        render :nothing => true
      end
    end
    it "should respond successfully if the current user is a super admin" do
      @user.update_attribute(:super_admin, true)
      get :index
      
      response.should be_success
    end
    
    it "should respond successfully if the current user has admin permissions" do
      @user.spud_admin_permissions.create(:name => "pages", :access => true)
      get :index
      
      response.should be_success
    end
    
    it "should redirect to the login if the current user is not logged in" do
      @session.destroy
      get :index
      
      response.should redirect_to(spud_admin_login_path)
    end
    
    it "should redirect to the root for a user without administrative priviledges" do
      @user.super_admin = false
      @user.spud_admin_permissions = []
      @user.save
      get :index
      
      response.should redirect_to(root_url)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tb_core-1.0.2 spec/controllers/spud/admin/application_controller_spec.rb
tb_core-1.0.1 spec/controllers/spud/admin/application_controller_spec.rb