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

Data seeds improvements #5056

Closed
wants to merge 384 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
384 commits
Select commit Hold shift + click to select a range
450b659
Update lib/hyrax/configuration.rb
elrayle Oct 8, 2021
5cc2e8f
Update lib/hyrax/configuration.rb
elrayle Oct 8, 2021
2326e63
Merge pull request #5176 from samvera/col_form
elrayle Oct 8, 2021
3682bb9
Merge pull request #5177 from samvera/af_form
elrayle Oct 8, 2021
e3dba86
Merge pull request #5175 from samvera/as_model
elrayle Oct 8, 2021
874c81b
use both `::Collection` and any configured class for filter queries
Oct 7, 2021
f7782bc
include core metadata in administrative sets
elrayle Oct 8, 2021
1259ea0
remove duplicate tests for administrative_set_indexer
elrayle Oct 8, 2021
01fe01c
adjust stubs in WorkShowPresenter specs
Oct 8, 2021
dbad658
squash
Oct 8, 2021
6237fd6
squash
Oct 8, 2021
2da50a2
fix out-of-path reference to `_view_type_group.html.erb` partial
Oct 8, 2021
a5ad618
switch call to deprecated presenter method with a helper call
Oct 8, 2021
f393838
change ManagedCollectionsServiceSpec to use valkyrie models in setup
Oct 9, 2021
2e2729f
update WorkSearchBuilder specs for Valkyrie
Oct 9, 2021
8f5d634
load collection from CanCan tooling in CollectionMembersController
Oct 9, 2021
662e311
don't look up destination collection for 'move' action to access id
Oct 11, 2021
f6bb8af
don't hardcode collection class expectations in some specs
Oct 12, 2021
9986429
add a publishable event for collection membership changes
Oct 11, 2021
57cc27f
apply general curation_concerns permissions to configured collection
Oct 12, 2021
27e5fa6
allow ResourceForm`s `#for` factory method to find Collection forms
Oct 12, 2021
02887aa
only skip loading resource for ActiveFedora in CollectionsController
Oct 12, 2021
50213ff
don't override a ChangeSet's existing data with a generic default
Oct 12, 2021
5866770
only set reindex-extent on AF collections
Oct 13, 2021
96f60a2
skip CollectionsMembershipActor specs if using Valkyrie collections
Oct 13, 2021
8b444a0
simplify setup and clarify expectations for PermissionsCreateService
Oct 13, 2021
fc0d4a0
use valkyrie for PermissionsCreateService
Oct 13, 2021
7666a8f
remove superflouous `subject` definitions from SolrDocument specs
Oct 13, 2021
8f64be3
don't use memoized `subject` to exercise code under test
Oct 13, 2021
17b75d0
add valkyrie handling for Dashboard::CollectionsController actions
Oct 12, 2021
8feff97
update the ResourceSync list writer to support Valkyrie collections
Oct 14, 2021
6f68d2c
Allow ExposedModelsRelation to support Valkryie
mcritchlow Oct 15, 2021
bd5a86d
Always redirect to root in read-only mode and show error flash
dlpierce Oct 15, 2021
108539f
Update generated catalog controller in dassie
dlpierce Oct 15, 2021
24076f0
Merge pull request #5159 from samvera/read-only-3x
dlpierce Oct 15, 2021
ac548c2
refactor `NestCollectionsController` and `NestCollectionsForm`
Oct 15, 2021
b537f65
deprecate `NestCollectionsController#build_*_form` methods
Oct 15, 2021
ccc49fb
refactor NestCollectionController specs
Oct 15, 2021
d5eefce
extract collection type id from gid
Oct 15, 2021
eafa8cd
failing test for collection not assigning depositor
elrayle Oct 18, 2021
859ade4
add depositor when collection is a valkyrie resource
elrayle Oct 18, 2021
3a9536e
only test models that exist in collection abilities
elrayle Oct 19, 2021
6c3c64f
refactor to always include `FactoryBot.`
elrayle Oct 19, 2021
4150a22
failing test for controller not copying collection type permissions t…
elrayle Oct 18, 2021
dac1efb
apply permissions to collection from collection_type
elrayle Oct 18, 2021
63ed5d6
Update spec/controllers/hyrax/dashboard/collections_controller_spec.rb
elrayle Oct 19, 2021
7121b3b
Update spec/controllers/hyrax/dashboard/collections_controller_spec.rb
elrayle Oct 19, 2021
a3a5d89
update Collection::PermissionCreateService to handle collections and …
elrayle Oct 16, 2021
b0044b8
use collection’s permission create service instead of duplicating the…
elrayle Oct 16, 2021
1fa578b
make admin sets respond to :collection_type_gid
elrayle Oct 19, 2021
9143984
skip CollectionForm specs if ActiveFedora isn't used for Collections
Oct 21, 2021
1dd5fda
skip ActiveFedora indexing if Wings is disabled
Oct 22, 2021
6066063
add param_key and plural to `Hyrax::CollectionName`
Oct 22, 2021
357bdd9
Merge pull request #5216 from samvera/collection-form-af-only
VivianChu Oct 22, 2021
fa00008
Merge pull request #5219 from samvera/col-param-key
VivianChu Oct 22, 2021
e7f351a
Merge pull request #5218 from samvera/disable-wings
VivianChu Oct 22, 2021
2937529
refactor specs for permission template access deletion
Oct 22, 2021
4cba6d9
find legacy collections in CollectionsSearchBuilder
Oct 21, 2021
328b52d
helperize resolution of thumbnail labels
Oct 22, 2021
d55b356
map SolrDocument#collection? to configured class
Oct 21, 2021
ca22bd7
add a file download event to `Hyrax.publisher`
Oct 20, 2021
ada661a
don't fall through to 204 No Content when unsure of model type
Oct 22, 2021
814359c
set Valkyrie versions to `'>= 2.1.1', '< 3.0.0.a’`
elrayle Oct 25, 2021
8e6cba6
Update hyrax.gemspec
elrayle Oct 27, 2021
2a41dba
add some contextual documentation for `DefaultMiddlewareStack`.
Oct 27, 2021
351f7b0
add @see documentation to `Hyrax::Controller#transactions`
Oct 28, 2021
d51cb75
Merge pull request #5228 from samvera/tx-docs
elrayle Oct 28, 2021
ca58b18
simplify _relationships partial view spec
Oct 28, 2021
61e8806
move creation process out of deprecated #create_default_admin_set method
elrayle Oct 24, 2021
6f8608d
add call! and create! which return the admin set
elrayle Oct 24, 2021
e9f88f9
separate out active fedora create of admin set
elrayle Oct 24, 2021
c38af93
support create of Hyrax::AdministrativeSet
elrayle Oct 24, 2021
546f16f
add test for new #create! in AdminSetCreateService
elrayle Oct 24, 2021
502bf6d
check that #create_default_admin_set calls #create_default_admin_set!
elrayle Oct 24, 2021
be6e24e
check that #create calls through to #create!
elrayle Oct 24, 2021
abdcd27
update . create_default_admin_set! to create Hyrax::AdministrativeSet
elrayle Oct 25, 2021
830a7ab
refactor to always use FactoryBot before build and create
elrayle Oct 25, 2021
780a187
Only test with Hyrax::AdministrativeSet
elrayle Oct 25, 2021
4b488ef
deprecate call and create
elrayle Oct 28, 2021
470f93f
respect hyrax index adapter config
Oct 25, 2021
d6c44f5
refactor AdminSetCreateService specs
elrayle Oct 28, 2021
12ccb72
break out single long test into multiple tests
elrayle Oct 28, 2021
29887d7
Merge pull request #5223 from samvera/index-adapter
elrayle Oct 29, 2021
1db8d3c
Merge pull request #5231 from samvera/relationships-partial
elrayle Oct 29, 2021
4acebd9
test AdminAdminSetMemberSearchBuilder for collection search
Oct 28, 2021
8ee8055
Merge pull request #5229 from samvera/col-admin-set-search
elrayle Oct 29, 2021
8251c8f
include module for PermissionTemplate
elrayle Nov 1, 2021
87f8845
Merge pull request #5238 from samvera/col_create_perm
elrayle Nov 1, 2021
37429a2
add depositor to pcdm collection indexer
elrayle Nov 2, 2021
d427efa
failing test for admin set create service #create! method for valkyri…
elrayle Nov 2, 2021
f43c78e
valkyrie_create! needs to use the result of save instead of passing i…
elrayle Nov 2, 2021
011ce3a
Merge pull request #5239 from samvera/col_index_depositor
elrayle Nov 2, 2021
97f4560
Merge pull request #5240 from samvera/fix_admin_set_valkyrie_create
elrayle Nov 2, 2021
10de79a
Allow work form to display when wings is disabled
elrayle Nov 3, 2021
268f1ab
Merge pull request #5242 from samvera/no_wings
dlpierce Nov 4, 2021
7932ca1
fix bug in Hyrax::Ability#download_permissions SolrDocument handling
Nov 5, 2021
4ac72df
Merge pull request #5250 from samvera/ability-solr-doc-download
dlpierce Nov 8, 2021
c35ba18
generated indexer test requires resource variable
elrayle Nov 5, 2021
403a2e4
refactor dashboard collections form template
Nov 8, 2021
43704c6
Adds workflow to trigger nurax deploy on push
Nov 9, 2021
5dd04d3
add a spec for DeepIndexingService
Nov 9, 2021
07e588b
Merge pull request #5252 from samvera/test-deep-index
dlpierce Nov 12, 2021
ff8be0d
Merge pull request #5251 from samvera/col-form
dlpierce Nov 12, 2021
89e1b47
Merge pull request #5220 from samvera/permission-templates-access-specs
dlpierce Nov 12, 2021
2ecfc79
Prepare release 3.2.0
dlpierce Nov 12, 2021
56ca515
Merge pull request #5256 from samvera/release-3.2.0
dlpierce Nov 16, 2021
83f99f5
listeners: add further comments about Dry::Events behavior
dunn Nov 18, 2021
f59cd82
create postgres_adapter for testing
elrayle Nov 5, 2021
8fea026
add valkyrie postgres adapter migrations to dassie
elrayle Nov 29, 2021
6a3d447
add valkyrie postgres migrations to test app
elrayle Nov 29, 2021
5fad817
add a list of actions that Hyrax::Ability defines rules for
Nov 30, 2021
61ed827
Merge pull request #5260 from samvera/ability-action-list
elrayle Nov 30, 2021
31b2b6e
persist the default admin set id in the database
elrayle Dec 1, 2021
ba7a0bb
save default admin set before testing for default_admin_set_id
elrayle Dec 2, 2021
b717a3c
Merge pull request #5263 from samvera/as_create_default_with_config
elrayle Dec 3, 2021
7412631
Analytics (#5089)
orangewolf Dec 3, 2021
da8abc8
make the member presenter factory for WorkShowPresenter configurable
Dec 3, 2021
cafca08
bump engine cart cache
Dec 3, 2021
105c3d2
Merge pull request #5269 from samvera/bump-engine-cart
elrayle Dec 3, 2021
fea44e4
update dassie schema to include new hyrax_default_administrative_set …
elrayle Dec 3, 2021
ce3a103
add transactions for creating an admin set
elrayle Oct 8, 2021
66271d7
Merge pull request #5270 from samvera/dassie_schema
elrayle Dec 3, 2021
703ce4a
make CharacterizationService configurable at the Job class level
Dec 6, 2021
ef4adc7
check if user can create based on configured collection model
elrayle Dec 6, 2021
8a636ba
add validations for required fields to pcdm_collection_form
elrayle Dec 7, 2021
de784a1
mark new work feature test pending
elrayle Nov 11, 2021
6d3658b
Update lib/hyrax/transactions/admin_set_create.rb
elrayle Dec 7, 2021
3ba11bf
Merge pull request #5268 from samvera/as_transactions
elrayle Dec 7, 2021
58e014e
Merge pull request #5273 from samvera/fix/5272_missing_new_collection…
elrayle Dec 7, 2021
90ec04f
Merge pull request #5274 from samvera/validate_pcdm_col
elrayle Dec 7, 2021
a3ed17f
Merge pull request #5255 from samvera/fix/5248_remove_gen_feature_spec
elrayle Dec 7, 2021
79c90af
Adding to troubleshooting section (#5262)
jlhardes Dec 8, 2021
fe34499
handle the case when table for saving default admin set doesn’t exist
elrayle Dec 8, 2021
e2c83ff
fix syntax in .env; no empty assignments
Dec 3, 2021
cd9baaf
test creation of collections when valkyrie resource
elrayle Dec 3, 2021
ebe5f72
mark unmodified tests pending ‘update of test to work with Hyrax::Pcd…
elrayle Dec 9, 2021
325dc6a
Fix working_directory_spec for docker-compose
marrus-sh Dec 7, 2021
1c14721
Correct spacing to please rubocop
marrus-sh Dec 8, 2021
b586aff
Use File.join to handle trailing slash variance
marrus-sh Dec 8, 2021
4d57079
fix dashboard -> collection not showing collections created as valkyr…
elrayle Dec 9, 2021
c8a2997
fix failure to forward to collection edit after create for PcdmCollec…
elrayle Dec 9, 2021
f937888
provide a NullAnalyticsParser if no analytics provider is given
Dec 10, 2021
d76407e
Merge pull request #5267 from samvera/val_col_create_tests
dlpierce Dec 10, 2021
fdf78a1
Merge pull request #5282 from samvera/val/col_listing
dlpierce Dec 10, 2021
85c8c7c
Merge pull request #5283 from samvera/val_col_create_forward
dlpierce Dec 10, 2021
6ecff5a
Merge pull request #5284 from samvera/analytics-parser-fallback
dlpierce Dec 10, 2021
524c490
temporarily skip thumbnail for PcdmCollection
elrayle Dec 10, 2021
b971747
Merge pull request #5287 from samvera/val/col_skip_thumbnail
dlpierce Dec 10, 2021
52bb3b1
Rename InvalidSolrID to RecordNotFound
marrus-sh Dec 13, 2021
4b51ad9
dassie: update db schema
dunn Dec 10, 2021
a91445f
use actual Hyrax::FileMetadata for ValkyrieFileSetIndexer spec
dunn Dec 15, 2021
3d0daba
wings: hard-code AF::File.default_sort_params
dunn Dec 15, 2021
89bc452
Address log4j CVE-2021-44228
mcritchlow Dec 15, 2021
6491c60
ValkyrieFileSetIndexer: fix indexing of RDF types
dunn Dec 15, 2021
e3baf5e
Fix SerializationError in Regenerate Derivatives job
mark-dce Dec 15, 2021
4ad489f
Update Solr version to 8.11.1 in Chart
mcritchlow Dec 17, 2021
2503857
Qa::Authorities: SearchBuilder#with not #where
marrus-sh Dec 17, 2021
9e744d1
Use SearchBuilder#with to determine nesting depth
marrus-sh Dec 18, 2021
45666fe
Use *_sim not *_tesim for catalog facet tests
marrus-sh Dec 10, 2021
8dfc116
Update solr version that has been tested
jlhardes Dec 17, 2021
73bde8e
add `Hyrax::Controller#repository`
Dec 11, 2021
d3f2257
Add `Hyrax::Controller#search_builder_class`
marrus-sh Dec 13, 2021
6ca5db0
use a fake instead of a double for LeaseSearchBuilder specs
Dec 8, 2021
c56659a
more fake search builders
Dec 8, 2021
180fa1a
Use FakeSearchBuilder in search builder tests
marrus-sh Dec 9, 2021
e937c3c
refactor specs for `Qa::Authorities::Collection` for readability
Dec 13, 2021
c4c4123
Please rubocop
marrus-sh Dec 18, 2021
e1c0c4f
Add `blacklight_config` to `RestrictionService`
marrus-sh Dec 14, 2021
313f283
Update WorksSearchBuilder specs for Blacklight 7
marrus-sh Dec 9, 2021
3aab0dc
ci: use new orb bundle command (#5319)
dunn Jan 7, 2022
f847693
dassie: add pry to gemfile
dunn Jan 6, 2022
f2c09c6
dassie: fix analytics defaults
dunn Jan 6, 2022
441b6f8
Support previous yaml config structure for Analytics (#5315)
orangewolf Jan 7, 2022
c52f3ea
refactor Hyrax::FileMetadata specs
Jan 11, 2022
64a610a
don't attempt to save `AF::WithMetadata::MetadataNode#file_hash`
Jan 11, 2022
90db4aa
teach hyrax how to characterize Valkyrie file uploads
dunn Dec 15, 2021
252c553
add spec for ValkyrieCharacterizationService
dunn Dec 17, 2021
e0b3871
rework ValkyrieCharacterizationService
Jan 11, 2022
d7f5cd7
fixup documentation and other comments on `ValkyrieIngestJob`
Jan 11, 2022
f928b65
lib/engine: add hydra-file_characterization
dunn Jan 11, 2022
51794cc
add a matcher to check a (valkyrie) FileSet for file members
Jan 12, 2022
3a389f6
make the characterization service configurable
Jan 12, 2022
86169ae
test deposit of files via WorkUploadsHandler
Jan 12, 2022
6c384f1
wings: add an error message for a Wings/Fedora-specific error
Jan 11, 2022
03201a5
Merge pull request #5253 from samvera/repo_dispatch
elrayle Jan 19, 2022
740840a
do not get all collections for dashboard (#5325)
elrayle Jan 19, 2022
dd6501a
fix dashboard/my/collections when default admin set table doesn’t exist
elrayle Jan 20, 2022
a728375
Merge pull request #5328 from samvera/bc_default_adminset
elrayle Jan 21, 2022
7b7c2ae
check solr directly for depositor instead of going through ActiveFedora
elrayle Jan 24, 2022
297bd6e
prepare release v3.3.0
Jan 21, 2022
cb48cf6
add @member_docs to assigns for dashboard/collections/show view spec
Jan 24, 2022
828cc4b
add Blacklight::Searchable-like behavior to `Hyrax::Controller`
Dec 11, 2021
c93caa5
ValkyrieIngestJob: ensure FileMetadata exists
dunn Jan 24, 2022
abc7263
remove unused private method in `WorkUploadsHandler`
Jan 25, 2022
5469ff8
fixup docs for ValkyrieIngestJob
Jan 25, 2022
21dafa9
fix failing test for #original_file? status
Jan 25, 2022
8790fb6
chart: bump version of hyrax for helm chart
Jan 24, 2022
4158803
add @member_docs to assigns for admin/admin_sets/show view spec
Jan 24, 2022
c032d21
add test for published events in ValkyrieIngestJob specs
Jan 25, 2022
052186a
unfreeze default FileMetadata#type array
Jan 25, 2022
dd993f3
Test returning of pcdm_collections, force globalid to a string when q…
cjcolvar Jan 25, 2022
593cea7
add a test for query of original file from a file_set after ingest
Jan 25, 2022
8b3ca45
Merge pull request #5368 from samvera/valkyrie_collection_type_collec…
elrayle Jan 25, 2022
8c0979b
Only call render if tabs should be shown
cjcolvar Jan 25, 2022
52fb8fc
publish updates for collection membership in transactional save
Jan 25, 2022
4df65d6
add payload documentation for `*.metadata.updated` events
Jan 25, 2022
0a1c287
Merge pull request #5373 from samvera/only_necessary_tabs
elrayle Jan 25, 2022
4165795
add new event topic for object membership changes; publish in ingest
Jan 25, 2022
181b227
Update valkyrie_ingest_job.rb
dunn Jan 25, 2022
3ed03db
update documentation for `ValkyrieIngestJob`
Jan 25, 2022
c783355
listen for membership changes on objects; index in response
Jan 25, 2022
f000b8b
update admin set create process to convert to valkyrie resource when …
elrayle Jan 25, 2022
8146e45
log create admin set errors
elrayle Jan 25, 2022
2df3a05
display admin set new form when configured for AdministrativeSet
elrayle Jan 25, 2022
67b7565
Merge pull request #5381 from samvera/val/as_config_class
elrayle Jan 26, 2022
945659f
prepopulate `AdministrativeSetForm#member_ids` for display in UI
Jan 26, 2022
1aed227
Persist visibility changes during PcdmCollection updates
cjcolvar Jan 26, 2022
326bcaa
wings: ensure FileMetadata pulled from `ActiveFedora` has a file id
Jan 27, 2022
aef09c8
restore compatiblitity for Valkyrie usage of FileActor; deprecate
Jan 27, 2022
8d0e7fb
ValkyrieIngestJob: don't publish stale metadata
dunn Jan 26, 2022
0475500
Merge pull request #5389 from samvera/admin-set-member-prepop
elrayle Jan 27, 2022
ce4f1be
a first hack at editing admin sets using Valkyrie
Jan 27, 2022
7ec9d9d
add a transactional destroy for valkyrie admin sets
Jan 27, 2022
34229d8
make rubocop happy
elrayle Jan 27, 2022
4ce581f
initial take on support create for valkyrie administrative sets
elrayle Jan 27, 2022
a624f32
use Hyrax.logger for logging
elrayle Jan 27, 2022
984dde5
Merge pull request #5392 from samvera/admin-set-edit-valkyrie
elrayle Jan 27, 2022
c959fef
Merge pull request #5394 from samvera/admin-set-create-valkyrie
elrayle Jan 27, 2022
8e41759
use helper to get permission template for collections and admin sets
elrayle Jan 27, 2022
bb9f393
WorkShowPresenter#member_presenter_factory: pick based on solr model
dunn Jan 27, 2022
4d0a998
use valkyrie-compatible controller methods in FileSet views
dunn Jan 27, 2022
d858666
chart: document chart publishing process
Jan 28, 2022
ccbb0e3
Merge pull request #5415 from samvera/chart-push
dlpierce Jan 28, 2022
6792f5f
add Hyrax::AdministrativeSets to the set of classes displayed on Dash…
elrayle Jan 28, 2022
0954b08
inculde permissions and visibility in AdministrativeSet solr doc
elrayle Jan 28, 2022
01606e3
Fix nokogiri on arm64 alpine
dlpierce Jan 27, 2022
54b6f04
Update FITS
dlpierce Jan 28, 2022
838a554
add collection_type_gid attribute to Hyrax::AdministrativeSets
elrayle Jan 31, 2022
f01616d
Merge pull request #5422 from samvera/as_index_gid
elrayle Jan 31, 2022
8d84eaa
AdministrativeSet#description should be single-valued
Jan 28, 2022
19bee57
Split off hyrax-work-base image and bundle install from dassie
dlpierce Jun 16, 2021
d81a025
Skip including the dassie Gemfile when building in docker-compose
dlpierce Jul 12, 2021
0e38ff0
Create new Valkyrie-based seed script
apertome Jul 14, 2021
db9779b
Implement creating basic works and collections using Valkyrie
apertome Jul 16, 2021
4aca3ae
Handle existing works/collections better; create more works
apertome Jul 16, 2021
31a510f
Integrate seed dirs; add environment variable
apertome Jul 16, 2021
f20b254
Cleanup
apertome Jul 16, 2021
75c88f0
Use real usernames rather than examples; add a child collection; use …
apertome Jul 22, 2021
a47fa40
Set works/collections to public
apertome Jul 27, 2021
d6d255b
Merge
apertome Jan 31, 2022
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
Prev Previous commit
Next Next commit
refactor specs for Qa::Authorities::Collection for readability
remove unused setup and managed whitespace for readability on
`Qa::Authorities::Collection`. i think this whole test setup can be refactored
to stop using `ActiveFedora`, and that should probably happen next.

this is motivated by these tests failing in Blacklight 7.
  • Loading branch information
tamsin johnson authored and tamsin johnson committed Dec 27, 2021
commit e937c3cae2991a1202c34bb4f17281cc2c13895d
7 changes: 3 additions & 4 deletions app/authorities/qa/authorities/collections.rb
Original file line number Diff line number Diff line change
@@ -7,12 +7,11 @@ class Collections < Qa::Authorities::Base
def search(_q, controller)
# The Hyrax::CollectionSearchBuilder expects a current_user
return [] unless controller.current_user
response, _docs = search_response(controller)
response, _ = search_response(controller)
docs = response.documents

docs.map do |doc|
id = doc.id
title = doc.title
{ id: id, label: title, value: id }
{ id: doc.id, label: doc.title, value: doc.id }
end
end

129 changes: 98 additions & 31 deletions spec/authorities/qa/authorities/collections_spec.rb
Original file line number Diff line number Diff line change
@@ -1,68 +1,135 @@
# frozen_string_literal: true

# @todo FactoryBot.build seems to be used to force indexing.
# this can probably be refactored to just index the content we want the
# authority service to find and avoid DB round trips associated with
# `with_permission_template`,etc...
RSpec.describe Qa::Authorities::Collections, :clean_repo do
subject(:service) { described_class.new }
let(:controller) { Qa::TermsController.new }
let(:user1) { build(:user) }
let(:user2) { build(:user) }
let(:q) { "foo" }
let(:service) { described_class.new }
let!(:collection1) { build(:private_collection_lw, id: 'col-1-own', title: ['foo foo'], user: user1, with_permission_template: true, with_solr_document: true) }
let!(:collection2) { build(:private_collection_lw, id: 'col-2-own', title: ['bar'], user: user1, with_permission_template: true, with_solr_document: true) }
let!(:collection3) { build(:private_collection_lw, id: 'col-3-own', title: ['another foo'], user: user1, with_permission_template: true, with_solr_document: true) }
let!(:collection4) { build(:private_collection_lw, id: 'col-4-none', title: ['foo foo foo'], user: user2, with_permission_template: true, with_solr_document: true) }
let(:user1) { FactoryBot.build(:user) }
let(:user2) { FactoryBot.build(:user) }

let!(:collection1) do
FactoryBot.build(:private_collection_lw,
title: ['foo foo'],
user: user1,
with_permission_template: true,
with_solr_document: true)
end

let!(:collection2) do
FactoryBot.build(:private_collection_lw,
title: ['bar'],
user: user1,
with_permission_template: true,
with_solr_document: true)
end

let!(:collection3) do
FactoryBot.build(:private_collection_lw,
title: ['another foo'],
user: user1,
with_permission_template: true,
with_solr_document: true)
end

let!(:collection4) do
FactoryBot.build(:private_collection_lw,
title: ['foo foo foo'],
user: user2,
with_permission_template: true,
with_solr_document: true)
end

let!(:collection5) do
build(:private_collection_lw, id: 'col-5-mgr', title: ['foo for you'], user: user2,
with_permission_template: { manage_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
title: ['foo for you'],
user: user2,
with_permission_template: { manage_users: [user1] },
with_solr_document: true)
end

let!(:collection6) do
build(:private_collection_lw, id: 'col-6-dep', title: ['foo too'], user: user2,
with_permission_template: { deposit_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
title: ['foo too'],
user: user2,
with_permission_template: { deposit_users: [user1] },
with_solr_document: true)
end

let!(:collection7) do
build(:private_collection_lw, id: 'col-7-view', title: ['foo bar baz'], user: user2,
with_permission_template: { view_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
title: ['foo bar baz'],
user: user2,
with_permission_template: { view_users: [user1] },
with_solr_document: true)
end

let!(:collection8) do
build(:private_collection_lw, id: 'col-8-mgr', title: ['bar for you'], user: user2,
with_permission_template: { manage_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
id: 'col-8-mgr',
title: ['bar for you'],
user: user2,
with_permission_template: { manage_users: [user1] },
with_solr_document: true)
end

let!(:collection9) do
build(:private_collection_lw, id: 'col-9-dep', title: ['bar too'], user: user2,
with_permission_template: { deposit_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
title: ['bar too'],
user: user2,
with_permission_template: { deposit_users: [user1] },
with_solr_document: true)
end

let!(:collection10) do
build(:private_collection_lw, id: 'col-10-view', title: ['bar bar baz'], user: user2,
with_permission_template: { view_users: [user1] }, with_solr_document: true)
FactoryBot.build(:private_collection_lw,
title: ['bar bar baz'],
user: user2,
with_permission_template: { view_users: [user1] },
with_solr_document: true)
end

before do
allow(controller).to receive(:params).and_return(params)
allow(controller).to receive(:current_user).and_return(user1)
end

subject { service.search(q, controller) }

describe '#search' do
context 'when access is read' do
let(:params) { ActionController::Parameters.new(q: q, access: 'read') }
let(:params) { ActionController::Parameters.new(q: 'foo', access: 'read') }

it 'displays a list of read collections for the current user' do
expect(subject.map { |result| result[:id] }).to match_array [collection1.id, collection3.id, collection5.id, collection6.id, collection7.id]
it 'lists collections the current user can read' do
expect(service.search(nil, controller))
.to contain_exactly(include(id: collection1.id),
include(id: collection3.id),
include(id: collection5.id),
include(id: collection6.id),
include(id: collection7.id))
end
end

context 'when access is edit' do
let(:params) { ActionController::Parameters.new(q: q, access: 'edit') }
let(:params) { ActionController::Parameters.new(q: 'foo', access: 'edit') }

it 'displays a list of edit collections for the current user' do
expect(subject.map { |result| result[:id] }).to match_array [collection1.id, collection3.id, collection5.id]
it 'lists collections the current user can edit' do
expect(service.search(nil, controller))
.to contain_exactly(include(id: collection1.id),
include(id: collection3.id),
include(id: collection5.id))
end
end

context 'when access is deposit' do
let(:params) { ActionController::Parameters.new(q: q, access: 'deposit') }
let(:params) { ActionController::Parameters.new(q: 'foo', access: 'deposit') }

it 'displays a list of edit and deposit collections for the current user' do
expect(subject.map { |result| result[:id] }).to match_array [collection1.id, collection3.id, collection5.id, collection6.id]
it 'lists collections the current user can edit or deposit' do
expect(service.search(nil, controller))
.to contain_exactly(include(id: collection1.id),
include(id: collection3.id),
include(id: collection5.id),
include(id: collection6.id))
end
end
end