Sha256: a11bcf861879ede1b372fc645107d753da1aa8eadfe062ba889e3dbd8529e469

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. spec_helper])

class TestAController
  include Lockdown::Session
end

describe Lockdown::Session do
  before do
    @controller = TestAController.new

    @actions = %w(posts/index posts/show posts/new posts/edit posts/create posts/update posts/destroy)

    @session = {:access_rights => @actions}

    @controller.stub!(:session).and_return(@session)
  end
  
  describe "#logged_in?" do
    it "should return false withou current_user_id" do
      @controller.send(:logged_in?).should == false
    end
  end

  describe "#current_user_id" do
    it "should return false withou current_user_id" do
      @session[:current_user_id] = 2
      @controller.send(:current_user_id).should == 2
    end
  end

  describe "#nil_lockdown_values" do
    it "should nil access_rights" do
      @controller.send :nil_lockdown_values
      @session[:access_rights].should == nil
    end
  end

  describe "#current_user_is_admin?" do
    it "should return true if access_rights == :all" do
      @actions = :all
      @session = {:access_rights => @actions}
      @controller.stub!(:session).and_return(@session)

      @controller.send(:current_user_is_admin?).should == true
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
revo-lockdown-1.7.1 spec/lockdown/session_spec.rb
revo-lockdown-1.7.0 spec/lockdown/session_spec.rb