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