Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempts to fix the failing specs for shares_controller_spec. #6411

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions spec/controllers/hyrax/my/shares_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
# frozen_string_literal: true
RSpec.describe Hyrax::My::SharesController, type: :controller do
RSpec.describe Hyrax::My::SharesController, :clean_repo, type: :controller do
describe "logged in user" do
let(:user) { create(:user) }

before do
sign_in user
end
before { sign_in user }

describe "#index" do
let(:other_user) { create(:user) }
let(:someone_else) { create(:user) }

let!(:my_work) { create(:work, user: user) }
let!(:unshared_work) { create(:work, user: other_user) }
let!(:shared_with_me) { create(:work, user: other_user, edit_users: [user, other_user]) }
let!(:read_shared_with_me) { create(:work, user: other_user, read_users: [user, other_user]) }
let!(:shared_with_someone_else) { create(:work, user: other_user, edit_users: [someone_else, other_user]) }
let!(:my_collection) { create(:public_collection_lw, user: user) }
let!(:shared_with_me) do
valkyrie_create(:monograph, depositor: other_user.user_key, edit_users: [user, other_user])
end

it "responds with success" do
get :index
expect(response).to be_successful
end

context "with multiple pages of results" do
before { 2.times { create(:work, user: other_user, edit_users: [user, other_user]) } }
before { 2.times { valkyrie_create(:monograph, depositor: other_user.user_key, edit_users: [user, other_user]) } }

it "paginates" do
get :index, params: { per_page: 2 }
expect(assigns[:document_list].length).to eq 2

get :index, params: { per_page: 2, page: 2 }
expect(assigns[:document_list].length).to be >= 1
expect(assigns[:document_list].length).to eq 1
end
end

it "shows only documents that are shared with me via edit access" do
get :index
expect(assigns[:document_list].map(&:id)).to contain_exactly(shared_with_me.id)
context "with other extant documents" do
let!(:my_work) { valkyrie_create(:monograph, depositor: user.user_key) }
let!(:unshared_work) { valkyrie_create(:monograph, depositor: other_user.user_key) }
let!(:read_shared_with_me) do
valkyrie_create(:monograph, depositor: other_user.user_key, read_users: [user, other_user])
end
let!(:shared_with_someone_else) do
valkyrie_create(:monograph, depositor: other_user.user_key, edit_users: [someone_else, other_user])
end
let!(:my_collection) { valkyrie_create(:hyrax_collection, :public, user: user) }

it "shows only documents that are shared with me via edit access" do
get :index
expect(assigns[:document_list].map(&:id)).to contain_exactly(shared_with_me.id)
end
end
end
end
Expand Down