Sha256: 49dc938025cddd95eccad843ead5229fafe247e102552d3115569da2af6395e7

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

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

describe Hydra::AccessControlsEvaluation do
  
  describe "editor?" do
    it "should return true if current_user.is_being_superuser? is true" do
      mock_user = FactoryGirl.build(:user, :email => "BigWig@example.com")
      mock_user.stubs(:is_being_superuser?).returns true
      controller.stubs(:current_user).returns mock_user
      helper.editor?.should be_true
    end
    it "should return false if the session[:user] is not logged in" do
      controller.stubs(:current_user).returns(nil)
      helper.editor?.should be_false
    end    
    it "should return false if the session[:user] does not have an editor role" do
      mock_user = mock("User")
      mock_user.stubs(:email).returns "nobody_special@example.com"
      mock_user.stubs(:is_being_superuser?).returns(false)
      mock_user.stubs(:new_record?).returns(false)
      controller.stubs(:current_user).returns(mock_user)
      helper.editor?.should be_false
    end
  end  
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hydra-head-4.1.3 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.1.2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.1.1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.1.0 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.0.3 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.0.2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.0.1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-4.0.0 test_support/spec/helpers/access_controls_evaluation_spec.rb