spec/unit/ability_spec.rb in hydra-access-controls-10.5.0 vs spec/unit/ability_spec.rb in hydra-access-controls-10.5.1
- old
+ new
@@ -29,22 +29,22 @@
end
it { should_not be_able_to(:create, ActiveFedora::Base) }
end
context "for a signed in user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
it { should_not be_able_to(:create, ActiveFedora::Base) }
end
# NOTES:
# See spec/requests/... for test coverage describing WHAT should appear on a page based on access permissions
# Test coverage for discover permission is in spec/requests/gated_discovery_spec.rb
describe "Given an asset that has been made publicly discoverable" do
- let(:asset) { FactoryGirl.create(:asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name: "public", access: "discover", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }]
asset.save
end
@@ -56,22 +56,22 @@
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
context "Then a registered user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
it { should be_able_to(:discover, asset) }
it { should_not be_able_to(:read, asset) }
it { should_not be_able_to(:edit, asset) }
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
end
describe "Given an asset that has been made publicly available (ie. open access)" do
- #let(:asset) { FactoryGirl.create(:open_access_asset) }
- let(:asset) { FactoryGirl.create(:asset) }
+ #let(:asset) { FactoryBot.create(:open_access_asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name: "public", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }]
asset.save
end
@@ -83,21 +83,21 @@
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
context "Then a registered user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
it { should be_able_to(:discover, asset) }
it { should be_able_to(:read, asset) }
it { should_not be_able_to(:edit, asset) }
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
end
describe "Given an asset with no custom access set" do
- let(:asset) { FactoryGirl.create(:asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name: "joe_creator", access: "edit", type: "person" }]
asset.save
end
let(:solr_doc) { SolrDocument.new(asset.to_solr.merge(id: asset.id)) }
@@ -108,19 +108,19 @@
it { should_not be_able_to(:edit, asset) }
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
context "Then a registered user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
it { should_not be_able_to(:discover, asset) }
it { should_not be_able_to(:read, asset) }
it { should_not be_able_to(:edit, asset) }
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
end
context "Then the Creator" do
- let(:user) { FactoryGirl.build(:joe_creator) }
+ let(:user) { FactoryBot.build(:joe_creator) }
it { should be_able_to(:discover, asset) }
it { should be_able_to(:read, asset) }
it { should be_able_to(:edit, asset) }
it { should be_able_to(:edit, solr_doc) }
it { should be_able_to(:update, asset) }
@@ -130,18 +130,18 @@
it { should_not be_able_to(:admin, asset) }
end
end
describe "Given an asset which registered users have read access to" do
- # let(:asset) { FactoryGirl.create(:org_read_access_asset) }
- let(:asset) { FactoryGirl.create(:asset) }
+ # let(:asset) { FactoryBot.create(:org_read_access_asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name: "registered", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }]
asset.save
end
context "The a registered user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
before do
allow(user).to receive(:new_record?).and_return(false)
end
it { should be_able_to(:discover, asset) }
@@ -152,58 +152,58 @@
it { should_not be_able_to(:admin, asset) }
end
end
describe "Given an asset with collaborator" do
- let(:asset) { FactoryGirl.create(:asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name:"africana-faculty", access: "edit", type: "group" }, {name: "calvin_collaborator", access: "edit", type: "person"}]
asset.save
end
after { asset.destroy }
context "Then a collaborator with edit access (user permision)" do
- let(:user) { FactoryGirl.build(:calvin_collaborator) }
+ let(:user) { FactoryBot.build(:calvin_collaborator) }
it { should be_able_to(:discover, asset) }
it { should be_able_to(:read, asset) }
it { should be_able_to(:edit, asset) }
it { should be_able_to(:update, asset) }
it { should be_able_to(:destroy, asset) }
it { should_not be_able_to(:admin, asset) }
end
context "Then a collaborator with edit access (group permision)" do
- let(:user) { FactoryGirl.build(:martia_morocco) }
+ let(:user) { FactoryBot.build(:martia_morocco) }
before do
allow(user).to receive(:groups).and_return(["faculty", "africana-faculty"])
end
it { should be_able_to(:read, asset) }
end
end
describe "Given an asset where dept can read & registered users can discover" do
- # let(:asset) { FactoryGirl.create(:dept_access_asset) }
- let(:asset) { FactoryGirl.create(:asset) }
+ # let(:asset) { FactoryBot.create(:dept_access_asset) }
+ let(:asset) { FactoryBot.create(:asset) }
before do
asset.permissions_attributes = [{ name: "africana-faculty", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }]
asset.save
end
context "Then a registered user" do
- let(:user) { FactoryGirl.build(:registered_user) }
+ let(:user) { FactoryBot.build(:registered_user) }
it { should_not be_able_to(:discover, asset) }
it { should_not be_able_to(:read, asset) }
it { should_not be_able_to(:edit, asset) }
it { should_not be_able_to(:update, asset) }
it { should_not be_able_to(:destroy, asset) }
it { should_not be_able_to(:admin, asset) }
end
context "Then someone whose role/group has read access" do
- let(:user) { FactoryGirl.build(:martia_morocco) }
+ let(:user) { FactoryBot.build(:martia_morocco) }
before do
allow(user).to receive(:groups).and_return(["faculty", "africana-faculty"])
end
it { should be_able_to(:discover, asset) }
@@ -226,11 +226,11 @@
def setup_my_permissions
can :accept, ActiveFedora::Base
end
end
end
- let(:user) { FactoryGirl.build(:staff) }
+ let(:user) { FactoryBot.build(:staff) }
after do
Object.send(:remove_const, :MyAbility)
end
@@ -239,17 +239,17 @@
it { should be_able_to(:accept, ActiveFedora::Base) }
end
describe "calling ability on two separate objects" do
- let(:asset1) { FactoryGirl.create(:asset) }
- let(:asset2) { FactoryGirl.create(:asset) }
+ let(:asset1) { FactoryBot.create(:asset) }
+ let(:asset2) { FactoryBot.create(:asset) }
before do
asset1.permissions_attributes = [{ name: "registered", access: "read", type: "group" }, { name: "joe_creator", access: "edit", type: "person" }, { name: "calvin_collaborator", access: "edit", type: "person" }]
asset1.save
end
- let(:user) { FactoryGirl.build(:calvin_collaborator) } # has access to @asset1, but not @asset2
+ let(:user) { FactoryBot.build(:calvin_collaborator) } # has access to @asset1, but not @asset2
after do
asset1.destroy
asset2.destroy
end
@@ -259,11 +259,11 @@
expect(subject).to_not be_able_to(:edit, asset2)
end
end
describe "download permissions" do
- let(:asset) { FactoryGirl.create(:asset) }
- let(:user) { FactoryGirl.build(:user) }
+ let(:asset) { FactoryBot.create(:asset) }
+ let(:user) { FactoryBot.build(:user) }
let(:file) { ActiveFedora::File.new() }
before { allow(file).to receive(:uri).and_return(uri) }
after { asset.destroy }