diff --git a/README.md b/README.md index be13d20476..ff0bac1fe9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Docs: [![Documentation Status](https://inch-ci.org/github/samvera/hyrax.svg?bran [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE) Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samvera.org/) -[![Ready Tickets](https://badge.waffle.io/samvera/hyrax.png?label=ready&milestone=2.0.0&title=Ready)](https://waffle.io/samvera/hyrax?milestone=2.0.0) +[![Ready Tickets](https://badge.waffle.io/samvera/hyrax.png?label=ready&milestone=2.x%20series&title=Ready)](https://waffle.io/samvera/hyrax?milestone=2.x%20series) # Table of Contents @@ -63,7 +63,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/ # Getting started This document contains instructions specific to setting up an app with __Hyrax -v2.0.0.beta5__. If you are looking for instructions on installing a different +v2.0.0.rc2__. If you are looking for instructions on installing a different version, be sure to select the appropriate branch or tag from the drop-down menu above. @@ -160,7 +160,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app. Generate a new Rails application using the template. ``` -rails _5.0.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.beta5/template.rb +rails _5.0.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.rc2/template.rb ``` Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including: diff --git a/Valkyrie_README.md b/Valkyrie_README.md index ba9017d238..b3f21bc62e 100644 --- a/Valkyrie_README.md +++ b/Valkyrie_README.md @@ -8,7 +8,7 @@ * Models do not validate themselves (See ChangeSets) * Models do not index themselves. * FileSet#original_file is now ??? -* In FactoryGirl factories: +* In FactoryBot factories: * use create_for_repository instead of create * Nested attributes (e.g. FileSet#permissions_attributes=) are out * Switch from create_date_dtsi to created_at_dtsi and system_modified_dtsi to timestamp diff --git a/app/actors/hyrax/actors/assign_representative_actor.rb b/app/actors/hyrax/actors/assign_representative_actor.rb deleted file mode 100644 index 777c914df4..0000000000 --- a/app/actors/hyrax/actors/assign_representative_actor.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Hyrax - module Actors - class AssignRepresentativeActor < AbstractActor - # @param [Hyrax::Actors::Environment] env - # @return [Boolean] true if create was successful - def create(env) - next_actor.create(env) && assign_representative(env) - end - - private - - def assign_representative(env) - unless env.curation_concern.representative_id - # TODO: Possible optimization here. Does this cause a fetch of members if they're already loaded? - representative = nil # curation_concern.ordered_members.association.reader.first.target - env.curation_concern.representative = representative if representative - end - env.curation_concern.save - end - end - end -end diff --git a/app/actors/hyrax/actors/create_with_remote_files_actor.rb b/app/actors/hyrax/actors/create_with_remote_files_actor.rb index 6d59029a84..e33680e60a 100644 --- a/app/actors/hyrax/actors/create_with_remote_files_actor.rb +++ b/app/actors/hyrax/actors/create_with_remote_files_actor.rb @@ -1,6 +1,10 @@ module Hyrax module Actors - # Attaches remote files to the work + # If there is a key `:remote_files' in the attributes, it attaches the files at the specified URIs + # to the work. e.g.: + # attributes[:remote_files] = filenames.map do |name| + # { url: "https://example.com/file/#{name}", file_name: name } + # end class CreateWithRemoteFilesActor < Hyrax::Actors::AbstractActor # @param [Hyrax::Actors::Environment] env # @return [Boolean] true if create was successful diff --git a/app/assets/javascripts/hyrax/save_work/visibility_component.es6 b/app/assets/javascripts/hyrax/save_work/visibility_component.es6 index 1225e1af03..841d16d9a0 100644 --- a/app/assets/javascripts/hyrax/save_work/visibility_component.es6 +++ b/app/assets/javascripts/hyrax/save_work/visibility_component.es6 @@ -76,14 +76,9 @@ export default class VisibilityComponent { // Apply visibility/release restrictions based on selected AdminSet applyRestrictions(visibility, release_no_delay, release_date, release_before) { - // If immediate release required and visibility specified - if(release_no_delay && visibility) { - // Select required visibility - this.selectVisibility(visibility) - } - else if(release_no_delay) { - // No visibility required, but must be released today. Disable embargo & lease. - this.disableEmbargoAndLease(); + // If immediate release required or the release date is in the past. + if(release_no_delay || (release_date && (new Date() > Date.parse(release_date)))) { + this.requireReleaseNow(visibility) } // Otherwise if future date and release_before==true, must be released between today and release_date else if(release_date && release_before) { @@ -137,6 +132,18 @@ export default class VisibilityComponent { this.selectVisibilityAfterEmbargo(visibility) } + // Require release now + requireReleaseNow(visibility) { + if(visibility) { + // Select required visibility + this.selectVisibility(visibility) + } + else { + // No visibility required, but must be released today. Disable embargo & lease. + this.disableEmbargoAndLease() + } + } + // Disable Embargo and Lease options. Work must be released immediately disableEmbargoAndLease() { this.disableVisibilityOptions(["embargo","lease"]) @@ -153,6 +160,8 @@ export default class VisibilityComponent { this.element.find(matchEnabled).prop("disabled", false) } this.element.find(matchDisabled).prop("disabled", true) + + this.checkEnabledVisibilityOption() } // Disable one or more visibility option (based on array of passed in options), @@ -166,6 +175,8 @@ export default class VisibilityComponent { this.element.find(matchDisabled).prop("disabled", true) } this.element.find(matchEnabled).prop("disabled", false) + + this.checkEnabledVisibilityOption() } // Create a jQuery matcher which will match for all the specified options @@ -255,6 +266,16 @@ export default class VisibilityComponent { return this.element.find("select[id$='_visibility_after_embargo']") } + // If the selected visibility option is disabled change selection to the + // least public option that is enabled. + checkEnabledVisibilityOption() { + if (this.element.find("[type='radio']:disabled:checked").length > 0) { + this.element.find("[type='radio']:enabled").last().prop('checked', true) + // Ensure required option is opened in form + this.showForm() + } + } + // Get today's date in YYYY-MM-DD format getToday() { let today = new Date() diff --git a/app/assets/stylesheets/_bootstrap-default-overrides.scss b/app/assets/stylesheets/_bootstrap-default-overrides.scss new file mode 100644 index 0000000000..8c911cb03c --- /dev/null +++ b/app/assets/stylesheets/_bootstrap-default-overrides.scss @@ -0,0 +1,5 @@ +// Brand colors +$brand-danger: #d33a35 !default; +$brand-success: #387f38 !default; +$brand-info: #2c76c7 !default; +$brand-warning: #565653 !default; diff --git a/app/assets/stylesheets/hyrax/_forms.scss b/app/assets/stylesheets/hyrax/_forms.scss index bafa9ae03f..6d9c4a67a4 100644 --- a/app/assets/stylesheets/hyrax/_forms.scss +++ b/app/assets/stylesheets/hyrax/_forms.scss @@ -20,6 +20,10 @@ legend small { } } +#savewidget a { + color: #2a62bc; +} + .label-checkbox .label-text { display:block; padding-left:1.2em; diff --git a/app/assets/stylesheets/hyrax/_header.scss b/app/assets/stylesheets/hyrax/_header.scss index c82bb2f0a1..56a8b5e3e9 100644 --- a/app/assets/stylesheets/hyrax/_header.scss +++ b/app/assets/stylesheets/hyrax/_header.scss @@ -20,3 +20,9 @@ .nav > li > .notify-number { padding-right: 0; } + +.dropdown-toggle:focus { + outline: 2px auto Highlight; // FireFox + outline: 5px auto -webkit-focus-ring-color; // Chrome, Safari + outline: -2px; +} diff --git a/app/controllers/concerns/hyrax/works_controller_behavior.rb b/app/controllers/concerns/hyrax/works_controller_behavior.rb index 88a6696f52..e438ab527a 100644 --- a/app/controllers/concerns/hyrax/works_controller_behavior.rb +++ b/app/controllers/concerns/hyrax/works_controller_behavior.rb @@ -7,7 +7,6 @@ module WorksControllerBehavior included do layout :decide_layout - copy_blacklight_config_from(::CatalogController) class_attribute :show_presenter, :search_builder_class self.show_presenter = Hyrax::WorkShowPresenter @@ -17,6 +16,7 @@ module WorksControllerBehavior storage_adapter: Valkyrie.config.storage_adapter ) + self.theme = 'hyrax/1_column' attr_accessor :curation_concern helper_method :curation_concern, :contextual_path diff --git a/app/controllers/hyrax/admin/permission_template_accesses_controller.rb b/app/controllers/hyrax/admin/permission_template_accesses_controller.rb index cb2452ad0b..62823c9066 100644 --- a/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +++ b/app/controllers/hyrax/admin/permission_template_accesses_controller.rb @@ -6,7 +6,7 @@ class PermissionTemplateAccessesController < ApplicationController def destroy ActiveRecord::Base.transaction do @permission_template_access.destroy - update_management if @permission_template_access.manage? + remove_access! end if @permission_template_access.destroyed? @@ -28,8 +28,9 @@ def admin_set_id @admin_set_id ||= @permission_template_access.permission_template.admin_set_id end - def update_management - Forms::PermissionTemplateForm.new(@permission_template_access.permission_template).update_management + def remove_access! + Forms::PermissionTemplateForm.new(@permission_template_access.permission_template) + .remove_access!(@permission_template_access) end end end diff --git a/app/controllers/hyrax/collections_controller.rb b/app/controllers/hyrax/collections_controller.rb index 331b63a9e1..6b53618f0d 100644 --- a/app/controllers/hyrax/collections_controller.rb +++ b/app/controllers/hyrax/collections_controller.rb @@ -5,6 +5,8 @@ class CollectionsController < ApplicationController layout :decide_layout load_and_authorize_resource except: [:index, :show, :create], instance_name: :collection + self.theme = 'hyrax/1_column' + # Renders a JSON response with a list of files in this collection # This is used by the edit form to populate the thumbnail_id dropdown def files diff --git a/app/forms/hyrax/forms/permission_template_form.rb b/app/forms/hyrax/forms/permission_template_form.rb index f4184d43e0..f92ef319d6 100644 --- a/app/forms/hyrax/forms/permission_template_form.rb +++ b/app/forms/hyrax/forms/permission_template_form.rb @@ -20,6 +20,9 @@ class PermissionTemplateForm # Stores the selected attr_writer :workflow_id + # Adding attributes hash to state to avoid having to pass it around + attr_accessor :attributes + def workflow_id @workflow_id || active_workflow.try(:id) end @@ -41,54 +44,114 @@ def initialize(model) # @return [Hash{Symbol => String, Boolean}] { :content_tab (for confirmation message), # :updated (true/false), # :error_code (for flash error lookup) } + # rubocop:disable Metrics/MethodLength def update(attributes) - return_info = { content_tab: tab_to_update(attributes) } + @attributes = attributes + return_info = { content_tab: tab_to_update } error_code = nil case return_info[:content_tab] when "participants" - update_participants_options(attributes) + update_participants_options when "visibility" - error_code = update_visibility_options(attributes) + error_code = update_visibility_options when "workflow" - grant_workflow_roles(attributes) + grant_workflow_roles end return_info[:error_code] = error_code if error_code return_info[:updated] = error_code ? false : true return_info end + # rubocop:enable Metrics/MethodLength - # If management roles have been granted or removed, then copy this access - # to the edit permissions of the AdminSet and to the WorkflowResponsibilities - # of the active workflow def update_management admin_set.update_access_controls! - update_workflow_approving_responsibilities + update_workflow_responsibilities + end + + # This method is used to revoke access to an Admin Set and its workflows + # + # @return [Void] + def remove_access!(permission_template_access) + construct_attributes_from_template_access!(permission_template_access) + admin_set.update_access_controls! + update_workflow_responsibilities(remove_agent: true) end private # @return [String] - def tab_to_update(attributes) + def tab_to_update return "participants" if attributes[:access_grants_attributes].present? return "workflow" if attributes[:workflow_id].present? return "visibility" if attributes.key?(:visibility) end + # This method is used to build the attributes that this class + # relies on using the passed-in PermissionTemplateAccess + # instance. This allows the class to use the same methods for + # granting access (when a new Admin Set manager is added, for + # instance), when called via #update, for revoking access as + # well when called via #remove_access! + # # @return [Void] - def update_participants_options(attributes) - update_permission_template(attributes) - # if managers were added, recalculate update the access controls on the AdminSet - return unless managers_updated?(attributes) - update_management + def construct_attributes_from_template_access!(permission_template_access) + @attributes = { + access_grants_attributes: { + "0" => { + access: permission_template_access.access, + agent_type: permission_template_access.agent_type, + agent_id: permission_template_access.agent_id + } + } + } end - # Grant workflow approve roles for any admin set managers - # and revoke the approving role for non-managers - def update_workflow_approving_responsibilities - return unless active_workflow - approving_role = Sipity::Role.find_by_name('approving') - return unless approving_role - active_workflow.update_responsibilities(role: approving_role, agents: manager_agents) + # @return [Void] + def update_participants_options + update_permission_template + update_workflow_responsibilities + # if managers were added or removed, recalculate update the access controls on the AdminSet + admin_set.update_access_controls! if managers_updated? + end + + # Grant appropriate workflow roles based on access specified + def update_workflow_responsibilities(remove_agent: false) + return unless available_workflows + roles = roles_for_agent + return if roles.none? + agents = remove_agent ? manager_agents - agents_from_attributes : manager_agents + agents_from_attributes + available_workflows.each do |workflow| + roles.each do |role| + workflow.update_responsibilities(role: role, agents: agents) + end + end + end + + def roles_for_agent + roles = [] + grants_as_collection.each do |grant| + case grant[:access] + when Hyrax::PermissionTemplateAccess::DEPOSIT + roles << Sipity::Role.find_by(name: Hyrax::RoleRegistry::DEPOSITING) + when Hyrax::PermissionTemplateAccess::MANAGE + roles += Sipity::Role.where(name: Hyrax::RoleRegistry.new.role_names) + # TODO: Figure out what to do here + # when Hyrax::PermissionTemplateAccess::VIEW + end + end + roles.uniq + end + + # @return [Array] a list sipity agents extracted from attrs + def agents_from_attributes + grants_as_collection.map do |grant| + agent = if grant[:agent_type] == 'user' + ::User.find_by_user_key(grant[:agent_id]) + else + Hyrax::Group.new(grant[:agent_id]) + end + PowerConverter.convert_to_sipity_agent(agent) + end end # @return [Array] a list of sipity agents corresponding to the manager role of the permission_template @@ -107,17 +170,17 @@ def manager_agents # @return [Array] a list of grants corresponding to the manager role of the permission_template def manager_grants - model.access_grants.where(access: 'manage'.freeze) + model.access_grants.where(access: Hyrax::PermissionTemplateAccess::MANAGE) end # @return [String, Nil] error_code if validation fails, nil otherwise - def update_visibility_options(attributes) - error_code = validate_visibility_combinations(attributes) + def update_visibility_options + error_code = validate_visibility_combinations return error_code if error_code - update_permission_template(attributes) + update_permission_template end - def activate_workflow_from(attributes) + def activate_workflow_from_attributes new_active_workflow_id = attributes[:workflow_id] || attributes['workflow_id'] if active_workflow return active_workflow if new_active_workflow_id.to_s == active_workflow.id.to_s @@ -131,28 +194,29 @@ def activate_workflow_from(attributes) # have all the roles for the new workflow # @return [Void] # @todo Instead of granting the manage users all of the roles (which means lots of emails), can we agree on a Managing role that all workflows should have? - def grant_workflow_roles(attributes) - new_active_workflow = activate_workflow_from(attributes) + def grant_workflow_roles + new_active_workflow = activate_workflow_from_attributes return unless new_active_workflow manager_agents.each do |agent| - active_workflow.workflow_roles.each do |role| - Sipity::WorkflowResponsibility.find_or_create_by!(workflow_role: role, agent: agent) + active_workflow.workflow_roles.each do |workflow_role| + new_workflow_role = Sipity::WorkflowRole.find_or_create_by!(workflow: new_active_workflow, role: workflow_role.role) + Sipity::WorkflowResponsibility.find_or_create_by!(workflow_role: new_workflow_role, agent: agent) end end end # @return [Nil] - def update_permission_template(attributes) - model.update(permission_template_update_params(attributes)) + def update_permission_template + model.update(permission_template_update_params) nil end - def managers_updated?(attributes) - grants_as_collection(attributes).any? { |x| x[:access] == 'manage' } + def managers_updated? + grants_as_collection.any? { |x| x[:access] == Hyrax::PermissionTemplateAccess::MANAGE } end # This allows the attributes - def grants_as_collection(attributes) + def grants_as_collection return [] unless attributes[:access_grants_attributes] attributes_collection = attributes[:access_grants_attributes] if attributes_collection.respond_to?(:permitted?) @@ -186,42 +250,43 @@ def select_release_varies_option(permission_template) # Removes release_varies and release_embargo from the returned attributes # These form fields are only used to update release_period # @return [Hash] attributes used to update the model - def permission_template_update_params(raw_attributes) - attributes = raw_attributes.except(:release_varies, :release_embargo) + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + def permission_template_update_params + filtered_attributes = attributes.except(:release_varies, :release_embargo) # If 'varies' before date option selected, then set release_period='before' and save release_date as-is - if raw_attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE - attributes[:release_period] = Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE + if attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE + filtered_attributes[:release_period] = Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE # Else if 'varies' + embargo selected, save embargo as the release_period - elsif raw_attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_EMBARGO && - raw_attributes[:release_embargo] - attributes[:release_period] = raw_attributes[:release_embargo] + elsif attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_EMBARGO && + attributes[:release_embargo] + filtered_attributes[:release_period] = attributes[:release_embargo] # In an embargo, the release_date should be unspecified as it is based on deposit date - attributes[:release_date] = nil + filtered_attributes[:release_date] = nil end - if attributes[:release_period] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY - # If release is "no delay", a release_date should never be allowed/specified - attributes[:release_date] = nil + if filtered_attributes[:release_period] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_NO_DELAY || (filtered_attributes[:release_period].blank? && attributes[:release_varies].blank?) + # If release is "no delay" or is "varies" and "allow depositor to decide", + # then a release_date should never be allowed/specified + filtered_attributes[:release_date] = nil end - attributes + filtered_attributes end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity # validate the hash of attributes used to update the visibility tab of the model - # @param [Hash] attributes # @return [String, Nil] the error code if invalid, nil if valid # rubocop:disable Metrics/CyclomaticComplexity - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/PerceivedComplexity - def validate_visibility_combinations(attributes) + # rubocop:disable Metrics/AbcSize + def validate_visibility_combinations return unless attributes.key?(:visibility) # only the visibility tab has validations # if "save" without any selections - none of the attributes are present return "nothing" if !attributes[:release_varies] && !attributes[:release_period] && !attributes[:release_date] && !attributes[:release_embargo] - # if "varies" without sub-options (in this case, release_varies will be missing) - return "varies" if attributes[:release_period].blank? && attributes[:release_varies].blank? - # if "varies before" but date not selected return "no_date" if attributes[:release_varies] == Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE && attributes[:release_date].blank? diff --git a/app/jobs/ingest_local_file_job.rb b/app/jobs/ingest_local_file_job.rb index 7e2457c3cc..e2630673bb 100644 --- a/app/jobs/ingest_local_file_job.rb +++ b/app/jobs/ingest_local_file_job.rb @@ -10,7 +10,6 @@ def perform(file_set, path, user) actor = Hyrax::Actors::FileSetActor.new(file_set, user) if actor.create_content(File.open(path)) - FileUtils.rm(path) Hyrax.config.callback.run(:after_import_local_file_success, file_set, user, path) else Hyrax.config.callback.run(:after_import_local_file_failure, file_set, user, path) diff --git a/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb b/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb new file mode 100644 index 0000000000..90ff31c447 --- /dev/null +++ b/app/renderers/hyrax/renderers/rights_statement_attribute_renderer.rb @@ -0,0 +1,25 @@ +module Hyrax + module Renderers + # This is used by PresentsAttributes to show licenses + # e.g.: presenter.attribute_to_html(:rights_statement, render_as: :rights_statement) + class RightsStatementAttributeRenderer < AttributeRenderer + private + + ## + # Special treatment for license/rights. A URL from the Hyrax gem's config/hyrax.rb is stored in the descMetadata of the + # curation_concern. If that URL is valid in form, then it is used as a link. If it is not valid, it is used as plain text. + def attribute_value_to_html(value) + begin + parsed_uri = URI.parse(value) + rescue + nil + end + if parsed_uri.nil? + ERB::Util.h(value) + else + %(#{Hyrax.config.rights_statement_service_class.new.label(value)}) + end + end + end + end +end diff --git a/app/services/hyrax/default_middleware_stack.rb b/app/services/hyrax/default_middleware_stack.rb index b598405156..21d095afbb 100644 --- a/app/services/hyrax/default_middleware_stack.rb +++ b/app/services/hyrax/default_middleware_stack.rb @@ -9,7 +9,6 @@ def self.build_stack middleware.use Hyrax::Actors::CreateWithFilesActor middleware.use Hyrax::Actors::CollectionsMembershipActor middleware.use Hyrax::Actors::AddToWorkActor - middleware.use Hyrax::Actors::AssignRepresentativeActor middleware.use Hyrax::Actors::AttachMembersActor middleware.use Hyrax::Actors::InterpretVisibilityActor middleware.use Hyrax::Actors::TransferRequestActor diff --git a/app/services/hyrax/file_set_derivatives_service.rb b/app/services/hyrax/file_set_derivatives_service.rb index 92d589ef8d..134b2d727c 100644 --- a/app/services/hyrax/file_set_derivatives_service.rb +++ b/app/services/hyrax/file_set_derivatives_service.rb @@ -48,15 +48,24 @@ def supported_mime_types def create_pdf_derivatives(filename) Hydra::Derivatives::PdfDerivatives.create(filename, - outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', url: derivative_url('thumbnail') }]) + outputs: [{ + label: :thumbnail, + format: 'jpg', + size: '338x493', + url: derivative_url('thumbnail'), + layer: 0 + }]) extract_full_text(filename, uri) end def create_office_document_derivatives(filename) Hydra::Derivatives::DocumentDerivatives.create(filename, - outputs: [{ label: :thumbnail, format: 'jpg', - size: '200x150>', - url: derivative_url('thumbnail') }]) + outputs: [{ + label: :thumbnail, format: 'jpg', + size: '200x150>', + url: derivative_url('thumbnail'), + layer: 0 + }]) extract_full_text(filename, uri) end diff --git a/app/services/hyrax/workflow/abstract_notification.rb b/app/services/hyrax/workflow/abstract_notification.rb index 323ffa1a53..81d95fcd2c 100644 --- a/app/services/hyrax/workflow/abstract_notification.rb +++ b/app/services/hyrax/workflow/abstract_notification.rb @@ -41,7 +41,8 @@ def initialize(entity, comment, user, recipients) @work_id = entity.proxy_for_global_id.sub(/.*\//, '') @title = entity.proxy_for.title.first @comment = comment.respond_to?(:comment) ? comment.comment.to_s : '' - @recipients = recipients + # Convert to hash with indifferent access to allow both string and symbol keys + @recipients = recipients.with_indifferent_access @user = user @entity = entity end @@ -73,7 +74,7 @@ def document_path end def users_to_notify - recipients.fetch('to', []) + recipients.fetch('cc', []) + recipients.fetch(:to, []) + recipients.fetch(:cc, []) end end end diff --git a/app/services/hyrax/workflow/notification_service.rb b/app/services/hyrax/workflow/notification_service.rb index f585251575..df4f1b0a87 100644 --- a/app/services/hyrax/workflow/notification_service.rb +++ b/app/services/hyrax/workflow/notification_service.rb @@ -48,18 +48,9 @@ def send_notification(notification) # @return [Hash] a hash with keys being the strategy (e.g. "to", "cc") and # the values are a list of users. def recipients(notification) - case entity.workflow_state.name - when 'pending_review' - # notify the managers to review the deposit (CC depositors) - { - to: entity.workflow.permission_template.agent_ids_for(access: 'manage', agent_type: 'user'), - cc: entity.workflow.permission_template.agent_ids_for(access: 'deposit', agent_type: 'user') - } - else - notification.recipients.each_with_object({}) do |r, h| - h[r.recipient_strategy] ||= [] - h[r.recipient_strategy] += PermissionQuery.scope_users_for_entity_and_roles(entity: entity, roles: r.role) - end + notification.recipients.each_with_object({}) do |r, h| + h[r.recipient_strategy] ||= [] + h[r.recipient_strategy] += PermissionQuery.scope_users_for_entity_and_roles(entity: entity, roles: r.role) end end diff --git a/app/services/hyrax/workflow/permission_query.rb b/app/services/hyrax/workflow/permission_query.rb index 171f1edb7c..8ad3c7e727 100644 --- a/app/services/hyrax/workflow/permission_query.rb +++ b/app/services/hyrax/workflow/permission_query.rb @@ -231,8 +231,8 @@ def scope_entities_for_the_user(user:) # # An ActiveRecord::Relation scope that meets the following criteria: # - # * Users that are directly associated with the given entity through on or - # more of the given roles + # * Users that are directly associated with the given entity through one or + # more of the given roles within the entity's workflow # * Users that are indirectly associated with the given entity by group # and role. # @@ -248,7 +248,7 @@ def scope_users_for_entity_and_roles(entity:, roles:) agent_table = Sipity::Agent.arel_table workflow_role_id_subquery = workflow_roles.project(workflow_roles[:id]).where( - workflow_roles[:role_id].in(role_ids) + workflow_roles[:workflow_id].eq(entity.workflow_id).and(workflow_roles[:role_id].in(role_ids)) ) workflow_agent_id_subquery = workflow_responsibilities.project(workflow_responsibilities[:agent_id]).where( diff --git a/app/services/hyrax/workflow/status_list_service.rb b/app/services/hyrax/workflow/status_list_service.rb index ffbde4de64..131bae0e8f 100644 --- a/app/services/hyrax/workflow/status_list_service.rb +++ b/app/services/hyrax/workflow/status_list_service.rb @@ -44,6 +44,7 @@ def search_solr work_query = WorksSearchBuilder.new([:filter_models], self).query work_query["fq"] += query(actionable_roles) work_query["rows"] = 1000 + # TODO: can we make this use a POST? repository.search(work_query).response["docs"] end diff --git a/app/views/hyrax/admin/admin_sets/_form_participants.html.erb b/app/views/hyrax/admin/admin_sets/_form_participants.html.erb index 864c549a52..c3e64a0112 100644 --- a/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +++ b/app/views/hyrax/admin/admin_sets/_form_participants.html.erb @@ -51,6 +51,7 @@ class: 'form-control' %> <%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info' %> +

<%= t('hyrax.admin.admin_sets.form.note')%>

<% end %> diff --git a/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb b/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb index ccce95ecc1..3a0419327b 100644 --- a/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +++ b/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb @@ -14,10 +14,16 @@
    +
  • + +
  • diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index ea388a6a13..fbc1a81cb2 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -10,4 +10,4 @@ <%= presenter.attribute_to_html(:related_url, render_as: :external_link) %> <%= presenter.attribute_to_html(:resource_type, render_as: :faceted) %> <%= presenter.attribute_to_html(:source) %> -<%= presenter.attribute_to_html(:rights_statement) %> +<%= presenter.attribute_to_html(:rights_statement, render_as: :rights_statement) %> diff --git a/app/views/hyrax/collections/show.html.erb b/app/views/hyrax/collections/show.html.erb index 3fb8afdf8b..4bbc548c52 100644 --- a/app/views/hyrax/collections/show.html.erb +++ b/app/views/hyrax/collections/show.html.erb @@ -12,6 +12,9 @@
<%= render 'media_display', presenter: @presenter %> + <% unless has_collection_search_parameters? %> + <%= render 'hyrax/dashboard/collections/show_actions', presenter: @presenter %> + <% end %>
diff --git a/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb b/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb index 124b17c40f..b67ac3d564 100644 --- a/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb +++ b/app/views/hyrax/dashboard/_index_partials/_proxy_rights.html.erb @@ -13,6 +13,7 @@ <% user.can_receive_deposits_from.each do |depositor| %> <%= depositor.name %> <%= link_to(hyrax.user_depositor_path(user, depositor), method: :delete, class: "remove-proxy-button") do %> + <%= I18n.t('hyrax.dashboard.proxy_delete') %> <% end %> <% end %> diff --git a/app/views/hyrax/my/_sort_and_per_page.html.erb b/app/views/hyrax/my/_sort_and_per_page.html.erb index 3f850bcdb4..0c6aa2c604 100644 --- a/app/views/hyrax/my/_sort_and_per_page.html.erb +++ b/app/views/hyrax/my/_sort_and_per_page.html.erb @@ -3,6 +3,7 @@ <%= form_tag search_action_for_dashboard, method: :get, class: 'per_page form-inline' do %>
+ <%= t('hyrax.dashboard.my.sr.results_per_page') %> <%= label_tag :per_page do %> Show <%= select_tag :per_page, options_for_select(['10', '20', '50', '100'], h(params[:per_page])), title: "Number of results to display per page" %> per page diff --git a/app/views/hyrax/notifications/_notifications.html.erb b/app/views/hyrax/notifications/_notifications.html.erb index 4ef13d7dbd..db3b3eac8e 100644 --- a/app/views/hyrax/notifications/_notifications.html.erb +++ b/app/views/hyrax/notifications/_notifications.html.erb @@ -24,6 +24,7 @@ class: "itemicon itemtrash", title: t('hyrax.mailbox.delete'), method: :delete do %> + <%= I18n.t('hyrax.dashboard.delete_notification') %> <% end %> diff --git a/config/locales/hyrax.de.yml b/config/locales/hyrax.de.yml index cafc661555..69d8976009 100644 --- a/config/locales/hyrax.de.yml +++ b/config/locales/hyrax.de.yml @@ -72,6 +72,7 @@ de: header: Admin-Set bearbeiten form: cancel: Abbrechen + note: Benutzern, denen eine neue Rolle zugewiesen wurde, wird nur die Rolle zugewiesen, die nach der Gewährung dieser Rolle hinterlegt wurde. permission_destroy_errors: admin_group: Die Gruppe der Administratoren des Repositoriums kann nicht entfernt werden permission_update_errors: @@ -133,6 +134,7 @@ de: no_delay: Keine Verzögerung - Freigabe aller Arbeiten, sobald sie hinterlegt sind title: Freigabe varies: + any: Dem Deponierer erlauben, sich zu entscheiden between: Zwischen "jetzt" und description: 'Variabel - Deponenten können den Freigabedatum für eine einzelne Arbeit festlegen:' embargo: @@ -141,6 +143,7 @@ de: 3yrs: 3 Jahre nach der Deponierung 6mos: 6 Monate nach der Deponierung select: Wählen Sie die Sperrfrist aus. + period: 'Der Einlieferer kann eine Embargo-Frist bis zu:' visibility: description: 'Nach dem Release-Datum können die Arbeiten in diesem Admin-Set eingesehen und heruntergeladen werden durch:' everyone: Jeder - alle Arbeiten in diesem Admin-Set werden öffentlich sein @@ -169,8 +172,8 @@ de: index: action: Aktion description: Beschreibung - feature: Charakteristisch - header: Charakteristik + feature: Features + header: Features sidebar: activity: Aktivität admin_sets: Admin-Sets @@ -430,6 +433,7 @@ de: works_in_collection: Arbeiten in dieser Sammlung create_work: Arbeien erstellen current_proxies: Aktuelle Proxies + delete_notification: Benachrichtigung löschen heading_actions: close: Schließen create_work: Arbeit erstellen @@ -481,6 +485,7 @@ de: no_transfer_requests: Sie haben keine Arbeitsübertragungsanforderungen erhalten no_transfers: Sie haben keine Arbeit übertragen proxy_activity: Proxy-Aktivität + proxy_delete: Proxy löschen proxy_user: Proxy-Benutzer show_admin: new_visitors: Neue Besucher diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml index de4cee1b23..0b36fb686a 100644 --- a/config/locales/hyrax.en.yml +++ b/config/locales/hyrax.en.yml @@ -71,6 +71,7 @@ en: header: "Edit Administrative Set" form: cancel: "Cancel" + note: "Users granted a new role will only gain the role on works that are deposited after that role has been granted." permission_destroy_errors: admin_group: "The repository administrators group cannot be removed" permission_update_notices: @@ -80,7 +81,6 @@ en: visibility: "The administrative set's release & visibility settings have been updated." workflow: "The administrative set's workflow has been updated." permission_update_errors: - varies: "Release option 'Varies' requires a date or embargo period." no_date: "A date is required for the selected release option." no_embargo: "An embargo period is required for the selected option." nothing: "Select release options before pressing save." @@ -125,15 +125,17 @@ en: current_participants: "Current Participants" form_visibility: cancel: "Cancel" - page_description: "Release and visibility settings control when works added to this set are made available for discovery and download and who can discover and download them." + page_description: "Release and visibility settings determine the options available to depositors when submitting a work to this administrative set. Changes to these settings do not affect previously deposited works." release: - description: "You can impose a delay (embargo) before works in this administrative set are released for discovery and download." - fixed: "Fixed -- delay release of all works until" - no_delay: "No delay -- release all works as soon as they are deposited" + description: "Set embargoes and lease polices for this administrative set." + fixed: "Depositor must choose embargo -- delay release of all works until" + no_delay: "Do not allow embargoes or leases" title: "Release" varies: - between: "Between \"now\" and" - description: "Varies -- depositors can set the release date for an individual work:" + any: "Depositor can choose any embargo length; leases are allowed" + between: "Depositor can choose embargo up to date:" + period: "Depositor can choose embargo period up to:" + description: "Allow depositor to choose settings:" embargo: 1yr: "1 year after deposit" 2yrs: "2 years after deposit" @@ -141,12 +143,12 @@ en: 6mos: "6 months after deposit" select: "Select embargo period.." visibility: - description: "After its release date, works in this set can be discovered and downloaded by:" - everyone: "Everyone -- all works in this set will be public" - institution: "Institution -- all works will be visible only to authenticated users of this institution" - restricted: "Restricted -- all works will be visible only to repository managers and managers and reviewers of this administrative set" + description: "Set visibility policies for the administrative set. Setting honors embargo policies above." + everyone: "Public - depositor can only choose public visibility setting" + institution: "Institution -- depositor can only select institution visibility setting" + restricted: "Private -- depositor can only select private for visibility. Access is restricted to repository administrators, managers, and viewers of the set. Must be used with \"No embargo\" setting above." title: "Visibility" - varies: "Varies -- default is public, but depositors can restrict the visibility of individual works" + varies: "All settings allowed -- depositor can choose. Must use this option to allow leases." form_workflow: cancel: "Cancel" no_workflows: "There are no workflows to select." @@ -458,14 +460,17 @@ en: detail_label: "Display summary details of" listing: "Listing of items you have deposited in" press_to: "Press to" + results_per_page: "Number of results to display per page" show_label: "Display all details of" works: "Your Works" no_activity: "User has no recent activity" no_notifications: "User has no notifications" + delete_notification: "Delete Notification" no_transfer_requests: "You haven't received any work transfer requests" no_transfers: "You haven't transferred any work" proxy_activity: "Proxy Activity" proxy_user: "Proxy User" + proxy_delete: "Delete Proxy" show_admin: new_visitors: "New Visitors" registered_users: "Registered users" diff --git a/config/locales/hyrax.es.yml b/config/locales/hyrax.es.yml index 9b9c0a474a..6d36b46162 100644 --- a/config/locales/hyrax.es.yml +++ b/config/locales/hyrax.es.yml @@ -72,6 +72,7 @@ es: header: Editar Conjunto Administrativo form: cancel: Cancelar + note: Los usuarios a los que se les otorgue un nuevo rol solo obtendrán el rol en los trabajos que se depositen después de que se haya otorgado ese rol. permission_destroy_errors: admin_group: No se puede eliminar el grupo de administradores del repositorio permission_update_errors: @@ -133,6 +134,7 @@ es: no_delay: Sin demora -- liberar todas los trabajos tan pronto como se depositen title: Lanzamiento varies: + any: Permitir que el depositante decida between: Entre "ahora" y description: 'Varía -- los depositantes pueden fijar la fecha de lanzamiento para un trabajo individual:' embargo: @@ -141,6 +143,7 @@ es: 3yrs: Tres años después del depósito 6mos: Seis meses después del depósito select: Seleccione el período de embargo... + period: 'El depositante puede elegir un período de embargo hasta:' visibility: description: 'Después de su fecha de lanzamiento, los trabajos de este conjunto pueden ser descubiertos y descargados por:' everyone: Todos -- todos los trabajos de este conjunto serán públicos. @@ -425,6 +428,7 @@ es: works_in_collection: Trabajos en esta colección create_work: Crear Trabajo current_proxies: Proxies actuales + delete_notification: Eliminar notificación heading_actions: close: Cerrar create_work: Crear trabajo @@ -476,6 +480,7 @@ es: no_transfer_requests: No ha recibido ninguna petición de transferencia no_transfers: No ha transferido ningún trabajo proxy_activity: Actividad de Proxy + proxy_delete: Eliminar proxy proxy_user: Usuario de Proxy show_admin: new_visitors: Visitantes Nuevos diff --git a/config/locales/hyrax.fr.yml b/config/locales/hyrax.fr.yml index a7071ecd2a..7c0e75ebea 100644 --- a/config/locales/hyrax.fr.yml +++ b/config/locales/hyrax.fr.yml @@ -72,6 +72,7 @@ fr: header: Modifier l'ensemble administratif form: cancel: Annuler + note: Les utilisateurs auxquels un nouveau rôle est attribué n'acquièrent un rôle que sur les œuvres déposées après l'attribution de ce rôle. permission_destroy_errors: admin_group: Le groupe des administrateurs du référentiel ne peut pas être supprimé permission_update_errors: @@ -133,6 +134,7 @@ fr: no_delay: Pas de retard - libère tous les travaux dès qu'ils sont déposés title: Libération varies: + any: Permettre au déposant de décider between: Entre «maintenant» et description: 'Variable - les déposants peuvent définir la date de sortie pour un travail individuel:' embargo: @@ -141,6 +143,7 @@ fr: 3yrs: 3 ans après le dépôt 6mos: 6 mois après le dépôt select: Sélectionnez la période d'embargo ... + period: 'Le déposant peut choisir la période d''embargo jusqu''à:' visibility: description: 'Après sa date de sortie, les travaux de cet ensemble peuvent être découverts et téléchargés par:' everyone: Tout le monde - tout fonctionne dans cet ensemble sera public @@ -430,6 +433,7 @@ fr: works_in_collection: Fonctionne dans cette collection create_work: Créer un travail current_proxies: Proxies actuelles + delete_notification: Supprimer la notification heading_actions: close: Fermer create_work: Créer un travail @@ -481,6 +485,7 @@ fr: no_transfer_requests: Vous n'avez reçu aucune demande de transfert de travail no_transfers: Vous n'avez transféré aucun travail proxy_activity: Activité de procuration + proxy_delete: Supprimer le proxy proxy_user: Utilisateur proxy show_admin: new_visitors: Nouveaux visiteurs diff --git a/config/locales/hyrax.it.yml b/config/locales/hyrax.it.yml index eacdd78f7a..aa77e23f38 100644 --- a/config/locales/hyrax.it.yml +++ b/config/locales/hyrax.it.yml @@ -72,6 +72,7 @@ it: header: Modifica impostazione amministrativa form: cancel: Annulla + note: Gli utenti che hanno assegnato un nuovo ruolo avranno solo il ruolo di opere che vengono depositate dopo che tale ruolo è stato concesso. permission_destroy_errors: admin_group: Impossibile rimuovere il gruppo amministratori di repository permission_update_errors: @@ -133,6 +134,7 @@ it: no_delay: Nessun ritardo - rilasciare tutti i lavori non appena vengono depositati title: Liberare varies: + any: Consentire al depositante di decidere between: Tra "ora" e " description: 'Varia - i depositanti possono impostare la data di rilascio per un lavoro individuale:' embargo: @@ -141,6 +143,7 @@ it: 3yrs: 3 anni dopo il deposito 6mos: 6 mesi dopo il deposito select: Seleziona il periodo di embargo .. + period: 'Depositor può scegliere il periodo di embargo fino a:' visibility: description: 'Dopo la data di rilascio, i lavori in questo set possono essere scoperti e scaricati da:' everyone: Tutti - tutti i lavori in questo set saranno pubblici @@ -430,6 +433,7 @@ it: works_in_collection: Funziona in questa collezione create_work: Crea lavoro current_proxies: Proxy attuali + delete_notification: Elimina notifica heading_actions: close: Vicino create_work: Crea lavoro @@ -481,6 +485,7 @@ it: no_transfer_requests: Non hai ricevuto richieste di trasferimento di lavoro no_transfers: Non hai trasferito alcun lavoro proxy_activity: Attività proxy + proxy_delete: Elimina proxy proxy_user: Utente Proxy show_admin: new_visitors: Nuovi visitatori diff --git a/config/locales/hyrax.pt-BR.yml b/config/locales/hyrax.pt-BR.yml index 847c019198..11fe0fc3ea 100644 --- a/config/locales/hyrax.pt-BR.yml +++ b/config/locales/hyrax.pt-BR.yml @@ -72,6 +72,7 @@ pt-BR: header: Editar Conjunto Administrativo form: cancel: Cancelar + note: Os usuários que receberam uma nova função só ganharão o papel nas obras que são depositadas depois que essa função foi concedida. permission_destroy_errors: admin_group: O grupo de administradores do repositório não pode ser removido permission_update_errors: @@ -133,6 +134,7 @@ pt-BR: no_delay: Sem atraso - liberte todos os trabalhos assim que eles são depositados title: Lançamento varies: + any: Permitir que o depositante decida between: Entre "agora" e description: 'Varia - os depositantes podem definir a data de lançamento para um trabalho individual:' embargo: @@ -141,6 +143,7 @@ pt-BR: 3yrs: 3 anos após o depósito 6mos: 6 meses após o depósito select: Selecione o período de embargo ... + period: 'O depositante pode escolher o período de embargo até:' visibility: description: 'Após a data de lançamento, os trabalhos deste conjunto podem ser descobertos e baixados por:' everyone: Todos - todos os trabalhos neste conjunto serão públicos @@ -430,6 +433,7 @@ pt-BR: works_in_collection: Funciona nesta coleção create_work: Criar trabalho current_proxies: Proxies atuais + delete_notification: Eliminar Notificação heading_actions: close: Fechar create_work: Criar trabalho @@ -481,6 +485,7 @@ pt-BR: no_transfer_requests: Você não recebeu nenhum pedido de transferência de trabalho no_transfers: Você não transferiu nenhum trabalho proxy_activity: Atividade de proxy + proxy_delete: Eliminar Proxy proxy_user: Usuário Proxy show_admin: new_visitors: Novos visitantes diff --git a/config/locales/hyrax.zh.yml b/config/locales/hyrax.zh.yml index 048f198218..fae6d9d3e3 100644 --- a/config/locales/hyrax.zh.yml +++ b/config/locales/hyrax.zh.yml @@ -78,6 +78,7 @@ zh: header: 编辑管理集 form: cancel: 取消 + note: 授予新角色的用户只能在授予该角色后存储的作品获得角色。 permission_destroy_errors: admin_group: 无法删除存储库管理员组 permission_update_errors: @@ -139,6 +140,7 @@ zh: no_delay: 没有延迟 -- 所有作品一旦存储即可发布 title: 发布 varies: + any: 允许存款人决定 between: 在'现在'之间 description: '可变的 -- 存储者可以设置一件作品的发布日期:' embargo: @@ -147,6 +149,7 @@ zh: 3yrs: 存储三年之后 6mos: 存储六个月之后 select: 选择时滞期限.. + period: 存款人可以选择禁运期限: visibility: description: '发布日期之后, 管理集内的作品可以被发现和下载:' everyone: 每个人 -- 管理集内的所有作品会公开 @@ -431,6 +434,7 @@ zh: works_in_collection: 在这个集合的作品 create_work: 创建作品 current_proxies: 目前代理 + delete_notification: 删除通知 heading_actions: close: 关闭 create_work: 创建作品 @@ -482,6 +486,7 @@ zh: no_transfer_requests: 您没有收到任何在作品转让请求 no_transfers: 您没有转让任何作品 proxy_activity: 代理活动 + proxy_delete: 删除代理 proxy_user: 代理用户 show_admin: new_visitors: 新访问者 diff --git a/hyrax.gemspec b/hyrax.gemspec index 4ae3973bdc..8e460b25a1 100644 --- a/hyrax.gemspec +++ b/hyrax.gemspec @@ -88,7 +88,7 @@ EOF spec.add_development_dependency 'capybara-maleficent', '~> 0.2' spec.add_development_dependency "chromedriver-helper" spec.add_development_dependency "selenium-webdriver" - spec.add_development_dependency "factory_girl_rails", '~> 4.4' + spec.add_development_dependency "factory_bot_rails", '~> 4.4' spec.add_development_dependency "equivalent-xml", '~> 0.5' spec.add_development_dependency "jasmine", '~> 2.3' # Pin rubocop and rubocop-rspec tightly. Minor-level version bumps @@ -104,7 +104,7 @@ EOF spec.add_development_dependency 'rubocop', '~> 0.49.1' spec.add_development_dependency 'rubocop-rspec', '~> 1.16.0' spec.add_development_dependency 'shoulda-matchers', '~> 3.1' - spec.add_development_dependency 'rails-controller-testing', '~> 0' + spec.add_development_dependency 'rails-controller-testing', '~> 1' spec.add_development_dependency 'webmock' spec.add_development_dependency 'i18n-debug' if ENV['I18N_DEBUG'] spec.add_development_dependency 'i18n_yaml_sorter' unless ENV['TRAVIS'] diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.de.yml b/lib/generators/hyrax/templates/config/locales/hyrax.de.yml index ba9032690e..71c6501700 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.de.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.de.yml @@ -4,7 +4,7 @@ de: search: fields: facet: - based_near_sim: Ort + based_near_label_sim: Ort creator_sim: Schöpfer file_format_sim: Format generic_type_sim: Art diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.en.yml b/lib/generators/hyrax/templates/config/locales/hyrax.en.yml index 13fbad8f8f..b2c01e9883 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.en.yml @@ -3,7 +3,7 @@ en: search: fields: facet: - based_near_sim: Location + based_near_label_sim: Location creator_sim: Creator file_format_sim: Format generic_type_sim: Type diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.es.yml b/lib/generators/hyrax/templates/config/locales/hyrax.es.yml index 44c01f88e6..16939a993f 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.es.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.es.yml @@ -4,7 +4,7 @@ es: search: fields: facet: - based_near_sim: Ubicación + based_near_label_sim: Ubicación creator_sim: Creador file_format_sim: Formato generic_type_sim: Tipo @@ -22,9 +22,9 @@ es: description_tesim: Descripción file_format_tesim: Formato de Archivo identifier_tesim: Identificador - license_tesim: Licencia keyword_tesim: Palabra clave language_tesim: Idioma + license_tesim: Licencia publisher_tesim: Editor rights_statement_tesim: Derechos subject_tesim: Tema diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml b/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml index e7a9307bc7..ef352493cd 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.fr.yml @@ -4,7 +4,7 @@ fr: search: fields: facet: - based_near_sim: Emplacement + based_near_label_sim: Emplacement creator_sim: Créateur file_format_sim: Format generic_type_sim: Type @@ -25,7 +25,9 @@ fr: keyword_tesim: Mot-clé language_tesim: La langue license_statement_tesim: Licence + license_tesim: Licence publisher_tesim: Éditeur + rights_statement_tesim: Déclaration des droits rights_tesim: Droits subject_tesim: Assujettir show: @@ -41,7 +43,9 @@ fr: keyword_tesim: Mot-clé language_tesim: La langue license_statement_tesim: Licence + license_tesim: Licence publisher_tesim: Éditeur + rights_statement_tesim: Déclaration des droits rights_tesim: Droits subject_tesim: Assujettir title_tesim: Titre diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.it.yml b/lib/generators/hyrax/templates/config/locales/hyrax.it.yml index 49e169b3b2..f3c81f0991 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.it.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.it.yml @@ -4,7 +4,7 @@ it: search: fields: facet: - based_near_sim: luogo + based_near_label_sim: luogo creator_sim: Creatore file_format_sim: Formato generic_type_sim: Tipo diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml b/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml index 9761d29f68..11a7528261 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.pt-BR.yml @@ -4,7 +4,7 @@ pt-BR: search: fields: facet: - based_near_sim: Localização + based_near_label_sim: Localização creator_sim: O Criador file_format_sim: Formato generic_type_sim: Tipo diff --git a/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml b/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml index cdfd273346..841ea0b7c8 100644 --- a/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml +++ b/lib/generators/hyrax/templates/config/locales/hyrax.zh.yml @@ -4,7 +4,7 @@ zh: search: fields: facet: - based_near_sim: 位置 + based_near_label_sim: 位置 creator_sim: 创造者 file_format_sim: 文件格式 generic_type_sim: 类型 diff --git a/lib/generators/hyrax/templates/hyrax.scss b/lib/generators/hyrax/templates/hyrax.scss index 6867e14771..7770348e36 100644 --- a/lib/generators/hyrax/templates/hyrax.scss +++ b/lib/generators/hyrax/templates/hyrax.scss @@ -5,6 +5,7 @@ */ @import "bootstrap-sprockets"; +@import "bootstrap-default-overrides"; @import 'bootstrap'; @import 'blacklight/blacklight'; @import "font-awesome"; diff --git a/lib/hyrax/configuration.rb b/lib/hyrax/configuration.rb index d8bc1521a2..733245f93f 100644 --- a/lib/hyrax/configuration.rb +++ b/lib/hyrax/configuration.rb @@ -228,6 +228,17 @@ def license_service_class @license_service_class ||= Hyrax::LicenseService end + # A configuration point for changing the behavior of the rights statement service. + # + # @!attribute [w] license_service_class + # A configuration point for changing the behavior of the license service. + # + # @see Hyrax::RightsStatementService for implementation details + attr_writer :rights_statement_service_class + def rights_statement_service_class + @rights_statement_service_class ||= Hyrax::RightsStatementService + end + attr_writer :banner_image def banner_image # This image can be used for free and without attribution. See here for source and license: https://github.com/samvera/hyrax/issues/1551#issuecomment-326624909 diff --git a/lib/hyrax/version.rb b/lib/hyrax/version.rb index c08ddacac5..0a0f3e39b4 100644 --- a/lib/hyrax/version.rb +++ b/lib/hyrax/version.rb @@ -1,3 +1,3 @@ module Hyrax - VERSION = '2.0.0.beta5'.freeze + VERSION = '2.0.0.rc2'.freeze end diff --git a/spec/abilities/file_set_abilities_spec.rb b/spec/abilities/file_set_abilities_spec.rb index 48cd7cc218..23e25cee23 100644 --- a/spec/abilities/file_set_abilities_spec.rb +++ b/spec/abilities/file_set_abilities_spec.rb @@ -27,7 +27,7 @@ end describe 'as a repository manager' do - let(:manager_user) { FactoryGirl.create(:admin) } + let(:manager_user) { FactoryBot.create(:admin) } let(:creating_user) { user } let(:current_user) { manager_user } @@ -41,7 +41,7 @@ end describe 'another authenticated user' do - let(:creating_user) { FactoryGirl.create(:user) } + let(:creating_user) { FactoryBot.create(:user) } let(:current_user) { user } it do @@ -54,7 +54,7 @@ end describe 'a nil user' do - let(:creating_user) { FactoryGirl.create(:user) } + let(:creating_user) { FactoryBot.create(:user) } let(:current_user) { nil } it do diff --git a/spec/abilities/generic_work_abilities_spec.rb b/spec/abilities/generic_work_abilities_spec.rb index 3afd584632..3b22ef1383 100644 --- a/spec/abilities/generic_work_abilities_spec.rb +++ b/spec/abilities/generic_work_abilities_spec.rb @@ -4,8 +4,8 @@ describe 'Abilities' do subject { Ability.new(current_user) } - let(:generic_work) { FactoryGirl.create_for_repository(:work, :private, user: creating_user) } - let(:user) { FactoryGirl.create(:user) } + let(:generic_work) { create_for_repository(:work, :private, user: creating_user) } + let(:user) { create(:user) } describe 'without embargo' do describe 'creator of object' do @@ -21,7 +21,7 @@ end describe 'as a repository manager' do - let(:manager_user) { FactoryGirl.create(:admin) } + let(:manager_user) { FactoryBot.create(:admin) } let(:creating_user) { user } let(:current_user) { manager_user } @@ -34,7 +34,7 @@ end describe 'another authenticated user' do - let(:creating_user) { FactoryGirl.create(:user) } + let(:creating_user) { FactoryBot.create(:user) } let(:current_user) { user } it do @@ -47,7 +47,7 @@ end describe 'a nil user' do - let(:creating_user) { FactoryGirl.create(:user) } + let(:creating_user) { FactoryBot.create(:user) } let(:current_user) { nil } it do diff --git a/spec/actors/hyrax/actors/generic_work_actor_spec.rb b/spec/actors/hyrax/actors/generic_work_actor_spec.rb index 2c9222da4b..c45847e915 100644 --- a/spec/actors/hyrax/actors/generic_work_actor_spec.rb +++ b/spec/actors/hyrax/actors/generic_work_actor_spec.rb @@ -260,7 +260,7 @@ end context 'with nil in_works_ids' do - let(:parent) { FactoryGirl.create_for_repository(:work) } + let(:parent) { create_for_repository(:work) } let(:attributes) do attributes_for(:work).merge( member_of_collection_ids: nil diff --git a/spec/actors/hyrax/actors/transactional_request_spec.rb b/spec/actors/hyrax/actors/transactional_request_spec.rb index 09ad288d72..e305e46f1f 100644 --- a/spec/actors/hyrax/actors/transactional_request_spec.rb +++ b/spec/actors/hyrax/actors/transactional_request_spec.rb @@ -10,7 +10,7 @@ def create(attributes) let(:good_actor) do Class.new(Hyrax::Actors::AbstractActor) do def create(_attributes) - FactoryGirl.create(:user) + FactoryBot.create(:user) end end end diff --git a/spec/controllers/hyrax/api/items_controller_spec.rb b/spec/controllers/hyrax/api/items_controller_spec.rb index a8ed9d5fca..c2415d1784 100644 --- a/spec/controllers/hyrax/api/items_controller_spec.rb +++ b/spec/controllers/hyrax/api/items_controller_spec.rb @@ -19,7 +19,7 @@ context 'with an HTTP GET or HEAD' do let(:token) { user.arkivo_token } - let(:item) { FactoryGirl.json(:post_item, token: token) } + let(:item) { FactoryBot.json(:post_item, token: token) } let(:item_hash) { JSON.parse(item) } context 'with a missing token' do @@ -113,7 +113,7 @@ let(:deposited_file) { FileSet.where(label: item_hash['file']['filename']).take } let(:a_work) { build :work, id: '123' } let!(:token) { user.arkivo_token } - let(:item) { FactoryGirl.json(:post_item, token: token) } + let(:item) { FactoryBot.json(:post_item, token: token) } let(:item_hash) { JSON.parse(item) } before do @@ -157,7 +157,7 @@ before { post :create, body: item, params: { format: :json } } let(:token) { 'unfamiliar_token' } - let(:item) { FactoryGirl.json(:post_item, token: token) } + let(:item) { FactoryBot.json(:post_item, token: token) } it "is unathorized" do expect(response).not_to be_success @@ -168,7 +168,7 @@ end context 'with an HTTP PUT' do - let(:put_item) { FactoryGirl.json(:put_item, token: token) } + let(:put_item) { FactoryBot.json(:put_item, token: token) } let(:token) { user.arkivo_token } let(:gw) { create_for_repository :work, id: '123' } @@ -253,7 +253,7 @@ context 'with a valid item and unfamiliar token' do let(:bad_token) { 'unfamiliar_token' } - let(:bad_token_item) { FactoryGirl.json(:put_item, token: bad_token) } + let(:bad_token_item) { FactoryBot.json(:put_item, token: bad_token) } before do request.env['RAW_POST_DATA'] = bad_token_item @@ -284,7 +284,7 @@ context 'with an HTTP DELETE' do let(:token) { user.arkivo_token } - let(:item) { FactoryGirl.json(:post_item, token: token) } + let(:item) { FactoryBot.json(:post_item, token: token) } let(:item_hash) { JSON.parse(item) } let(:gw) { create_for_repository :work, id: '123' } diff --git a/spec/controllers/hyrax/citations_controller_spec.rb b/spec/controllers/hyrax/citations_controller_spec.rb index 90c86b5d1f..47236dac68 100644 --- a/spec/controllers/hyrax/citations_controller_spec.rb +++ b/spec/controllers/hyrax/citations_controller_spec.rb @@ -14,7 +14,7 @@ expect(controller).to receive(:add_breadcrumb).with('My Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :work, params: { id: work } expect(response).to be_successful - expect(response).to render_template('layouts/hyrax') + expect(response).to render_template('layouts/hyrax/1_column') expect(assigns(:presenter)).to be_kind_of Hyrax::WorkShowPresenter end end @@ -42,7 +42,7 @@ expect(controller).to receive(:add_breadcrumb).with('My Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :file, params: { id: file_set } expect(response).to be_successful - expect(response).to render_template('layouts/hyrax') + expect(response).to render_template('layouts/hyrax/1_column') expect(assigns(:presenter)).to be_kind_of Hyrax::FileSetPresenter end end diff --git a/spec/controllers/hyrax/collections_controller_spec.rb b/spec/controllers/hyrax/collections_controller_spec.rb index 1d8a75cbb3..993521af9d 100644 --- a/spec/controllers/hyrax/collections_controller_spec.rb +++ b/spec/controllers/hyrax/collections_controller_spec.rb @@ -31,6 +31,7 @@ expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :show, params: { id: collection } expect(response).to be_successful + expect(response).to render_template("layouts/hyrax/1_column") expect(assigns[:presenter]).to be_kind_of Hyrax::CollectionPresenter expect(assigns[:presenter].title).to match_array collection.title expect(assigns[:member_docs].map(&:id)).to match_array [asset1, asset2, asset3].map { |asset| asset.id.to_s } diff --git a/spec/controllers/hyrax/content_blocks_controller_spec.rb b/spec/controllers/hyrax/content_blocks_controller_spec.rb index 2877fa532d..6e5c4cce8e 100644 --- a/spec/controllers/hyrax/content_blocks_controller_spec.rb +++ b/spec/controllers/hyrax/content_blocks_controller_spec.rb @@ -1,12 +1,12 @@ RSpec.describe Hyrax::ContentBlocksController, type: :controller do let!(:announcement_text) do - FactoryGirl.create(:content_block, name: 'announcement_text') + FactoryBot.create(:content_block, name: 'announcement_text') end let!(:marketing_text) do - FactoryGirl.create(:content_block, name: 'marketing_text') + FactoryBot.create(:content_block, name: 'marketing_text') end let!(:featured_researcher) do - FactoryGirl.create(:content_block, name: 'featured_researcher') + FactoryBot.create(:content_block, name: 'featured_researcher') end before do @@ -14,7 +14,7 @@ end context 'with an unprivileged user' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } describe "GET #edit" do it "denies the request" do @@ -32,7 +32,7 @@ end context 'with an administrator' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } describe "GET #edit" do it "renders breadcrumbs" do diff --git a/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb b/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb index 8b4ea86e34..a98239e9f1 100644 --- a/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::Dashboard::ProfilesController do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do sign_in user @@ -71,7 +71,7 @@ describe "#update" do context "the profile of another user" do - let(:another_user) { FactoryGirl.create(:user) } + let(:another_user) { FactoryBot.create(:user) } it "does not allow other users to update" do post :update, params: { id: another_user.user_key, user: { avatar: nil } } diff --git a/spec/controllers/hyrax/featured_work_lists_controller_spec.rb b/spec/controllers/hyrax/featured_work_lists_controller_spec.rb index 58d7118d93..8ddbc7c291 100644 --- a/spec/controllers/hyrax/featured_work_lists_controller_spec.rb +++ b/spec/controllers/hyrax/featured_work_lists_controller_spec.rb @@ -4,8 +4,8 @@ expect(controller).to receive(:authorize!).with(:update, FeaturedWork) end - let(:feature1) { FactoryGirl.create(:featured_work) } - let(:feature2) { FactoryGirl.create(:featured_work) } + let(:feature1) { FactoryBot.create(:featured_work) } + let(:feature2) { FactoryBot.create(:featured_work) } it "is successful" do post :create, params: { diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb index d804ff8183..3cb393a816 100644 --- a/spec/controllers/hyrax/generic_works_controller_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_spec.rb @@ -58,7 +58,7 @@ expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) get :show, params: { id: work } expect(response).to be_successful - expect(response).to render_template("layouts/hyrax") + expect(response).to render_template("layouts/hyrax/1_column") end end diff --git a/spec/controllers/hyrax/homepage_controller_spec.rb b/spec/controllers/hyrax/homepage_controller_spec.rb index 98d4cd0c90..558da3f6a9 100644 --- a/spec/controllers/hyrax/homepage_controller_spec.rb +++ b/spec/controllers/hyrax/homepage_controller_spec.rb @@ -92,7 +92,7 @@ end context "with featured works" do - let!(:my_work) { FactoryGirl.create_for_repository(:work, user: user) } + let!(:my_work) { create_for_repository(:work, user: user) } before do FeaturedWork.create!(work_id: my_work.id) diff --git a/spec/controllers/hyrax/pages_controller_spec.rb b/spec/controllers/hyrax/pages_controller_spec.rb index 5738b6ad5c..f2931c175e 100644 --- a/spec/controllers/hyrax/pages_controller_spec.rb +++ b/spec/controllers/hyrax/pages_controller_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::PagesController, type: :controller do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do sign_in user @@ -34,16 +34,16 @@ end context 'when editing pages' do let!(:about_page) do - FactoryGirl.create(:content_block, name: 'about_page') + FactoryBot.create(:content_block, name: 'about_page') end let!(:help_page) do - FactoryGirl.create(:content_block, name: 'help_page') + FactoryBot.create(:content_block, name: 'help_page') end let!(:agreement_page) do - FactoryGirl.create(:content_block, name: 'agreement_page') + FactoryBot.create(:content_block, name: 'agreement_page') end let!(:terms_page) do - FactoryGirl.create(:content_block, name: 'terms_page') + FactoryBot.create(:content_block, name: 'terms_page') end context 'with an unprivileged user' do @@ -63,7 +63,7 @@ end context 'with an administrator' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } describe "GET #edit" do it "renders breadcrumbs and dashboard layout" do diff --git a/spec/controllers/hyrax/users_controller_spec.rb b/spec/controllers/hyrax/users_controller_spec.rb index a3e9a6bd18..94f38d9302 100644 --- a/spec/controllers/hyrax/users_controller_spec.rb +++ b/spec/controllers/hyrax/users_controller_spec.rb @@ -81,7 +81,7 @@ end it "uses the base query" do - u3 = FactoryGirl.create(:user) + u3 = FactoryBot.create(:user) allow(controller).to receive(:base_query).and_return(["email == \"#{u3.email}\""]) get :index expect(assigns[:users]).to include(u3) diff --git a/spec/controllers/hyrax/workflow_actions_controller_spec.rb b/spec/controllers/hyrax/workflow_actions_controller_spec.rb index 1078f37a79..2415787c3f 100644 --- a/spec/controllers/hyrax/workflow_actions_controller_spec.rb +++ b/spec/controllers/hyrax/workflow_actions_controller_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::WorkflowActionsController, type: :controller do - let(:user) { FactoryGirl.create(:user) } + let(:user) { create(:user) } let(:generic_work) { create_for_repository(:work) } let(:form) { instance_double(Hyrax::Forms::WorkflowActionForm) } diff --git a/spec/conversions/power_converters/polymorphic_type_spec.rb b/spec/conversions/power_converters/polymorphic_type_spec.rb index ede2a2ec1f..1252721949 100644 --- a/spec/conversions/power_converters/polymorphic_type_spec.rb +++ b/spec/conversions/power_converters/polymorphic_type_spec.rb @@ -7,7 +7,7 @@ expect(PowerConverter.convert_to_polymorphic_type(object)).to eq(:symbol) end it 'will convert an ActiveRecord::Base object' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) expect(PowerConverter.convert_to_polymorphic_type(user)).to eq(user.class) end it 'will convert an object that responds to #base_class' do diff --git a/spec/factories/admin_sets.rb b/spec/factories/admin_sets.rb index 241523eec0..8670ca62c4 100644 --- a/spec/factories/admin_sets.rb +++ b/spec/factories/admin_sets.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :admin_set do sequence(:title) { |n| ["Title #{n}"] } diff --git a/spec/factories/api_items.rb b/spec/factories/api_items.rb index aa2dae010b..6069a49cbc 100644 --- a/spec/factories/api_items.rb +++ b/spec/factories/api_items.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :post_item, class: Hash do skip_create diff --git a/spec/factories/collections_factory.rb b/spec/factories/collections_factory.rb index eb36303ceb..7990c20d80 100644 --- a/spec/factories/collections_factory.rb +++ b/spec/factories/collections_factory.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :collection do transient do - user { FactoryGirl.create(:user) } + user { FactoryBot.create(:user) } end sequence(:title) { |n| ["Title #{n}"] } diff --git a/spec/factories/content_blocks.rb b/spec/factories/content_blocks.rb index 33a6b4655e..e6a10cf68a 100644 --- a/spec/factories/content_blocks.rb +++ b/spec/factories/content_blocks.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :content_block do |_cb| end end diff --git a/spec/factories/featured_works.rb b/spec/factories/featured_works.rb index fbfc780355..9acef078a9 100644 --- a/spec/factories/featured_works.rb +++ b/spec/factories/featured_works.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :featured_work do |_u| end end diff --git a/spec/factories/file_sets.rb b/spec/factories/file_sets.rb index d9504302c4..41b59719e0 100644 --- a/spec/factories/file_sets.rb +++ b/spec/factories/file_sets.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :file_set do transient do - user { FactoryGirl.create(:user) } + user { FactoryBot.create(:user) } content nil end after(:build) do |fs, evaluator| diff --git a/spec/factories/generic_works.rb b/spec/factories/generic_works.rb index 60ca54666c..e03e7464c2 100644 --- a/spec/factories/generic_works.rb +++ b/spec/factories/generic_works.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :work, class: GenericWork do to_create do |instance| persister = Valkyrie::MetadataAdapter.find(:indexing_persister).persister @@ -6,7 +6,7 @@ end transient do - user { FactoryGirl.create(:user) } + user { FactoryBot.create(:user) } # Set to true (or a hash) if you want to create an admin set with_admin_set false end @@ -131,6 +131,6 @@ end title ['Test title'] - depositor { FactoryGirl.create(:user).user_key } + depositor { FactoryBot.create(:user).user_key } end end diff --git a/spec/factories/operations.rb b/spec/factories/operations.rb index 685c8dfcae..0641f97b91 100644 --- a/spec/factories/operations.rb +++ b/spec/factories/operations.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :operation, class: Hyrax::Operation do operation_type "Test operation" diff --git a/spec/factories/permission_template_accesses.rb b/spec/factories/permission_template_accesses.rb index e03f8aa9f5..3fa28064ed 100644 --- a/spec/factories/permission_template_accesses.rb +++ b/spec/factories/permission_template_accesses.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :permission_template_access, class: Hyrax::PermissionTemplateAccess do permission_template trait :manage do diff --git a/spec/factories/permission_templates.rb b/spec/factories/permission_templates.rb index ed46c5365e..4b934add16 100644 --- a/spec/factories/permission_templates.rb +++ b/spec/factories/permission_templates.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :permission_template, class: Hyrax::PermissionTemplate do # Given that there is a one to one strong relation between permission_template and admin_set, # with a unique index on the admin_set_id, I don't want to have duplication in admin_set_id diff --git a/spec/factories/proxy_deposit_requests.rb b/spec/factories/proxy_deposit_requests.rb index 715579a434..75b7b258fc 100644 --- a/spec/factories/proxy_deposit_requests.rb +++ b/spec/factories/proxy_deposit_requests.rb @@ -1,6 +1,6 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :proxy_deposit_request do end end diff --git a/spec/factories/single_use_links.rb b/spec/factories/single_use_links.rb index d7c0a8cd08..b70b91c43b 100644 --- a/spec/factories/single_use_links.rb +++ b/spec/factories/single_use_links.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :single_use_link do factory :show_link do itemId 'fs-id' diff --git a/spec/factories/sipity_entities.rb b/spec/factories/sipity_entities.rb index 82f4cc3d07..ac54b12671 100644 --- a/spec/factories/sipity_entities.rb +++ b/spec/factories/sipity_entities.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :sipity_entity, class: Sipity::Entity do proxy_for_global_id 'gid://internal/Mock/1' workflow { workflow_state.workflow } diff --git a/spec/factories/uploaded_files.rb b/spec/factories/uploaded_files.rb index 77ce31c8d7..e388c84e5a 100644 --- a/spec/factories/uploaded_files.rb +++ b/spec/factories/uploaded_files.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :uploaded_file, class: Hyrax::UploadedFile do user end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index b40ca03c5d..232f374c6d 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,11 +1,11 @@ -FactoryGirl.define do +FactoryBot.define do factory :user do sequence(:email) { |n| "user#{n}@example.com" } password 'password' transient do # Allow for custom groups when a user is instantiated. - # @example FactoryGirl.create(:user, groups: 'avacado') + # @example FactoryBot.create(:user, groups: 'avacado') groups [] end diff --git a/spec/factories/workflow_actions.rb b/spec/factories/workflow_actions.rb index ed35efcfc3..f434895f59 100644 --- a/spec/factories/workflow_actions.rb +++ b/spec/factories/workflow_actions.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :workflow_action, class: Sipity::WorkflowAction do workflow name 'submit' diff --git a/spec/factories/workflow_states.rb b/spec/factories/workflow_states.rb index 5231bad573..9ddbdbbc91 100644 --- a/spec/factories/workflow_states.rb +++ b/spec/factories/workflow_states.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :workflow_state, class: Sipity::WorkflowState do workflow name 'initial' diff --git a/spec/factories/workflows.rb b/spec/factories/workflows.rb index 8bc7d45db4..cbc2474cf7 100644 --- a/spec/factories/workflows.rb +++ b/spec/factories/workflows.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :workflow, class: Sipity::Workflow do sequence(:name) { |n| "generic_work-#{n}" } permission_template diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index fa150a4cc1..73446afc90 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,6 +1,6 @@ RSpec.feature "Notifications page", type: :feature do before do - sign_in FactoryGirl.create(:user_with_mail) + sign_in FactoryBot.create(:user_with_mail) visit "/notifications" end diff --git a/spec/forms/hyrax/forms/permission_template_form_spec.rb b/spec/forms/hyrax/forms/permission_template_form_spec.rb index 816eb91b82..87b47e385d 100644 --- a/spec/forms/hyrax/forms/permission_template_form_spec.rb +++ b/spec/forms/hyrax/forms/permission_template_form_spec.rb @@ -17,6 +17,111 @@ expect(form.workflow_id).to eq(workflow.id) end + describe 'integration tests' do + let(:permission_template) { create(:permission_template, with_admin_set: true, with_workflows: true) } + + subject do + form.update( + ActionController::Parameters.new( + access_grants_attributes: [ + ActionController::Parameters.new(agent_type: "user", + agent_id: user.user_key, + access: access_level).permit! + ] + ).permit! + ) + end + + before do + # Create MANAGING role manually + Sipity::Role[Hyrax::RoleRegistry::MANAGING] + end + + def count_template_accesses_for(user, access_level) + Hyrax::PermissionTemplateAccess.where( + agent_id: user.user_key, + access: access_level + ).count + end + + def count_workflow_responsibilities_for(user) + Sipity::WorkflowResponsibility.where(agent: user.to_sipity_agent).count + end + + it 'starts with no PTAs' do + expect(permission_template.access_grants).to be_empty + end + + context 'with manager users' do + let(:user) { create(:user) } + let(:access_level) { 'manage' } + + it 'adds the expected permission template accesses and workflow responsibilities' do + expect { subject }.to change { + count_template_accesses_for(user, access_level) + }.from(0).to(1).and change { + count_workflow_responsibilities_for(user) + }.from(0).to(6) + end + + it 'removes workflow responsibilities' do + subject + expect do + form.remove_access!( + permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level) + ) + end.to change { count_workflow_responsibilities_for(user) } + .from(6).to(0) + end + end + + context 'with depositor users' do + let(:user) { create(:user) } + let(:access_level) { 'deposit' } + + it 'adds the expected permission template accesses and workflow responsibilities' do + expect { subject }.to change { + count_template_accesses_for(user, access_level) + }.from(0).to(1).and change { + count_workflow_responsibilities_for(user) + }.from(0).to(2) + end + + it 'removes workflow responsibilities' do + subject + expect do + form.remove_access!( + permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level) + ) + end.to change { count_workflow_responsibilities_for(user) } + .from(2).to(0) + end + end + + context 'with viewer users' do + let(:user) { create(:user) } + let(:access_level) { 'view' } + + it 'adds the expected permission template accesses and workflow responsibilities' do + expect { subject }.to change { + count_template_accesses_for(user, access_level) + }.from(0).to(1).and change { + count_workflow_responsibilities_for(user) + }.by(0) + end + + it 'does nothing (yet)' do + subject + expect do + form.remove_access!( + permission_template.access_grants.find_by(agent_id: user.user_key, access: access_level) + ) + end.to change { count_workflow_responsibilities_for(user) } + .by(0) + end + end + end + describe "#update" do subject { form.update(input_params) } @@ -237,7 +342,10 @@ def count_workflow_roles_for(user) end describe "#grant_workflow_roles" do - subject { form.send(:grant_workflow_roles, attributes) } + subject do + form.attributes = attributes + form.send(:grant_workflow_roles) + end let(:attributes) { { workflow_id: workflow.id } } let(:workflow) { create(:workflow, permission_template: permission_template, active: true) } @@ -320,6 +428,13 @@ def count_workflow_roles_for(user) it_behaves_like 'valid attributes' end + describe 'varies, with depositor choice' do + let(:release_period) { '' } + let(:release_varies) { '' } + + it_behaves_like 'valid attributes' + end + describe 'varies, with date selected' do let(:release_date) { Time.zone.today + 2.months } let(:release_varies) { Hyrax::PermissionTemplate::RELEASE_TEXT_VALUE_BEFORE_DATE } @@ -424,7 +539,10 @@ def count_workflow_roles_for(user) describe "#permission_template_update_params" do let(:permission_template) { create(:permission_template, admin_set_id: admin_set.id) } - subject { form.send(:permission_template_update_params, input_params) } + subject do + form.attributes = input_params + form.send(:permission_template_update_params) + end context "with release varies by date selected" do let(:input_params) do diff --git a/spec/helpers/hyrax/content_block_helper_spec.rb b/spec/helpers/hyrax/content_block_helper_spec.rb index 6d26a283a7..eeae8f1fde 100644 --- a/spec/helpers/hyrax/content_block_helper_spec.rb +++ b/spec/helpers/hyrax/content_block_helper_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::ContentBlockHelper, type: :helper do - let(:content_block) { FactoryGirl.create(:content_block, value: "

foo bar

") } + let(:content_block) { FactoryBot.create(:content_block, value: "

foo bar

") } describe '#displayable_content_block' do let(:options) { {} } diff --git a/spec/helpers/hyrax/trophy_helper_spec.rb b/spec/helpers/hyrax/trophy_helper_spec.rb index dbe53faf5e..e9c31e83e1 100644 --- a/spec/helpers/hyrax/trophy_helper_spec.rb +++ b/spec/helpers/hyrax/trophy_helper_spec.rb @@ -1,6 +1,6 @@ RSpec.describe Hyrax::TrophyHelper, type: :helper do describe "#display_trophy_link" do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:id) { '9999' } let(:text_attributes) { '[data-add-text="Highlight Work on Profile"][data-remove-text="Unhighlight Work"]' } diff --git a/spec/javascripts/visibility_component_spec.js b/spec/javascripts/visibility_component_spec.js index d43fa8a737..0084344d27 100644 --- a/spec/javascripts/visibility_component_spec.js +++ b/spec/javascripts/visibility_component_spec.js @@ -169,6 +169,25 @@ describe("VisibilityComponent", function() { expect(target.requireEmbargo).toHaveBeenCalledWith("authenticated", futureDate); }); }); + describe("with required past release date, dont restrict visibility", function() { + beforeEach(function() { + spyOn(target, 'disableEmbargoAndLease'); + }); + it("disable embargo and lease", function() { + target.applyRestrictions(undefined, undefined, "2017-01-01", false); + expect(target.disableEmbargoAndLease).toHaveBeenCalled(); + }); + }); + describe("with required past release date, and required visibility", function() { + beforeEach(function() { + spyOn(target, 'selectVisibility'); + }); + it("require visibility", function() { + var visibility = "authenticated"; + target.applyRestrictions(visibility, undefined, "2017-01-01", false); + expect(target.selectVisibility).toHaveBeenCalledWith(visibility); + }); + }); }); //selectVisibility(visibility) @@ -416,6 +435,31 @@ describe("VisibilityComponent", function() { expect(target.getVisibilityAfterEmbargoInput()).toHaveProp("name", "generic_work[visibility_after_embargo]"); }); }); + + //checkEnabledVisibilityOption() + describe("checkEnabledVisibilityOption", function() { + describe("with disabled option selected", function() { + beforeEach(function() { + target.enableAllOptions(); + element.find("[type='radio'][value='restricted']").prop("checked", true).prop("disabled", true); + }); + it("selects last enabled radio option", function() { + target.checkEnabledVisibilityOption(); + expect(element.find("[type='radio'][value='restricted']")).not.toBeChecked(); + expect(element.find("[type='radio'][value='lease']")).toBeChecked(); + }); + }); + describe("with enabled option selected", function() { + beforeEach(function() { + target.enableAllOptions(); + element.find("[type='radio'][value='open']").prop("checked", true); + }); + it("does not change selection", function() { + target.checkEnabledVisibilityOption(); + expect(element.find("[type='radio'][value='open']")).toBeChecked(); + }); + }); + }); }); // Generate a form that includes AdminSet selectbox (with a passed in option) diff --git a/spec/jobs/create_derivatives_job_spec.rb b/spec/jobs/create_derivatives_job_spec.rb index 3a8c9b91ba..c949f086d1 100644 --- a/spec/jobs/create_derivatives_job_spec.rb +++ b/spec/jobs/create_derivatives_job_spec.rb @@ -83,11 +83,10 @@ .with(/test\.pdf/, outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', - url: String }]) + url: String, + layer: 0 }]) expect(Hydra::Derivatives::FullTextExtract).to receive(:create) - .with(/test\.pdf/, outputs: [{ url: RDF::URI, - container: "extracted_text" }]) - + .with(/test\.pdf/, outputs: [{ url: RDF::URI, container: "extracted_text" }]) described_class.perform_now(file_set, file.id) end end diff --git a/spec/jobs/ingest_local_file_job_spec.rb b/spec/jobs/ingest_local_file_job_spec.rb index df1715720a..00ee666a66 100644 --- a/spec/jobs/ingest_local_file_job_spec.rb +++ b/spec/jobs/ingest_local_file_job_spec.rb @@ -4,16 +4,13 @@ let(:file_set) { FileSet.new } let(:actor) { double } - let(:mock_upload_directory) { 'spec/mock_upload_directory' } - before do - Dir.mkdir mock_upload_directory unless File.exist? mock_upload_directory - FileUtils.copy(File.expand_path('../../fixtures/world.png', __FILE__), mock_upload_directory) allow(Hyrax::Actors::FileSetActor).to receive(:new).with(file_set, user).and_return(actor) end it 'has attached a file' do + expect(FileUtils).not_to receive(:rm) expect(actor).to receive(:create_content).and_return(true) - described_class.perform_now(file_set, File.join(mock_upload_directory, 'world.png'), user) + described_class.perform_now(file_set, File.join(fixture_path, 'world.png'), user) end end diff --git a/spec/lib/hyrax/arkivo/actor_spec.rb b/spec/lib/hyrax/arkivo/actor_spec.rb index c22d43fdab..a9a8afd947 100644 --- a/spec/lib/hyrax/arkivo/actor_spec.rb +++ b/spec/lib/hyrax/arkivo/actor_spec.rb @@ -4,7 +4,7 @@ subject { described_class.new(user, item) } let(:user) { create(:user) } - let(:item) { JSON.parse(FactoryGirl.json(:post_item)) } + let(:item) { JSON.parse(FactoryBot.json(:post_item)) } let(:storage_adapter) { Valkyrie::StorageAdapter.find(:disk) } describe 'Tempfile monkey-patches' do @@ -32,7 +32,7 @@ end describe '#update_work_from_item' do - let(:item) { JSON.parse(FactoryGirl.json(:put_item)) } + let(:item) { JSON.parse(FactoryBot.json(:put_item)) } let(:title) { ['ZZZZZ'] } let(:description) { ['This is rather lengthy.'] } let(:checksum) { 'abc123' } diff --git a/spec/lib/hyrax/arkivo/metadata_munger_spec.rb b/spec/lib/hyrax/arkivo/metadata_munger_spec.rb index b4fb1aa14d..411a2731d0 100644 --- a/spec/lib/hyrax/arkivo/metadata_munger_spec.rb +++ b/spec/lib/hyrax/arkivo/metadata_munger_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Hyrax::Arkivo::MetadataMunger do subject { described_class.new(metadata) } - let(:metadata) { JSON.parse(FactoryGirl.json(:post_item))['metadata'] } + let(:metadata) { JSON.parse(FactoryBot.json(:post_item))['metadata'] } it 'makes camelCase symbols into underscored strings' do expect(metadata).to include('resourceType', 'dateCreated', 'basedNear') diff --git a/spec/lib/hyrax/arkivo/schema_validator_spec.rb b/spec/lib/hyrax/arkivo/schema_validator_spec.rb index 4b041f69c9..fe4fccd877 100644 --- a/spec/lib/hyrax/arkivo/schema_validator_spec.rb +++ b/spec/lib/hyrax/arkivo/schema_validator_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::Arkivo::SchemaValidator do - let(:item) { JSON.parse(FactoryGirl.json(:post_item)) } + let(:item) { JSON.parse(FactoryBot.json(:post_item)) } it 'ensures a token is included' do expect do diff --git a/spec/lib/hyrax/configuration_spec.rb b/spec/lib/hyrax/configuration_spec.rb index a792e7c624..37012841f1 100644 --- a/spec/lib/hyrax/configuration_spec.rb +++ b/spec/lib/hyrax/configuration_spec.rb @@ -53,6 +53,8 @@ it { is_expected.to respond_to(:libreoffice_path) } it { is_expected.to respond_to(:registered_linked_data_resources) } it { is_expected.to respond_to(:registered_linked_data_resources=) } + it { is_expected.to respond_to(:license_service_class) } + it { is_expected.to respond_to(:license_service_class=) } it { is_expected.to respond_to(:max_days_between_fixity_checks=) } it { is_expected.to respond_to(:max_days_between_fixity_checks) } it { is_expected.to respond_to(:max_notifications_for_dashboard) } @@ -62,6 +64,8 @@ it { is_expected.to respond_to(:persistent_hostpath) } it { is_expected.to respond_to(:realtime_notifications?) } it { is_expected.to respond_to(:realtime_notifications=) } + it { is_expected.to respond_to(:rights_statement_service_class) } + it { is_expected.to respond_to(:rights_statement_service_class=) } it { is_expected.to respond_to(:redis_namespace) } it { is_expected.to respond_to(:subject_prefix) } it { is_expected.to respond_to(:translate_id_to_uri) } diff --git a/spec/models/generic_work_spec.rb b/spec/models/generic_work_spec.rb index 579c80b118..76f837b07d 100644 --- a/spec/models/generic_work_spec.rb +++ b/spec/models/generic_work_spec.rb @@ -24,7 +24,7 @@ end describe "to_sipity_entity" do - let(:state) { FactoryGirl.create(:workflow_state) } + let(:state) { create(:workflow_state) } let(:work) { create_for_repository(:work) } before do diff --git a/spec/models/hyrax/user_usage_stats_spec.rb b/spec/models/hyrax/user_usage_stats_spec.rb index d18d97132a..e99d5409c1 100644 --- a/spec/models/hyrax/user_usage_stats_spec.rb +++ b/spec/models/hyrax/user_usage_stats_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyrax::UserUsageStats do - subject { FactoryGirl.create(:user) } + subject { FactoryBot.create(:user) } describe 'with cached stats' do let!(:stat_1_day_ago) { UserStat.create!(user_id: subject.id, date: 1.day.ago, file_views: 3, file_downloads: 2, work_views: 5) } diff --git a/spec/models/sipity/entity_spec.rb b/spec/models/sipity/entity_spec.rb index 0583a87aee..0d721e7807 100644 --- a/spec/models/sipity/entity_spec.rb +++ b/spec/models/sipity/entity_spec.rb @@ -16,7 +16,7 @@ module Sipity end describe '#proxy_for' do - let(:work) { FactoryGirl.create_for_repository(:work) } + let(:work) { create_for_repository(:work) } let(:entity) { Sipity::Entity.new(proxy_for_global_id: work.to_global_id) } it 'will retrieve based on a GlobalID of the object' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 708a07b5d9..defe3c5f0f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,10 +1,10 @@ RSpec.describe User, type: :model do - let(:user) { FactoryGirl.build(:user) } - let(:another_user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } + let(:another_user) { FactoryBot.build(:user) } describe 'verifying factories' do describe ':user' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } it 'will, by default, have no groups' do expect(user.groups).to eq([]) @@ -13,7 +13,7 @@ expect(user.class.find(user.id).groups).to eq([]) end it 'will allow for override of groups' do - user = FactoryGirl.build(:user, groups: 'chicken') + user = FactoryBot.build(:user, groups: 'chicken') expect(user.groups).to eq(['chicken']) user.save! # Ensuring that we can refind it and have the correct groups @@ -21,7 +21,7 @@ end end describe ':admin' do - let(:admin_user) { FactoryGirl.create(:admin) } + let(:admin_user) { FactoryBot.create(:admin) } it 'will have an "admin" group' do expect(admin_user.groups).to eq(['admin']) @@ -236,8 +236,8 @@ end end describe "scope Users" do - let!(:basic_user) { FactoryGirl.create(:user) } - let!(:guest_user) { FactoryGirl.create(:user, :guest) } + let!(:basic_user) { FactoryBot.create(:user) } + let!(:guest_user) { FactoryBot.create(:user, :guest) } let!(:audit_user) { User.audit_user } let!(:batch_user) { User.batch_user } diff --git a/spec/presenters/hyrax/admin/users_presenter_spec.rb b/spec/presenters/hyrax/admin/users_presenter_spec.rb index 41e1b3c621..5fb57f7247 100644 --- a/spec/presenters/hyrax/admin/users_presenter_spec.rb +++ b/spec/presenters/hyrax/admin/users_presenter_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Hyrax::Admin::UsersPresenter do let(:instance) { described_class.new } - let!(:user) { FactoryGirl.create(:user) } - let!(:admin_user) { FactoryGirl.create(:user, groups: 'admin') } + let!(:user) { FactoryBot.create(:user) } + let!(:admin_user) { FactoryBot.create(:user, groups: 'admin') } let!(:audit_user) { User.audit_user } let!(:batch_user) { User.batch_user } diff --git a/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb b/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb new file mode 100644 index 0000000000..7865f4e541 --- /dev/null +++ b/spec/renderers/hyrax/renderers/rights_statement_attribute_renderer_spec.rb @@ -0,0 +1,20 @@ +RSpec.describe Hyrax::Renderers::RightsStatementAttributeRenderer do + let(:field) { :rights_statement } + let(:renderer) { described_class.new(field, ['http://rightsstatements.org/vocab/InC/1.0/']) } + + describe "#attribute_to_html" do + subject { Nokogiri::HTML(renderer.render) } + + let(:expected) { Nokogiri::HTML(tr_content) } + + let(:tr_content) do + "Rights statement\n" \ + "" + end + + it { expect(renderer).not_to be_microdata(field) } + it { expect(subject).to be_equivalent_to(expected) } + end +end diff --git a/spec/services/hyrax/default_middleware_stack_spec.rb b/spec/services/hyrax/default_middleware_stack_spec.rb index 8e61137499..9ce140970f 100644 --- a/spec/services/hyrax/default_middleware_stack_spec.rb +++ b/spec/services/hyrax/default_middleware_stack_spec.rb @@ -13,7 +13,6 @@ Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CollectionsMembershipActor, Hyrax::Actors::AddToWorkActor, - Hyrax::Actors::AssignRepresentativeActor, Hyrax::Actors::AttachMembersActor, Hyrax::Actors::InterpretVisibilityActor, Hyrax::Actors::TransferRequestActor, diff --git a/spec/services/hyrax/embargo_service_spec.rb b/spec/services/hyrax/embargo_service_spec.rb index 08760bcd47..e9c28c4b00 100644 --- a/spec/services/hyrax/embargo_service_spec.rb +++ b/spec/services/hyrax/embargo_service_spec.rb @@ -5,19 +5,19 @@ let(:past_date) { 2.days.ago } let!(:work_with_expired_embargo1) do - FactoryGirl.build(:work, embargo_release_date: past_date.to_s).tap do |work| + build(:work, embargo_release_date: past_date.to_s).tap do |work| work.save(validate: false) end end let!(:work_with_expired_embargo2) do - FactoryGirl.build(:work, embargo_release_date: past_date.to_s).tap do |work| + build(:work, embargo_release_date: past_date.to_s).tap do |work| work.save(validate: false) end end - let!(:work_with_embargo_in_effect) { FactoryGirl.create_for_repository(:work, embargo_release_date: future_date.to_s) } - let!(:work_without_embargo) { FactoryGirl.create_for_repository(:work) } + let!(:work_with_embargo_in_effect) { create_for_repository(:work, embargo_release_date: future_date.to_s) } + let!(:work_without_embargo) { create_for_repository(:work) } describe '#assets_with_expired_embargoes' do it 'returns an array of assets with expired embargoes' do diff --git a/spec/services/hyrax/workflow/notification_service_spec.rb b/spec/services/hyrax/workflow/notification_service_spec.rb index 11d12958c5..057627d2f9 100644 --- a/spec/services/hyrax/workflow/notification_service_spec.rb +++ b/spec/services/hyrax/workflow/notification_service_spec.rb @@ -23,11 +23,6 @@ let(:action) { Sipity::WorkflowAction.new(notifiable_contexts: [notifiable_context]) } let(:entity) { Sipity::Entity.new } let(:user) { User.new } - - let(:workflow) { Sipity::Workflow.new } - let(:workflow_state) { Sipity::WorkflowState.new } - let(:permission_template) { Hyrax::PermissionTemplate.new } - let(:instance) do described_class.new(entity: entity, action: action, @@ -35,34 +30,6 @@ user: user) end - describe '#recipients' do - context 'when an entity requires review' do - let(:creator) { [instance_double(User)] } - let(:managers) { [instance_double(User), instance_double(User)] } - let(:notification) { Sipity::Notification.new(name: 'pending review notification') } - - before do - allow(instance).to receive(:send_notification) # mock it so it does nothing - allow(entity).to receive(:workflow_state).and_return(workflow_state) - allow(workflow_state).to receive(:name).and_return('pending_review') - allow(entity).to receive(:workflow).and_return(workflow) - # Mock the permission_template queries - allow(workflow).to receive(:permission_template).and_return(permission_template) - allow(permission_template).to receive(:agent_ids_for) - .with(access: 'manage', agent_type: 'user') - .and_return(managers) - allow(permission_template).to receive(:agent_ids_for) - .with(access: 'deposit', agent_type: 'user') - .and_return(creator) - end - - it 'identifies the managers and depositor for notifications' do - recipients = instance.recipients(notification) - expect(recipients).to eq(to: managers, cc: creator) - end - end - end - describe "#call" do subject { instance.call } @@ -81,8 +48,6 @@ def self.send_notification; end let(:creator_rel) { double(ActiveRecord::Relation, to_ary: creator) } before do - allow(entity).to receive(:workflow_state).and_return(workflow_state) - allow(workflow_state).to receive(:name).and_return('not_pending_review') allow(Hyrax::Workflow::PermissionQuery).to receive(:scope_users_for_entity_and_roles) .with(entity: entity, roles: advising) diff --git a/spec/services/hyrax/workflow/permission_generator_spec.rb b/spec/services/hyrax/workflow/permission_generator_spec.rb index 86b25039ba..e66491e380 100644 --- a/spec/services/hyrax/workflow/permission_generator_spec.rb +++ b/spec/services/hyrax/workflow/permission_generator_spec.rb @@ -1,7 +1,7 @@ module Hyrax module Workflow RSpec.describe PermissionGenerator do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:role) { Sipity::Role.create!(name: 'creating_user') } let(:workflow) { create(:workflow, name: 'workflow') } let(:workflow_state) { workflow.initial_workflow_state } diff --git a/spec/services/hyrax/workflow/status_list_service_spec.rb b/spec/services/hyrax/workflow/status_list_service_spec.rb index 763ef1c093..c9ebe46834 100644 --- a/spec/services/hyrax/workflow/status_list_service_spec.rb +++ b/spec/services/hyrax/workflow/status_list_service_spec.rb @@ -41,6 +41,18 @@ expect(results.first.to_s).to eq 'Hey dood!' expect(results.first.workflow_state).to eq 'initial' end + + describe '#search_solr' do + let(:mock_response) { { 'response' => { 'docs' => [{}, {}, {}] } } } + + it 'queries Solr via HTTP POST method' do + allow(ActiveFedora::SolrService).to receive(:post).and_return(mock_response) + allow(ActiveFedora::SolrService).to receive(:get) + service.send(:search_solr) + expect(ActiveFedora::SolrService).to have_received(:post) + expect(ActiveFedora::SolrService).not_to have_received(:get) + end + end end context "when user doesn't have roles" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1d7d5d843b..f5fee6a5fb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,7 +21,7 @@ def coverage_needed? SimpleCov.command_name 'spec' end -require 'factory_girl' +require 'factory_bot' require 'engine_cart' EngineCart.load_application! @@ -89,7 +89,7 @@ def loaddb class JsonStrategy def initialize - @strategy = FactoryGirl.strategy_by_name(:create).new + @strategy = FactoryBot.strategy_by_name(:create).new end delegate :association, to: :@strategy @@ -99,9 +99,9 @@ def result(evaluation) end end -FactoryGirl.register_strategy(:json, JsonStrategy) -FactoryGirl.definition_file_paths = [File.expand_path("../factories", __FILE__)] -FactoryGirl.find_definitions +FactoryBot.register_strategy(:json, JsonStrategy) +FactoryBot.definition_file_paths = [File.expand_path("../factories", __FILE__)] +FactoryBot.find_definitions module EngineRoutes def self.included(base) @@ -197,7 +197,7 @@ def main_app config.include Capybara::RSpecMatchers, type: :input config.include InputSupport, type: :input - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.infer_spec_type_from_file_location! diff --git a/spec/support/features/create_strategy_for_repository_pattern.rb b/spec/support/features/create_strategy_for_repository_pattern.rb index fcfd5ed766..c30328cca2 100644 --- a/spec/support/features/create_strategy_for_repository_pattern.rb +++ b/spec/support/features/create_strategy_for_repository_pattern.rb @@ -23,4 +23,4 @@ def result(evaluation) result end end -FactoryGirl.register_strategy(:create_for_repository, CreateStrategyForRepositoryPattern) +FactoryBot.register_strategy(:create_for_repository, CreateStrategyForRepositoryPattern) diff --git a/spec/support/features/session_helpers.rb b/spec/support/features/session_helpers.rb index 85c0040a9f..53e903bc32 100644 --- a/spec/support/features/session_helpers.rb +++ b/spec/support/features/session_helpers.rb @@ -3,7 +3,7 @@ module Features module SessionHelpers def sign_in(who = :user) logout - user = who.is_a?(User) ? who : FactoryGirl.build(:user).tap(&:save!) + user = who.is_a?(User) ? who : FactoryBot.build(:user).tap(&:save!) visit new_user_session_path fill_in 'Email', with: user.email fill_in 'Password', with: user.password diff --git a/spec/views/hyrax/admin/admin_sets/_form_visibility.html.erb_spec.rb b/spec/views/hyrax/admin/admin_sets/_form_visibility.html.erb_spec.rb index 5c30fb4c1a..a1a96eb6fb 100644 --- a/spec/views/hyrax/admin/admin_sets/_form_visibility.html.erb_spec.rb +++ b/spec/views/hyrax/admin/admin_sets/_form_visibility.html.erb_spec.rb @@ -12,6 +12,7 @@ it "has the form" do expect(rendered).to have_selector('#visibility input[type=radio][name="permission_template[release_period]"][value=now]') expect(rendered).to have_selector('#visibility input[type=radio][name="permission_template[release_period]"][value=fixed]') + expect(rendered).to have_selector('#visibility input[type=radio][name="permission_template[release_varies]"][value=""]') expect(rendered).to have_selector('#visibility input[type=radio][name="permission_template[release_varies]"][value=before]') expect(rendered).to have_selector('#visibility input[type=radio][name="permission_template[release_varies]"][value=embargo]') expect(rendered).to have_selector('#visibility select[name="permission_template[release_embargo]"]') diff --git a/spec/views/hyrax/admin/users/index.html.erb_spec.rb b/spec/views/hyrax/admin/users/index.html.erb_spec.rb index 552db3f915..38df15dc55 100644 --- a/spec/views/hyrax/admin/users/index.html.erb_spec.rb +++ b/spec/views/hyrax/admin/users/index.html.erb_spec.rb @@ -3,7 +3,7 @@ let(:users) { [] } before do - (1..4).each { |i| users << FactoryGirl.build(:user, display_name: "user#{i}", email: "email#{i}@example.com", last_sign_in_at: Time.zone.now - 15.minutes, created_at: Time.zone.now - 3.days) } + (1..4).each { |i| users << FactoryBot.build(:user, display_name: "user#{i}", email: "email#{i}@example.com", last_sign_in_at: Time.zone.now - 15.minutes, created_at: Time.zone.now - 3.days) } allow(presenter).to receive(:users).and_return(users) assign(:presenter, presenter) end diff --git a/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb b/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb index 7dd6f6328c..68220a5f9b 100644 --- a/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb +++ b/spec/views/hyrax/base/_attribute_rows.html.erb_spec.rb @@ -18,6 +18,6 @@ end it 'shows rights statement with link to statement URL' do - expect(page).to have_link(rights_statement_uri) + expect(page).to have_link("In Copyright", href: rights_statement_uri) end end diff --git a/spec/views/hyrax/collections/show.html.erb_spec.rb b/spec/views/hyrax/collections/show.html.erb_spec.rb index 7da9113c6d..410b204802 100644 --- a/spec/views/hyrax/collections/show.html.erb_spec.rb +++ b/spec/views/hyrax/collections/show.html.erb_spec.rb @@ -10,23 +10,41 @@ before do allow(document).to receive(:hydra_model).and_return(::Collection) allow(controller).to receive(:current_user).and_return(stub_model(User)) - allow(view).to receive(:can?).with(:edit, document).and_return(true) - allow(view).to receive(:can?).with(:destroy, document).and_return(true) allow(presenter).to receive(:total_items).and_return(0) assign(:presenter, presenter) # Stub route because view specs don't handle engine routes allow(view).to receive(:collection_path).and_return("/collection/123") + allow(view).to receive(:edit_dashboard_collection_path).and_return("/dashboard/collection/123/edit") stub_template '_search_form.html.erb' => 'search form' stub_template 'hyrax/collections/_sort_and_per_page.html.erb' => 'sort and per page' stub_template 'hyrax/collections/_document_list.html.erb' => 'document list' stub_template 'hyrax/collections/_paginate.html.erb' => 'paginate' stub_template 'hyrax/collections/_media_display.html.erb' => '' - render end - it 'draws the page' do - expect(rendered).to match '' + describe 'as normal user' do + it 'draws the page' do + allow(view).to receive(:can?).with(:edit, document).and_return(false) + allow(view).to receive(:can?).with(:destroy, document).and_return(false) + render + + expect(rendered).to match '' + end + end + + describe 'as editor' do + it 'includes edit actions' do + allow(view).to receive(:can?).with(:edit, document).and_return(true) + allow(view).to receive(:can?).with(:destroy, document).and_return(true) + render + + expect(rendered).to have_selector 'h2', text: 'Actions' + expect(rendered).to have_link 'Edit' + expect(rendered).to have_link 'Delete' + expect(rendered).to have_link 'Add works' + expect(rendered).to match '' + end end end diff --git a/spec/views/pages/show.html.erb_spec.rb b/spec/views/pages/show.html.erb_spec.rb index 8732b09b86..0da583ab80 100644 --- a/spec/views/pages/show.html.erb_spec.rb +++ b/spec/views/pages/show.html.erb_spec.rb @@ -1,5 +1,5 @@ RSpec.describe "hyrax/pages/show", type: :view do - let(:content_block) { FactoryGirl.create(:content_block, name: 'terms_page') } + let(:content_block) { FactoryBot.create(:content_block, name: 'terms_page') } before do assign(:page, content_block) diff --git a/template.rb b/template.rb index d7e159395e..40fe89b03c 100644 --- a/template.rb +++ b/template.rb @@ -1,4 +1,4 @@ -gem 'hyrax', '2.0.0.beta5' +gem 'hyrax', '2.0.0.rc2' run 'bundle install' generate 'hyrax:install', '-f' rails_command 'db:migrate'