-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reconfigures Collection show pages values. (#755)
* Reconfigures Collection show pages values. * Corrects verbiage. * Corrects one more typo.
- Loading branch information
Showing
9 changed files
with
298 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
config/initializers/hyrax_collection_presenter_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
# [Hyrax-overwrite-v5.0.1] - Adds in our desired collection terms to the show page. | ||
|
||
Rails.application.config.to_prepare do | ||
Hyrax::CollectionPresenter.class_eval do | ||
def self.terms | ||
[ | ||
:creator, :emory_persistent_id, :holding_repository, :institution, :contact_information, :keyword, | ||
:subject, :subject_geo, :subject_names, :rights_notes, :notes | ||
] | ||
end | ||
|
||
delegate(*terms, to: :solr_document) | ||
|
||
def self.admin_terms | ||
[:emory_ark, :system_of_record_ID, :staff_notes, :internal_rights_note, :administrative_unit] | ||
end | ||
|
||
delegate(*admin_terms, to: :solr_document) | ||
|
||
def admin_terms_with_values | ||
self.class.admin_terms.select { |t| self[t].present? } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# frozen_string_literal: true | ||
require 'rails_helper' | ||
require 'hyrax/specs/shared_specs/factories/hyrax_collection' | ||
include Warden::Test::Helpers | ||
|
||
RSpec.describe 'viewing a Collection show page', type: :feature do | ||
let(:user) { FactoryBot.create(:user) } | ||
selector_value_array = [ | ||
['.hyc-title', 'A Good Title'], | ||
['.hyc-description', 'A good description.'], | ||
['.col-sm-8 dd', 'Tom Wolfe'], | ||
['.col-sm-8 dd', '12345678-cor'], | ||
['.col-sm-8 dd', 'Emory University. Library'], | ||
['.col-sm-8 dd', 'Emory University'], | ||
['.col-sm-8 dd', '4075555555'], | ||
['.col-sm-8 dd', 'book'], | ||
['.col-sm-8 dd', 'Southern States'], | ||
['.col-sm-8 dd', 'Atlanta, Georgia, USA'], | ||
['.col-sm-8 dd', 'Radley, Boo'], | ||
['.col-sm-8 dd', 'A note about rights.'], | ||
['.col-sm-8 dd', 'A gernal note.'] | ||
] | ||
|
||
admin_selector_value_array = [ | ||
['.col-sm-8 dd', 'doi:123456'], | ||
['.col-sm-8 dd', '12345789'], | ||
['.col-sm-8 dd', 'A note from a staff member.'], | ||
['.col-sm-8 dd', 'An internal note about rights.'], | ||
['.col-sm-8 dd', 'Faculty'] | ||
] | ||
|
||
dashboard_selector_value_array = [ | ||
['.collection-title', 'A Good Title'], | ||
['.collection-description-wrapper section', 'A good description.'], | ||
['.row dd.col-7', 'Tom Wolfe'], | ||
['.row dd.col-7', '12345678-cor'], | ||
['.row dd.col-7', 'Emory University. Library'], | ||
['.row dd.col-7', 'Emory University'], | ||
['.row dd.col-7', '4075555555'], | ||
['.row dd.col-7', 'book'], | ||
['.row dd.col-7', 'Southern States'], | ||
['.row dd.col-7', 'Atlanta, Georgia, USA'], | ||
['.row dd.col-7', 'Radley, Boo'], | ||
['.row dd.col-7', 'A note about rights.'], | ||
['.row dd.col-7', 'A gernal note.'] | ||
] | ||
|
||
dashboard_admin_selector_value_array = [ | ||
['.row dd.col-7', 'doi:123456'], | ||
['.row dd.col-7', '12345789'], | ||
['.row dd.col-7', 'A note from a staff member.'], | ||
['.row dd.col-7', 'An internal note about rights.'], | ||
['.row dd.col-7', 'Faculty'] | ||
] | ||
|
||
shared_examples 'checks for expected values' do |user_type, test_array| | ||
it "contains the expected values when #{user_type} user" do | ||
test_array.each do |selector, value| | ||
expect(page).to have_selector(selector, text: value) | ||
end | ||
end | ||
end | ||
|
||
shared_examples 'checks for lack of expected values' do |user_type, test_array| | ||
it "contains the expected values when #{user_type} user" do | ||
test_array.each do |selector, value| | ||
expect(page).not_to have_selector(selector, text: value) | ||
end | ||
end | ||
end | ||
|
||
let(:collection) do | ||
FactoryBot.valkyrie_create( | ||
:hyrax_collection, | ||
:public, | ||
title: ['A Good Title'], | ||
description: 'A good description.', | ||
creator: ['Tom Wolfe'], | ||
emory_persistent_id: '12345678-cor', | ||
holding_repository: 'Emory University. Library', | ||
institution: 'Emory University', | ||
contact_information: '4075555555', | ||
keyword: ['book', 'fiction'], | ||
subject: ['Southern States'], | ||
subject_geo: ['Atlanta, Georgia, USA'], | ||
subject_names: ['Radley, Boo'], | ||
rights_notes: ['A note about rights.'], | ||
notes: ['A gernal note.'], | ||
emory_ark: ['doi:123456'], | ||
system_of_record_ID: '12345789', | ||
staff_notes: ['A note from a staff member.'], | ||
internal_rights_note: 'An internal note about rights.', | ||
administrative_unit: 'Faculty' | ||
) | ||
end | ||
|
||
before do | ||
visit "/collections/#{collection.id}" | ||
end | ||
|
||
include_examples 'checks for expected values', 'normal', selector_value_array | ||
include_examples 'checks for lack of expected values', 'normal', admin_selector_value_array | ||
|
||
context 'when admin logged in' do | ||
before do | ||
# the below code adds the admin role to user | ||
user.roles << Role.find_or_create_by(name: Hyrax.config.admin_user_group_name) | ||
user.save | ||
login_as user | ||
visit "/collections/#{collection.id}" | ||
end | ||
|
||
include_examples 'checks for expected values', 'admin', selector_value_array | ||
include_examples 'checks for expected values', 'admin', admin_selector_value_array | ||
end | ||
|
||
describe 'dashboard collection show page' do | ||
before do | ||
login_as user | ||
visit "/dashboard/collections/#{collection.id}" | ||
end | ||
|
||
include_examples 'checks for expected values', 'normal', dashboard_selector_value_array | ||
include_examples 'checks for lack of expected values', 'normal', dashboard_admin_selector_value_array | ||
|
||
context 'when admin logged in' do | ||
before do | ||
# the below code adds the admin role to user | ||
user.roles << Role.find_or_create_by(name: Hyrax.config.admin_user_group_name) | ||
user.save | ||
login_as user | ||
visit "/dashboard/collections/#{collection.id}" | ||
end | ||
|
||
include_examples 'checks for expected values', 'admin', dashboard_selector_value_array | ||
include_examples 'checks for expected values', 'admin', dashboard_admin_selector_value_array | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,52 @@ | |
'\"2024-07-08T15:36:11.455+00:00\",\"event_start\":\"2024-07-07T15:46:11.455+00:00\",\"event_type\":' \ | ||
'\"Policy Assignment\",\"initiating_user\":\"[email protected]\",\"outcome\":\"Success\",' \ | ||
'\"software_version\":\"SelfDeposit 1.0\"}') | ||
include_examples('tests for a direct solr index value return', | ||
'emory_persistent_id', | ||
'emory_persistent_id_ssi', | ||
'12345678-cor') | ||
include_examples('tests for a direct solr index value return', | ||
'holding_repository', | ||
'holding_repository_ssi', | ||
'Emory University. Libraries') | ||
include_examples('tests for a direct solr index value return', | ||
'institution', | ||
'institution_ssi', | ||
'Emory University') | ||
include_examples('tests for a direct solr index value return', | ||
'contact_information', | ||
'contact_information_ssi', | ||
'4075555555') | ||
include_examples('tests for a direct solr index value return', | ||
'subject_geo', | ||
'subject_geo_ssim', | ||
['Atlanta, Georgia, USA']) | ||
include_examples('tests for a direct solr index value return', | ||
'subject_names', | ||
'subject_names_ssim', | ||
['Carter, Jimmy']) | ||
include_examples('tests for a direct solr index value return', | ||
'notes', | ||
'notes_ssim', | ||
['A note.']) | ||
include_examples('tests for a direct solr index value return', | ||
'emory_ark', | ||
'emory_ark_tesim', | ||
['doi:123456']) | ||
include_examples('tests for a direct solr index value return', | ||
'system_of_record_ID', | ||
'system_of_record_ID_ssi', | ||
'12345678-cor') | ||
include_examples('tests for a direct solr index value return', | ||
'staff_notes', | ||
'staff_notes_tesim', | ||
['A note.']) | ||
include_examples('tests for a direct solr index value return', | ||
'internal_rights_note', | ||
'internal_rights_note_tesi', | ||
'A note.') | ||
include_examples('tests for a direct solr index value return', | ||
'administrative_unit', | ||
'administrative_unit_ssi', | ||
'Faculty') | ||
end |