spec/unit/admin_policy_spec.rb in hydra-access-controls-10.3.4 vs spec/unit/admin_policy_spec.rb in hydra-access-controls-10.4.0.rc1

- old
+ new

@@ -118,13 +118,14 @@ # # Policy-based Access Controls # describe "When accessing assets with Policies associated" do + let(:user) { FactoryGirl.build(:martia_morocco) } + before do - @user = FactoryGirl.build(:martia_morocco) - allow(RoleMapper).to receive(:roles).with(@user).and_return(@user.roles) + allow(user).to receive(:groups).and_return(["faculty", "africana-faculty"]) end before(:all) do class TestAbility include Hydra::PolicyAwareAbility @@ -133,11 +134,11 @@ after(:all) do Object.send(:remove_const, :TestAbility) end - subject { TestAbility.new(@user) } + subject { TestAbility.new(user) } context "Given a policy grants read access to a group I belong to" do before do @policy = Hydra::AdminPolicy.new @policy.default_permissions.build({:type=>"group", :access=>"read", :name=>"africana-faculty"}) @@ -189,11 +190,11 @@ end context "And a subscribing asset grants read access to me as an individual" do before do @asset = ModsAsset.new() - @asset.read_users = [@user.uid] + @asset.read_users = [user.uid] @asset.admin_policy = @policy @asset.save end it "Then I should be able to view the asset" do @@ -233,10 +234,10 @@ end context "And a subscribing asset grants read access to me as an individual" do before do @asset = ModsAsset.new() - @asset.read_users = [@user.uid] + @asset.read_users = [user.uid] @asset.admin_policy = @policy @asset.save end it "Then I should be able to view the asset" do