Sha256: 301f2cfd5b3ba0e2732e0b39e3337dc09fd96feb92b67eade6490edfa31e080b

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 Bytes

Contents

require 'spec_helper'

require 'action_controller'
class AdminController < ActionController::Base
  include RightOn::ActionControllerExtensions
  def current_user
    Thread.current[:user]
  end
end

describe AdminController do
  let(:basic_user) { User.where(name: 'basic').first }
  let(:admin_user) { User.where(name: 'admin').first }

  before do
    Bootstrap.reset_database
    controller.params = {controller: 'admin', action: 'index'}
  end

  let(:controller) { AdminController.new }
  context 'basic user' do
    before { Thread.current[:user] = basic_user }
    it 'should not allow access' do
      expect(controller.access_allowed?).to be false
    end
  end

  context 'admin user' do
    before { Thread.current[:user] = admin_user }
    it 'should allow access' do
      expect(controller.access_allowed?).to be true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
right_on-0.3.0 spec/action_controller_extensions_spec.rb
right_on-0.2.0 spec/action_controller_extensions_spec.rb
right_on-0.1.0 spec/action_controller_extensions_spec.rb