Sha256: 1b35791731addb82f9ace895871406bd8b4d487521a9cc205cd2ad1fc50d5726

Contents?: true

Size: 1.35 KB

Versions: 19

Compression:

Stored size: 1.35 KB

Contents

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

describe Hydra::AccessControlsEvaluation do
  
  describe "test_permission" do
    it "should automatically add logged-in users to 'registered' group" do
      mock_user = mock("User", :email => "logged_in_person@example.com")
      helper.stubs(:read_groups).returns(["registered"])
      helper.stubs(:current_user).returns(nil)
      helper.test_permission(:read).should == false 
      helper.stubs(:current_user).returns(mock_user)
      helper.test_permission(:read).should == true 
    end
  end
  
  describe "editor?" do
    it "should return true if current_user.is_being_superuser? is true" do
      mock_user = mock("User", :email => "BigWig@example.com")
      mock_user.stubs(:is_being_superuser?).returns true
      helper.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
      helper.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", :email=>"nobody_special@example.com")
      mock_user.stubs(:is_being_superuser?).returns(false)
      helper.stubs(:current_user).returns(mock_user)
      helper.editor?.should be_false
    end
  end  
  
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hydra-head-4.0.0.rc2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.3.0 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.0 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.0.pre3 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.0.pre2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.2.0.pre1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.5 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.4 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.3 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0.rc2 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0.rc1 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0.pre5 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0.pre4 test_support/spec/helpers/access_controls_evaluation_spec.rb
hydra-head-3.1.0.pre3 test_support/spec/helpers/access_controls_evaluation_spec.rb