diff --git a/.rubocop.yml b/.rubocop.yml index 1236d5bd8..348cf6399 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ require: rubocop-rspec -inherit_from: .rubocop_fix_me.yml +inherit_from: rubocop_fix_me.yml AllCops: TargetRubyVersion: 2.5 @@ -13,6 +13,7 @@ AllCops: - "bin/**/*" - "Gemfile" - "Rakefile" + - "spec/**/*" - "lib/tasks/**/*" - "config/**/*" - "sa_scripts/**/*" diff --git a/.rubocop_fix_me.yml b/.rubocop_fix_me.yml deleted file mode 100644 index bd3d8039a..000000000 --- a/.rubocop_fix_me.yml +++ /dev/null @@ -1,1095 +0,0 @@ -Style/Documentation: - Exclude: - - "spec/**/*" - -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - "app/indexers/default_work_indexer.rb" - -Metrics/MethodLength: - Exclude: - - "app/indexers/default_work_indexer.rb" - - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" - - "app/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer.rb" - - "app/forms/scholars_archive/dataset_form_behavior.rb" - - "app/forms/scholars_archive/default_work_form_behavior.rb" - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - - "app/jobs/characterize_job.rb" - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/jobs/reindex_everything_job.rb" - - "app/jobs/reindex_model_job.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/application_controller.rb" - - "app/controllers/hyrax/contact_form_controller.rb" - - "app/controllers/concerns/scholars_archive/download_analytics_behavior.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/controllers/concerns/hyrax/contact_form_recaptcha_behavior.rb" - - "app/helpers/application_helper.rb" - - "app/services/scholars_archive/records_by_user_group_and_visibility.rb" - - "app/services/scholars_archive/caching_service.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - - "app/services/scholars_archive/osu_api_service.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/inputs/multi_value_select_other_input.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_date_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - - "lib/scholars_archive/embargoes/embargo_releaser.rb" - - "lib/scholars_archive/document/qualified_dublin_core.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/nested_related_items_validator.rb" - - "lib/scholars_archive/validators/other_option_degree_validator.rb" - - "app/services/scholars_archive/degree_level_service.rb" - - "lib/qa/authorities/geonames.rb" - -Metrics/BlockLength: - ExcludedMethods: ["included"] - Exclude: - - "spec/**/*" - - "app/indexers/default_work_indexer.rb" - - "app/forms/scholars_archive/dataset_form_behavior.rb" - - "app/forms/scholars_archive/default_work_form_behavior.rb" - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" - - "app/models/concerns/scholars_archive/default_metadata.rb" - - "app/presenters/concerns/scholars_archive/default_presenter_behavior.rb" - - "app/controllers/catalog_controller.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - -Style/ConditionalAssignment: - Exclude: - - "app/indexers/default_work_indexer.rb" - - "app/renderers/hyrax/renderers/edtf_attribute_renderer.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/helpers/hyrax_helper.rb" - - "app/inputs/multi_value_label_url_input.rb" - -Metrics/CyclomaticComplexity: - Exclude: - - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - - "lib/scholars_archive/validators/nested_related_items_validator.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - - "app/services/scholars_archive/degree_level_service.rb" - - "app/indexers/default_work_indexer.rb" - - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/actors/scholars_archive/actors/create_with_ext_relation_actor.rb" - -Metrics/PerceivedComplexity: - Exclude: - - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/nested_related_items_validator.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - - "app/indexers/default_work_indexer.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/services/scholars_archive/degree_level_service.rb" - - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" - - "app/actors/scholars_archive/actors/create_with_ext_relation_actor.rb" - -Naming/MethodParameterName: - Exclude: - - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" - - "app/authorities/parsers/academic_units_parser.rb" - - "app/authorities/parsers/degree_fields_parser.rb" - - "app/jobs/resolrize_job.rb" - - "app/helpers/application_helper.rb" - - "app/services/scholars_archive/license_service.rb" - - "lib/qa/authorities/geonames.rb" - -Naming/MemoizedInstanceVariableName: - Exclude: - - "app/forms/hyrax/forms/batch_upload_form.rb" - -Lint/RedundantCopEnableDirective: - Exclude: - - "app/forms/hyrax/forms/collection_form.rb" - -Metrics/ClassLength: - Exclude: - - "app/models/solr_document.rb" - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/catalog_controller.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_date_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - -Lint/AmbiguousBlockAssociation: - Exclude: - - "app/models/oai_set.rb" - -Style/Next: - Exclude: - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - -Style/RedundantInterpolation: - Exclude: - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/inputs/multi_value_ordered_input.rb" - -Layout/ArrayAlignment: - Exclude: - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - -Layout/MultilineArrayBraceLayout: - Exclude: - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - -Style/SymbolProc: - Exclude: - - "app/models/concerns/scholars_archive/has_solr_labels.rb" - - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - -Lint/ShadowedArgument: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - -Style/RedundantAssignment: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - -Style/KeywordParametersOrder: - Exclude: - - "app/services/hyrax/workflow/metadata_only_record.rb" - -Style/OptionalBooleanParameter: - Exclude: - - "app/services/scholars_archive/degree_grantors_service.rb" - -Style/MultilineIfThen: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - -Style/RedundantCondition: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - - "app/helpers/application_helper.rb" - -Style/SafeNavigation: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - -Layout/MultilineMethodCallIndentation: - Exclude: - - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - -Metrics/ModuleLength: - Exclude: - - "app/models/concerns/scholars_archive/default_metadata.rb" - - "app/helpers/application_helper.rb" - -Style/GuardClause: - Exclude: - - "app/models/user.rb" - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/application_controller.rb" - - "app/controllers/concerns/scholars_archive/download_analytics_behavior.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/helpers/application_helper.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - - "app/services/scholars_archive/osu_api_service.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/other_option_degree_validator.rb" - -Lint/ParenthesesAsGroupedExpression: - Exclude: - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - - "spec/models/user_spec.rb" - - "spec/services/scholars_archive/all_facet_values_service_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/nested_related_items_validator.rb" - - "lib/scholars_archive/validators/other_option_degree_validator.rb" - -Naming/PredicateName: - Exclude: - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/controllers/concerns/hyrax/contact_form_recaptcha_behavior.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "lib/scholars_archive/triple_powered_properties/triple_powered_form.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - -Style/NumericPredicate: - Exclude: - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/nested_related_items_validator.rb" - -Lint/RedundantStringCoercion: - Exclude: - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - - "spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb" - -Style/ZeroLengthPredicate: - Exclude: - - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" - - "app/services/scholars_archive/triple_powered_service.rb" - -Naming/AccessorMethodName: - Exclude: - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/controllers/blacklight_advanced_search/advanced_controller.rb" - - "app/services/scholars_archive/osu_api_service.rb" - -Lint/UnusedBlockArgument: - Exclude: - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - -Security/YAMLLoad: - Exclude: - - "app/authorities/scholars_archive/cache_based_authority.rb" - - "app/jobs/reindex_everything_job.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/services/scholars_archive/admin_set_select_service.rb" - -Lint/UselessAccessModifier: - Exclude: - - "app/authorities/parsers/academic_units_parser.rb" - - "app/authorities/parsers/degree_fields_parser.rb" - - "app/services/scholars_archive/caching_service.rb" - - "app/services/scholars_archive/edtf_date_compare_service.rb" - - "app/services/scholars_archive/label_and_ordered_parser_service.rb" - - "app/services/scholars_archive/label_parser_service.rb" - - "app/services/scholars_archive/ordered_parser_service.rb" - - "app/services/scholars_archive/field_validation_service.rb" - -Lint/IneffectiveAccessModifier: - Exclude: - - "app/authorities/parsers/academic_units_parser.rb" - - "app/authorities/parsers/degree_fields_parser.rb" - - "app/services/scholars_archive/caching_service.rb" - - "app/services/scholars_archive/edtf_date_compare_service.rb" - - "app/services/scholars_archive/label_and_ordered_parser_service.rb" - - "app/services/scholars_archive/label_parser_service.rb" - - "app/services/scholars_archive/ordered_parser_service.rb" - - "app/services/scholars_archive/field_validation_service.rb" - -Style/NumericLiterals: - Exclude: - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/jobs/reindex_everything_job.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/services/scholars_archive/records_by_user_group_and_visibility.rb" - - "app/services/scholars_archive/all_facet_values_service.rb" - - "app/services/scholars_archive/parent_query_service.rb" - - "spec/services/scholars_archive/parent_query_service_spec.rb" - - "spec/services/scholars_archive/osu_api_service_spec.rb" - -Style/RescueStandardError: - Exclude: - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/jobs/reindex_everything_job.rb" - - "app/jobs/reindex_model_job.rb" - - "app/controllers/application_controller.rb" - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - - "lib/scholars_archive/embargoes/embargo_releaser.rb" - -Style/StringLiteralsInInterpolation: - Exclude: - - "app/jobs/migrate_creators_no_handles_job.rb" - - "app/jobs/reindex_everything_job.rb" - -Naming/VariableName: - Exclude: - - "app/jobs/resolrize_job.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - -Lint/EmptyWhen: - Exclude: - - "app/controllers/scholars_archive/handles_controller.rb" - -Style/IfUnlessModifier: - Exclude: - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - -Style/AndOr: - Exclude: - - "app/controllers/scholars_archive/handles_controller.rb" - - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" - - "app/controllers/concerns/scholars_archive/my_shares_behavior.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - -Layout/CommentIndentation: - Exclude: - - "app/controllers/catalog_controller.rb" - - "spec/spec_helper.rb" - - "lib/scholars_archive/document/qualified_dublin_core.rb" - -Style/TrailingUnderscoreVariable: - Exclude: - - "app/controllers/blacklight_advanced_search/advanced_controller.rb" - -Style/NestedTernaryOperator: - Exclude: - - "app/helpers/application_helper.rb" - -Layout/SpaceInsideParens: - Exclude: - - "app/helpers/application_helper.rb" - - "app/services/scholars_archive/handle_error_logging_service.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - "app/services/scholars_archive/admin_set_select_service.rb" - - "spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb" - - "spec/scholars_archive/validators/other_option_degree_validator_spec.rb" - - "spec/scholars_archive/validators/other_affiliation_validator_spec.rb" - -Style/NegatedIf: - Exclude: - - "app/services/scholars_archive/edtf_date_compare_service.rb" - -Style/InverseMethods: - Exclude: - - "app/services/scholars_archive/triple_powered_service.rb" - - "app/services/scholars_archive/label_and_ordered_parser_service.rb" - -Style/EmptyElse: - Exclude: - - "app/services/scholars_archive/osu_api_service.rb" - - "app/services/scholars_archive/field_validation_service.rb" - -Lint/InterpolationCheck: - Exclude: - - "app/services/scholars_archive/osu_api_service.rb" - -Style/IfInsideElse: - Exclude: - - "app/services/scholars_archive/field_validation_service.rb" - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - -Style/RedundantFreeze: - Exclude: - - "app/inputs/multi_value_select_other_input.rb" - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_date_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - -Lint/UnusedMethodArgument: - Exclude: - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_date_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - -Layout/SpaceInsideStringInterpolation: - Exclude: - - "app/inputs/multi_value_label_url_input.rb" - - "app/inputs/multi_value_ordered_input.rb" - -Naming/VariableNumber: - Exclude: - - "app/inputs/multi_value_ordered_input.rb" - - "app/controllers/scholars_archive/handles_controller.rb" - -RSpec/ExampleWording: - Exclude: - - "spec/active_support/logger_spec.rb" - - "spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb" - - "spec/models/nested_ordered_title_spec.rb" - - "spec/models/nested_related_items_spec.rb" - - "spec/models/nested_geo_spec.rb" - - "spec/models/nested_ordered_creator_spec.rb" - - "spec/models/default_spec.rb" - - "spec/models/solr_document_spec.rb" - - "spec/authorities/scholars_archive/cache_based_authority_spec.rb" - - "spec/authorities/scholars_archive/extended_file_based_authority_spec.rb" - - "spec/controllers/scholars_archive/handles_controller_spec.rb" - - "spec/services/scholars_archive/edtf_date_compare_service_spec.rb" - -RSpec/ContextWording: - Exclude: - - "spec/scholars_archive/validators/graduation_year_validator_spec.rb" - - "spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb" - - "spec/features/create_oer_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/models/default_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/authorities/scholars_archive/cache_based_authority_spec.rb" - - "spec/authorities/scholars_archive/extended_file_based_authority_spec.rb" - - "spec/controllers/scholars_archive/handles_controller_spec.rb" - - "spec/controllers/hyrax/contact_form_controller_spec.rb" - - "spec/views/graduate_thesis_or_dissertations/edit_fields/_license.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "spec/views/records/edit_fields/_nested_related_items.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_name.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_level.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_grantors.html.erb_spec.rb" - - "spec/views/records/edit_fields/_dates_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_geo_section.html.erb_spec.rb" - - "spec/views/shared/_select_work_type_modal.html.erb_spec.rb" - - "spec/views/hyrax/base/_form_instructions_spec.rb" - - "spec/views/honors_college_theses/edit_fields/_license.html.erb_spec.rb" - - "spec/services/scholars_archive/admin_set_select_service_spec.rb" - -Style/BlockComments: - Exclude: - - "spec/spec_helper.rb" - -Layout/BlockAlignment: - Exclude: - - "spec/spec_helper.rb" - - "spec/forms/hyrax/purchased_e_resource_form_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - -RSpec/NamedSubject: - Exclude: - - "spec/renderers/hyrax/renderers/search_and_external_link_attribute_renderer_spec.rb" - - "spec/renderers/hyrax/renderers/external_link_attribute_renderer_spec.rb" - - "spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb" - - "spec/renderers/hyrax/renderers/edtf_attribute_renderer_spec.rb" - - "spec/models/nested_ordered_title_spec.rb" - - "spec/models/nested_related_items_spec.rb" - - "spec/models/nested_geo_spec.rb" - - "spec/models/nested_ordered_creator_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/services/scholars_archive/other_option_create_success_service_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -RSpec/VerifiedDoubles: - Exclude: - - "spec/forms/hyrax/eesc_publication_form_spec.rb" - - "spec/forms/hyrax/open_educational_resource_form_spec.rb" - - "spec/forms/hyrax/article_form_spec.rb" - - "spec/forms/hyrax/default_form_spec.rb" - - "spec/forms/hyrax/purchased_e_resource_form_spec.rb" - - "spec/forms/hyrax/administrative_report_or_publication_form_spec.rb" - - "spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb" - - "spec/forms/hyrax/technical_report_form_spec.rb" - - "spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb" - - "spec/forms/hyrax/dataset_form_spec.rb" - - "spec/forms/hyrax/graduate_project_form_spec.rb" - - "spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb" - - "spec/models/search_builder_spec.rb" - - "spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb" - - "spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb" - - "spec/presenters/hyrax/default_presenter_spec.rb" - - "spec/presenters/hyrax/dataset_presenter_spec.rb" - - "spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb" - - "spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_project_presenter_spec.rb" - - "spec/presenters/hyrax/eesc_publication_presenter_spec.rb" - - "spec/presenters/hyrax/article_presenter_spec.rb" - - "spec/presenters/hyrax/open_educational_resource_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb" - - "spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb" - - "spec/presenters/hyrax/technical_report_presenter_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/views/graduate_thesis_or_dissertations/edit_fields/_license.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "spec/views/records/edit_fields/_nested_related_items.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_name.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_level.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_grantors.html.erb_spec.rb" - - "spec/views/records/edit_fields/_dates_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_geo_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_academic_affiliation.html.erb_spec.rb" - - "spec/views/shared/_select_work_type_modal.html.erb_spec.rb" - - "spec/views/hyrax/base/_work_description.erb_spec.rb" - - "spec/views/hyrax/base/_form_instructions_spec.rb" - - "spec/views/hyrax/base/_form.html.erb_spec.rb" - - "spec/views/hyrax/my/works/index.html.erb_spec.rb" - - "spec/views/honors_college_theses/edit_fields/_license.html.erb_spec.rb" - - "spec/services/scholars_archive/all_facet_values_service_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - - "spec/services/hyrax/workflow/deletion_approval_notification_spec.rb" - - "spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb" - - "spec/services/hyrax/workflow/pending_deletion_notification_spec.rb" - - "spec/views/hyrax/base/_items.html.erb_spec.rb" - -Lint/AmbiguousOperator: - Exclude: - - "spec/forms/hyrax/eesc_publication_form_spec.rb" - - "spec/forms/hyrax/open_educational_resource_form_spec.rb" - - "spec/forms/hyrax/default_form_spec.rb" - - "spec/forms/hyrax/purchased_e_resource_form_spec.rb" - - "spec/forms/hyrax/administrative_report_or_publication_form_spec.rb" - - "spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb" - - "spec/forms/hyrax/technical_report_form_spec.rb" - - "spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb" - - "spec/forms/hyrax/dataset_form_spec.rb" - - "spec/forms/hyrax/graduate_project_form_spec.rb" - - "spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb" - -Lint/RedundantSplatExpansion: - Exclude: - - "spec/forms/hyrax/eesc_publication_form_spec.rb" - - "spec/forms/hyrax/open_educational_resource_form_spec.rb" - - "spec/forms/hyrax/default_form_spec.rb" - - "spec/forms/hyrax/purchased_e_resource_form_spec.rb" - - "spec/forms/hyrax/administrative_report_or_publication_form_spec.rb" - - "spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb" - - "spec/forms/hyrax/technical_report_form_spec.rb" - - "spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb" - - "spec/forms/hyrax/dataset_form_spec.rb" - - "spec/forms/hyrax/graduate_project_form_spec.rb" - - "spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb" - -RSpec/NotToNot: - Exclude: - - "spec/forms/hyrax/eesc_publication_form_spec.rb" - - "spec/forms/hyrax/default_form_spec.rb" - - "spec/forms/hyrax/administrative_report_or_publication_form_spec.rb" - - "spec/forms/hyrax/technical_report_form_spec.rb" - - "spec/forms/hyrax/dataset_form_spec.rb" - - "spec/models/other_option_spec.rb" - -Style/MixinUsage: - Exclude: - - "spec/features/create_oer_spec.rb" - - "spec/features/modal_pagination_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/controllers/other_options_controller_spec.rb" - -RSpec/Capybara: - Exclude: - - "spec/features/create_oer_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - -Style/RedundantBegin: - Exclude: - - "spec/features/create_oer_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/services/hyrax/workflow/deletion_approval_notification_spec.rb" - - "spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb" - - "spec/services/hyrax/workflow/pending_deletion_notification_spec.rb" - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - -Style/RedundantReturn: - Exclude: - - "app/models/oai_set.rb" - -RSpec/ExampleLength: - Exclude: - - "spec/features/create_oer_spec.rb" - - "spec/features/modal_pagination_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/models/default_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - - "spec/renderers/hyrax/renderers/external_link_attribute_renderer_spec.rb" - -RSpec/MultipleExpectations: - Exclude: - - "spec/features/create_oer_spec.rb" - - "spec/features/modal_pagination_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_default_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_eesc_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_default_work_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_etd_spec.rb" - - "spec/features/create_purchased_e_resource_spec.rb" - - "spec/features/create_dataset_spec.rb" - - "spec/features/create_article_spec.rb" - - "spec/features/create_open_educational_resource_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/models/default_spec.rb" - - "spec/models/user_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/authorities/scholars_archive/extended_file_based_authority_spec.rb" - - "spec/controllers/scholars_archive/single_use_links_viewer_controller_spec.rb" - - "spec/controllers/scholars_archive/downloads_controller_spec.rb" - - "spec/views/graduate_thesis_or_dissertations/edit_fields/_license.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_name.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_level.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_grantors.html.erb_spec.rb" - - "spec/views/records/edit_fields/_dates_section.html.erb_spec.rb" - - "spec/views/hyrax/base/_work_description.erb_spec.rb" - - "spec/views/honors_college_theses/edit_fields/_license.html.erb_spec.rb" - - "spec/services/scholars_archive/other_option_create_success_service_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - - "spec/services/hyrax/workflow/deletion_approval_notification_spec.rb" - - "spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb" - - "spec/services/hyrax/workflow/pending_deletion_notification_spec.rb" - - "spec/views/hyrax/base/_items.html.erb_spec.rb" - -RSpec/MultipleMemoizedHelpers: - Exclude: - - "spec/workers/fetch_failed_graph_worker_spec.rb" - - "spec/workers/fetch_graph_worker_spec.rb" - - "spec/views/hyrax/base/_form_instructions_spec.rb" - - "spec/views/hyrax/base/_form_progress.html.erb_spec.rb" - - "spec/views/hyrax/base/_work_description.erb_spec.rb" - - "spec/views/records/edit_fields/_academic_affiliation.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_grantors.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_level.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_name.html.erb_spec.rb" - - "spec/views/records/edit_fields/_dates_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_geo_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_nested_related_items.html.erb_spec.rb" - - "spec/views/shared/_select_work_type_modal.html.erb_spec.rb" - - "spec/services/scholars_archive/other_option_create_success_service_spec.rb" - - "spec/services/scholars_archive/osu_api_service_spec.rb" - - "spec/services/hyrax/workflow/pending_deletion_notification_spec.rb" - - "spec/services/hyrax/workflow/deletion_approval_notification_spec.rb" - - "spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb" - - "spec/scholars_archive/validators/other_option_degree_validator_spec.rb" - - "spec/scholars_archive/validators/other_option_degree_validator_spec.rb" - - "spec/scholars_archive/validators/nested_related_items_validator_spec.rb" - - "spec/renderers/hyrax/renderers/search_and_external_link_attribute_renderer_spec.rb" - - "spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb" - - "spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb" - - "spec/presenters/hyrax/article_presenter_spec.rb" - - "spec/presenters/hyrax/dataset_presenter_spec.rb" - - "spec/presenters/hyrax/default_presenter_spec.rb" - - "spec/presenters/hyrax/eesc_publication_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_project_presenter_spec.rb" - - "spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb" - - "spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb" - - "spec/presenters/hyrax/open_educational_resource_presenter_spec.rb" - - "spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb" - - "spec/presenters/hyrax/technical_report_presenter_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - - "spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb" - - "spec/active_support/logger_spec.rb" - - "spec/views/hyrax/base/_items.html.erb_spec.rb" - -Style/MethodCallWithoutArgsParentheses: - Exclude: - - "spec/features/modal_pagination_spec.rb" - - "spec/models/default_spec.rb" - - "spec/services/scholars_archive/all_facet_values_service_spec.rb" - -RSpec/InstanceVariable: - Exclude: - - "spec/features/create_graduate_thesis_or_dissertation_spec.rb" - - "spec/features/create_administrative_report_or_publication_spec.rb" - - "spec/features/create_graduate_project_spec.rb" - - "spec/features/create_conference_proceedings_or_journal_spec.rb" - - "spec/features/create_honors_college_thesis_spec.rb" - - "spec/features/create_technical_report_spec.rb" - - "spec/features/create_undergraduate_thesis_or_project_spec.rb" - -RSpec/DescribedClass: - Exclude: - - "spec/system/**/*" - - "spec/views/**/*" - - "spec/models/nested_ordered_title_spec.rb" - - "spec/models/nested_related_items_spec.rb" - - "spec/models/nested_geo_spec.rb" - - "spec/models/nested_ordered_creator_spec.rb" - - "spec/requests/scholars_archive/handles_request_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -RSpec/LeakyConstantDeclaration: - Exclude: - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -RSpec/EmptyExampleGroup: - Exclude: - - "spec/models/search_builder_spec.rb" - -Style/EmptyLiteral: - Exclude: - - "spec/models/search_builder_spec.rb" - -RSpec/LeadingSubject: - Exclude: - - "spec/models/search_builder_spec.rb" - - "spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb" - - "spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb" - - "spec/presenters/hyrax/default_presenter_spec.rb" - - "spec/presenters/hyrax/dataset_presenter_spec.rb" - - "spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb" - - "spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_project_presenter_spec.rb" - - "spec/presenters/hyrax/eesc_publication_presenter_spec.rb" - - "spec/presenters/hyrax/article_presenter_spec.rb" - - "spec/presenters/hyrax/open_educational_resource_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb" - - "spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb" - - "spec/presenters/hyrax/technical_report_presenter_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - - "spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -RSpec/NestedGroups: - Exclude: - - "spec/models/default_spec.rb" - - "spec/controllers/hyrax/contact_form_controller_spec.rb" - -RSpec/ExpectInHook: - Exclude: - - "spec/views/hyrax/base/_items.html.erb_spec.rb" - -RSpec/StubbedMock: - Exclude: - - "spec/views/hyrax/base/_items.html.erb_spec.rb" - -Style/TrailingCommaInHashLiteral: - Exclude: - - "spec/models/default_spec.rb" - - "spec/models/solr_document_spec.rb" - - "spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb" - -Layout/MultilineMethodCallBraceLayout: - Exclude: - - "spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb" - - "spec/presenters/hyrax/default_presenter_spec.rb" - - "spec/presenters/hyrax/dataset_presenter_spec.rb" - - "spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb" - - "spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_project_presenter_spec.rb" - - "spec/presenters/hyrax/eesc_publication_presenter_spec.rb" - - "spec/presenters/hyrax/open_educational_resource_presenter_spec.rb" - - "spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb" - - "spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb" - - "spec/presenters/hyrax/technical_report_presenter_spec.rb" - -RSpec/DescribeClass: - Exclude: - - "spec/requests/scholars_archive/handles_request_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -RSpec/PredicateMatcher: - Exclude: - - "spec/authorities/scholars_archive/extended_file_based_authority_spec.rb" - -RSpec/ScatteredLet: - Exclude: - - "spec/controllers/hyrax/contact_form_controller_spec.rb" - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -Layout/MultilineBlockLayout: - Exclude: - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - -Layout/MultilineHashBraceLayout: - Exclude: - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "lib/scholars_archive/feature_class_uri_to_label.rb" - - "lib/qa/authorities/geonames.rb" - -Layout/BlockEndNewline: - Exclude: - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - -Style/ExpandPathArguments: - Exclude: - - "spec/rails_helper.rb" - -RSpec/FilePath: - Exclude: - - "spec/services/scholars_archive/licence_service_spec.rb" - -Style/LineEndConcatenation: - Exclude: - - "spec/services/scholars_archive/osu_api_service_spec.rb" - -Layout/MultilineOperationIndentation: - Exclude: - - "spec/services/scholars_archive/osu_api_service_spec.rb" - -RSpec/HookArgument: - Exclude: - - "spec/services/scholars_archive/osu_api_service_spec.rb" - -RSpec/SubjectStub: - Exclude: - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -Lint/UnifiedInteger: - Exclude: - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - -Layout/EmptyLinesAroundModuleBody: - Exclude: - - "lib/scholars_archive/triple_powered_properties/errors.rb" - - "lib/scholars_archive/triple_powered_properties/triple_powered_form.rb" - -Lint/NonLocalExitFromIterator: - Exclude: - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - -Style/ClassCheck: - Exclude: - - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" - - "lib/hyrax/controlled_vocabularies/location.rb" - -Style/Alias: - Exclude: - - "lib/scholars_archive/document/qualified_dublin_core.rb" - -Style/MethodDefParentheses: - Exclude: - - "lib/scholars_archive/document/qualified_dublin_core.rb" - -Capybara/VisibilityMatcher: - Exclude: - - "spec/views/records/edit_fields/_degree_field.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_grantors.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_level.html.erb_spec.rb" - - "spec/views/records/edit_fields/_degree_name.html.erb_spec.rb" - - "spec/views/records/edit_fields/_geo_section.html.erb_spec.rb" - - "spec/views/records/edit_fields/_nested_related_items.html.erb_spec.rb" - -Style/SingleArgumentDig: - Exclude: - - "app/authorities/parsers/academic_units_parser.rb" - - "app/authorities/parsers/degree_fields_parser.rb" - -Style/CombinableLoops: - Exclude: - - "spec/views/records/edit_fields/_geo_section.html.erb_spec.rb" - -Style/AccessorGrouping: - Exclude: - - "app/models/nested_geo.rb" - -RSpec/RepeatedExampleGroupDescription: - Exclude: - - "spec/models/default_spec.rb" - - "spec/scholars_archive/validators/graduation_year_validator_spec.rb" - -RSpec/UnspecifiedException: - Exclude: - - "spec/services/scholars_archive/research_organization_registry_service_spec.rb" - -Lint/RedundantCopDisableDirective: - Exclude: - - "app/indexers/concerns/scholars_archive/indexes_combined_sort_date.rb" - - "app/services/scholars_archive/workflow/deposit_received_notification.rb" - - "app/jobs/reindex_chunk_job.rb" - -Style/CommentAnnotation: - Exclude: - - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" - - "app/jobs/resolrize_job.rb" - - "lib/qa/authorities/geonames.rb" - -Lint/ConstantDefinitionInBlock: - Exclude: - - "spec/inputs/multi_value_date_input_spec.rb" - - "spec/inputs/multi_value_label_url_input_spec.rb" - - "spec/inputs/multi_value_ordered_input_spec.rb" - -Lint/EmptyFile: - Exclude: - - "spec/scholars_archive/triple_powered_properties/errors_spec.rb" - -Lint/NonDeterministicRequireOrder: - Exclude: - - "spec/rails_helper.rb" - -RSpec/EmptyHook: - Exclude: - - "spec/scholars_archive/validators/other_option_degree_validator_spec.rb" - -RSpec/ContextMethod: - Exclude: - - "spec/controllers/scholars_archive/handles_controller_spec.rb" - -Style/SoleNestedConditional: - Exclude: - - "lib/scholars_archive/validators/other_affiliation_validator.rb" - - "lib/scholars_archive/validators/other_option_degree_validator.rb" - -Style/ClassEqualityComparison: - Exclude: - - "app/controllers/application_controller.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - -Style/RedundantRegexpEscape: - Exclude: - - "app/helpers/scholars_archive/citations_behaviors/formatters/apa_formatter.rb" - - "app/helpers/scholars_archive/citations_behaviors/formatters/chicago_formatter.rb" - - "app/helpers/scholars_archive/citations_behaviors/formatters/mla_formatter.rb" - - "app/workers/fetch_failed_graph_worker.rb" - - "app/workers/fetch_graph_worker.rb" - - "app/models/concerns/hyrax/doi/doi_behavior.rb" - - "app/models/hyrax/contact_form.rb" - -Style/RedundantRegexpCharacterClass: - Exclude: - - "app/models/hyrax/contact_form.rb" - -Style/CaseLikeIf: - Exclude: - - "app/inputs/multi_value_ordered_input.rb" - - "app/models/concerns/scholars_archive/date_operations.rb" - - "app/services/scholars_archive/field_validation_service.rb" - - "app/services/scholars_archive/param_scrubber.rb" - -Style/GlobalStdStream: - Exclude: - - "app/services/scholars_archive/osu_api_service.rb" - -Style/WordArray: - Exclude: - - "app/helpers/hyrax_helper.rb" - -Layout/BeginEndAlignment: - Exclude: - - "app/forms/hyrax/forms/collection_form.rb" - -Layout/EmptyLinesAroundAttributeAccessor: - Exclude: - - "app/models/concerns/scholars_archive/date_operations.rb" - - "lib/scholars_archive/migrate_ordered_metadata_service.rb" - - "app/models/hyrax/contact_form.rb" - -Migration/DepartmentName: - Exclude: - - "app/forms/hyrax/forms/collection_form.rb" - -Lint/UselessMethodDefinition: - Exclude: - - "app/forms/scholars_archive/date_terms_behavior.rb" - - "app/services/scholars_archive/workflow/pending_review_notification.rb" - -Lint/MissingSuper: - Exclude: - - "app/models/oai_set.rb" diff --git a/Gemfile.lock b/Gemfile.lock index a5cfede87..1359b75d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,17 +26,6 @@ GIT rdf-vocab sparql-client -GIT - remote: https://github.com/samvera-labs/hyrax-doi.git - revision: 8fb839af0517096bb05f09925fe1aa77fe32b84a - branch: main - specs: - hyrax-doi (0.2.0) - bolognese (~> 1.8, >= 1.8.6) - flipflop (~> 2.3) - hyrax (>= 2.9, < 4.0) - rails (~> 5.2.4, >= 5.2.4.3) - GEM remote: https://rubygems.org/ specs: @@ -144,10 +133,6 @@ GEM bcp47 (0.3.3) i18n bcrypt (3.1.20) - benchmark_methods (0.7) - bibtex-ruby (6.1.0) - latex-decode (~> 0.0) - racc (~> 1.7) bigdecimal (3.1.8) bindex (0.8.1) blacklight (6.25.0) @@ -180,30 +165,6 @@ GEM jquery-rails rails (>= 3.0) tether-rails - bolognese (1.11.5) - activesupport (>= 4.2.5) - benchmark_methods (~> 0.7) - bibtex-ruby (>= 5.1.0) - builder (~> 3.2, >= 3.2.2) - citeproc-ruby (~> 1.1, >= 1.1.12) - colorize (~> 0.8.1) - concurrent-ruby (~> 1.1, >= 1.1.5) - csl-styles (~> 1.0, >= 1.0.1.10) - edtf (~> 3.0, >= 3.0.4) - gender_detector (~> 0.1.2) - iso8601 (~> 0.9.1) - json-ld-preloaded (~> 3.1, >= 3.1.3) - jsonlint (~> 0.3.0) - loofah (~> 2.0, >= 2.0.3) - maremma (>= 4.9.4, < 5) - namae (~> 1.0) - nokogiri (>= 1.13.2, < 1.14) - oj (~> 3.10) - oj_mimic_json (~> 1.0, >= 1.0.1) - postrank-uri (~> 1.0, >= 1.0.18) - rdf-rdfxml (~> 3.1) - rdf-turtle (~> 3.1) - thor (>= 0.19) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) @@ -242,11 +203,6 @@ GEM coffee-rails (>= 3.2) railties (>= 3.0) sassc-rails (>= 2.1.2) - citeproc (1.0.10) - namae (~> 1.0) - citeproc-ruby (1.1.14) - citeproc (~> 1.0, >= 1.0.9) - csl (~> 1.6) clipboard-rails (1.7.1) cliver (0.3.2) coderay (1.1.3) @@ -257,7 +213,6 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - colorize (0.8.1) concurrent-ruby (1.3.1) connection_pool (2.4.1) coveralls (0.8.23) @@ -270,11 +225,6 @@ GEM bigdecimal rexml crass (1.0.6) - csl (1.6.0) - namae (~> 1.0) - rexml - csl-styles (1.0.1.11) - csl (~> 1.0) csv (3.3.0) dalli (3.2.8) database_cleaner (1.8.5) @@ -407,8 +357,6 @@ GEM jquery-rails font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) - gender_detector (0.1.2) - unicode_utils (>= 1.3.0) geocoder (1.8.3) base64 (>= 0.1.0) csv (>= 3.0.0) @@ -566,7 +514,6 @@ GEM activesupport (>= 4) invisible_captcha (2.3.0) rails (>= 5.2) - iso8601 (0.9.1) jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) @@ -596,9 +543,6 @@ GEM rdf (~> 3.1) json-schema (4.3.0) addressable (>= 2.8) - jsonlint (0.3.0) - oj (~> 3) - optimist (~> 3) jwt (2.8.1) base64 kaminari (1.2.2) @@ -616,7 +560,6 @@ GEM kaminari_route_prefix (0.1.1) kaminari (~> 1.0) language_server-protocol (3.17.0.3) - latex-decode (0.4.0) ld-patch (3.2.2) ebnf (~> 2.3) rdf (~> 3.2) @@ -691,17 +634,6 @@ GEM carrierwave (>= 0.5.8) rails (>= 5.0.0) marcel (1.0.4) - maremma (4.9.8) - activesupport (>= 4.2.5) - addressable (>= 2.3.6) - builder (~> 3.2, >= 3.2.2) - excon (~> 0.71.0) - faraday (~> 0.17.3) - faraday-encoding (~> 0.0.4) - faraday_middleware (~> 0.14.0) - nokogiri (>= 1.11.2, < 1.14.0) - oj (>= 2.8.3) - oj_mimic_json (~> 1.0, >= 1.0.1) matrix (0.4.2) method_source (1.1.0) mime-types (3.5.2) @@ -715,8 +647,6 @@ GEM multi_xml (0.6.0) multipart-post (2.4.1) mysql2 (0.5.6) - namae (1.2.0) - racc (~> 1.7) nest (3.2.0) redic net-http-persistent (4.0.2) @@ -759,13 +689,9 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 4) - oj (3.16.3) - bigdecimal (>= 3.0) - oj_mimic_json (1.0.1) okcomputer (1.18.5) openseadragon (0.6.0) rails (> 3.2.0) - optimist (3.1.0) orm_adapter (0.5.0) os (1.1.4) parallel (1.24.0) @@ -778,10 +704,6 @@ GEM cliver (~> 0.3.1) websocket-driver (>= 0.2.0) posix-spawn (0.3.15) - postrank-uri (1.1) - addressable (>= 2.4.0) - nokogiri (>= 1.8.0) - public_suffix (>= 4.0.0, < 5) power_converter (0.1.2) prometheus-client (4.2.2) pry (0.14.2) @@ -1135,7 +1057,6 @@ GEM execjs (>= 0.3.0, < 3) unicode-display_width (2.5.0) unicode-types (1.9.0) - unicode_utils (1.4.0) validatable (1.6.7) valkyrie (2.2.0) activemodel @@ -1227,7 +1148,6 @@ DEPENDENCIES honeycomb-beeline (>= 2.10.0) hydra-role-management hyrax (= 3.6.0) - hyrax-doi! invisible_captcha jbuilder (~> 2.5) jquery-rails diff --git a/app/actors/scholars_archive/actors/add_other_field_option_actor.rb b/app/actors/scholars_archive/actors/add_other_field_option_actor.rb index 65666195b..aca6786e4 100644 --- a/app/actors/scholars_archive/actors/add_other_field_option_actor.rb +++ b/app/actors/scholars_archive/actors/add_other_field_option_actor.rb @@ -27,7 +27,7 @@ def degree_present?(env) def save_custom_option(env) puts 'save custom option if any' - if degree_present? (env) + if degree_present?(env) if env.attributes['degree_field_other'].present? && is_valid_other_field_multiple?(env, :degree_field) puts 'saving degree field other and notifying admin' all_new_entries = persist_multiple_other_entries(env, :degree_field) @@ -51,7 +51,7 @@ def save_custom_option(env) notify_admin(env, field: :degree_grantors, new_entries: env.curation_concern.degree_grantors_other) end - if other_affiliation_other_present? (env) + if other_affiliation_other_present?(env) puts 'other affiliation other and notifying admin' all_new_entries = persist_multiple_other_entries(env, :other_affiliation) notify_admin(env, field: :other_affiliation, new_entries: all_new_entries) @@ -105,7 +105,7 @@ def persist_multiple_other_entries(env, field) puts 'persist multiple other entries' all_current_entries = get_all_other_options(env, field).map(&:name) all_new_entries = [] - other_field = "#{field.to_s}_other" + other_field = "#{field}_other" return all_new_entries if env.attributes[other_field].blank? @@ -120,7 +120,7 @@ def persist_multiple_other_entries(env, field) end def update_custom_option(env) - if degree_present? (env) + if degree_present?(env) if is_valid_other_field_multiple?(env, :degree_field) all_new_entries = persist_multiple_other_entries(env, :degree_field) @@ -154,7 +154,7 @@ def update_custom_option(env) end end - if other_affiliation_other_present? (env) + if other_affiliation_other_present?(env) all_new_entries = persist_multiple_other_entries(env, :other_affiliation) notify_admin(env, field: :other_affiliation, new_entries: all_new_entries) end @@ -168,11 +168,11 @@ def degree_grantors_present?(record) end def notify_admin(env, field:, new_entries:) - if new_entries.present? && new_entries.respond_to?(:size) && new_entries.size > 0 - ScholarsArchive::OtherOptionCreateSuccessService.new(env.curation_concern, - field: field, - new_entries: new_entries).call - end + return unless new_entries.present? && new_entries.respond_to?(:size) && new_entries.size.positive? + + ScholarsArchive::OtherOptionCreateSuccessService.new(env.curation_concern, + field: field, + new_entries: new_entries).call end def get_other_option(env, field) diff --git a/app/actors/scholars_archive/actors/nested_fields_operations_actor.rb b/app/actors/scholars_archive/actors/nested_fields_operations_actor.rb index 340dc2c3d..15b68597f 100644 --- a/app/actors/scholars_archive/actors/nested_fields_operations_actor.rb +++ b/app/actors/scholars_archive/actors/nested_fields_operations_actor.rb @@ -26,24 +26,24 @@ def nested_geo_present?(env) end def set_geo_coordinates(env) - if env.attributes['nested_geo_attributes'] - env.attributes['nested_geo_attributes'].each do |box, value| - if [value['label'], value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']].none? { |f| !f.present? } - bbox = [value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']] - value['bbox'] = bbox.join(',') - end - if [value['label'], value['point_lat'], value['point_lon']].none? { |f| !f.present? } - point = [value['point_lat'], value['point_lon']] - value['point'] = point.join(',') - end + return unless env.attributes['nested_geo_attributes'] + + env.attributes['nested_geo_attributes'].each do |_box, value| + if [value['label'], value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']].none? { |f| !f.present? } + bbox = [value['bbox_lat_north'], value['bbox_lon_west'], value['bbox_lat_south'], value['bbox_lon_east']] + value['bbox'] = bbox.join(',') + end + if [value['label'], value['point_lat'], value['point_lon']].none? { |f| !f.present? } + point = [value['point_lat'], value['point_lon']] + value['point'] = point.join(',') end - clean_up_nested_attributes(env) end + clean_up_nested_attributes(env) end def save_nested_elements(env) clean_up_fields(env) - return true unless nested_geo_present? (env) + return true unless nested_geo_present?(env) set_geo_coordinates(env) true @@ -51,22 +51,22 @@ def save_nested_elements(env) def update_nested_elements(env) clean_up_fields(env) - return true unless nested_geo_present? (env) + return true unless nested_geo_present?(env) set_geo_coordinates(env) true end def clean_up_fields(env) - # Note: since we aren't storing "Other" values in fedora for other_affiliation, here we can skip them + # NOTE: since we aren't storing "Other" values in fedora for other_affiliation, here we can skip them # for the model and only keep valid uri values. add_other_field_option_actor is responsible for persisting the # text values provided by the user for these "Other" entries. Here we are just removing/cleaning up the # selection before getting to the ModelActor, which is where the attributes appears to be persisted in fedora - env.attributes['other_affiliation'].to_a.delete_if { |x| x == 'Other' } if env.attributes['other_affiliation'] + env.attributes['other_affiliation']&.to_a&.delete_if { |x| x == 'Other' } end def clean_up_nested_attributes(env) - env.attributes['nested_geo_attributes'].each do |k, v| + env.attributes['nested_geo_attributes'].each do |_k, v| v.delete('point_lon') v.delete('point_lat') v.delete('bbox_lat_north') diff --git a/app/authorities/parsers/academic_units_parser.rb b/app/authorities/parsers/academic_units_parser.rb index 7d06617ba..6a4102407 100644 --- a/app/authorities/parsers/academic_units_parser.rb +++ b/app/authorities/parsers/academic_units_parser.rb @@ -7,13 +7,11 @@ def self.parse(jsonld) extract_and_massage_data(jsonld) end - private - def self.extract_and_massage_data(jsonld) - graph = JSON.parse(jsonld).dig('@graph') + graph = JSON.parse(jsonld)['@graph'] return [{ id: 'invalid', term: 'invalid', active: true }] if graph.nil? - terms = graph.map { |g| { id: g.dig('@id'), term: labels_with_dates(g), active: true } } + terms = graph.map { |g| { id: g['@id'], term: labels_with_dates(g), active: true } } # return only terms that have id and label terms.delete_if { |term| term[:id].nil? || term[:term].nil? } end @@ -22,7 +20,7 @@ def self.labels_with_dates(g) label = g.dig('rdfs:label', '@value') return label if label.nil? - date = g.dig('dc:date') + date = g['dc:date'] date = g.dig('dc:date', '@value') if date.is_a?(Hash) date = date.join(', ') if date.is_a?(Array) "#{label} - #{date}" diff --git a/app/authorities/parsers/degree_fields_parser.rb b/app/authorities/parsers/degree_fields_parser.rb index fc99b649f..5779a5bd0 100644 --- a/app/authorities/parsers/degree_fields_parser.rb +++ b/app/authorities/parsers/degree_fields_parser.rb @@ -7,13 +7,11 @@ def self.parse(jsonld) extract_and_massage_data(jsonld) end - private - def self.extract_and_massage_data(jsonld) - graph = JSON.parse(jsonld).dig('@graph') + graph = JSON.parse(jsonld)['@graph'] return [{ id: 'invalid', term: 'invalid', active: true }] if graph.nil? - terms = graph.map { |g| { id: g.dig('@id'), term: labels_with_dates(g), active: true } unless deprecated?(g) }.compact + terms = graph.map { |g| { id: g['@id'], term: labels_with_dates(g), active: true } unless deprecated?(g) }.compact # return only terms that have id and label terms.delete_if { |term| term[:id].nil? || term[:term].nil? } end @@ -22,7 +20,7 @@ def self.labels_with_dates(g) label = g.dig('rdfs:label', '@value') return label if label.nil? - date = g.dig('dc:date') + date = g['dc:date'] date = g.dig('dc:date', '@value') if date.is_a?(Hash) date = date.join(', ') if date.is_a?(Array) "#{label} - #{date}" @@ -30,7 +28,7 @@ def self.labels_with_dates(g) def self.deprecated?(g) # return true if value is in isReplacedBy - g.dig('dc:isReplacedBy') + g['dc:isReplacedBy'] end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7c1e2d761..14abc3125 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,13 +26,13 @@ class ApplicationController < ActionController::Base # API. This helps to maintain details of the user type (student, employee, etc) # which can be leveraged to improve the usability for different types of users. def update_from_person_api - if user_signed_in? - begin - current_user.update_from_person_api - rescue - # Don't fail hard when the API queries fail - logger.error('Failed accessing OSU API, unable to synchronize user details.') - end + return unless user_signed_in? + + begin + current_user.update_from_person_api + rescue StandardError + # Don't fail hard when the API queries fail + logger.error('Failed accessing OSU API, unable to synchronize user details.') end end @@ -52,16 +52,16 @@ def http_header_auth? # it as authenticated. This allows for API requests to flow through without requiring # a CAS authentication to happen beforehand. def http_header_auth_login - if !user_signed_in? && request.headers.key?('HTTP_API_AUTHENTICATION') - credentials = api_credentials(request.headers) - if http_header_auth? - u = User.where(email: credentials[:config][:username]).first - sign_in :user, u - authenticate_user! - else - warden.custom_failure! - render json: 'Unable to authenticate user.', status: 422 - end + return unless !user_signed_in? && request.headers.key?('HTTP_API_AUTHENTICATION') + + credentials = api_credentials(request.headers) + if http_header_auth? + u = User.where(email: credentials[:config][:username]).first + sign_in :user, u + authenticate_user! + else + warden.custom_failure! + render json: 'Unable to authenticate user.', status: 422 end end diff --git a/app/controllers/blacklight_advanced_search/advanced_controller.rb b/app/controllers/blacklight_advanced_search/advanced_controller.rb index a6d55b96c..236ee3546 100644 --- a/app/controllers/blacklight_advanced_search/advanced_controller.rb +++ b/app/controllers/blacklight_advanced_search/advanced_controller.rb @@ -24,7 +24,7 @@ def get_advanced_search_facets v.delete(:limit) end - response, _ = search_results(params) do |search_builder| + response, = search_results(params) do |search_builder| search_builder.except(:add_advanced_search_to_solr).append(:facets_for_advanced_search_form) end diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 8fb7de4ab..c1e426250 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -75,7 +75,7 @@ def self.modified_field config.add_facet_field 'creator_sfacet', label: 'Creator', limit: 5, helper_method: :diacritic_facet_denorm_affixes config.add_facet_field 'contributor_sfacet', label: 'Contributor', limit: 5, helper_method: :diacritic_facet_denorm_affixes -# config.add_facet_field 'date_facet_yearly_ssim', :label => 'Date', :range => true + # config.add_facet_field 'date_facet_yearly_ssim', :label => 'Date', :range => true config.add_facet_field('date_facet_yearly_ssim') do |field| field.label = 'Date' field.range = true @@ -342,7 +342,7 @@ def self.modified_field end config.add_search_field('degree_field_label') do |field| -# solr_name = solr_name("degree_field_label", :stored_searchable) + # solr_name = solr_name("degree_field_label", :stored_searchable) solr_name = 'degree_field_label_tesim' field.label = 'Degree Field' field.solr_parameters = { diff --git a/app/controllers/concerns/scholars_archive/download_analytics_behavior.rb b/app/controllers/concerns/scholars_archive/download_analytics_behavior.rb index 2c40ba3c5..26b84abe4 100644 --- a/app/controllers/concerns/scholars_archive/download_analytics_behavior.rb +++ b/app/controllers/concerns/scholars_archive/download_analytics_behavior.rb @@ -10,59 +10,59 @@ module DownloadAnalyticsBehavior def track_download # Add in special case to ignore collection of analytic data - unless Hyrax.config.google_analytics_id.blank? || params[:file].to_s.downcase == 'thumbnail' || request.path.include?('/admin/') - # Staccato works with Google Analytics v1 api: - # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters - # Staccato on Github: https://github.com/tpitale/staccato - begin - # GA4 collection url - base_uri = URI('https://www.google-analytics.com/g/collect') - # Update host header for submission to GA4 - headers = { - 'Accept-Language': request.headers['HTTP_ACCEPT_LANGUAGE'], - 'Host': 'www.google-analytics.com', - 'Origin': request.headers['HTTP_ORIGIN'], - 'Referer': request.headers['HTTP_REFERER'], - 'User-Agent': request.headers['HTTP_USER_AGENT'] - } + return if Hyrax.config.google_analytics_id.blank? || params[:file].to_s.downcase == 'thumbnail' || request.path.include?('/admin/') - file_download_params = { - 'v': '2', # Protocol version - 'tid': Hyrax.config.google_analytics_id.to_s, # Tracking ID - 'cid': SecureRandom.uuid.to_s, # Client ID - 'dl': request.url.to_s, # Document Location URL - 'dh': request.server_name.to_s, # Document Host Name - 'dr': request.referrer.to_s, # Document Referrer - 'dt': params[:id].to_s, # Document Title - 'en': 'Download', # Event Name - 'ep.event_category': 'Files', # Event Category - 'ep.event_label': params[:id].to_s # Event Label - } - # Combine params as query params and base URI - file_download_uri = URI.parse([base_uri, URI.encode_www_form(file_download_params)].join('?')) - # Submit File Download - ::Net::HTTP.post(file_download_uri, nil, headers) + # Staccato works with Google Analytics v1 api: + # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters + # Staccato on Github: https://github.com/tpitale/staccato + begin + # GA4 collection url + base_uri = URI('https://www.google-analytics.com/g/collect') + # Update host header for submission to GA4 + headers = { + 'Accept-Language': request.headers['HTTP_ACCEPT_LANGUAGE'], + 'Host': 'www.google-analytics.com', + 'Origin': request.headers['HTTP_ORIGIN'], + 'Referer': request.headers['HTTP_REFERER'], + 'User-Agent': request.headers['HTTP_USER_AGENT'] + } - # Disable Staccato tracking until Staccato can be updated for GA4 - # tracker = Staccato.tracker(Hyrax.config.google_analytics_id) - # tracker.event(category: 'Files', - # action: 'Downloaded', - # label: params[:id], - # linkid: request.url, - # user_agent: request.headers['User-Agent'], - # user_ip: request.remote_ip) - # # Setting the title to be the download id provides an easy way to group - # # and count on GA - # tracker.pageview(path: request.url, - # hostname: request.server_name, - # title: params[:id], - # user_agent: request.headers['User-Agent'], - # user_ip: request.remote_ip) - # tracker.track - rescue StandardError => e - Rails.logger.error "Analytics Error: #{e.message} : #{e.backtrace}" - nil - end + file_download_params = { + 'v': '2', # Protocol version + 'tid': Hyrax.config.google_analytics_id.to_s, # Tracking ID + 'cid': SecureRandom.uuid.to_s, # Client ID + 'dl': request.url.to_s, # Document Location URL + 'dh': request.server_name.to_s, # Document Host Name + 'dr': request.referrer.to_s, # Document Referrer + 'dt': params[:id].to_s, # Document Title + 'en': 'Download', # Event Name + 'ep.event_category': 'Files', # Event Category + 'ep.event_label': params[:id].to_s # Event Label + } + # Combine params as query params and base URI + file_download_uri = URI.parse([base_uri, URI.encode_www_form(file_download_params)].join('?')) + # Submit File Download + ::Net::HTTP.post(file_download_uri, nil, headers) + + # Disable Staccato tracking until Staccato can be updated for GA4 + # tracker = Staccato.tracker(Hyrax.config.google_analytics_id) + # tracker.event(category: 'Files', + # action: 'Downloaded', + # label: params[:id], + # linkid: request.url, + # user_agent: request.headers['User-Agent'], + # user_ip: request.remote_ip) + # # Setting the title to be the download id provides an easy way to group + # # and count on GA + # tracker.pageview(path: request.url, + # hostname: request.server_name, + # title: params[:id], + # user_agent: request.headers['User-Agent'], + # user_ip: request.remote_ip) + # tracker.track + rescue StandardError => e + Rails.logger.error "Analytics Error: #{e.message} : #{e.backtrace}" + nil end end end diff --git a/app/controllers/concerns/scholars_archive/works_controller_behavior.rb b/app/controllers/concerns/scholars_archive/works_controller_behavior.rb index 444597a73..3ebb82bf7 100644 --- a/app/controllers/concerns/scholars_archive/works_controller_behavior.rb +++ b/app/controllers/concerns/scholars_archive/works_controller_behavior.rb @@ -151,13 +151,13 @@ def parse_geo geo.bbox_lon_east = box_array[3] geo.type = :bbox.to_s end - if geo.point.present? - # point is stored as a string array of lat/long string arrays like: '["121.1", "121.2"]', however only one array of lat/long array is stored, so the first will need to be converted to simple array of strings like: ["121.1","121.2"] - point_array = geo.point.to_a.first.tr('[]" ', '').split(',') - geo.point_lat = point_array[0] - geo.point_lon = point_array[1] - geo.type = :point.to_s - end + next unless geo.point.present? + + # point is stored as a string array of lat/long string arrays like: '["121.1", "121.2"]', however only one array of lat/long array is stored, so the first will need to be converted to simple array of strings like: ["121.1","121.2"] + point_array = geo.point.to_a.first.tr('[]" ', '').split(',') + geo.point_lat = point_array[0] + geo.point_lon = point_array[1] + geo.type = :point.to_s end end diff --git a/app/controllers/scholars_archive/handles_controller.rb b/app/controllers/scholars_archive/handles_controller.rb index 66b9aebe5..73963a35c 100644 --- a/app/controllers/scholars_archive/handles_controller.rb +++ b/app/controllers/scholars_archive/handles_controller.rb @@ -52,47 +52,41 @@ def handle_download def handle_redirects new_od_path = od_redirects['handles_od_communities_collections'][params[:handle_localname]] - if new_od_path - redirect_to new_od_path and return - end + redirect_to new_od_path and return if new_od_path new_od_items_path = od_items_redirects['handles_od_items'][params[:handle_localname]] - if new_od_items_path - redirect_to new_od_items_path and return - end + redirect_to new_od_items_path and return if new_od_items_path new_ir_collections_path = ir_collections_redirects['handles_ir_communities_collections'][params[:handle_localname]] - if new_ir_collections_path - redirect_to new_ir_collections_path and return - end + redirect_to new_ir_collections_path and return if new_ir_collections_path new_ir_mismatch_path = ir_mismatch_redirects['handles_mismatched_items'][params[:handle_localname]] - if new_ir_mismatch_path - redirect_to new_ir_mismatch_path and return - end + return unless new_ir_mismatch_path + + redirect_to new_ir_mismatch_path and return end def od_redirects - YAML.load(File.read('config/handles_od_communities_collections.yml')) + YAML.safe_load(File.read('config/handles_od_communities_collections.yml')) end def od_items_redirects - YAML.load(File.read('config/handles_od_items.yml')) + YAML.safe_load(File.read('config/handles_od_items.yml')) end def ir_collections_redirects - YAML.load(File.read('config/handles_ir_communities_collections.yml')) + YAML.safe_load(File.read('config/handles_ir_communities_collections.yml')) end def ir_mismatch_redirects - YAML.load(File.read('config/handles_mismatched_items.yml')) + YAML.safe_load(File.read('config/handles_mismatched_items.yml')) end def verify_handle_prefix - if params[:handle_prefix] != '1957' - ScholarsArchive::HandleErrorLoggingService.log_incorrect_handle_prefix_error(params) - redirect_to root_path - end + return unless params[:handle_prefix] != '1957' + + ScholarsArchive::HandleErrorLoggingService.log_incorrect_handle_prefix_error(params) + redirect_to root_path end def filesets_for_work(work) @@ -115,11 +109,11 @@ def filesets_for_work(work) def extract_all_filesets(work) filesets = [] work.members.each do |member| - if member.class.to_s != 'FileSet' - filesets << extract_all_filesets(member) - else - filesets << member - end + filesets << if member.class.to_s != 'FileSet' + extract_all_filesets(member) + else + member + end end filesets.flatten.compact end @@ -147,11 +141,11 @@ def query_fedora_for_work(id, work_type) def query_solr_for_work(handle) # Query solr - ActiveFedora::SolrService.query("replaces_ssim:#{handle}", rows: 1000000) + ActiveFedora::SolrService.query("replaces_ssim:#{handle}", rows: 1_000_000) end def query_solr_for_filesets(label) - ActiveFedora::SolrService.query("has_model_ssim:FileSet AND label_ssi:#{label}", rows: 10000) + ActiveFedora::SolrService.query("has_model_ssim:FileSet AND label_ssi:#{label}", rows: 10_000) end end end diff --git a/app/forms/hyrax/forms/batch_upload_form.rb b/app/forms/hyrax/forms/batch_upload_form.rb index 392c389ae..9292ed918 100644 --- a/app/forms/hyrax/forms/batch_upload_form.rb +++ b/app/forms/hyrax/forms/batch_upload_form.rb @@ -38,7 +38,7 @@ def primary_terms # Override of ActiveModel::Model name that allows us to use our custom name class def self.model_name - @_model_name ||= begin + @model_name ||= begin namespace = parents.detect do |n| n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming? end diff --git a/app/forms/hyrax/forms/collection_form.rb b/app/forms/hyrax/forms/collection_form.rb index 34c9dc7ed..cc01d016c 100644 --- a/app/forms/hyrax/forms/collection_form.rb +++ b/app/forms/hyrax/forms/collection_form.rb @@ -46,9 +46,9 @@ def initialize(model, current_ability, repository) def permission_template @permission_template ||= begin - template_model = PermissionTemplate.find_or_create_by(source_id: model.id) - PermissionTemplateForm.new(template_model) - end + template_model = PermissionTemplate.find_or_create_by(source_id: model.id) + PermissionTemplateForm.new(template_model) + end end # @return [Hash] All FileSets in the collection, file.to_s is the key, file.id is the value @@ -151,6 +151,6 @@ def member_presenters(member_ids) presenter_args: [nil]) end end - # rubocop:enable ClassLength + # rubocop:enable Metrics/ClassLength end end diff --git a/app/forms/scholars_archive/date_terms_behavior.rb b/app/forms/scholars_archive/date_terms_behavior.rb index c8eae3c67..2858bfb39 100644 --- a/app/forms/scholars_archive/date_terms_behavior.rb +++ b/app/forms/scholars_archive/date_terms_behavior.rb @@ -6,9 +6,6 @@ module DateTermsBehavior extend ActiveSupport::Concern included do - def date_terms - super - end end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2583f5674..f374f651d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -104,12 +104,18 @@ def embargo_select_options end def selected_embargo(release_date, options) - if release_date - options_hash = options.map { |option| option.second.instance_of?(ActiveSupport::TimeWithZone) ? [option.first, option.second ? option.second.strftime('%Y-%m-%d') : option.second] : option }.to_h - key = options_hash.key(release_date.strftime('%Y-%m-%d')) - value = options.to_h[key] - value ? value : 'other' - end + return unless release_date + + options_hash = options.map do |option| + if option.second.instance_of?(ActiveSupport::TimeWithZone) + [option.first, option.second ? option.second.strftime('%Y-%m-%d') : option.second] + else + option + end + end.to_h + key = options_hash.key(release_date.strftime('%Y-%m-%d')) + value = options.to_h[key] + value || 'other' end def help_block_wrapper @@ -120,7 +126,7 @@ def generate_previous_page_link(search_state, request_keys, page: current_page) Kaminari::Helpers::PrevPage.new(self, params: search_state, param_name: request_keys[:page], current_page: page).url end - def generate_next_page_link(search_state, request_keys, page: ) + def generate_next_page_link(search_state, request_keys, page:) Kaminari::Helpers::NextPage.new(self, params: search_state, param_name: request_keys[:page], current_page: page).url end diff --git a/app/helpers/hyrax_helper.rb b/app/helpers/hyrax_helper.rb index ebf1d6364..a2ba94d88 100644 --- a/app/helpers/hyrax_helper.rb +++ b/app/helpers/hyrax_helper.rb @@ -12,13 +12,12 @@ def human_readable_date_edtf(options) value = options[:value].first date = Date.edtf(value) if date.instance_of? EDTF::Interval - output = "#{date.from.edtf} to #{date.to.edtf}" + "#{date.from.edtf} to #{date.to.edtf}" elsif date.present? - output = date.edtf + date.edtf else - output = value + value end - output end # NEW TAB: Add in the system to map out new tab for OCR @@ -54,7 +53,7 @@ def diacritic_facet_denorm_affixes(value) # Create a list of words to always be lowercase # Some more affixes could be added from here: # https://en.wikipedia.org/wiki/List_of_family_name_affixes - force_lower = %w[de la las los jr jr. du del della d' van\ der von van] + force_lower = ['de', 'la', 'las', 'los', 'jr', 'jr.', 'du', 'del', 'della', "d'", 'van der', 'von', 'van'] # Capitalize the first letter of each word value = value.titleize # Downcase words in our list diff --git a/app/helpers/scholars_archive/citations_behaviors/formatters/apa_formatter.rb b/app/helpers/scholars_archive/citations_behaviors/formatters/apa_formatter.rb index 174d30c94..2fb360476 100644 --- a/app/helpers/scholars_archive/citations_behaviors/formatters/apa_formatter.rb +++ b/app/helpers/scholars_archive/citations_behaviors/formatters/apa_formatter.rb @@ -11,7 +11,7 @@ def setup_pub_date(work) # END OVERRIDE if first_date.present? first_date = CGI.escapeHTML(first_date) - date_value = first_date.gsub(/[^0-9|n\.d\.]/, '')[0, 4] + date_value = first_date.gsub(/[^0-9|n.d.]/, '')[0, 4] return nil if date_value.nil? end clean_end_punctuation(date_value) if date_value diff --git a/app/helpers/scholars_archive/citations_behaviors/formatters/chicago_formatter.rb b/app/helpers/scholars_archive/citations_behaviors/formatters/chicago_formatter.rb index 8498c96bd..7f2213fa1 100644 --- a/app/helpers/scholars_archive/citations_behaviors/formatters/chicago_formatter.rb +++ b/app/helpers/scholars_archive/citations_behaviors/formatters/chicago_formatter.rb @@ -11,7 +11,7 @@ def setup_pub_date(work) # END OVERRIDE if first_date.present? first_date = CGI.escapeHTML(first_date) - date_value = first_date.gsub(/[^0-9|n\.d\.]/, '')[0, 4] + date_value = first_date.gsub(/[^0-9|n.d.]/, '')[0, 4] return nil if date_value.nil? end clean_end_punctuation(date_value) if date_value diff --git a/app/helpers/scholars_archive/citations_behaviors/formatters/mla_formatter.rb b/app/helpers/scholars_archive/citations_behaviors/formatters/mla_formatter.rb index f3f3052f8..c8ad969e5 100644 --- a/app/helpers/scholars_archive/citations_behaviors/formatters/mla_formatter.rb +++ b/app/helpers/scholars_archive/citations_behaviors/formatters/mla_formatter.rb @@ -11,7 +11,7 @@ def setup_pub_date(work) # END OVERRIDE if first_date.present? first_date = CGI.escapeHTML(first_date) - date_value = first_date.gsub(/[^0-9|n\.d\.]/, '')[0, 4] + date_value = first_date.gsub(/[^0-9|n.d.]/, '')[0, 4] return nil if date_value.nil? end clean_end_punctuation(date_value) if date_value diff --git a/app/indexers/concerns/scholars_archive/indexes_combined_sort_date.rb b/app/indexers/concerns/scholars_archive/indexes_combined_sort_date.rb index c53404e20..5cf3086d4 100644 --- a/app/indexers/concerns/scholars_archive/indexes_combined_sort_date.rb +++ b/app/indexers/concerns/scholars_archive/indexes_combined_sort_date.rb @@ -15,9 +15,6 @@ def index_combined_date_field(object, solr_doc) private # Get the date for the date created sorting as an EDTF object - # rubocop:disable Metrics/AbcSize - # rubocop:disable Metrics/CyclomaticComplexity - # rubocop:disable Metrics/PerceivedComplexity def edtf_sorting_date(object) # Figure out which date to use date = if object.respond_to?(:date_issued) && object.date_issued.present? @@ -33,7 +30,5 @@ def edtf_sorting_date(object) Date.edtf(Array(date).first) end # rubocop:enable Metrics/AbcSize - # rubocop:enable Metrics/CyclomaticComplexity - # rubocop:enable Metrics/PerceivedComplexity end end diff --git a/app/indexers/default_work_indexer.rb b/app/indexers/default_work_indexer.rb index 61b15a107..c4b2e437f 100644 --- a/app/indexers/default_work_indexer.rb +++ b/app/indexers/default_work_indexer.rb @@ -49,11 +49,11 @@ def embargo_date_range_string(solr_doc, start_date, end_date) end def title_for_solr_doc(object, solr_doc) - if object.nested_ordered_title.first.present? - solr_doc['title_ssi'] = object.nested_ordered_title.first.title.first - else - solr_doc['title_ssi'] = object.title.first - end + solr_doc['title_ssi'] = if object.nested_ordered_title.first.present? + object.nested_ordered_title.first.title.first + else + object.title.first + end end def triple_powered_properties_for_solr_doc(object, solr_doc) diff --git a/app/inputs/multi_value_date_input.rb b/app/inputs/multi_value_date_input.rb index 9d16bbe7a..e7e46eb33 100644 --- a/app/inputs/multi_value_date_input.rb +++ b/app/inputs/multi_value_date_input.rb @@ -3,7 +3,7 @@ # Multi valued date input class MultiValueDateInput < MultiValueInput def input_type - 'multi_value'.freeze + 'multi_value' end private @@ -94,7 +94,7 @@ def calendar_input_outer_wrapper HTML end - def build_start_calendar(value, index) + def build_start_calendar(_value, index) start_date_options = start_date_options(index) input_start_date = @builder.text_field('', start_date_options) diff --git a/app/inputs/multi_value_label_url_input.rb b/app/inputs/multi_value_label_url_input.rb index 91a116a2e..19d658316 100644 --- a/app/inputs/multi_value_label_url_input.rb +++ b/app/inputs/multi_value_label_url_input.rb @@ -3,10 +3,10 @@ # Multi value label uri input class MultiValueLabelUrlInput < MultiValueInput def input_type - 'multi_value'.freeze + 'multi_value' end - def input(wrapper_options) + def input(_wrapper_options) @rendered_first_element = false input_html_classes.unshift('string') input_html_options[:name] ||= "#{object_name}[#{attribute_name}][]" @@ -22,9 +22,9 @@ def input(wrapper_options) protected - def inner_wrapper(value, index) + def inner_wrapper(value, _index) <<-HTML -
  • +
  • #{yield}
  • HTML @@ -33,9 +33,7 @@ def inner_wrapper(value, index) private def build_field(value, index) - if value.new_record? - index = value.object_id - end + index = value.object_id if value.new_record? label_options = build_label_options(value, index) input_label = @builder.text_field(:label, label_options) @@ -56,13 +54,13 @@ def build_field(value, index) value.validation_msg.present? ? value.validation_msg : '' end - if value.validation_msg.present? - nested_item = nested_item_wrapper(value) do - "#{help_block}#{input_label}#{input_related_url}" - end - else - nested_item = "#{input_label}#{input_related_url}" - end + nested_item = if value.validation_msg.present? + nested_item_wrapper(value) do + "#{help_block}#{input_label}#{input_related_url}" + end + else + "#{input_label}#{input_related_url}" + end "#{input_id}#{destroy_input}#{nested_item}" end @@ -117,11 +115,11 @@ def build_url_options(value, index) end def nested_field_name(property, index) - "#{object_name}[#{attribute_name}_attributes][#{index.to_s}][#{property}]" + "#{object_name}[#{attribute_name}_attributes][#{index}][#{property}]" end def nested_field_id(property, index) - "#{object_name}_#{attribute_name}_attributes_#{index.to_s}_#{property}" + "#{object_name}_#{attribute_name}_attributes_#{index}_#{property}" end def collection diff --git a/app/inputs/multi_value_ordered_input.rb b/app/inputs/multi_value_ordered_input.rb index e7386a1f6..13cebf2f0 100644 --- a/app/inputs/multi_value_ordered_input.rb +++ b/app/inputs/multi_value_ordered_input.rb @@ -3,10 +3,10 @@ # Multi value ordered input class MultiValueOrderedInput < MultiValueInput def input_type - 'multi_value'.freeze + 'multi_value' end - def input(wrapper_options) + def input(_wrapper_options) @rendered_first_element = false input_html_classes.unshift('string') input_html_options[:name] ||= "#{object_name}[#{attribute_name}][]" @@ -22,7 +22,7 @@ def input(wrapper_options) protected - def inner_wrapper(value, index) + def inner_wrapper(value, _index) "
  • @@ -41,15 +41,15 @@ def inner_wrapper(value, index) end def multi_input_nested_item_class(value) - "#{'multi-input-nested-item' if has_multi_input_elements?(value)}" + ('multi-input-nested-item' if has_multi_input_elements?(value)).to_s end def text_area_class(value) - "#{'text-area-nested-field' if is_text_area?(value)}" + ('text-area-nested-field' if is_text_area?(value)).to_s end def text_area_handle_class(value) - "#{'text-area-dd-handle' if is_text_area?(value)}" + ('text-area-dd-handle' if is_text_area?(value)).to_s end def has_multi_input_elements?(value) @@ -70,26 +70,25 @@ def outer_wrapper private def build_field(value, index) - if value.new_record? - index = value.object_id - end + index = value.object_id if value.new_record? - if value.is_a?(NestedOrderedCreator) + case value + when NestedOrderedCreator item_options = build_item_options(value, index, :creator) input_field = @builder.text_field(:creator, item_options) - elsif value.is_a?(NestedOrderedTitle) + when NestedOrderedTitle item_options = build_item_options(value, index, :title) input_field = @builder.text_field(:title, item_options) - elsif value.is_a?(NestedOrderedAbstract) + when NestedOrderedAbstract item_options = build_item_options(value, index, :abstract) input_field = @builder.text_area(:abstract, item_options) - elsif value.is_a?(NestedOrderedContributor) + when NestedOrderedContributor item_options = build_item_options(value, index, :contributor) input_field = @builder.text_field(:contributor, item_options) - elsif value.is_a?(NestedOrderedAdditionalInformation) + when NestedOrderedAdditionalInformation item_options = build_item_options(value, index, :additional_information) input_field = @builder.text_area(:additional_information, item_options) - elsif value.is_a?(NestedRelatedItems) + when NestedRelatedItems item_options = build_item_options(value, index, :label) url_options = build_item_options(value, index, :related_url) input_field = @builder.text_field(:label, item_options) @@ -118,22 +117,23 @@ def build_nested_item(value, index) index_options = build_index_options(value, index) input_index = @builder.text_field(:index, index_options) - if value.is_a?(NestedOrderedCreator) + case value + when NestedOrderedCreator creator_options = build_creator_options(value, index) input_creator = @builder.text_field(:creator, creator_options) nested_item = "#{input_creator}#{input_index}" - elsif value.is_a?(NestedOrderedTitle) + when NestedOrderedTitle title_options = build_title_options(value, index) input_title = @builder.text_field(:title, title_options) nested_item = "#{input_title}#{input_index}" - elsif value.is_a?(NestedRelatedItems) + when NestedRelatedItems label_options = build_related_items_label_options(value, index) url_options = build_related_items_url_options(value, index) input_label = @builder.text_field(:label, label_options) input_url = @builder.text_field(:related_url, url_options) nested_item = "#{input_label}#{input_url}#{input_index}" end - "#{nested_item}" + nested_item.to_s end def build_id_options(value, index) @@ -182,11 +182,11 @@ def prop_with_labels end def nested_field_name(property, index) - "#{object_name}[#{attribute_name}_attributes][#{index.to_s}][#{property}]" + "#{object_name}[#{attribute_name}_attributes][#{index}][#{property}]" end def nested_field_id(property, index) - "#{object_name}_#{attribute_name}_attributes_#{index.to_s}_#{property}" + "#{object_name}_#{attribute_name}_attributes_#{index}_#{property}" end def collection diff --git a/app/inputs/multi_value_select_other_input.rb b/app/inputs/multi_value_select_other_input.rb index 91416051c..158c54959 100644 --- a/app/inputs/multi_value_select_other_input.rb +++ b/app/inputs/multi_value_select_other_input.rb @@ -4,7 +4,7 @@ class MultiValueSelectOtherInput < MultiValueSelectInput # Overriding so that we can handle the "Other" option with an input def input_type - 'multi_value'.freeze + 'multi_value' end private diff --git a/app/jobs/migrate_creators_no_handles_job.rb b/app/jobs/migrate_creators_no_handles_job.rb index e030b7e8b..c55b28e42 100644 --- a/app/jobs/migrate_creators_no_handles_job.rb +++ b/app/jobs/migrate_creators_no_handles_job.rb @@ -10,21 +10,20 @@ def perform logger = Logger.new(File.join(Rails.root, 'log', file_name)) # Query solr for all docs without handles (exclude docs with handles) - docs = ActiveFedora::SolrService.query('creator_tesim:* AND -has_model_ssim:FileSet AND -replaces_tesim:[* TO *]', { rows: 100000 }) + docs = ActiveFedora::SolrService.query('creator_tesim:* AND -has_model_ssim:FileSet AND -replaces_tesim:[* TO *]', { rows: 100_000 }) # Iterate over all docs docs.each do |doc| # Find work based on ID - unless doc['nested_ordered_creator_label_ssim'].present? - - begin - # Find work based on ID - work = ActiveFedora::Base.find(doc['id']) - update_work(work, logger) - rescue => e - logger.info "\t\t failed to update work id #{doc["id"]}, error found:" - logger.info "\t\t #{e.message}" - end + next if doc['nested_ordered_creator_label_ssim'].present? + + begin + # Find work based on ID + work = ActiveFedora::Base.find(doc['id']) + update_work(work, logger) + rescue StandardError => e + logger.info "\t\t failed to update work id #{doc['id']}, error found:" + logger.info "\t\t #{e.message}" end end logger.info 'DONE' @@ -33,25 +32,25 @@ def perform def update_work(work, logger) ordered_creators = [] - if work.respond_to?(:nested_ordered_creator_attributes=) && work.respond_to?(:nested_ordered_creator) - # Iterate over the creators - work.creator.each_with_index do |creator, i| - # Translate creators over to nested ordered creators - ordered_creators << { - index: i.to_s, - creator: creator.to_s - } - end + return unless work.respond_to?(:nested_ordered_creator_attributes=) && work.respond_to?(:nested_ordered_creator) + + # Iterate over the creators + work.creator.each_with_index do |creator, i| + # Translate creators over to nested ordered creators + ordered_creators << { + index: i.to_s, + creator: creator.to_s + } + end - work.nested_ordered_creator_attributes = ordered_creators + work.nested_ordered_creator_attributes = ordered_creators - logger.info "\t migrating creators #{work.creator.to_a.to_s} to nested ordered creators #{ordered_creators.to_s} for work #{work.id} (#{work.model_name.to_s})" + logger.info "\t migrating creators #{work.creator.to_a} to nested ordered creators #{ordered_creators} for work #{work.id} (#{work.model_name})" - if work.save - logger.info "\t update for work id #{work.id} (#{work.model_name.to_s}) completed successfully" - else - logger.info "\t failed to update work id #{work.id} (#{work.model_name.to_s}) on save" - end + if work.save + logger.info "\t update for work id #{work.id} (#{work.model_name}) completed successfully" + else + logger.info "\t failed to update work id #{work.id} (#{work.model_name}) on save" end end end diff --git a/app/jobs/reindex_chunk_job.rb b/app/jobs/reindex_chunk_job.rb index 72f257e42..9e071aa6c 100644 --- a/app/jobs/reindex_chunk_job.rb +++ b/app/jobs/reindex_chunk_job.rb @@ -5,7 +5,6 @@ class ReindexChunkJob < ScholarsArchive::ApplicationJob queue_as :reindex # rubocop:disable Metrics/MethodLength - # rubocop:disable Metrics/AbcSize def perform(uris) counter = 0 logger = Rails.logger diff --git a/app/jobs/reindex_everything_job.rb b/app/jobs/reindex_everything_job.rb index ac7ef2562..07a3ba673 100644 --- a/app/jobs/reindex_everything_job.rb +++ b/app/jobs/reindex_everything_job.rb @@ -5,20 +5,20 @@ class ReindexEverythingJob < ScholarsArchive::ApplicationJob queue_as :reindex def perform - admin_set_map = YAML.load(File.read('config/admin_set_map.yml')) + admin_set_map = YAML.safe_load(File.read('config/admin_set_map.yml')) Rails.logger.info 'Reindex Everything' counter = 0 admin_set_map.each do |model, desc| - index = ActiveFedora::SolrService.get("has_model_ssim:#{model}", rows: 100000)['response']['docs'] + index = ActiveFedora::SolrService.get("has_model_ssim:#{model}", rows: 100_000)['response']['docs'] Rails.logger.info "Reindexing #{model} (#{desc}): #{index.count}" index.each do |work| - Rails.logger.info "\t reindexing #{work["id"]}" + Rails.logger.info "\t reindexing #{work['id']}" begin ActiveFedora::Base.find(work['id']).update_index counter += 1 - rescue => e - Rails.logger.info "Failed to reindex #{work["id"]}: #{e.message}" + rescue StandardError => e + Rails.logger.info "Failed to reindex #{work['id']}: #{e.message}" end end end diff --git a/app/jobs/reindex_model_job.rb b/app/jobs/reindex_model_job.rb index c507ccd87..fe3d0923e 100644 --- a/app/jobs/reindex_model_job.rb +++ b/app/jobs/reindex_model_job.rb @@ -14,7 +14,7 @@ def perform(model_name, uris) logger.info "\t reindexing #{work.id}" work.update_index counter += 1 - rescue => e + rescue StandardError => e logger.info "Failed to reindex #{work.id}: #{e.message}" next end diff --git a/app/jobs/resolrize_job.rb b/app/jobs/resolrize_job.rb index 228e0a517..573f86bcc 100644 --- a/app/jobs/resolrize_job.rb +++ b/app/jobs/resolrize_job.rb @@ -4,7 +4,7 @@ class ResolrizeJob < Hyrax::ApplicationJob queue_as :reindex - # Note: Exposing arguments available in ActiveFedora::Base.reindex_everything: batch_size, softCommit, progress_bar and final_commit + # NOTE: Exposing arguments available in ActiveFedora::Base.reindex_everything: batch_size, softCommit, progress_bar and final_commit def perform(batch_size: 50, softCommit: true, progress_bar: false, final_commit: false) ActiveFedora::Base.reindex_everything(batch_size: batch_size, softCommit: softCommit, diff --git a/app/models/concerns/scholars_archive/date_operations.rb b/app/models/concerns/scholars_archive/date_operations.rb index 54e756496..36e0f20be 100644 --- a/app/models/concerns/scholars_archive/date_operations.rb +++ b/app/models/concerns/scholars_archive/date_operations.rb @@ -8,8 +8,7 @@ module DateOperations def to_solr(solr_doc = {}) solr_doc = super solr_doc = solr_doc.merge({ 'date_decades_ssim' => decades }) - solr_doc = solr_doc.merge({ 'date_facet_yearly_ssim' => date_facet_yearly }) - solr_doc + solr_doc.merge({ 'date_facet_yearly_ssim' => date_facet_yearly }) end # date_facet_yearly is intended to be used for date_facet_yearly_ssim, which is used by the facet provided @@ -46,11 +45,11 @@ def decades # Determine the date value to use for Decades facet and date facet yearly processing. def date_value - if date_created.present? then + if date_created.present? date_created - elsif date_copyright.present? then + elsif date_copyright.present? date_copyright - elsif date_issued.present? then + elsif date_issued.present? date_issued end end @@ -83,19 +82,20 @@ def decade_dates dates = DateDecadeConverter.new(date_value).run dates ||= Array.wrap(DecadeDecorator.new(parsed_year)) if parsed_year - dates ? dates : [] + dates || [] end def parsed_year - clean_datetime.year if clean_datetime + clean_datetime&.year end def clean_datetime - if date_value =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ # YYYY-MM-DD + case date_value + when /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/ # YYYY-MM-DD DateTime.strptime(date_value, '%Y-%m-%d') - elsif date_value =~ /^[0-9]{4}-[0-9]{2}$/ # YYYY-MM + when /^[0-9]{4}-[0-9]{2}$/ # YYYY-MM DateTime.strptime(date_value, '%Y-%m') - elsif date_value =~ /^[0-9]{4}/ # YYYY + when /^[0-9]{4}/ # YYYY DateTime.strptime(date_value.split('-').first, '%Y') else Rails.logger.warn "Invalid date_value: #{date_value}. Acceptable formats: YYYY-MM-DD, YYYY-MM, YYYY." @@ -106,6 +106,7 @@ def clean_datetime # Date decorator class DecadeDecorator attr_accessor :year + def initialize(year) @year = year end @@ -129,6 +130,7 @@ def last_year # when calling run. Expected input dates: "2017-12-01", "2017-12", "2017", "2017-2018", "2010-2020", "1900-1940" class DateDecadeConverter attr_accessor :date + def initialize(date) @date = date end diff --git a/app/models/concerns/scholars_archive/has_nested_ordered_properties.rb b/app/models/concerns/scholars_archive/has_nested_ordered_properties.rb index 94c1be1c6..bb71bab22 100644 --- a/app/models/concerns/scholars_archive/has_nested_ordered_properties.rb +++ b/app/models/concerns/scholars_archive/has_nested_ordered_properties.rb @@ -34,23 +34,23 @@ def additional_information # input: [["My Title","0"], ["Another Tilte", "1"]] # output: [["My Title", "Another Title"]] def ordered_titles - sort_titles_by_index.map { |titles| titles.first } + sort_titles_by_index.map(&:first) end def ordered_creators - sort_creators_by_index.map { |creators| creators.first } + sort_creators_by_index.map(&:first) end def ordered_abstracts - sort_abstracts_by_index.map { |abstracts| abstracts.first } + sort_abstracts_by_index.map(&:first) end def ordered_contributors - sort_contributors_by_index.map { |contributors| contributors.first } + sort_contributors_by_index.map(&:first) end def ordered_info - sort_info_by_index.map { |info| info.first } + sort_info_by_index.map(&:first) end # Returns a sorted array (by index value) of nested titles given an array with two @@ -91,32 +91,32 @@ def sort_info_by_index # output: [["Another Title", "1"], ["My Title", "0"]] def validate_titles nested_ordered_title.select { |i| (i.instance_of? NestedOrderedTitle) && (i.index.first.present? && i.title.first.present?) && (i.index.first.instance_of? String) && (i.title.first.instance_of? String) } - .map { |i| i.instance_of?(NestedOrderedTitle) ? [i.title.first, i.index.first] : [i] } - .select(&:present?) + .map { |i| i.instance_of?(NestedOrderedTitle) ? [i.title.first, i.index.first] : [i] } + .select(&:present?) end def validate_creators nested_ordered_creator.select { |i| (i.instance_of? NestedOrderedCreator) && (i.index.first.present? && i.creator.first.present?) && (i.index.first.instance_of? String) && (i.creator.first.instance_of? String) } - .map { |i| i.instance_of?(NestedOrderedCreator) ? [i.creator.first, i.index.first] : [i] } - .select(&:present?) + .map { |i| i.instance_of?(NestedOrderedCreator) ? [i.creator.first, i.index.first] : [i] } + .select(&:present?) end def validate_abstracts nested_ordered_abstract.select { |i| (i.instance_of? NestedOrderedAbstract) && (i.index.first.present? && i.abstract.first.present?) && (i.index.first.instance_of? String) && (i.abstract.first.instance_of? String) } - .map { |i| i.instance_of?(NestedOrderedAbstract) ? [i.abstract.first, i.index.first] : [i] } - .select(&:present?) + .map { |i| i.instance_of?(NestedOrderedAbstract) ? [i.abstract.first, i.index.first] : [i] } + .select(&:present?) end def validate_contributors nested_ordered_contributor.select { |i| (i.instance_of? NestedOrderedContributor) && (i.index.first.present? && i.contributor.first.present?) && (i.index.first.instance_of? String) && (i.contributor.first.instance_of? String) } - .map { |i| i.instance_of?(NestedOrderedContributor) ? [i.contributor.first, i.index.first] : [i] } - .select(&:present?) + .map { |i| i.instance_of?(NestedOrderedContributor) ? [i.contributor.first, i.index.first] : [i] } + .select(&:present?) end def validate_info nested_ordered_additional_information.select { |i| (i.instance_of? NestedOrderedAdditionalInformation) && (i.index.first.present? && i.additional_information.first.present?) && (i.index.first.instance_of? String) && (i.additional_information.first.instance_of? String) } - .map { |i| i.instance_of?(NestedOrderedAdditionalInformation) ? [i.additional_information.first, i.index.first] : [i] } - .select(&:present?) + .map { |i| i.instance_of?(NestedOrderedAdditionalInformation) ? [i.additional_information.first, i.index.first] : [i] } + .select(&:present?) end end end diff --git a/app/models/concerns/scholars_archive/has_solr_labels.rb b/app/models/concerns/scholars_archive/has_solr_labels.rb index 7598bebbf..8f2d8a3b9 100644 --- a/app/models/concerns/scholars_archive/has_solr_labels.rb +++ b/app/models/concerns/scholars_archive/has_solr_labels.rb @@ -9,15 +9,15 @@ module HasSolrLabels def to_solr(solr_doc = {}) super.tap do |doc| nested_geo.each do |geo| - if geo.instance_of? NestedGeo - if geo.point.present? && geo.type.blank? - geo.point = "#{geo.label.first} (#{geo.point.first})" - geo.type = :point.to_s - end - if geo.bbox.present? && geo.type.blank? - geo.bbox = "#{geo.label.first} (#{geo.bbox.first})" - geo.type = :bbox.to_s - end + next unless geo.instance_of? NestedGeo + + if geo.point.present? && geo.type.blank? + geo.point = "#{geo.label.first} (#{geo.point.first})" + geo.type = :point.to_s + end + if geo.bbox.present? && geo.type.blank? + geo.bbox = "#{geo.label.first} (#{geo.bbox.first})" + geo.type = :bbox.to_s end end point_labels = nested_geo.flat_map { |i| i.instance_of?(NestedGeo) ? i.point : '' }.select(&:present?).flatten.map { |i| i[0] } @@ -25,28 +25,27 @@ def to_solr(solr_doc = {}) labels = point_labels + bbox_labels related_items_labels = nested_related_items.map { |i| i.instance_of?(NestedRelatedItems) ? "#{i.label.first}$#{i.related_url.first}$#{i.index.first}" : i }.select(&:present?) ordered_creator_labels = nested_ordered_creator.map { |i| i.instance_of?(NestedOrderedCreator) ? "#{i.creator.first}$#{i.index.first}" : i }.select(&:present?) - creator_labels = nested_ordered_creator.map { |i| i.instance_of?(NestedOrderedCreator) ? "#{i.creator.first}" : i }.select(&:present?).uniq + creator_labels = nested_ordered_creator.map { |i| i.instance_of?(NestedOrderedCreator) ? i.creator.first.to_s : i }.select(&:present?).uniq ordered_title_labels = nested_ordered_title.map { |i| i.instance_of?(NestedOrderedTitle) ? "#{i.title.first}$#{i.index.first}" : i }.select(&:present?) ordered_abstract_labels = nested_ordered_abstract.map { |i| i.instance_of?(NestedOrderedAbstract) ? "#{i.abstract.first}$#{i.index.first}" : i }.select(&:present?) ordered_contributor_labels = nested_ordered_contributor.map { |i| i.instance_of?(NestedOrderedContributor) ? "#{i.contributor.first}$#{i.index.first}" : i }.select(&:present?) - contributor_labels = nested_ordered_contributor.map { |i| i.instance_of?(NestedOrderedContributor) ? "#{i.contributor.first}" : i }.select(&:present?).uniq + contributor_labels = nested_ordered_contributor.map { |i| i.instance_of?(NestedOrderedContributor) ? i.contributor.first.to_s : i }.select(&:present?).uniq ordered_additional_information_labels = nested_ordered_additional_information.map { |i| i.instance_of?(NestedOrderedAdditionalInformation) ? "#{i.additional_information.first}$#{i.index.first}" : i }.select(&:present?) labels = [{ label: 'nested_geo_label', data: labels }, - { label: 'nested_related_items_label', data: related_items_labels }, - { label: 'nested_ordered_creator_label', data: ordered_creator_labels }, - { label: 'nested_ordered_title_label', data: ordered_title_labels }, - { label: 'nested_ordered_abstract_label', data: ordered_abstract_labels }, - { label: 'nested_ordered_contributor_label', data: ordered_contributor_labels }, - { label: 'nested_ordered_additional_information_label', data: ordered_additional_information_labels } - ] + { label: 'nested_related_items_label', data: related_items_labels }, + { label: 'nested_ordered_creator_label', data: ordered_creator_labels }, + { label: 'nested_ordered_title_label', data: ordered_title_labels }, + { label: 'nested_ordered_abstract_label', data: ordered_abstract_labels }, + { label: 'nested_ordered_contributor_label', data: ordered_contributor_labels }, + { label: 'nested_ordered_additional_information_label', data: ordered_additional_information_labels }] labels.each do |label_set| doc["#{label_set[:label]}_ssim"] = label_set[:data] doc["#{label_set[:label]}_tesim"] = label_set[:data] end if ordered_title_labels.present? - ordered_titles = nested_ordered_title.select { |i| i.instance_of?(NestedOrderedTitle) ? (i.title.present? && i.index.present?) : i.present? }.map { |i| i.instance_of?(NestedOrderedTitle) ? [i.title.first, i.index.first] : [i] }.select(&:present?).sort_by { |titles| titles.second }.map { |titles| titles.first } + ordered_titles = nested_ordered_title.select { |i| i.instance_of?(NestedOrderedTitle) ? (i.title.present? && i.index.present?) : i.present? }.map { |i| i.instance_of?(NestedOrderedTitle) ? [i.title.first, i.index.first] : [i] }.select(&:present?).sort_by(&:second).map(&:first) doc['title_tesim'] = ordered_titles doc['nested_ordered_title_label_tesim'] = ordered_titles diff --git a/app/models/hyrax/contact_form.rb b/app/models/hyrax/contact_form.rb index 970d866a7..080c2a395 100644 --- a/app/models/hyrax/contact_form.rb +++ b/app/models/hyrax/contact_form.rb @@ -6,8 +6,9 @@ module Hyrax class ContactForm include ActiveModel::Model attr_accessor :contact_method, :category, :name, :email, :subject, :message + validates :email, :category, :name, :subject, :message, presence: true - validates :email, format: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i, allow_blank: true + validates :email, format: /\A([\w.%+-]+)@([\w-]+\.)+(\w{2,})\z/i, allow_blank: true # - can't use this without ActiveRecord::Base validates_inclusion_of :category, in: self.class.issue_types_for_locale diff --git a/app/models/oai_set.rb b/app/models/oai_set.rb index 438939a1a..d57834f45 100644 --- a/app/models/oai_set.rb +++ b/app/models/oai_set.rb @@ -24,7 +24,7 @@ def from_spec(spec) def sets_from_facets(facets) sets = [] facets.each do |_facet, terms| - sets.concat terms.each_slice(2).map { |t| new(t.first) } + sets.concat(terms.each_slice(2).map { |t| new(t.first) }) end sets.empty? ? nil : sets end @@ -52,6 +52,6 @@ def description_from_spec describe_meta = ActiveFedora::SolrService.query("has_model_ssim:AdminSet AND id:#{@spec}", rows: 1).first['description_tesim']&.first # CONDITION: Check the condition to return the correct description to display on OAI - return describe_meta if describe_meta.blank? == false + describe_meta if describe_meta.blank? == false end end diff --git a/app/models/user.rb b/app/models/user.rb index 0352d6244..e02cc8a2c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -44,14 +44,14 @@ def cas_extra_attributes=(extra_attributes) # number of seconds have elapsed since the previous update occurred. def update_from_person_api right_now = DateTime.now.in_time_zone(ScholarsArchive::Application.config.time_zone) - if !api_person_updated_at || api_person_updated_at + ENV['OSU_API_PERSON_REFRESH_SECONDS'].to_i.seconds < right_now - service = ScholarsArchive::OsuApiService.new - person = service.get_person(username) - self.api_person_type = person['attributes']['primaryAffiliation'] - self.api_person_updated_at = DateTime.now - # TODO: set api_student_type to nil, undergraduate, or graduate once the Person API has been extended to support fetching this data - save - end + return unless !api_person_updated_at || api_person_updated_at + ENV['OSU_API_PERSON_REFRESH_SECONDS'].to_i.seconds < right_now + + service = ScholarsArchive::OsuApiService.new + person = service.get_person(username) + self.api_person_type = person['attributes']['primaryAffiliation'] + self.api_person_updated_at = DateTime.now + # TODO: set api_student_type to nil, undergraduate, or graduate once the Person API has been extended to support fetching this data + save end # If api_person_type is set, evaluate if the user is an employee or not. Default to diff --git a/app/renderers/hyrax/renderers/edtf_attribute_renderer.rb b/app/renderers/hyrax/renderers/edtf_attribute_renderer.rb index e3a8740a8..8545f4ded 100644 --- a/app/renderers/hyrax/renderers/edtf_attribute_renderer.rb +++ b/app/renderers/hyrax/renderers/edtf_attribute_renderer.rb @@ -15,11 +15,11 @@ class EdtfAttributeRenderer < AttributeRenderer # Special treatment for special dates (edtf) def attribute_value_to_html(value) date = Date.edtf(value) - if date.present? - output = date.edtf - else - output = value - end + output = if date.present? + date.edtf + else + value + end link_to_sa_field(search_field, output) end diff --git a/app/services/hyrax/workflow/metadata_only_record.rb b/app/services/hyrax/workflow/metadata_only_record.rb index d4d5c3b58..23980561a 100644 --- a/app/services/hyrax/workflow/metadata_only_record.rb +++ b/app/services/hyrax/workflow/metadata_only_record.rb @@ -6,7 +6,7 @@ module Workflow # Sets the work and filesets to private module MetadataOnlyRecord # rubocop:disable Lint/UnusedMethodArgument - def self.call(user: _user, target:, **) + def self.call(target:, user: _user, **) target.file_sets.each(&:destroy) target.thumbnail_id = '' end diff --git a/app/services/scholars_archive/admin_set_select_service.rb b/app/services/scholars_archive/admin_set_select_service.rb index 0a153206a..cac824327 100644 --- a/app/services/scholars_archive/admin_set_select_service.rb +++ b/app/services/scholars_archive/admin_set_select_service.rb @@ -9,9 +9,9 @@ class AdminSetSelectService # Inputs: Model, Select Options # Output: Array with stingified admin set name ["Article"] def self.select(model, select_options) - admin_set_name = YAML.load(File.read('config/admin_set_map.yml'))[model] + admin_set_name = YAML.safe_load(File.read('config/admin_set_map.yml'))[model] mapped_admin_set = select_options.find { |o| o.first.casecmp(admin_set_name).zero? } - [ mapped_admin_set || select_options.find { |o| o.first.casecmp(ENV['SCHOLARSARCHIVE_DEFAULT_ADMIN_SET']).zero? } ].flatten + [mapped_admin_set || select_options.find { |o| o.first.casecmp(ENV['SCHOLARSARCHIVE_DEFAULT_ADMIN_SET']).zero? }].flatten end end end diff --git a/app/services/scholars_archive/all_facet_values_service.rb b/app/services/scholars_archive/all_facet_values_service.rb index eb1209624..264d96396 100644 --- a/app/services/scholars_archive/all_facet_values_service.rb +++ b/app/services/scholars_archive/all_facet_values_service.rb @@ -64,8 +64,8 @@ def facet_params(facet_field, params) params[:rows] = 0 params[:facet] = 'on' params['facet.field'] = facet_field - params['facet.limit'] = 100000 - params["f.#{facet_field}.facet.limit"] = 100000 + params['facet.limit'] = 100_000 + params["f.#{facet_field}.facet.limit"] = 100_000 params end end diff --git a/app/services/scholars_archive/caching_service.rb b/app/services/scholars_archive/caching_service.rb index d0041057e..9e0bf9193 100644 --- a/app/services/scholars_archive/caching_service.rb +++ b/app/services/scholars_archive/caching_service.rb @@ -9,8 +9,6 @@ def self.fetch_or_store_in_cache(uri, expires_in) fetch_or_cache_json_from_etag(uri, expires_in) end - private - def self.fetch_or_cache_json_from_etag(uri, expires_in) etag = fetch_etag(uri) data = read_etag_from_cache(uri) diff --git a/app/services/scholars_archive/edtf_date_compare_service.rb b/app/services/scholars_archive/edtf_date_compare_service.rb index a9bc33560..6f50c5b8e 100644 --- a/app/services/scholars_archive/edtf_date_compare_service.rb +++ b/app/services/scholars_archive/edtf_date_compare_service.rb @@ -12,8 +12,6 @@ def self.includes_open_dates?(active_option) last_five_years_include?(active_option) ? parse_date(active_option).include?('open') : false end - private - # This method normalizes the active_option sent into this method. If the # date comes not in the form {date1, date2, date..range} it will coerce it # into that form so Date.edtf will be able to parse it. active_option is in @@ -24,7 +22,7 @@ def self.last_five_years_include?(active_option) normalized_date = "{#{academic_date}}" unless academic_date.include?('{') return parse_academic_affiliation(normalized_date) unless normalized_date.nil? || !normalized_date.include?('/') - date_in_past_five_years?(normalized_date, academic_date) if !academic_date.include?('/') + date_in_past_five_years?(normalized_date, academic_date) unless academic_date.include?('/') end def self.parse_date(active_option) diff --git a/app/services/scholars_archive/field_validation_service.rb b/app/services/scholars_archive/field_validation_service.rb index 96803a7ae..1b0b49998 100644 --- a/app/services/scholars_archive/field_validation_service.rb +++ b/app/services/scholars_archive/field_validation_service.rb @@ -24,13 +24,14 @@ def self.degree_grantors_options(value, env_user) end def self.get_collection(field, record: nil, env_user: nil) - if field.to_s == 'degree_level' + case field.to_s + when 'degree_level' degree_level_options(env_user) - elsif field.to_s == 'degree_grantors' + when 'degree_grantors' degree_grantors_options(record.degree_grantors, env_user) - elsif field.to_s == 'degree_name' + when 'degree_name' degree_name_options(env_user) - elsif field.to_s == 'degree_field' + when 'degree_field' degree_field_options(env_user) else [] @@ -69,8 +70,8 @@ def self.is_valid_other_field?(record, field: nil, env_user: nil) collection = get_collection(field, record: record, env_user: env_user) if other_value.present? error_counter += 1 if other_value_in_collection? other_value: other_value, collection: collection - else - error_counter += 1 if record.class.ancestors.include?(::ScholarsArchive::EtdMetadata) && record.attributes[field.to_s] == 'Other' + elsif record.class.ancestors.include?(::ScholarsArchive::EtdMetadata) && record.attributes[field.to_s] == 'Other' + error_counter += 1 end error_counter <= 0 end @@ -85,8 +86,8 @@ def self.is_valid_other_field_multiple?(record, env_attributes: nil, field: nil, other_value.each do |entry| error_counter += 1 if other_value_in_collection? other_value: entry, collection: collection end - else - error_counter += 1 if record.class.ancestors.include?(::ScholarsArchive::EtdMetadata) && record.attributes[field.to_s].present? && record.attributes[field.to_s].include?('Other') + elsif record.class.ancestors.include?(::ScholarsArchive::EtdMetadata) && record.attributes[field.to_s].present? && record.attributes[field.to_s].include?('Other') + error_counter += 1 end error_counter <= 0 end @@ -126,7 +127,7 @@ def self.validate_other_value_multiple?(record, field: nil, env_user: nil) # end end - if error_counter > 0 + if error_counter.positive? valid_values.each do |entry| record.send(field) << [{ option: 'Other', err_valid_val: true, other_entry: entry.to_s }.to_json] end @@ -138,8 +139,6 @@ def self.other_value_in_collection?(other_value: nil, collection: []) !collection.select { |option| option.include? other_value }.empty? ? true : false end - private - def self.add_error_message(record, field, error_msg) record.errors[field.to_s] << error_msg end diff --git a/app/services/scholars_archive/handle_error_logging_service.rb b/app/services/scholars_archive/handle_error_logging_service.rb index d469aa6ad..689d3bf20 100644 --- a/app/services/scholars_archive/handle_error_logging_service.rb +++ b/app/services/scholars_archive/handle_error_logging_service.rb @@ -4,37 +4,37 @@ module ScholarsArchive # Handle errors class HandleErrorLoggingService def self.log_no_files_found_error(handle_params, work, handle_url) - logger = Logger.new("#{Rails.root}/log/handle_errors.log" ) - logger.warn( 'WARNING: MISSING_FILES_ERROR' ) - logger.warn( '========================================================================================================================' ) - logger.warn( "No file was found for the work #{work.title} for the direct download link provided." ) - logger.warn( "Handle Url: #{handle_url}}" ) - logger.warn( "ir.library.oregonstate.edu/bitstream/handle/#{handle_params[:handle_prefix]}/#{handle_params[:handle_localname]}/#{handle_params[:file]}.#{handle_params[:format]}" ) + logger = Logger.new("#{Rails.root}/log/handle_errors.log") + logger.warn('WARNING: MISSING_FILES_ERROR') + logger.warn('========================================================================================================================') + logger.warn("No file was found for the work #{work.title} for the direct download link provided.") + logger.warn("Handle Url: #{handle_url}}") + logger.warn("ir.library.oregonstate.edu/bitstream/handle/#{handle_params[:handle_prefix]}/#{handle_params[:handle_localname]}/#{handle_params[:file]}.#{handle_params[:format]}") end def self.log_too_many_files_found_error(handle_params, work, handle_url) - logger = Logger.new("#{Rails.root}/log/handle_errors.log" ) - logger.warn( 'WARNING: TOO_MANY_FILES_ERROR' ) - logger.warn( '========================================================================================================================' ) - logger.warn( 'Multiple files were found with the same file name. Cannot decide which file to use.' ) - logger.warn( "#{work.title} was the original work from handle #{handle_url}" ) - logger.warn( "ir.library.oregonstate.edu/bitstream/handle/#{handle_params[:handle_prefix]}/#{handle_params[:handle_localname]}/#{handle_params[:file]}.#{handle_params[:format]}" ) + logger = Logger.new("#{Rails.root}/log/handle_errors.log") + logger.warn('WARNING: TOO_MANY_FILES_ERROR') + logger.warn('========================================================================================================================') + logger.warn('Multiple files were found with the same file name. Cannot decide which file to use.') + logger.warn("#{work.title} was the original work from handle #{handle_url}") + logger.warn("ir.library.oregonstate.edu/bitstream/handle/#{handle_params[:handle_prefix]}/#{handle_params[:handle_localname]}/#{handle_params[:file]}.#{handle_params[:format]}") end def self.log_incorrect_handle_prefix_error(handle_params) - logger = Logger.new("#{Rails.root}/log/handle_errors.log" ) - logger.warn( 'WARNING: INCORRECT_HANDLE_PREFIX_ERROR' ) - logger.warn( '========================================================================================================================' ) - logger.warn( 'The handle id that was provided was incorrect' ) - logger.warn( "Handle LOCALNAME: #{handle_params[:handle_prefix]}" ) + logger = Logger.new("#{Rails.root}/log/handle_errors.log") + logger.warn('WARNING: INCORRECT_HANDLE_PREFIX_ERROR') + logger.warn('========================================================================================================================') + logger.warn('The handle id that was provided was incorrect') + logger.warn("Handle LOCALNAME: #{handle_params[:handle_prefix]}") end def self.log_no_work_found_error(handle_params) - logger = Logger.new("#{Rails.root}/log/handle_errors.log" ) - logger.warn( 'WARNING: NO_WORK_FOUND_ERROR' ) - logger.warn( '========================================================================================================================' ) - logger.warn( 'The LOCALNAME that was provided was incorrect' ) - logger.warn( "LOCALNAME: #{handle_params[:handle_localname]}" ) + logger = Logger.new("#{Rails.root}/log/handle_errors.log") + logger.warn('WARNING: NO_WORK_FOUND_ERROR') + logger.warn('========================================================================================================================') + logger.warn('The LOCALNAME that was provided was incorrect') + logger.warn("LOCALNAME: #{handle_params[:handle_localname]}") end end end diff --git a/app/services/scholars_archive/label_and_ordered_parser_service.rb b/app/services/scholars_archive/label_and_ordered_parser_service.rb index a3af61128..c74041def 100644 --- a/app/services/scholars_archive/label_and_ordered_parser_service.rb +++ b/app/services/scholars_archive/label_and_ordered_parser_service.rb @@ -16,11 +16,9 @@ def self.parse_label_uris(labels) labels.each do |label| parsed_label_uris << { 'label' => extract_label(label), 'uri' => extract_uri(label), 'index' => extract_index(label) } end - parsed_label_uris.sort_by { |hash| hash['index'].to_i }.select { |hash| !hash['label'].empty? } + parsed_label_uris.sort_by { |hash| hash['index'].to_i }.reject { |hash| hash['label'].empty? } end - private - def self.extract_label(label) items = build_array(label) items[0...-2].join('$') diff --git a/app/services/scholars_archive/label_parser_service.rb b/app/services/scholars_archive/label_parser_service.rb index 0654c39ca..26f7a5013 100644 --- a/app/services/scholars_archive/label_parser_service.rb +++ b/app/services/scholars_archive/label_parser_service.rb @@ -66,8 +66,6 @@ def self.location_parse_labels(labels) labels end - private - def self.strip_uri(label) items = build_array(label) items[0...-1].join('$') diff --git a/app/services/scholars_archive/ordered_parser_service.rb b/app/services/scholars_archive/ordered_parser_service.rb index e2c15333d..32ac8f25e 100644 --- a/app/services/scholars_archive/ordered_parser_service.rb +++ b/app/services/scholars_archive/ordered_parser_service.rb @@ -8,8 +8,6 @@ def self.parse(labels) labels.map { |label| parse_index(label) }.sort_by { |array| array[1].to_i }.map { |array| array[0] } end - private - def self.build_array(label) label&.split('$') || [] end diff --git a/app/services/scholars_archive/osu_api_service.rb b/app/services/scholars_archive/osu_api_service.rb index df1e4fbe4..4b73cae87 100644 --- a/app/services/scholars_archive/osu_api_service.rb +++ b/app/services/scholars_archive/osu_api_service.rb @@ -9,7 +9,7 @@ class OsuApiService attr_accessor :token, :logger, :people def initialize(logger = nil) - @logger = logger || Logger.new(STDOUT) + @logger = logger || Logger.new($stdout) @people = {} @token = get_token end @@ -24,13 +24,11 @@ def get_person(onid) response = get(url, params, header) @logger.debug('OsuApiService#get_person : returned user') if response.status == 200 @logger.error("OsuApiService#get_person(#{onid}) failed : #{response.status} : #{response.reason_phrase}") unless response.status == 200 - if response.status == 200 - o = JSON.parse(response.body) - @people[onid] = o['data'].first - @people[onid] - else - nil - end + return unless response.status == 200 + + o = JSON.parse(response.body) + @people[onid] = o['data'].first + @people[onid] end private @@ -48,12 +46,10 @@ def get_token @logger.debug("OsuApiService#get_token : fetching token : #{url}") response = post(url, { grant_type: 'client_credentials', client_id: ENV['OSU_API_CLIENT_ID'], client_secret: ENV['OSU_API_CLIENT_SECRET'] }) @logger.error("OsuApiService#get_token failed : #{response.status} : #{response.reason_phrase}") unless response.status == 200 - if response.status == 200 - json = JSON.parse(response.body) - json['access_token'] - else - raise 'OsuApiService#get_token failed: #{response.status} : #{response.reason_phrase}' - end + raise "OsuApiService#get_token failed: #{response.status} : #{response.reason_phrase}" unless response.status == 200 + + json = JSON.parse(response.body) + json['access_token'] end def authorization_header diff --git a/app/services/scholars_archive/param_scrubber.rb b/app/services/scholars_archive/param_scrubber.rb index cb33af116..b2bfef333 100644 --- a/app/services/scholars_archive/param_scrubber.rb +++ b/app/services/scholars_archive/param_scrubber.rb @@ -5,16 +5,17 @@ module ScholarsArchive class ParamScrubber def self.scrub(params, hash_key) params[hash_key].each_pair do |attr, value| - if value.is_a?(Array) + case value + when Array # Set the mapped array on the params hash set_values(params, hash_key, attr, mapped_values(value)) # If value is a Hash - elsif value.is_a? ActionController::Parameters + when ActionController::Parameters # Recursively dig into the hashes # find the raw value and set them on the params hash set_values(params, hash_key, attr, extract_hash_values(value.to_enum.to_h).to_hash) - elsif value.is_a? String + when String # set the stripped string on the params set_params(params, hash_key, attr, value) end diff --git a/app/services/scholars_archive/parent_query_service.rb b/app/services/scholars_archive/parent_query_service.rb index 92de6e21f..291d60f9b 100644 --- a/app/services/scholars_archive/parent_query_service.rb +++ b/app/services/scholars_archive/parent_query_service.rb @@ -4,7 +4,7 @@ module ScholarsArchive # Query for parent class ParentQueryService def self.query_parents_for_id(child_id) - ActiveFedora::SolrService.get("member_ids_ssim:#{child_id}", rows: 100000)['response']['docs'] + ActiveFedora::SolrService.get("member_ids_ssim:#{child_id}", rows: 100_000)['response']['docs'] end end end diff --git a/app/services/scholars_archive/records_by_user_group_and_visibility.rb b/app/services/scholars_archive/records_by_user_group_and_visibility.rb index 4919c7af5..82b0fe7ae 100644 --- a/app/services/scholars_archive/records_by_user_group_and_visibility.rb +++ b/app/services/scholars_archive/records_by_user_group_and_visibility.rb @@ -54,7 +54,7 @@ def solr_params(query_strings, facet_field) rows: 0, queries: query_strings, facets: { fields: [facet_field] }, - 'facet.limit' => 10000 + 'facet.limit' => 10_000 } end diff --git a/app/services/scholars_archive/triple_powered_service.rb b/app/services/scholars_archive/triple_powered_service.rb index 3134904ae..9bbe23eef 100644 --- a/app/services/scholars_archive/triple_powered_service.rb +++ b/app/services/scholars_archive/triple_powered_service.rb @@ -9,7 +9,7 @@ def fetch_all_labels(uris) labels = [] uris.each do |uri| graph = fetch_from_store(uri) - labels << predicate_labels(graph).values.flatten.compact.collect { |label| "#{label}$#{uri.to_s}" } + labels << predicate_labels(graph).values.flatten.compact.collect { |label| "#{label}$#{uri}" } end labels.flatten.compact end @@ -19,10 +19,10 @@ def fetch_all_labels_with_date(uris) uris.each do |uri| graph = fetch_from_store(uri) values = predicate_label_dates(graph).values.flatten.compact - labels << if values.size > 0 - values.collect { |label_date| "#{label_date}$#{uri.to_s}" } + labels << if values.size.positive? + values.collect { |label_date| "#{label_date}$#{uri}" } else - predicate_labels(graph).values.flatten.compact.collect { |label| "#{label}$#{uri.to_s}" } + predicate_labels(graph).values.flatten.compact.collect { |label| "#{label}$#{uri}" } end end labels.flatten.compact @@ -45,8 +45,8 @@ def predicate_label_dates(graph) rdf_label_predicates.each do |predicate| label_dates[predicate.to_s] = [] label_dates[predicate.to_s] << label_dates_query(graph, predicate) - .select { |statement| !statement.is_a?(Array) } - .map { |statement| "#{statement.label.to_s} - #{statement.date.to_s}" } + .reject { |statement| statement.is_a?(Array) } + .map { |statement| "#{statement.label} - #{statement.date}" } label_dates[predicate.to_s].flatten!.compact! end label_dates @@ -72,9 +72,9 @@ def predicate_labels(graph) rdf_label_predicates.each do |predicate| # GET: Fetch all the labels all_labels = graph - .query(predicate: predicate) - .select { |statement| !statement.is_a?(Array) } - .map(&:object) + .query(predicate: predicate) + .reject { |statement| statement.is_a?(Array) } + .map(&:object) # ASSIGN: Assign all the labels to the labels arr labels[predicate.to_s] = all_labels.map(&:to_s) @@ -82,7 +82,7 @@ def predicate_labels(graph) eng_labels = all_labels .select { |value| value.respond_to?(:language) ? value.language.in?(%i[en en-us]) : true } # CHECK: Assign the english label and check the english label - labels[predicate.to_s] = eng_labels.map(&:to_s) if eng_labels.count > 0 + labels[predicate.to_s] = eng_labels.map(&:to_s) if eng_labels.count.positive? labels[predicate.to_s].compact! end labels @@ -101,15 +101,15 @@ def rdf_label_predicates end def fetch_from_store(uri) - unless uri.blank? - begin - @triplestore ||= TriplestoreAdapter::Triplestore.new(TriplestoreAdapter::Client.new(ENV['SCHOLARSARCHIVE_TRIPLESTORE_ADAPTER_TYPE'] || 'blazegraph', - ENV['SCHOLARSARCHIVE_TRIPLESTORE_ADAPTER_URL'] || 'http://localhost:9999/blazegraph/namespace/development/sparql')) - @triplestore.fetch(uri, from_remote: true) - rescue TriplestoreAdapter::TriplestoreException => e - Rails.logger.warn e.message - nil - end + return if uri.blank? + + begin + @triplestore ||= TriplestoreAdapter::Triplestore.new(TriplestoreAdapter::Client.new(ENV['SCHOLARSARCHIVE_TRIPLESTORE_ADAPTER_TYPE'] || 'blazegraph', + ENV['SCHOLARSARCHIVE_TRIPLESTORE_ADAPTER_URL'] || 'http://localhost:9999/blazegraph/namespace/development/sparql')) + @triplestore.fetch(uri, from_remote: true) + rescue TriplestoreAdapter::TriplestoreException => e + Rails.logger.warn e.message + nil end end end diff --git a/app/services/scholars_archive/workflow/deposit_received_notification.rb b/app/services/scholars_archive/workflow/deposit_received_notification.rb index 50e7353fc..da1173447 100644 --- a/app/services/scholars_archive/workflow/deposit_received_notification.rb +++ b/app/services/scholars_archive/workflow/deposit_received_notification.rb @@ -10,9 +10,7 @@ def subject 'Thank you for your deposit to ScholarsArchive@OSU' end - # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength - # rubocop:disable Lint/Void def message if SolrDocument.find(work_id)['resource_type_tesim']&.include?('Article') "ScholarsArchive@OSU has received your deposit: #{title} @@ -46,10 +44,9 @@ def message Visit https://ir.library.oregonstate.edu/ and go to your dashboard for more info." end end + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength - # rubocop:enable Lint/Void - # Add the user who initiated this action to the list of users being notified def users_to_notify [user] diff --git a/app/services/scholars_archive/workflow/pending_review_notification.rb b/app/services/scholars_archive/workflow/pending_review_notification.rb index 48fed9635..771b268ee 100644 --- a/app/services/scholars_archive/workflow/pending_review_notification.rb +++ b/app/services/scholars_archive/workflow/pending_review_notification.rb @@ -13,10 +13,6 @@ def subject def message "The item: #{title} (#{link_to work_id, citeable_url}) was deposited by #{user.user_key} and is awaiting review. #{comment}" end - - def users_to_notify - super - end end end end diff --git a/app/workers/fetch_failed_graph_worker.rb b/app/workers/fetch_failed_graph_worker.rb index 86acf2285..50586374e 100644 --- a/app/workers/fetch_failed_graph_worker.rb +++ b/app/workers/fetch_failed_graph_worker.rb @@ -39,7 +39,7 @@ def solr_funding_body_linked_insert(solr_doc, val) end def default_accept_header - RDF::Util::File::HttpAdapter.default_accept_header.sub(%r{, \*\/\*;q=0\.1\Z}, '') + RDF::Util::File::HttpAdapter.default_accept_header.sub(%r{, \*/\*;q=0\.1\Z}, '') end def run_success_callback(user, val) diff --git a/app/workers/fetch_graph_worker.rb b/app/workers/fetch_graph_worker.rb index 7e6480c7c..8dbef860e 100644 --- a/app/workers/fetch_graph_worker.rb +++ b/app/workers/fetch_graph_worker.rb @@ -100,6 +100,6 @@ def fetch_failed_graph(pid, val, controlled_prop) end def default_accept_header - RDF::Util::File::HttpAdapter.default_accept_header.sub(%r{, \*\/\*;q=0\.1\Z}, '') + RDF::Util::File::HttpAdapter.default_accept_header.sub(%r{, \*/\*;q=0\.1\Z}, '') end end diff --git a/lib/qa/authorities/geonames.rb b/lib/qa/authorities/geonames.rb index 1cf79d72f..f661629c9 100644 --- a/lib/qa/authorities/geonames.rb +++ b/lib/qa/authorities/geonames.rb @@ -19,8 +19,7 @@ def translate_fcl(fcl) 'S' => 'Spot', 'T' => 'Hypsographic', 'U' => 'Undersea', - 'V' => 'Vegetation' - }[fcl] + 'V' => 'Vegetation' }[fcl] end end @@ -75,7 +74,7 @@ def find_url(id) # Reformats the data received from the service def parse_authority_response(response) response['geonames'].map do |result| - # Note: the trailing slash is meaningful. + # NOTE: the trailing slash is meaningful. { 'id' => "https://sws.geonames.org/#{result['geonameId']}/", 'label' => label.call(result) } end @@ -83,7 +82,7 @@ def parse_authority_response(response) # REFORMAT: Format data with the id given def parse_response_with_id(response) - # Note: the trailing slash is meaningful. + # NOTE: the trailing slash is meaningful. [{ 'id' => "https://sws.geonames.org/#{response['geonameId']}/", 'label' => label.call(response) }] end diff --git a/lib/scholars_archive/document/qualified_dublin_core.rb b/lib/scholars_archive/document/qualified_dublin_core.rb index adb7defd4..292dc1d3a 100644 --- a/lib/scholars_archive/document/qualified_dublin_core.rb +++ b/lib/scholars_archive/document/qualified_dublin_core.rb @@ -10,8 +10,8 @@ def self.extended(document) end def self.register_export_formats(document) -# document.will_export_as(:xml) -# document.will_export_as(:dc_xml, "text/xml") + # document.will_export_as(:xml) + # document.will_export_as(:dc_xml, "text/xml") document.will_export_as(:oai_qdc_xml, 'text/xml') end @@ -36,12 +36,12 @@ def export_as_oai_qdc_xml xml.target! end - alias_method :export_as_xml, :export_as_oai_qdc_xml - alias_method :export_as_qdc_xml, :export_as_oai_qdc_xml + alias export_as_xml export_as_oai_qdc_xml + alias export_as_qdc_xml export_as_oai_qdc_xml private - def qualified_dublin_core_field_name? field + def qualified_dublin_core_field_name?(field) qualified_dublin_core_field_names.include? field.to_sym end end diff --git a/lib/scholars_archive/feature_class_uri_to_label.rb b/lib/scholars_archive/feature_class_uri_to_label.rb index da3bf73b8..2c74b8279 100644 --- a/lib/scholars_archive/feature_class_uri_to_label.rb +++ b/lib/scholars_archive/feature_class_uri_to_label.rb @@ -12,8 +12,7 @@ def uri_to_label(uri) 'https://www.geonames.org/ontology#S' => 'Spot', 'https://www.geonames.org/ontology#T' => 'Hypsographic', 'https://www.geonames.org/ontology#U' => 'Undersea', - 'https://www.geonames.org/ontology#V' => 'Vegetation' - }[uri] + 'https://www.geonames.org/ontology#V' => 'Vegetation' }[uri] end end end diff --git a/lib/scholars_archive/migrate_ordered_metadata_service.rb b/lib/scholars_archive/migrate_ordered_metadata_service.rb index eaa45aaf8..c595055e0 100644 --- a/lib/scholars_archive/migrate_ordered_metadata_service.rb +++ b/lib/scholars_archive/migrate_ordered_metadata_service.rb @@ -6,6 +6,7 @@ module ScholarsArchive # Migration for ordered metadata class MigrateOrderedMetadataService attr_reader :creator_csv + ## # Open and read CSVs into memory to prevent unnecessary IO for processing multiple works, # then provide methods for querying, ordering, and migrating a work based on CSV data and/or @@ -88,7 +89,7 @@ def has_migrated?(handle: nil, work: nil, force_update: false) work.save log("MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : #{doc['id']} : Work successfully migrated") - work.members.reject { |m| m.class.to_s == 'FileSet' }.each do |child| + work.members.reject { |m| m.instance_of?(::FileSet) }.each do |child| log("MigrateOrderedMetadataService(handle:#{handle}, work:#{work_id}) : child_work:#{child.id} : Finding child work, attempting to migrate") unless creators.empty? diff --git a/lib/scholars_archive/triple_powered_properties/errors.rb b/lib/scholars_archive/triple_powered_properties/errors.rb index c78576568..515f8dea3 100644 --- a/lib/scholars_archive/triple_powered_properties/errors.rb +++ b/lib/scholars_archive/triple_powered_properties/errors.rb @@ -2,7 +2,6 @@ module ScholarsArchive::TriplePoweredProperties module Errors - ## # Base error class TriplePoweredPropertyError < StandardError diff --git a/lib/scholars_archive/triple_powered_properties/has_url_validator.rb b/lib/scholars_archive/triple_powered_properties/has_url_validator.rb index 95892e381..f26940af9 100644 --- a/lib/scholars_archive/triple_powered_properties/has_url_validator.rb +++ b/lib/scholars_archive/triple_powered_properties/has_url_validator.rb @@ -24,13 +24,11 @@ def validate(record) return if values.include? 'Other' values.each do |value| - begin - uri = URI.parse(value) - rescue - record.errors[prop[:field]] << "#{value} is not a URL" - else - record.errors[prop[:field]] << "#{value} is invalid" unless uri.kind_of?(URI::HTTP) - end + uri = URI.parse(value) + rescue StandardError + record.errors[prop[:field]] << "#{value} is not a URL" + else + record.errors[prop[:field]] << "#{value} is invalid" unless uri.is_a?(URI::HTTP) end end end diff --git a/lib/scholars_archive/triple_powered_properties/triple_powered_form.rb b/lib/scholars_archive/triple_powered_properties/triple_powered_form.rb index 6c0b675c8..fed913403 100644 --- a/lib/scholars_archive/triple_powered_properties/triple_powered_form.rb +++ b/lib/scholars_archive/triple_powered_properties/triple_powered_form.rb @@ -3,7 +3,6 @@ module ScholarsArchive::TriplePoweredProperties # Makes form triple powered module TriplePoweredForm - ## # Checks the model of this form to evaluate if a property is triple powered # @param property [Symbol] the models property to be evaluated diff --git a/lib/scholars_archive/validators/nested_related_items_validator.rb b/lib/scholars_archive/validators/nested_related_items_validator.rb index 67f685a49..7ed94e96c 100644 --- a/lib/scholars_archive/validators/nested_related_items_validator.rb +++ b/lib/scholars_archive/validators/nested_related_items_validator.rb @@ -4,7 +4,7 @@ module ScholarsArchive::Validators # Validate labels and presence of related item class NestedRelatedItemsValidator < ActiveModel::Validator def validate(record) - validate_nested_fields record, 0 if nested_related_items_present? (record) + validate_nested_fields record, 0 if nested_related_items_present?(record) end def validate_nested_fields(record, error_counter = 0) @@ -36,7 +36,7 @@ def validate_related_item(item, record) end # process item before returning so that they can be updated in the form - if error_counter > 0 && item._destroy == false + if error_counter.positive? && item._destroy == false related_item = record.nested_related_items.to_a.find { |i| i.label.first == item.label.first && i.related_url.first == item.related_url.first } related_item.validation_msg = I18n.translate(:"simple_form.actor_validation.nested_related_item_value_missing") if related_item.present? end diff --git a/lib/scholars_archive/validators/other_affiliation_validator.rb b/lib/scholars_archive/validators/other_affiliation_validator.rb index 3c4fb061e..d4ce819a3 100644 --- a/lib/scholars_archive/validators/other_affiliation_validator.rb +++ b/lib/scholars_archive/validators/other_affiliation_validator.rb @@ -17,9 +17,9 @@ def other_affiliation_options(env_user) end def current_user_editor(record) - if record.respond_to?(:current_username) - User.find_by_username(record.current_username.to_s) if record.current_username.present? - end + return unless record.respond_to?(:current_username) + + User.find_by_username(record.current_username.to_s) if record.current_username.present? end # This will now check if there is value passed in, since this can be used for optional fields (i.e. other_affiliation) @@ -41,16 +41,14 @@ def validate_other_value_multiple?(record, field: nil, collection: []) valid_values << entry.to_s end end - else - if record.attributes[field.to_s].present? && record.attributes[field.to_s].include?('Other') - err_message = I18n.t('simple_form.actor_validation.other_value_missing') - add_error_message(record, other_field, err_message) - record.send(field) << [{ option: 'Other', err_msg: err_message }.to_json] - error_counter += 1 - end + elsif record.attributes[field.to_s].present? && record.attributes[field.to_s].include?('Other') + err_message = I18n.t('simple_form.actor_validation.other_value_missing') + add_error_message(record, other_field, err_message) + record.send(field) << [{ option: 'Other', err_msg: err_message }.to_json] + error_counter += 1 end - if error_counter > 0 + if error_counter.positive? valid_values.each do |entry| record.send(field) << [{ option: 'Other', err_valid_val: true, other_entry: entry.to_s }.to_json] end diff --git a/lib/scholars_archive/validators/other_option_degree_validator.rb b/lib/scholars_archive/validators/other_option_degree_validator.rb index 3f95951bb..a68ffbb49 100644 --- a/lib/scholars_archive/validators/other_option_degree_validator.rb +++ b/lib/scholars_archive/validators/other_option_degree_validator.rb @@ -14,7 +14,7 @@ def degree_grantors_present?(record) def validate(record) error_counter = 0 - if degree_present? (record) + if degree_present?(record) # check if degree_level_other is already in the list or is missing error_counter += ScholarsArchive::FieldValidationService.validate_other_value? record, field: :degree_level, @@ -31,7 +31,7 @@ def validate(record) env_user: current_user_editor(record) end - if degree_grantors_present? (record) + if degree_grantors_present?(record) # check if degree_grantors_other is already in the list or is missing error_counter += ScholarsArchive::FieldValidationService.validate_other_value? record, field: :degree_grantors, @@ -42,9 +42,9 @@ def validate(record) end def current_user_editor(record) - if record.respond_to?(:current_username) - User.find_by_username(record.current_username.to_s) if record.current_username.present? - end + return unless record.respond_to?(:current_username) + + User.find_by_username(record.current_username.to_s) if record.current_username.present? end end end diff --git a/rubocop_fix_me.yml b/rubocop_fix_me.yml new file mode 100644 index 000000000..b1552d8fc --- /dev/null +++ b/rubocop_fix_me.yml @@ -0,0 +1,183 @@ +Lint/EmptyWhen: + Exclude: + - "app/controllers/scholars_archive/handles_controller.rb" +Security/YAMLLoad: + Exclude: + - "app/authorities/scholars_archive/cache_based_authority.rb" +Lint/MissingSuper: + Exclude: + - "app/models/oai_set.rb" +Lint/NonLocalExitFromIterator: + Exclude: + - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" + - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" +Lint/ShadowedArgument: + Exclude: + - "app/models/concerns/scholars_archive/date_operations.rb" +Metrics/BlockLength: + Exclude: + - "app/controllers/catalog_controller.rb" + - "app/models/concerns/scholars_archive/has_solr_labels.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" +Metrics/ClassLength: + Exclude: + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/controllers/catalog_controller.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/inputs/multi_value_date_input.rb" + - "app/inputs/multi_value_label_url_input.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/models/solr_document.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" +Metrics/CyclomaticComplexity: + Exclude: + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/create_with_ext_relation_actor.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/indexers/default_work_indexer.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_solr_labels.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/services/scholars_archive/degree_level_service.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" + - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" + - "lib/scholars_archive/validators/nested_related_items_validator.rb" + - "lib/scholars_archive/validators/other_affiliation_validator.rb" +Metrics/MethodLength: + Exclude: + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" + - "app/controllers/application_controller.rb" + - "app/controllers/concerns/scholars_archive/download_analytics_behavior.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/controllers/hyrax/contact_form_controller.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/forms/scholars_archive/dataset_form_behavior.rb" + - "app/forms/scholars_archive/default_work_form_behavior.rb" + - "app/helpers/application_helper.rb" + - "app/helpers/application_helper.rb" + - "app/helpers/application_helper.rb" + - "app/indexers/default_work_indexer.rb" + - "app/indexers/default_work_indexer.rb" + - "app/inputs/multi_value_date_input.rb" + - "app/inputs/multi_value_date_input.rb" + - "app/inputs/multi_value_date_input.rb" + - "app/inputs/multi_value_label_url_input.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/inputs/multi_value_select_other_input.rb" + - "app/jobs/characterize_job.rb" + - "app/jobs/migrate_creators_no_handles_job.rb" + - "app/jobs/migrate_creators_no_handles_job.rb" + - "app/jobs/reindex_everything_job.rb" + - "app/jobs/reindex_model_job.rb" + - "app/models/concerns/scholars_archive/date_operations.rb" + - "app/models/concerns/scholars_archive/has_solr_labels.rb" + - "app/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/services/scholars_archive/caching_service.rb" + - "app/services/scholars_archive/degree_level_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/osu_api_service.rb" + - "app/services/scholars_archive/records_by_user_group_and_visibility.rb" + - "app/services/scholars_archive/triple_powered_service.rb" + - "app/services/scholars_archive/triple_powered_service.rb" + - "lib/qa/authorities/geonames.rb" + - "lib/scholars_archive/document/qualified_dublin_core.rb" + - "lib/scholars_archive/embargoes/embargo_releaser.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" + - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" + - "lib/scholars_archive/validators/nested_related_items_validator.rb" + - "lib/scholars_archive/validators/other_affiliation_validator.rb" + - "lib/scholars_archive/validators/other_option_degree_validator.rb" +Metrics/ModuleLength: + Exclude: + - "app/helpers/application_helper.rb" + - "app/models/concerns/scholars_archive/default_metadata.rb" +Metrics/PerceivedComplexity: + Exclude: + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/create_with_ext_relation_actor.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/indexers/default_work_indexer.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_nested_ordered_properties.rb" + - "app/models/concerns/scholars_archive/has_solr_labels.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/services/scholars_archive/degree_level_service.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" + - "lib/scholars_archive/triple_powered_properties/has_url_validator.rb" + - "lib/scholars_archive/validators/nested_related_items_validator.rb" + - "lib/scholars_archive/validators/other_affiliation_validator.rb" +Naming/AccessorMethodName: + Exclude: + - "app/actors/scholars_archive/actors/nested_fields_operations_actor.rb" + - "app/controllers/blacklight_advanced_search/advanced_controller.rb" + - "app/controllers/concerns/scholars_archive/works_controller_behavior.rb" + - "app/services/scholars_archive/osu_api_service.rb" +Naming/MethodParameterName: + Exclude: + - "app/authorities/parsers/academic_units_parser.rb" + - "app/authorities/parsers/degree_fields_parser.rb" + - "app/authorities/parsers/degree_fields_parser.rb" + - "app/helpers/application_helper.rb" + - "app/helpers/application_helper.rb" + - "app/helpers/application_helper.rb" + - "app/jobs/resolrize_job.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/renderers/hyrax/renderers/search_and_external_link_attribute_renderer.rb" + - "app/services/scholars_archive/license_service.rb" + - "lib/qa/authorities/geonames.rb" + - "lib/qa/authorities/geonames.rb" + - "lib/qa/authorities/geonames.rb" + - "lib/qa/authorities/geonames.rb" +Naming/PredicateName: + Exclude: + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/actors/scholars_archive/actors/add_other_field_option_actor.rb" + - "app/controllers/concerns/hyrax/contact_form_recaptcha_behavior.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/inputs/multi_value_ordered_input.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" + - "lib/scholars_archive/migrate_ordered_metadata_service.rb" + - "lib/scholars_archive/triple_powered_properties/triple_powered_form.rb" +Naming/VariableName: + Exclude: + - "app/jobs/resolrize_job.rb" + - "app/jobs/resolrize_job.rb" +Naming/VariableNumber: + Exclude: + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/controllers/scholars_archive/handles_controller.rb" + - "app/inputs/multi_value_ordered_input.rb" +Style/EmptyElse: + Exclude: + - "app/services/scholars_archive/field_validation_service.rb" + - "app/services/scholars_archive/field_validation_service.rb" +Style/OptionalBooleanParameter: + Exclude: + - "app/services/scholars_archive/degree_grantors_service.rb" diff --git a/spec/active_support/logger_spec.rb b/spec/active_support/logger_spec.rb index af5b5b149..8382e6fe6 100644 --- a/spec/active_support/logger_spec.rb +++ b/spec/active_support/logger_spec.rb @@ -90,7 +90,7 @@ end # FAIL TEST #1: Testing to see the parsing fail - it 'will not parse correctly w/ some edge cases' do + it 'does not parse correctly w/ some edge cases' do logger.add(severity, msg5, progname) log.rewind @@ -104,7 +104,7 @@ end # FAIL TEST #2: Testing to see the parsing fail - it 'will not parse correctly w/ having bracket inside the uri' do + it 'does not parse correctly w/ having bracket inside the uri' do logger.add(severity, msg6, progname) log.rewind diff --git a/spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb b/spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb index 447014129..688a79341 100644 --- a/spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb +++ b/spec/actors/scholars_archive/actors/add_other_field_option_actor_spec.rb @@ -3,6 +3,13 @@ require 'rails_helper' require 'spec_helper' RSpec.describe ScholarsArchive::Actors::AddOtherFieldOptionActor do + subject(:middleware) do + stack = ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use described_class + end + stack.build(terminator) + end + let(:curation_concern) do GraduateThesisOrDissertation.new do |work| work.attributes = attributes @@ -25,13 +32,6 @@ let(:env) { Hyrax::Actors::Environment.new(curation_concern, ability, attributes) } let(:terminator) { Hyrax::Actors::Terminator.new } - subject(:middleware) do - stack = ActionDispatch::MiddlewareStack.new.tap do |middleware| - middleware.use described_class - end - stack.build(terminator) - end - before do allow_any_instance_of(ScholarsArchive::DegreeLevelService).to receive(:select_sorted_all_options).and_return([%w[Other Other], %w[Certificate Certificate]]) allow_any_instance_of(ScholarsArchive::DegreeFieldService).to receive(:select_sorted_current_options).and_return([%w[Other Other], %w[Zoology Zoology]]) diff --git a/spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb b/spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb index 73e509e49..d1af61f27 100644 --- a/spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb +++ b/spec/actors/scholars_archive/actors/nested_fields_operations_actor_spec.rb @@ -3,6 +3,13 @@ require 'rails_helper' require 'spec_helper' RSpec.describe ScholarsArchive::Actors::NestedFieldsOperationsActor do + subject(:middleware) do + stack = ActionDispatch::MiddlewareStack.new.tap do |middleware| + middleware.use described_class + end + stack.build(terminator) + end + let(:curation_concern) do Default.new do |work| work.attributes = attributes @@ -15,13 +22,13 @@ let(:env) { Hyrax::Actors::Environment.new(curation_concern, ability, attributes) } let(:terminator) { Hyrax::Actors::Terminator.new } let(:attributes) do - { - title: ['test'], - creator: ['Blah'], - rights_statement: ['blah.blah'], - resource_type: ['blah'], - } - end + { + title: ['test'], + creator: ['Blah'], + rights_statement: ['blah.blah'], + resource_type: ['blah'] + } + end let(:nested_geo_attributes) do { '2' => { @@ -47,13 +54,6 @@ let(:expected_point) { 'a,b' } let(:expected_bbox) { '1,2,3,4' } - subject(:middleware) do - stack = ActionDispatch::MiddlewareStack.new.tap do |middleware| - middleware.use described_class - end - stack.build(terminator) - end - describe '#create' do context 'with nested geo attributes' do before do diff --git a/spec/authorities/scholars_archive/cache_based_authority_spec.rb b/spec/authorities/scholars_archive/cache_based_authority_spec.rb index 031d05019..4b4242903 100644 --- a/spec/authorities/scholars_archive/cache_based_authority_spec.rb +++ b/spec/authorities/scholars_archive/cache_based_authority_spec.rb @@ -14,7 +14,7 @@ end context 'When terms is called' do - it 'should return an array of the properly formatted terms' do + it 'returns an array of the properly formatted terms' do expect(authority.all).to eq [{ 'id' => 'http://opaquenamespace.org/ns/osuAcademicUnits/0Ct5bACm', 'label' => 'Forestry', 'active' => true }] end end diff --git a/spec/authorities/scholars_archive/extended_file_based_authority_spec.rb b/spec/authorities/scholars_archive/extended_file_based_authority_spec.rb index 9412c1366..2a2a960cc 100644 --- a/spec/authorities/scholars_archive/extended_file_based_authority_spec.rb +++ b/spec/authorities/scholars_archive/extended_file_based_authority_spec.rb @@ -26,11 +26,11 @@ describe '#terms' do context 'When terms is called' do - it 'should return an array of the all of the terms' do + it 'returns an array of the all of the terms' do expect(authority.all).to eq terms expect(authority.all.map { |t| t[:admin_only] }.count).to eq 5 - expect(authority.all.map { |t| t[:admin_only] }.include?(true)).to be_truthy - expect(authority.all.map { |t| t[:admin_only] }.include?(false)).to be_truthy + expect(authority.all.map { |t| t[:admin_only] }).to include(true) + expect(authority.all.map { |t| t[:admin_only] }).to include(false) end end end diff --git a/spec/controllers/hyrax/contact_form_controller_spec.rb b/spec/controllers/hyrax/contact_form_controller_spec.rb index 07ab8c605..f3aa2658c 100644 --- a/spec/controllers/hyrax/contact_form_controller_spec.rb +++ b/spec/controllers/hyrax/contact_form_controller_spec.rb @@ -4,7 +4,6 @@ RSpec.describe Hyrax::ContactFormController, type: :controller do let(:user) { User.new(email: 'test@example.com', guest: false) { |u| u.save!(validate: false) } } - routes { Hyrax::Engine.routes } let(:required_params) do { category: 'Depositing content', @@ -16,6 +15,8 @@ end let(:contact_form) { Hyrax::ContactForm.new(required_params) } + routes { Hyrax::Engine.routes } + before { sign_in(user) } describe '#check_recaptcha' do diff --git a/spec/controllers/scholars_archive/handles_controller_spec.rb b/spec/controllers/scholars_archive/handles_controller_spec.rb index bcad48c8e..04687b479 100644 --- a/spec/controllers/scholars_archive/handles_controller_spec.rb +++ b/spec/controllers/scholars_archive/handles_controller_spec.rb @@ -6,13 +6,13 @@ let(:work) { Default.new(title: ['blah'], id: 'asdfasdf') } let(:fileset) { FileSet.new(title: ['cat.jpg'], id: 'qwerqwer') } - context '#get handle_show' do + describe '#get handle_show' do context 'when a work exists with the proper handle' do before do allow(controller).to receive(:find_work).and_return(work) end - it 'Should reroute the user to the show page' do + it 'reroutes the user to the show page' do get :handle_show, params: { handle_prefix: '1957', handle_localname: '12345' } expect(response.status).to eq 302 end @@ -23,21 +23,21 @@ allow(controller).to receive(:find_work).and_return(nil) end - it 'Should reroute the user to work not found error page' do + it 'reroutes the user to work not found error page' do get :handle_show, params: { handle_prefix: '1957', handle_localname: '12345' } expect(response.status).to eq 404 end end end - context '#get handle_download' do + describe '#get handle_download' do context 'when a work and its file set exists' do before do allow(controller).to receive(:find_work).and_return(work) allow(controller).to receive(:filesets_for_work).and_return([fileset]) end - it 'Should reroute the user to the download link' do + it 'reroutes the user to the download link' do get :handle_download, params: { handle_prefix: '1957', handle_localname: '12345', file: 'cat.jpg' } expect(response).to redirect_to "/downloads/#{fileset.id}" end @@ -48,7 +48,7 @@ allow(controller).to receive(:find_work).and_return(nil) end - it 'Should reroute the user to the work not found page' do + it 'reroutes the user to the work not found page' do get :handle_download, params: { handle_prefix: '1957', handle_localname: '12345', file: 'cat.jpg' } expect(response.status).to eq 404 end @@ -60,7 +60,7 @@ allow(controller).to receive(:filesets_for_work).and_return([]) end - it 'Should reroute the user to 404 file not found page' do + it 'reroutes the user to 404 file not found page' do get :handle_download, params: { handle_prefix: '1957', handle_localname: '12345', file: 'catasdf' } expect(response.status).to eq 404 end @@ -72,7 +72,7 @@ allow(controller).to receive(:filesets_for_work).and_return([fileset, fileset]) end - it 'Should reroute the user to the show page' do + it 'reroutes the user to the show page' do get :handle_download, params: { handle_prefix: '1957', handle_localname: '12345', file: 'cat.jpg' } expect(response.status).to eq 302 end diff --git a/spec/features/create_administrative_report_or_publication_spec.rb b/spec/features/create_administrative_report_or_publication_spec.rb index 7145559c2..a42983c48 100644 --- a/spec/features/create_administrative_report_or_publication_spec.rb +++ b/spec/features/create_administrative_report_or_publication_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Administrative Report Or Publication', js: false do +RSpec.describe 'Create a Administrative Report Or Publication', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_article_spec.rb b/spec/features/create_article_spec.rb index f88efd703..74feafff8 100644 --- a/spec/features/create_article_spec.rb +++ b/spec/features/create_article_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Article', skip: true, type: :feature do +RSpec.describe 'Create a Article', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_conference_proceedings_or_journal_spec.rb b/spec/features/create_conference_proceedings_or_journal_spec.rb index 21144f778..4ed95c7d0 100644 --- a/spec/features/create_conference_proceedings_or_journal_spec.rb +++ b/spec/features/create_conference_proceedings_or_journal_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Conference Proceedings Or Journal', js: false do +RSpec.describe 'Create a Conference Proceedings Or Journal', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_dataset_spec.rb b/spec/features/create_dataset_spec.rb index 98a3ba1ad..342fa0a0d 100644 --- a/spec/features/create_dataset_spec.rb +++ b/spec/features/create_dataset_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Dataset', skip: true, type: :feature do +RSpec.describe 'Create a Dataset', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_default_spec.rb b/spec/features/create_default_spec.rb index 32dc7f881..7057e64ee 100644 --- a/spec/features/create_default_spec.rb +++ b/spec/features/create_default_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Default', skip: true, type: :feature do +RSpec.describe 'Create a Default', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_default_work_spec.rb b/spec/features/create_default_work_spec.rb index 009d6a06b..4672d4731 100644 --- a/spec/features/create_default_work_spec.rb +++ b/spec/features/create_default_work_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a DefaultWork', skip: true, type: :feature do +RSpec.describe 'Create a DefaultWork', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_eesc_publication_spec.rb b/spec/features/create_eesc_publication_spec.rb index 011662366..0a067adf8 100644 --- a/spec/features/create_eesc_publication_spec.rb +++ b/spec/features/create_eesc_publication_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Eesc Publication', skip: true, type: :feature do +RSpec.describe 'Create a Eesc Publication', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_etd_spec.rb b/spec/features/create_etd_spec.rb index 438ecd682..ec23d435a 100644 --- a/spec/features/create_etd_spec.rb +++ b/spec/features/create_etd_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Etd', skip: true, type: :feature do +RSpec.describe 'Create a Etd', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_graduate_project_spec.rb b/spec/features/create_graduate_project_spec.rb index 5fd0c2dba..6b2271d11 100644 --- a/spec/features/create_graduate_project_spec.rb +++ b/spec/features/create_graduate_project_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Graduate Project', js: false do +RSpec.describe 'Create a Graduate Project', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_graduate_thesis_or_dissertation_spec.rb b/spec/features/create_graduate_thesis_or_dissertation_spec.rb index 855f2a315..2b0bb95d7 100644 --- a/spec/features/create_graduate_thesis_or_dissertation_spec.rb +++ b/spec/features/create_graduate_thesis_or_dissertation_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Graduate Thesis Or Dissertation', js: false do +RSpec.describe 'Create a Graduate Thesis Or Dissertation', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_honors_college_thesis_spec.rb b/spec/features/create_honors_college_thesis_spec.rb index 411c694f0..60d79a665 100644 --- a/spec/features/create_honors_college_thesis_spec.rb +++ b/spec/features/create_honors_college_thesis_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Honors College Thesis', js: false do +RSpec.describe 'Create a Honors College Thesis', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_oer_spec.rb b/spec/features/create_oer_spec.rb index d69e388a4..45ca0da5e 100644 --- a/spec/features/create_oer_spec.rb +++ b/spec/features/create_oer_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Oer', skip: true, type: :feature do +RSpec.describe 'Create a Oer', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_open_educational_resource_spec.rb b/spec/features/create_open_educational_resource_spec.rb index b474df42e..68d7a44b7 100644 --- a/spec/features/create_open_educational_resource_spec.rb +++ b/spec/features/create_open_educational_resource_spec.rb @@ -6,21 +6,19 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Open Educational Resource', skip: true, type: :feature do +RSpec.describe 'Create a Open Educational Resource', skip: true, type: :feature do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_purchased_e_resource_spec.rb b/spec/features/create_purchased_e_resource_spec.rb index c030f3c87..234b212c1 100644 --- a/spec/features/create_purchased_e_resource_spec.rb +++ b/spec/features/create_purchased_e_resource_spec.rb @@ -7,21 +7,19 @@ include Warden::Test::Helpers # NOTE: If you generated more than one work, you have to set "js: true" -RSpec.feature 'Create a PurchasedEResource', skip: true, type: :feature, js: false do +RSpec.describe 'Create a PurchasedEResource', skip: true, type: :feature, js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } end let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_technical_report_spec.rb b/spec/features/create_technical_report_spec.rb index dad5ba061..59f618806 100644 --- a/spec/features/create_technical_report_spec.rb +++ b/spec/features/create_technical_report_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Technical Report', js: false do +RSpec.describe 'Create a Technical Report', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/create_undergraduate_thesis_or_project_spec.rb b/spec/features/create_undergraduate_thesis_or_project_spec.rb index 549ec638d..f0eed1363 100644 --- a/spec/features/create_undergraduate_thesis_or_project_spec.rb +++ b/spec/features/create_undergraduate_thesis_or_project_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' include Warden::Test::Helpers -RSpec.feature 'Create a Undergraduate Thesis Or Project', js: false do +RSpec.describe 'Create a Undergraduate Thesis Or Project', js: false do context 'a logged in user' do let(:user) do User.new(email: 'test@example.com', username: 'test', guest: false, api_person_updated_at: DateTime.now) { |u| u.save!(validate: false) } @@ -15,14 +15,12 @@ let(:current_ability) { user.ability } let(:admin_set) do - begin - AdminSet.find('admin_set/default') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'admin_set/default', - title: ['title'], - description: ['A substantial description'], - edit_users: ['admin']) - end + AdminSet.find('admin_set/default') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'admin_set/default', + title: ['title'], + description: ['A substantial description'], + edit_users: ['admin']) end let(:permission_template) do diff --git a/spec/features/modal_pagination_spec.rb b/spec/features/modal_pagination_spec.rb index 6e35ececf..6635563c3 100644 --- a/spec/features/modal_pagination_spec.rb +++ b/spec/features/modal_pagination_spec.rb @@ -43,7 +43,7 @@ before do visit '/' - allow_any_instance_of(ApplicationHelper).to receive(:max_page_number).with(anything(), anything(), anything()).and_return(2) + allow_any_instance_of(ApplicationHelper).to receive(:max_page_number).with(anything, anything, anything).and_return(2) end describe 'when searching the catalog' do diff --git a/spec/forms/hyrax/administrative_report_or_publication_form_spec.rb b/spec/forms/hyrax/administrative_report_or_publication_form_spec.rb index 4777c2929..7a66394de 100644 --- a/spec/forms/hyrax/administrative_report_or_publication_form_spec.rb +++ b/spec/forms/hyrax/administrative_report_or_publication_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_valid date_reviewed date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection] + expect(described_class.terms).to include(*%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_valid date_reviewed date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection]) end it 'has the proper required fields' do @@ -23,11 +23,11 @@ end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[doi alternative_title nested_ordered_abstract subject license] + expect(new_form.primary_terms).to include(*%i[doi alternative_title nested_ordered_abstract subject license]) end it 'has the proper secondary terms' do - expect(new_form.secondary_terms).to_not include *%i[license resource_type subject] + expect(new_form.secondary_terms).not_to include(*%i[license resource_type subject]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb b/spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb index d20852911..3efb30d24 100644 --- a/spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb +++ b/spec/forms/hyrax/conference_proceedings_or_journal_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by isbn] + expect(described_class.terms).to include(*%i[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by isbn]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/dataset_form_spec.rb b/spec/forms/hyrax/dataset_form_spec.rb index df246a9da..c5118003e 100644 --- a/spec/forms/hyrax/dataset_form_spec.rb +++ b/spec/forms/hyrax/dataset_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection] + expect(described_class.terms).to include(*%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection]) end it 'has the proper required fields' do @@ -23,11 +23,11 @@ end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[nested_ordered_title alternative_title nested_ordered_creator academic_affiliation other_affiliation nested_ordered_contributor nested_ordered_abstract license resource_type doi bibliographic_citation in_series subject rights_statement] + expect(new_form.primary_terms).to include(*%i[nested_ordered_title alternative_title nested_ordered_creator academic_affiliation other_affiliation nested_ordered_contributor nested_ordered_abstract license resource_type doi bibliographic_citation in_series subject rights_statement]) end it 'has the proper secondary terms' do - expect(new_form.secondary_terms).to_not include *%i[license resource_type] + expect(new_form.secondary_terms).not_to include(*%i[license resource_type]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/default_form_spec.rb b/spec/forms/hyrax/default_form_spec.rb index 153b0752a..9cdc5414b 100644 --- a/spec/forms/hyrax/default_form_spec.rb +++ b/spec/forms/hyrax/default_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[isbn issn doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection conference_location conference_name conference_section contributor_advisor] + expect(described_class.terms).to include(*%i[isbn issn doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection conference_location conference_name conference_section contributor_advisor]) end it 'has the proper required fields' do @@ -23,11 +23,11 @@ end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[doi alternative_title nested_ordered_abstract subject license contributor_advisor] + expect(new_form.primary_terms).to include(*%i[doi alternative_title nested_ordered_abstract subject license contributor_advisor]) end it 'has the proper secondary terms' do - expect(new_form.secondary_terms).to_not include *%i[license resource_type subject] + expect(new_form.secondary_terms).not_to include(*%i[license resource_type subject]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/eesc_publication_form_spec.rb b/spec/forms/hyrax/eesc_publication_form_spec.rb index edf4bd30f..141159f65 100644 --- a/spec/forms/hyrax/eesc_publication_form_spec.rb +++ b/spec/forms/hyrax/eesc_publication_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection] + expect(described_class.terms).to include(*%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection]) end it 'has the proper required fields' do @@ -23,11 +23,11 @@ end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[doi alternative_title nested_ordered_abstract subject license] + expect(new_form.primary_terms).to include(*%i[doi alternative_title nested_ordered_abstract subject license]) end it 'has the proper secondary terms' do - expect(new_form.secondary_terms).to_not include *%i[license resource_type subject] + expect(new_form.secondary_terms).not_to include(*%i[license resource_type subject]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/graduate_project_form_spec.rb b/spec/forms/hyrax/graduate_project_form_spec.rb index b515f800e..f9613da16 100644 --- a/spec/forms/hyrax/graduate_project_form_spec.rb +++ b/spec/forms/hyrax/graduate_project_form_spec.rb @@ -15,19 +15,19 @@ end xit 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline] + expect(described_class.terms).to include(*%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline]) end it 'has the proper required fields' do - expect(described_class.required_fields).to include *%i[degree_level degree_name degree_field degree_grantors graduation_year] + expect(described_class.required_fields).to include(*%i[degree_level degree_name degree_field degree_grantors graduation_year]) end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[contributor_advisor contributor_committeemember] + expect(new_form.primary_terms).to include(*%i[contributor_advisor contributor_committeemember]) end xit 'has the proper secondary terms' do - expect(new_form.secondary_terms).to include *%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn] + expect(new_form.secondary_terms).to include(*%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb b/spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb index d8cfca44b..087b325d5 100644 --- a/spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb +++ b/spec/forms/hyrax/graduate_thesis_or_dissertation_form_spec.rb @@ -15,19 +15,19 @@ end xit 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline] + expect(described_class.terms).to include(*%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline]) end it 'has the proper required fields' do - expect(described_class.required_fields).to include *%i[degree_level degree_name degree_field degree_grantors graduation_year] + expect(described_class.required_fields).to include(*%i[degree_level degree_name degree_field degree_grantors graduation_year]) end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[contributor_advisor contributor_committeemember] + expect(new_form.primary_terms).to include(*%i[contributor_advisor contributor_committeemember]) end xit 'has the proper secondary terms' do - expect(new_form.secondary_terms).to include *%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn] + expect(new_form.secondary_terms).to include(*%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/open_educational_resource_form_spec.rb b/spec/forms/hyrax/open_educational_resource_form_spec.rb index 5c4755db1..b3ce0ca3e 100644 --- a/spec/forms/hyrax/open_educational_resource_form_spec.rb +++ b/spec/forms/hyrax/open_educational_resource_form_spec.rb @@ -15,7 +15,7 @@ end xit 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[resource_type is_based_on_url interactivity_type learning_resource_type typical_age_range time_required duration] + expect(described_class.terms).to include(*%i[resource_type is_based_on_url interactivity_type learning_resource_type typical_age_range time_required duration]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/purchased_e_resource_form_spec.rb b/spec/forms/hyrax/purchased_e_resource_form_spec.rb index 5564006b0..50c5d0e5a 100644 --- a/spec/forms/hyrax/purchased_e_resource_form_spec.rb +++ b/spec/forms/hyrax/purchased_e_resource_form_spec.rb @@ -5,8 +5,8 @@ RSpec.describe Hyrax::PurchasedEResourceForm do let(:new_form) { described_class.new(PurchasedEResource.new, nil, double('Controller')) } let(:user) do - User.new(email: 'test@example.com', guest: false) { |u| u.save!(validate: false) } - end + User.new(email: 'test@example.com', guest: false) { |u| u.save!(validate: false) } + end let(:ability) { double('Ability') } before do @@ -15,7 +15,7 @@ end xit 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by] + expect(described_class.terms).to include(*%i[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/technical_report_form_spec.rb b/spec/forms/hyrax/technical_report_form_spec.rb index 1f9919ca5..35f903112 100644 --- a/spec/forms/hyrax/technical_report_form_spec.rb +++ b/spec/forms/hyrax/technical_report_form_spec.rb @@ -15,7 +15,7 @@ end it 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection] + expect(described_class.terms).to include(*%i[doi alternative_title nested_ordered_abstract license based_near resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed nested_ordered_additional_information digitization_spec file_extent file_format dspace_community dspace_collection]) end it 'has the proper required fields' do @@ -23,11 +23,11 @@ end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[doi alternative_title nested_ordered_abstract subject license] + expect(new_form.primary_terms).to include(*%i[doi alternative_title nested_ordered_abstract subject license]) end it 'has the proper secondary terms' do - expect(new_form.secondary_terms).to_not include *%i[license resource_type subject] + expect(new_form.secondary_terms).not_to include(*%i[license resource_type subject]) end it 'responds to date_terms' do diff --git a/spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb b/spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb index cdce9eee7..253b4108b 100644 --- a/spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb +++ b/spec/forms/hyrax/undergraduate_thesis_or_project_form_spec.rb @@ -15,15 +15,15 @@ end xit 'responds to terms with the proper list of terms' do - expect(described_class.terms).to include *%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline] + expect(described_class.terms).to include(*%i[degree_level degree_name degree_field degree_grantors contributor_advisor contributor_committeemember graduation_year degree_discipline]) end it 'has the proper primary terms' do - expect(new_form.primary_terms).to include *%i[contributor_advisor contributor_committeemember degree_level degree_name degree_field degree_grantors graduation_year] + expect(new_form.primary_terms).to include(*%i[contributor_advisor contributor_committeemember degree_level degree_name degree_field degree_grantors graduation_year]) end xit 'has the proper secondary terms' do - expect(new_form.secondary_terms).to include *%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn] + expect(new_form.secondary_terms).to include(*%i[nested_related_items hydrologic_unit_code geo_section funding_statement publisher peerreviewed language file_format file_extent digitization_spec replaces nested_ordered_additional_information isbn issn]) end it 'responds to date_terms' do diff --git a/spec/inputs/multi_value_date_input_spec.rb b/spec/inputs/multi_value_date_input_spec.rb index 5462b56e3..952bc2aad 100644 --- a/spec/inputs/multi_value_date_input_spec.rb +++ b/spec/inputs/multi_value_date_input_spec.rb @@ -9,19 +9,19 @@ class Foo < ActiveFedora::Base end describe '#build_field' do + subject { MultiValueDateInput.new(builder, :multi_value_date, nil, :multi_value, {}) } + let(:foo) { Foo.new } + let(:builder) { double('builder', object: foo, object_name: 'foo') } let(:date1) { '2017-08-03' } let(:date2) { '2017-08-12' } - before { foo.multi_value_date = [date1, date2] } - let(:builder) { double('builder', object: foo, object_name: 'foo') } - - subject { MultiValueDateInput.new(builder, :multi_value_date, nil, :multi_value, {}) } + before { foo.multi_value_date = [date1, date2] } it 'renders multi-value' do - expect(subject).to receive(:build_field).with(date1, Fixnum) - expect(subject).to receive(:build_field).with(date2, Fixnum) - expect(subject).to receive(:build_field).with('', Fixnum) + expect(subject).to receive(:build_field).with(date1, Integer) + expect(subject).to receive(:build_field).with(date2, Integer) + expect(subject).to receive(:build_field).with('', Integer) subject.input({}) end end diff --git a/spec/inputs/multi_value_label_url_input_spec.rb b/spec/inputs/multi_value_label_url_input_spec.rb index 312880334..c02292a01 100644 --- a/spec/inputs/multi_value_label_url_input_spec.rb +++ b/spec/inputs/multi_value_label_url_input_spec.rb @@ -11,18 +11,18 @@ class Foo < ActiveFedora::Base end describe '#build_field' do + subject { MultiValueLabelUrlInput.new(builder, :bar, nil, :multi_value, {}) } + let(:foo) { Foo.new } + let(:builder) { double('builder', object: foo, object_name: 'foo') } let(:ref1) { NestedRelatedItems.new(RDF::Node.new, Default::GeneratedResourceSchema.new) } let(:ref2) { NestedRelatedItems.new(RDF::Node.new, Default::GeneratedResourceSchema.new) } - before { foo.bar = [ref1, ref2] } - let(:builder) { double('builder', object: foo, object_name: 'foo') } - - subject { MultiValueLabelUrlInput.new(builder, :bar, nil, :multi_value, {}) } + before { foo.bar = [ref1, ref2] } it 'renders multi-value' do - expect(subject).to receive(:build_field).with(ref1, Fixnum) - expect(subject).to receive(:build_field).with(ref2, Fixnum) + expect(subject).to receive(:build_field).with(ref1, Integer) + expect(subject).to receive(:build_field).with(ref2, Integer) subject.input({}) end end diff --git a/spec/inputs/multi_value_ordered_input_spec.rb b/spec/inputs/multi_value_ordered_input_spec.rb index 427e321c2..1798f3a82 100644 --- a/spec/inputs/multi_value_ordered_input_spec.rb +++ b/spec/inputs/multi_value_ordered_input_spec.rb @@ -10,7 +10,10 @@ class FooBar < ActiveFedora::Base end describe '#collection' do + subject { MultiValueOrderedInput.new(builder, :nested_ordered_creator, nil, :multi_value, {}) } + let(:foo) { FooBar.new } + let(:builder) { double('builder', object: foo, object_name: 'foo') } let(:creator1) { NestedOrderedCreator.new(RDF::Node.new, Default::GeneratedResourceSchema.new) } let(:creator2) { NestedOrderedCreator.new(RDF::Node.new, Default::GeneratedResourceSchema.new) } @@ -41,10 +44,6 @@ class FooBar < ActiveFedora::Base foo.nested_ordered_creator = [creator1, creator2, creator3, creator4, creator5, creator6] end - let(:builder) { double('builder', object: foo, object_name: 'foo') } - - subject { MultiValueOrderedInput.new(builder, :nested_ordered_creator, nil, :multi_value, {}) } - it 'renders multi-value and checks order' do expect(subject).to receive(:build_field).with(creator1, Integer) expect(subject).to receive(:build_field).with(creator2, Integer) @@ -52,7 +51,7 @@ class FooBar < ActiveFedora::Base expect(subject).to receive(:build_field).with(creator4, Integer) expect(subject).to receive(:build_field).with(creator5, Integer) expect(subject).to receive(:build_field).with(creator6, Integer) - expect(subject.send(:collection).map { |c| c.creator.first }).to eq (%w[creator0 creator1 creator2 creator3 creator10 creator21]) + expect(subject.send(:collection).map { |c| c.creator.first }).to eq(%w[creator0 creator1 creator2 creator3 creator10 creator21]) subject.input({}) end end diff --git a/spec/models/default_spec.rb b/spec/models/default_spec.rb index ab456cdea..56d316070 100644 --- a/spec/models/default_spec.rb +++ b/spec/models/default_spec.rb @@ -38,7 +38,7 @@ g end - it 'should be blank' do + it 'is blank' do expect(facet).to be_nil end end @@ -58,13 +58,13 @@ g end - it 'should be blank' do + it 'is blank' do expect(facet).to be_nil end end context 'when given a date' do - it 'should be that year' do + it 'is that year' do expect(facet).to eq [2022] end end @@ -72,7 +72,7 @@ context 'when given just a year' do let(:date) { '2011' } - it 'should pull the year' do + it 'pulls the year' do expect(facet).to eq [2011] end end @@ -81,7 +81,7 @@ context 'when is a range of dates YYYY-mm-dd/YYY-mm-dd' do let(:date) { '1925-12-01/1927-01-01' } - it 'should have years in that range' do + it 'has years in that range' do expect(facet).to eq [1925, 1926, 1927] end end @@ -89,7 +89,7 @@ context 'when is a range of years only YYYY/YYYY' do let(:date) { '2014/2017' } - it 'should have years in that range' do + it 'has years in that range' do expect(facet).to eq [2014, 2015, 2016, 2017] end end @@ -97,7 +97,7 @@ context 'when is a range of year and month only YYYY-mm/YYY-mm' do let(:date) { '2017-12/2018-01' } - it 'should have years in that range' do + it 'has years in that range' do expect(facet).to eq [2017, 2018] end end @@ -127,7 +127,7 @@ g end - it 'should be blank' do + it 'is blank' do expect(facet).to be_nil end end @@ -144,7 +144,7 @@ end let(:date_created) { '1973-03-09' } - it 'should be that decade' do + it 'is that decade' do expect(facet).to eq ['1970-1979'] end end @@ -160,7 +160,7 @@ end let(:date_copyright) { '1943' } - it 'should be that decade' do + it 'is that decade' do expect(facet).to eq ['1940-1949'] end end @@ -176,14 +176,14 @@ end let(:date_issued) { '1943' } - it 'should be that decade' do + it 'is that decade' do expect(facet).to eq ['1940-1949'] end end end context 'when given a date' do - it 'should be that decade' do + it 'is that decade' do expect(facet).to eq ['2020-2029'] end end @@ -191,7 +191,7 @@ context 'when given just a year' do let(:date) { '2011' } - it 'should pull the date' do + it 'pulls the date' do expect(facet).to eq ['2010-2019'] end end @@ -200,7 +200,7 @@ context 'when is in a single decade' do let(:date) { '1910-1915' } - it 'should have only one entry' do + it 'has only one entry' do expect(facet).to eq ['1910-1919'] end end @@ -208,14 +208,14 @@ context 'which spans decades' do let(:date) { '1910-1920' } - it 'should have two entries' do + it 'has two entries' do expect(facet).to eq %w[1910-1919 1920-1929] end context 'which is more than 30 years' do let(:date) { '1900-1940' } - it 'should be blank' do + it 'is blank' do expect(facet).to be_nil end end @@ -231,7 +231,7 @@ }] end - it 'should be able to delete items' do + it 'is able to delete items' do g = described_class.new(keyword: ['test']) g.nested_geo_attributes = attributes g.nested_geo_attributes = [ @@ -250,14 +250,14 @@ expect(g.nested_geo.first.label).to eq ['Banana'] end - it 'should work on already persisted items' do + it 'works on already persisted items' do g = described_class.new(keyword: ['test']) g.nested_geo_attributes = attributes g.nested_ordered_title_attributes = nested_ordered_title_attributes expect(g.nested_geo.first.label).to eq ['Salem'] end - it 'should be able to edit' do + it 'is able to edit' do g = described_class.new(keyword: ['test']) g.nested_geo_attributes = attributes g.nested_ordered_title_attributes = nested_ordered_title_attributes @@ -270,12 +270,12 @@ expect(g.nested_geo.first.label).to eq ['Banana'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_geo_attributes = [ { label: '', - point: '', + point: '' } ] g.nested_ordered_title_attributes = nested_ordered_title_attributes @@ -283,7 +283,7 @@ end end - it 'should be able to create multiple nested geo points' do + it 'is able to create multiple nested geo points' do g = described_class.new(keyword: ['test']) g.nested_geo_attributes = [ { @@ -306,8 +306,8 @@ }] end - it 'should be able to delete items' do - g = described_class.new() + it 'is able to delete items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = attributes g.nested_ordered_creator_attributes = [ @@ -324,8 +324,8 @@ expect(g.nested_ordered_creator.first.creator).to eq ['CreatorB'] end - it 'should not persist items when all are blank' do - g = described_class.new() + it 'does not persist items when all are blank' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { @@ -340,8 +340,8 @@ expect(g.nested_ordered_creator.length).to eq 0 end - it 'should not persist item when only creator is blank' do - g = described_class.new() + it 'does not persist item when only creator is blank' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { @@ -352,8 +352,8 @@ expect(g.nested_ordered_creator.length).to eq 0 end - it 'should persist item when only index is blank' do - g = described_class.new() + it 'persists item when only index is blank' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { @@ -364,15 +364,15 @@ expect(g.nested_ordered_creator.length).to eq 1 end - it 'should work on already persisted items' do - g = described_class.new() + it 'works on already persisted items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = attributes expect(g.nested_ordered_creator.first.creator).to eq ['CreatorA'] end - it 'should be able to edit' do - g = described_class.new() + it 'is able to edit' do + g = described_class.new g.nested_ordered_creator_attributes = attributes g.nested_ordered_title_attributes = nested_ordered_title_attributes expect(g.nested_ordered_creator.length).to eq 1 @@ -384,21 +384,21 @@ expect(g.nested_ordered_creator.first.creator).to eq ['CreatorB'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { index: '', - creator: '', + creator: '' } ] expect(g.nested_ordered_creator.length).to eq 0 end end - it 'should be able to create multiple nested ordered creators' do - g = described_class.new() + it 'is able to create multiple nested ordered creators' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { @@ -416,8 +416,8 @@ end # Test sort is happening on id as integer, especially for more than 10 items, see Issue #1773 - it 'should return multiple nested ordered creators in correct order' do - g = described_class.new() + it 'returns multiple nested ordered creators in correct order' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_creator_attributes = [ { 'index' => '0', 'creator' => 'Creator0' }, @@ -439,8 +439,8 @@ }] end - it 'should be able to delete items' do - g = described_class.new() + it 'is able to delete items' do + g = described_class.new g.nested_related_items_attributes = attributes g.nested_related_items_attributes = [ { @@ -457,8 +457,8 @@ expect(g.nested_related_items.first.label).to eq ['LabelB'] end - it 'should not persist items when all are blank' do - g = described_class.new() + it 'does not persist items when all are blank' do + g = described_class.new g.nested_ordered_title_attributes = attributes g.nested_related_items_attributes = [ { @@ -475,14 +475,14 @@ expect(g.nested_related_items.length).to eq 0 end - it 'should work on already persisted items' do - g = described_class.new() + it 'works on already persisted items' do + g = described_class.new g.nested_related_items_attributes = attributes expect(g.nested_related_items.first.label).to eq ['LabelA'] end - it 'should be able to edit' do - g = described_class.new() + it 'is able to edit' do + g = described_class.new g.nested_related_items_attributes = attributes expect(g.nested_related_items.length).to eq 1 expect(g.nested_related_items.first.label).to eq ['LabelA'] @@ -493,7 +493,7 @@ expect(g.nested_related_items.first.label).to eq ['LabelB'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_related_items_attributes = [ { @@ -506,8 +506,8 @@ end end - it 'should be able to create multiple nested related items with order index' do - g = described_class.new() + it 'is able to create multiple nested related items with order index' do + g = described_class.new g.nested_related_items_attributes = [ { 'index' => '0', @@ -534,8 +534,8 @@ }] end - it 'should be able to delete items' do - g = described_class.new() + it 'is able to delete items' do + g = described_class.new g.nested_ordered_title_attributes = attributes g.nested_ordered_title_attributes = [ { @@ -551,8 +551,8 @@ expect(g.nested_ordered_title.first.title).to eq ['TitleB'] end - it 'should not persist items when all are blank' do - g = described_class.new() + it 'does not persist items when all are blank' do + g = described_class.new g.nested_ordered_title_attributes = [ { index: '', @@ -566,8 +566,8 @@ expect(g.nested_ordered_title.length).to eq 0 end - it 'should not persist item when only title is blank' do - g = described_class.new() + it 'does not persist item when only title is blank' do + g = described_class.new g.nested_ordered_title_attributes = [ { index: '1', @@ -577,8 +577,8 @@ expect(g.nested_ordered_title.length).to eq 0 end - it 'should persist item when only index is blank' do - g = described_class.new() + it 'persists item when only index is blank' do + g = described_class.new g.nested_ordered_title_attributes = [ { index: '', @@ -588,14 +588,14 @@ expect(g.nested_ordered_title.length).to eq 1 end - it 'should work on already persisted items' do - g = described_class.new() + it 'works on already persisted items' do + g = described_class.new g.nested_ordered_title_attributes = attributes expect(g.nested_ordered_title.first.title).to eq ['TitleA'] end - it 'should be able to edit' do - g = described_class.new() + it 'is able to edit' do + g = described_class.new g.nested_ordered_title_attributes = attributes expect(g.nested_ordered_title.length).to eq 1 expect(g.nested_ordered_title.first.title).to eq ['TitleA'] @@ -606,20 +606,20 @@ expect(g.nested_ordered_title.first.title).to eq ['TitleB'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_ordered_title_attributes = [ { index: '', - title: '', + title: '' } ] expect(g.nested_ordered_title.length).to eq 0 end end - it 'should be able to create multiple nested ordered title' do - g = described_class.new() + it 'is able to create multiple nested ordered title' do + g = described_class.new g.nested_ordered_title_attributes = [ { 'index' => '0', @@ -643,8 +643,8 @@ }] end - it 'should be able to delete items' do - g = described_class.new() + it 'is able to delete items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_contributor_attributes = attributes g.nested_ordered_contributor_attributes = [ @@ -661,8 +661,8 @@ expect(g.nested_ordered_contributor.first.contributor).to eq ['ContributorB'] end - it 'should not persist items when all are blank' do - g = described_class.new() + it 'does not persist items when all are blank' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_contributor_attributes = [ { @@ -677,8 +677,8 @@ expect(g.nested_ordered_contributor.length).to eq 0 end - it 'should not persist item when only contributor is blank' do - g = described_class.new() + it 'does not persist item when only contributor is blank' do + g = described_class.new g.nested_ordered_contributor_attributes = [ { index: '1', @@ -688,8 +688,8 @@ expect(g.nested_ordered_contributor.length).to eq 0 end - it 'should persist item when only index is blank' do - g = described_class.new() + it 'persists item when only index is blank' do + g = described_class.new g.nested_ordered_contributor_attributes = [ { index: '', @@ -699,15 +699,15 @@ expect(g.nested_ordered_contributor.length).to eq 1 end - it 'should work on already persisted items' do - g = described_class.new() + it 'works on already persisted items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_contributor_attributes = attributes expect(g.nested_ordered_contributor.first.contributor).to eq ['ContributorA'] end - it 'should be able to edit' do - g = described_class.new() + it 'is able to edit' do + g = described_class.new g.nested_ordered_contributor_attributes = attributes g.nested_ordered_title_attributes = nested_ordered_title_attributes expect(g.nested_ordered_contributor.length).to eq 1 @@ -719,13 +719,13 @@ expect(g.nested_ordered_contributor.first.contributor).to eq ['ContributorB'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_contributor_attributes = [ { index: '', - contributor: '', + contributor: '' } ] expect(g.nested_ordered_contributor.length).to eq 0 @@ -740,8 +740,8 @@ }] end - it 'should be able to delete items' do - g = described_class.new() + it 'is able to delete items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_abstract_attributes = attributes g.nested_ordered_abstract_attributes = [ @@ -758,8 +758,8 @@ expect(g.nested_ordered_abstract.first.abstract).to eq ['AbstractB'] end - it 'should not persist items when all are blank' do - g = described_class.new() + it 'does not persist items when all are blank' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_abstract_attributes = [ { @@ -774,8 +774,8 @@ expect(g.nested_ordered_abstract.length).to eq 0 end - it 'should not persist item when only abstract is blank' do - g = described_class.new() + it 'does not persist item when only abstract is blank' do + g = described_class.new g.nested_ordered_abstract_attributes = [ { index: '1', @@ -785,8 +785,8 @@ expect(g.nested_ordered_abstract.length).to eq 0 end - it 'should persist item when only index is blank' do - g = described_class.new() + it 'persists item when only index is blank' do + g = described_class.new g.nested_ordered_abstract_attributes = [ { index: '', @@ -796,15 +796,15 @@ expect(g.nested_ordered_abstract.length).to eq 1 end - it 'should work on already persisted items' do - g = described_class.new() + it 'works on already persisted items' do + g = described_class.new g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_abstract_attributes = attributes expect(g.nested_ordered_abstract.first.abstract).to eq ['AbstractA'] end - it 'should be able to edit' do - g = described_class.new() + it 'is able to edit' do + g = described_class.new g.nested_ordered_abstract_attributes = attributes g.nested_ordered_title_attributes = nested_ordered_title_attributes expect(g.nested_ordered_abstract.length).to eq 1 @@ -816,13 +816,13 @@ expect(g.nested_ordered_abstract.first.abstract).to eq ['AbstractB'] end - it 'should not create blank ones' do + it 'does not create blank ones' do g = described_class.new(keyword: ['test']) g.nested_ordered_title_attributes = nested_ordered_title_attributes g.nested_ordered_abstract_attributes = [ { index: '', - abstract: '', + abstract: '' } ] expect(g.nested_ordered_abstract.length).to eq 0 diff --git a/spec/models/nested_geo_spec.rb b/spec/models/nested_geo_spec.rb index 23f52c560..93e7b7dd9 100644 --- a/spec/models/nested_geo_spec.rb +++ b/spec/models/nested_geo_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe NestedGeo do - subject { NestedGeo.new(uri, parent) } + subject { described_class.new(uri, parent) } let(:uri) { RDF::Node.new } let(:parent) { Default::GeneratedResourceSchema.new } @@ -13,7 +13,7 @@ context 'with a string hash uri' do let(:uri) { '#bla_46' } - it 'should make it a URI' do + it 'makes it a URI' do expect(subject.rdf_subject).to eq RDF::URI('#bla_46') end end diff --git a/spec/models/nested_ordered_creator_spec.rb b/spec/models/nested_ordered_creator_spec.rb index 0d9260052..8a3d3db8f 100644 --- a/spec/models/nested_ordered_creator_spec.rb +++ b/spec/models/nested_ordered_creator_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe NestedOrderedCreator do - subject { NestedOrderedCreator.new(uri, parent) } + subject { described_class.new(uri, parent) } let(:uri) { RDF::Node.new } let(:parent) { Default::GeneratedResourceSchema.new } @@ -13,7 +13,7 @@ context 'with a string hash uri' do let(:uri) { '#bla_46' } - it 'should make it a URI' do + it 'makes it a URI' do expect(subject.rdf_subject).to eq RDF::URI('#bla_46') end end diff --git a/spec/models/nested_ordered_title_spec.rb b/spec/models/nested_ordered_title_spec.rb index f617a54f8..e6a578d68 100644 --- a/spec/models/nested_ordered_title_spec.rb +++ b/spec/models/nested_ordered_title_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe NestedOrderedTitle do - subject { NestedOrderedTitle.new(uri, parent) } + subject { described_class.new(uri, parent) } let(:uri) { RDF::Node.new } let(:parent) { Default::GeneratedResourceSchema.new } @@ -13,7 +13,7 @@ context 'with a string hash uri' do let(:uri) { '#bla_46' } - it 'should make it a URI' do + it 'makes it a URI' do expect(subject.rdf_subject).to eq RDF::URI('#bla_46') end end diff --git a/spec/models/nested_related_items_spec.rb b/spec/models/nested_related_items_spec.rb index 2714db157..f22a76e43 100644 --- a/spec/models/nested_related_items_spec.rb +++ b/spec/models/nested_related_items_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe NestedRelatedItems do - subject { NestedRelatedItems.new(uri, parent) } + subject { described_class.new(uri, parent) } let(:uri) { RDF::Node.new } let(:parent) { Default::GeneratedResourceSchema.new } @@ -13,7 +13,7 @@ context 'with a string hash uri' do let(:uri) { '#bla_46' } - it 'should make it a URI' do + it 'makes it a URI' do expect(subject.rdf_subject).to eq RDF::URI('#bla_46') end end diff --git a/spec/models/other_option_spec.rb b/spec/models/other_option_spec.rb index 5ca9ec3d7..21a2cceb4 100644 --- a/spec/models/other_option_spec.rb +++ b/spec/models/other_option_spec.rb @@ -9,6 +9,6 @@ it 'is not valid without a proper attributes' do other = described_class.new(name: nil, work_id: nil, property_name: nil) - expect(other).to_not be_valid + expect(other).not_to be_valid end end diff --git a/spec/models/search_builder_spec.rb b/spec/models/search_builder_spec.rb index bc2ed5b02..ccfa9ee8d 100644 --- a/spec/models/search_builder_spec.rb +++ b/spec/models/search_builder_spec.rb @@ -1,21 +1,3 @@ # frozen_string_literal: true require 'rails_helper' - -describe SearchBuilder do - let(:user_params) { Hash.new } - let(:blacklight_config) { Blacklight::Configuration.new } - let(:scope) { double blacklight_config: blacklight_config } - - subject(:search_builder) { described_class.new scope } - - # describe "my custom step" do - # subject(:query_parameters) do - # search_builder.with(user_params).processed_parameters - # end - # - # it "adds my custom data" do - # expect(query_parameters).to include :custom_data - # end - # end -end diff --git a/spec/models/solr_document_spec.rb b/spec/models/solr_document_spec.rb index 92fba8459..3dbcd25cd 100644 --- a/spec/models/solr_document_spec.rb +++ b/spec/models/solr_document_spec.rb @@ -8,7 +8,7 @@ document = described_class.new({ 'academic_affiliation_label_ssim' => ['label1$www.blah.com'] }) - it 'should return the label' do + it 'returns the label' do expect(document.academic_affiliation_label).to eq [{ 'label' => 'label1', 'uri' => 'www.blah.com' }] end end @@ -19,7 +19,7 @@ document = described_class.new({ 'other_affiliation_label_ssim' => ['label1$www.blah.com'] }) - it 'should return the label' do + it 'returns the label' do expect(document.other_affiliation_label).to eq [{ 'label' => 'label1', 'uri' => 'www.blah.com' }] end end @@ -31,7 +31,7 @@ document = described_class.new({ 'funding_body_linked_ssim' => ['label1$www.blah.com'] }) - it 'should return the label' do + it 'returns the label' do expect(document.funding_body_label).to eq [{ 'label' => 'label1', 'uri' => 'www.blah.com' }] end end @@ -42,7 +42,7 @@ document = described_class.new({ 'embargo_date_range_ssim' => 'first_date to second_date' }) - it 'should return the range' do + it 'returns the range' do expect(document.embargo_date_range).to eq 'first_date to second_date' end end @@ -53,7 +53,7 @@ document = described_class.new({ 'degree_grantors_label_ssim' => ['label1$www.blah.com'] }) - it 'should return the label' do + it 'returns the label' do expect(document.degree_grantors_label).to eq [{ 'label' => 'label1', 'uri' => 'www.blah.com' }] end end @@ -61,7 +61,7 @@ describe '#nested_geo' do context 'when there are no geo points' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'nested_geo_label_ssim' => [] }) @@ -70,7 +70,7 @@ end context 'when there are geo coordinates' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_geo_label_ssim' => ['Test'] }) @@ -81,7 +81,7 @@ describe '#nested_related_items' do context 'when there are no related items' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'nested_related_items_label_ssim' => [] }) @@ -90,7 +90,7 @@ end context 'when there are related items' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_related_items_label_ssim' => ['label1$www.blah.com$0'] }) @@ -101,7 +101,7 @@ describe '#nested_ordered_creator' do context 'when there are no ordered creators' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'nested_ordered_creator_label_ssim' => [] }) @@ -110,7 +110,7 @@ end context 'when there are ordered creators' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_creator_label_ssim' => ['creator1$0'] }) @@ -121,7 +121,7 @@ describe '#title' do context 'when there are no core metadata titles and no ordered titles' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'title_tesim' => [] }) @@ -130,7 +130,7 @@ end context 'when there are only ordered titles' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_title_label_ssim' => ['title3$0', 'title4$1'] }) @@ -139,7 +139,7 @@ end context 'when there are only core metadata titles' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'title_tesim' => %w[title2 title1] }) @@ -148,10 +148,10 @@ end context 'when there are both core metadata titles and ordered titles' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'title_tesim' => %w[title1 title2], - 'nested_ordered_title_label_ssim' => ['title3$0', 'title4$1'], + 'nested_ordered_title_label_ssim' => ['title3$0', 'title4$1'] }) expect(document.title).to eq %w[title3 title4] end @@ -160,7 +160,7 @@ describe '#creator' do context 'when there are no core metadata creators and no ordered creators' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'creator_tesim' => [] }) @@ -169,7 +169,7 @@ end context 'when there are only ordered creators' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_creator_label_ssim' => ['creatorA$0', 'creatorB$1'] }) @@ -178,7 +178,7 @@ end context 'when there are only core metadata creators' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'creator_tesim' => %w[creatorB creatorA] }) @@ -187,10 +187,10 @@ end context 'when there are both core metadata creators and ordered creators' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'creator_tesim' => %w[creatorA creatorB], - 'nested_ordered_creator_label_ssim' => ['creatorC$0', 'creatorD$1'], + 'nested_ordered_creator_label_ssim' => ['creatorC$0', 'creatorD$1'] }) expect(document.creator).to eq %w[creatorC creatorD] end @@ -199,7 +199,7 @@ describe '#abstract' do context 'when there are no core metadata abstracts and no ordered abstracts' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'abstract_tesim' => [] }) @@ -208,7 +208,7 @@ end context 'when there are only ordered abstracts' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_abstract_label_ssim' => ['abstractA$0', 'abstractB$1'] }) @@ -217,7 +217,7 @@ end context 'when there are only old abstracts' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'abstract_tesim' => %w[abstractB abstractA] }) @@ -226,10 +226,10 @@ end context 'when there are both old and ordered abstracts' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'abstract_tesim' => %w[abstractA abstractB], - 'nested_ordered_abstract_label_ssim' => ['abstractC$0', 'abstractD$1'], + 'nested_ordered_abstract_label_ssim' => ['abstractC$0', 'abstractD$1'] }) expect(document.abstract).to eq %w[abstractC abstractD] end @@ -238,7 +238,7 @@ describe '#additional_information' do context 'when there are no core metadata additional_informations and no ordered additional_informations' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'additional_information_tesim' => [] }) @@ -247,7 +247,7 @@ end context 'when there are only ordered additional_informations' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_additional_information_label_ssim' => ['additional_informationA$0', 'additional_informationB$1'] }) @@ -256,7 +256,7 @@ end context 'when there are only core metadata additional_informations' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'additional_information_tesim' => %w[additional_informationB additional_informationA] }) @@ -265,10 +265,10 @@ end context 'when there are both core metadata creators and ordered additional_informations' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'additional_information_ssim' => %w[additional_informationA additional_informationB], - 'nested_ordered_additional_information_label_ssim' => ['additional_informationC$0', 'additional_informationD$1'], + 'nested_ordered_additional_information_label_ssim' => ['additional_informationC$0', 'additional_informationD$1'] }) expect(document.additional_information).to eq %w[additional_informationC additional_informationD] end @@ -277,7 +277,7 @@ describe '#nested_ordered_title' do context 'when there are no ordered titles' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'nested_ordered_title_label_ssim' => [] }) @@ -286,7 +286,7 @@ end context 'when there are ordered titles' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'nested_ordered_title_label_ssim' => ['title1$0'] }) @@ -297,7 +297,7 @@ describe '#oai_nested_related_items_label' do context 'when there are no related items' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'nested_related_items_label_ssim' => [] }) @@ -306,7 +306,7 @@ end context 'when there are related items' do - it 'should return their labels and uris as array' do + it 'returns their labels and uris as array' do document = described_class.new({ 'nested_related_items_label_ssim' => ['label1$www.blah.com$0', 'label3$www.example.org$1'] }) @@ -317,7 +317,7 @@ describe '#oai_academic_affiliation_label' do context 'when there are no related items' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'academic_affiliation_label_ssim' => [] }) @@ -326,7 +326,7 @@ end context 'when there are academic affiliations' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'academic_affiliation_label_ssim' => ['Technical Journalism$http://opaquenamespace.org/ns/osuAcademicUnits/DhPwxzf1', 'Aerospace Studies$http://opaquenamespace.org/ns/osuAcademicUnits/Rn0bhPiY'] }) @@ -337,7 +337,7 @@ describe '#oai_other_affiliation_label' do context 'when there are no related items' do - it 'should return an empty array' do + it 'returns an empty array' do document = described_class.new({ 'other_affiliation_label_ssim' => [] }) @@ -346,7 +346,7 @@ end context 'when there are other (non-academic) affiliations' do - it 'should return their labels' do + it 'returns their labels' do document = described_class.new({ 'other_affiliation_label_ssim' => ['OSU Press$http://id.loc.gov/authorities/names/n82039655', 'Honors College$http://opaquenamespace.org/ns/subject/OregonStateUniversityHonorsCollege'] }) @@ -357,7 +357,7 @@ describe '#oai_rights' do context 'when there is only a Rights Statement' do - it 'should return the Rights Statement label' do + it 'returns the Rights Statement label' do document = described_class.new({ 'rights_statement_label_ssim' => ['In Copyright - Educational Use Permitted'] }) @@ -366,7 +366,7 @@ end context 'when there is only a License' do - it 'should return the License label' do + it 'returns the License label' do document = described_class.new({ 'license_label_ssim' => ['CC0 1.0 Universal'] }) @@ -375,7 +375,7 @@ end context 'when there is both a Rights Statement and a License' do - it 'should return only the License label' do + it 'returns only the License label' do document = described_class.new({ 'rights_statement_label_ssim' => ['In Copyright - Educational Use Permitted'], 'license_label_ssim' => ['CC0 1.0 Universal'] @@ -387,7 +387,7 @@ describe '#oai_identifier' do context 'when there is an item' do - it 'should return the web identifier for OAI use' do + it 'returns the web identifier for OAI use' do document = described_class.new({ 'has_model_ssim' => ['Default'], 'id' => ['xw42n789j'] diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 244f9798a..896725dce 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -9,7 +9,7 @@ it 'has an email' do expect(user.email).to be_kind_of String - expect(user.email).to eq ('test@example.com') + expect(user.email).to eq('test@example.com') end it 'has mailbox-related methods defined' do diff --git a/spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb b/spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb index 8baa4be5c..06a1a2770 100644 --- a/spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb +++ b/spec/presenters/hyrax/administrative_report_or_publication_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe AdministrativeReportOrPublicationPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[doi abstract alternative_title license based_near_linked resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed_label digitization_spec file_extent file_format dspace_community dspace_collection] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/article_presenter_spec.rb b/spec/presenters/hyrax/article_presenter_spec.rb index 2ac0c31dc..c3455139d 100644 --- a/spec/presenters/hyrax/article_presenter_spec.rb +++ b/spec/presenters/hyrax/article_presenter_spec.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true RSpec.describe ArticlePresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -27,8 +29,6 @@ %w[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by isbn web_of_science_uid] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb b/spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb index cd80683ed..d966567bd 100644 --- a/spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb +++ b/spec/presenters/hyrax/conference_proceedings_or_journal_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe ConferenceProceedingsOrJournalPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,15 +22,14 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } let(:solr_properties) do %w[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by isbn] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/dataset_presenter_spec.rb b/spec/presenters/hyrax/dataset_presenter_spec.rb index c41763094..8620b1415 100644 --- a/spec/presenters/hyrax/dataset_presenter_spec.rb +++ b/spec/presenters/hyrax/dataset_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe DatasetPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[doi abstract alternative_title license based_near_linked resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed_label digitization_spec file_extent file_format dspace_community dspace_collection] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/default_presenter_spec.rb b/spec/presenters/hyrax/default_presenter_spec.rb index 546c9e247..9fcbee3bc 100644 --- a/spec/presenters/hyrax/default_presenter_spec.rb +++ b/spec/presenters/hyrax/default_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe DefaultPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[doi abstract alternative_title license based_near_linked resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed_label digitization_spec file_extent file_format dspace_community dspace_collection] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/eesc_publication_presenter_spec.rb b/spec/presenters/hyrax/eesc_publication_presenter_spec.rb index 136094f30..1578eb5c1 100644 --- a/spec/presenters/hyrax/eesc_publication_presenter_spec.rb +++ b/spec/presenters/hyrax/eesc_publication_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe EescPublicationPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[doi abstract alternative_title license based_near_linked resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed_label digitization_spec file_extent file_format dspace_community dspace_collection] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/graduate_project_presenter_spec.rb b/spec/presenters/hyrax/graduate_project_presenter_spec.rb index 02d462691..4e8e43533 100644 --- a/spec/presenters/hyrax/graduate_project_presenter_spec.rb +++ b/spec/presenters/hyrax/graduate_project_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe GraduateProjectPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[contributor_advisor contributor_committeemember degree_discipline degree_field degree_grantors degree_level degree_name graduation_year] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb b/spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb index 671ceb08a..643dd7da1 100644 --- a/spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb +++ b/spec/presenters/hyrax/graduate_thesis_or_dissertation_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe GraduateThesisOrDissertationPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[contributor_advisor contributor_committeemember degree_discipline degree_field degree_grantors degree_level degree_name graduation_year] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb b/spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb index 644965c16..dda3a1186 100644 --- a/spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb +++ b/spec/presenters/hyrax/honors_college_thesis_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe HonorsCollegeThesisPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -27,8 +29,6 @@ %i[contributor_advisor contributor_committeemember degree_discipline degree_field degree_grantors degree_level degree_name graduation_year] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(presenter).to delegate_method(property).to(:solr_document) diff --git a/spec/presenters/hyrax/open_educational_resource_presenter_spec.rb b/spec/presenters/hyrax/open_educational_resource_presenter_spec.rb index 60eec85ca..24bb45123 100644 --- a/spec/presenters/hyrax/open_educational_resource_presenter_spec.rb +++ b/spec/presenters/hyrax/open_educational_resource_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe OpenEducationalResourcePresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[is_based_on_url interactivity_type learning_resource_type typical_age_range time_required duration] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb b/spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb index 70c1431d2..c8ea8f077 100644 --- a/spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb +++ b/spec/presenters/hyrax/purchased_e_resource_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe PurchasedEResourcePresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,15 +22,14 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } let(:solr_properties) do %w[resource_type editor has_volume has_number conference_location conference_name conference_section has_journal is_referenced_by isbn] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/technical_report_presenter_spec.rb b/spec/presenters/hyrax/technical_report_presenter_spec.rb index 7bc4bdea4..5f85397b4 100644 --- a/spec/presenters/hyrax/technical_report_presenter_spec.rb +++ b/spec/presenters/hyrax/technical_report_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe TechnicalReportPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[doi abstract alternative_title license based_near_linked resource_type date_available date_copyright date_issued date_collected date_reviewed date_valid date_accepted replaces hydrologic_unit_code funding_body funding_statement in_series tableofcontents bibliographic_citation peerreviewed_label digitization_spec file_extent file_format dspace_community dspace_collection] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb b/spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb index cfe3bd7cf..92fe2e753 100644 --- a/spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb +++ b/spec/presenters/hyrax/undergraduate_thesis_or_project_presenter_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe UndergraduateThesisOrProjectPresenter do + subject { presenter } + let(:solr_document) { SolrDocument.new(attributes) } let(:ability) { double 'Ability' } let(:presenter) { described_class.new(solr_document, ability) } @@ -20,7 +22,8 @@ id: '123abc', nested_ordered_title_attributes: nested_ordered_title_attributes, depositor: user.user_key, - label: 'filename.tif') + label: 'filename.tif' + ) end let(:user) { double(user_key: 'sarah') } @@ -28,8 +31,6 @@ %w[contributor_advisor contributor_committeemember degree_discipline degree_field degree_grantors degree_level degree_name graduation_year] end - subject { presenter } - it 'delegates to the solr_document' do solr_properties.each do |property| expect(solr_document).to receive(property.to_sym) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 895652998..6a2bfbc28 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,7 @@ ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path('../config/environment', __dir__) # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' @@ -12,7 +12,7 @@ require 'triplestore_adapter' require 'shoulda/matchers' -Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f } # Add additional requires below this line. Rails is not loaded until this point! diff --git a/spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb b/spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb index 41e949b09..b25e718e7 100644 --- a/spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb +++ b/spec/renderers/hyrax/renderers/scholars_archive_nested_attribute_renderer_spec.rb @@ -46,7 +46,7 @@ Sholars archive nested diff --git a/spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb b/spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb index 779a502d9..4b4a0ce5c 100644 --- a/spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb +++ b/spec/scholars_archive/triple_powered_properties/triple_powered_form_spec.rb @@ -4,14 +4,14 @@ RSpec.describe ScholarsArchive::TriplePoweredProperties::TriplePoweredForm do describe '#has_triple_powered_property?' do - let(:form) { Hyrax::DefaultForm.new(Default.new({ based_near: [ url ], title: ['TestTest'] }), instance_double('Ability'), instance_double('Controller')) } + let(:form) { Hyrax::DefaultForm.new(Default.new({ based_near: [url], title: ['TestTest'] }), instance_double('Ability'), instance_double('Controller')) } let(:url) { 'http://opaquenamespace.org/ns/TestVocabulary/TestTerm' } xit 'should return a truthy statement if it has a triple powered property' do expect(form.has_triple_powered_property?({ field: :based_near })).to eq true end - it 'should return a falsey statement if it does not have a triple powered property' do + it 'returns a falsey statement if it does not have a triple powered property' do expect(form.has_triple_powered_property?({ field: :anything_else })).to eq false end end diff --git a/spec/scholars_archive/validators/other_affiliation_validator_spec.rb b/spec/scholars_archive/validators/other_affiliation_validator_spec.rb index 1de2892e5..202a1c973 100644 --- a/spec/scholars_archive/validators/other_affiliation_validator_spec.rb +++ b/spec/scholars_archive/validators/other_affiliation_validator_spec.rb @@ -23,7 +23,7 @@ } end - let(:test_other_affiliation_other) { [ 'test entry one', 'test entry two'] } + let(:test_other_affiliation_other) { ['test entry one', 'test entry two'] } before do allow_any_instance_of(User).to receive(:admin?).and_return(true) @@ -39,7 +39,7 @@ end context 'with invalid other values selected for degree_field and degree_level' do - let(:test_other_affiliation_other) { [ 'Oregon State University Bioenergy Minor Program'] } + let(:test_other_affiliation_other) { ['Oregon State University Bioenergy Minor Program'] } it 'raises error if the other_affiliation entry already exists' do expect(record.errors[:other_affiliation_other].first).to eq "This 'Other' value: \"Oregon State University Bioenergy Minor Program\" already exists, please select from the list." diff --git a/spec/scholars_archive/validators/other_option_degree_validator_spec.rb b/spec/scholars_archive/validators/other_option_degree_validator_spec.rb index bfb566435..da71f77eb 100644 --- a/spec/scholars_archive/validators/other_option_degree_validator_spec.rb +++ b/spec/scholars_archive/validators/other_option_degree_validator_spec.rb @@ -31,7 +31,7 @@ let(:test_degree_level_other) { 'test1 degree level other' } let(:test_degree_name_other) { ['test1 degree name other'] } let(:test_degree_grantors_other) { 'test1 degree grantors other' } - let(:test_other_affiliation_other) { [ 'test entry one', 'test entry two'] } + let(:test_other_affiliation_other) { ['test entry one', 'test entry two'] } before do allow(depositor).to receive(:admin?).and_return(true) @@ -53,7 +53,7 @@ let(:test_degree_field_other) { ['Zoology'] } let(:test_degree_name_other) { ['Master of Arts (M.A.)'] } let(:test_degree_grantors_other) { 'Oregon State University' } - let(:test_other_affiliation_other) { [ 'Bioenergy Minor Program'] } + let(:test_other_affiliation_other) { ['Bioenergy Minor Program'] } it 'raises error if the degree level already exists' do expect(record.errors[:degree_level_other].first).to eq "This 'Other' value: \"Certificate\" already exists, please select from the list." @@ -78,10 +78,6 @@ let(:test_degree_name_other) { [] } let(:test_degree_grantors_other) { '' } - before do - # curation_concern.id = "test3" - end - it 'raises error if degree_level is blank' do expect(record.errors[:degree_level_other].first).to eq nil end diff --git a/spec/services/hyrax/workflow/deletion_approval_notification_spec.rb b/spec/services/hyrax/workflow/deletion_approval_notification_spec.rb index 1f7c59fed..154d4f5f9 100644 --- a/spec/services/hyrax/workflow/deletion_approval_notification_spec.rb +++ b/spec/services/hyrax/workflow/deletion_approval_notification_spec.rb @@ -14,14 +14,12 @@ end let(:work) { Article.create(title: ['New Article']) } let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: [depositor.username]) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: [depositor.username]) end let(:permission_template) do Hyrax::PermissionTemplate.create!(source_id: admin_set.id) diff --git a/spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb b/spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb index 8a635c056..b1c9b18f5 100644 --- a/spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb +++ b/spec/services/hyrax/workflow/deletion_request_rejection_notification_spec.rb @@ -14,14 +14,12 @@ end let(:work) { Article.create(title: ['New Article']) } let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: [depositor.username]) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: [depositor.username]) end let(:permission_template) do Hyrax::PermissionTemplate.create!(source_id: admin_set.id) diff --git a/spec/services/hyrax/workflow/pending_deletion_notification_spec.rb b/spec/services/hyrax/workflow/pending_deletion_notification_spec.rb index d72e86d6b..163fd4125 100644 --- a/spec/services/hyrax/workflow/pending_deletion_notification_spec.rb +++ b/spec/services/hyrax/workflow/pending_deletion_notification_spec.rb @@ -14,14 +14,12 @@ end let(:work) { Article.create(title: ['New Article']) } let(:admin_set) do - begin - AdminSet.find('blah') - rescue ActiveFedora::ObjectNotFoundError - AdminSet.create(id: 'blah', - title: ['title'], - description: ['A substantial description'], - edit_users: [depositor.username]) - end + AdminSet.find('blah') + rescue ActiveFedora::ObjectNotFoundError + AdminSet.create(id: 'blah', + title: ['title'], + description: ['A substantial description'], + edit_users: [depositor.username]) end let(:permission_template) do Hyrax::PermissionTemplate.create!(source_id: admin_set.id) diff --git a/spec/services/scholars_archive/all_facet_values_service_spec.rb b/spec/services/scholars_archive/all_facet_values_service_spec.rb index 1cc5d265b..a8df91a1a 100644 --- a/spec/services/scholars_archive/all_facet_values_service_spec.rb +++ b/spec/services/scholars_archive/all_facet_values_service_spec.rb @@ -12,12 +12,12 @@ describe '#call' do before do allow(facet).to receive(:key).and_return(facet_key) - allow(service).to receive(:catalog_search_params).with(anything()).and_return({}) - allow(service).to receive(:solr_facets).with(anything(), anything()).and_return(solr_results) + allow(service).to receive(:catalog_search_params).with(anything).and_return({}) + allow(service).to receive(:solr_facets).with(anything, anything).and_return(solr_results) end it 'returns all unique creators in an array' do - expect(service.call(facet, {})).to eq (facet_results) + expect(service.call(facet, {})).to eq(facet_results) end end end diff --git a/spec/services/scholars_archive/edtf_date_compare_service_spec.rb b/spec/services/scholars_archive/edtf_date_compare_service_spec.rb index 45f8942ec..d0b0debc9 100644 --- a/spec/services/scholars_archive/edtf_date_compare_service_spec.rb +++ b/spec/services/scholars_archive/edtf_date_compare_service_spec.rb @@ -18,7 +18,7 @@ context 'when date is in the last five years and not open' do let(:active_option) { ['Animal Sciences - 1984/2013', 'http://opaquenamespace.org/ns/osuAcademicUnits/EaDtECbp'] } - it 'should not include the option in the list' do + it 'does not include the option in the list' do expect(described_class.includes_open_dates?(active_option)).to eq false end end @@ -26,7 +26,7 @@ context 'when date is in the last five years and is open' do let(:active_option) { ['Animal and Rangeland Sciences - 2013/open', 'http://opaquenamespace.org/ns/osuAcademicUnits/ZWAvMfi7'] } - it 'it should include the option in the list' do + it 'includes the option in the list' do expect(described_class.includes_open_dates?(active_option)).to eq true end end @@ -34,7 +34,7 @@ context 'when date is not in the last five years' do let(:active_option) { ['4-H Youth Development Education - 2006/2010', 'http://opaquenamespace.org/ns/osuAcademicUnits/5eh7OKFX'] } - it 'should not include the option in the list' do + it 'does not include the option in the list' do expect(described_class.includes_open_dates?(active_option)).to eq false end end diff --git a/spec/services/scholars_archive/osu_api_service_spec.rb b/spec/services/scholars_archive/osu_api_service_spec.rb index eaf745f3d..7d44ea111 100644 --- a/spec/services/scholars_archive/osu_api_service_spec.rb +++ b/spec/services/scholars_archive/osu_api_service_spec.rb @@ -27,7 +27,7 @@ 'emailAddress' => 'bogus.email', 'username' => 'bogususername', 'alternatePhoneNumber' => nil, - 'osuuid' => 12345678901 }, + 'osuuid' => 12_345_678_901 }, 'links' => { 'self' => 'https://api.oregonstate.edu/v1/directory/12345678901' } } end let(:response_status) { 200 } @@ -41,7 +41,7 @@ r end - before(:each) do + before do allow_any_instance_of(described_class).to receive(:get_token).and_return('fakie') end @@ -50,7 +50,7 @@ end describe '#get_person' do - before(:each) do + before do allow(service).to receive(:get).and_return(response) end diff --git a/spec/services/scholars_archive/parent_query_service_spec.rb b/spec/services/scholars_archive/parent_query_service_spec.rb index 433fa6a97..32ad5f6b0 100644 --- a/spec/services/scholars_archive/parent_query_service_spec.rb +++ b/spec/services/scholars_archive/parent_query_service_spec.rb @@ -10,7 +10,7 @@ describe '#query_parents_for_id' do context 'when a child work exists with a parent' do before do - allow(ActiveFedora::SolrService).to receive(:get).with("member_ids_ssim:#{child_id}", rows: 100000).and_return(parent_doc) + allow(ActiveFedora::SolrService).to receive(:get).with("member_ids_ssim:#{child_id}", rows: 100_000).and_return(parent_doc) end it 'returns the parent works' do @@ -20,7 +20,7 @@ context 'when a work exists without a parent' do before do - allow(ActiveFedora::SolrService).to receive(:get).with("member_ids_ssim:#{child_id}", rows: 100000).and_return(empty_results) + allow(ActiveFedora::SolrService).to receive(:get).with("member_ids_ssim:#{child_id}", rows: 100_000).and_return(empty_results) end it 'returns an empty array' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6a1de1309..4fb2bec29 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,54 +67,52 @@ config.shared_context_metadata_behavior = :apply_to_host_groups # The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = 'doc' - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # with RSpec, but feel free to customize to your heart's content. + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = 'doc' + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed config.before do |example| if example.metadata[:type] == :feature && Capybara.current_driver != :rack_test DatabaseCleaner.strategy = :truncation diff --git a/spec/views/records/edit_fields/_degree_field.html.erb_spec.rb b/spec/views/records/edit_fields/_degree_field.html.erb_spec.rb index 06d358b90..a60372e1e 100644 --- a/spec/views/records/edit_fields/_degree_field.html.erb_spec.rb +++ b/spec/views/records/edit_fields/_degree_field.html.erb_spec.rb @@ -108,9 +108,10 @@ end context "for a work with degree field where 'Other' was not selected" do - let(:attributes) do { title: ['test'], creator: ['Blah'], rights_statement: ['blah.blah'], resource_type: ['blah'], degree_field: - ['Animal Breeding - 1952', 'http://opaquenamespace.org/ns/osuDegreeFields/KWzvXUyz'] - } end + let(:attributes) do + { title: ['test'], creator: ['Blah'], rights_statement: ['blah.blah'], resource_type: ['blah'], degree_field: + ['Animal Breeding - 1952', 'http://opaquenamespace.org/ns/osuDegreeFields/KWzvXUyz'] } + end before do allow_any_instance_of(ScholarsArchive::DegreeFieldService).to receive(:select_sorted_all_options).and_return([%w[Other Other]]) diff --git a/spec/views/records/edit_fields/_geo_section.html.erb_spec.rb b/spec/views/records/edit_fields/_geo_section.html.erb_spec.rb index 83414335c..eee0d88c5 100644 --- a/spec/views/records/edit_fields/_geo_section.html.erb_spec.rb +++ b/spec/views/records/edit_fields/_geo_section.html.erb_spec.rb @@ -48,8 +48,10 @@ before do assign(:curation_concern, work) - form.nested_geo.each { |geo| geo.point.present? ? geo.type = :point.to_s : '' } - form.nested_geo.each { |geo| geo.point.present? ? geo.point = "#{test_point[:label]} (#{test_point[:point]})" : '' } + form.nested_geo.each do |geo| + geo.point.present? ? geo.type = :point.to_s : '' + geo.point.present? ? geo.point = "#{test_point[:label]} (#{test_point[:point]})" : '' + end assign(:form, form) render inline: form_template end @@ -84,8 +86,10 @@ before do assign(:curation_concern, work) - form.nested_geo.each { |geo| geo.bbox.present? ? geo.type = :bbox.to_s : '' } - form.nested_geo.each { |geo| geo.bbox.present? ? geo.bbox = "#{test_box[:label]} (#{test_box[:bbox]})" : '' } + form.nested_geo.each do |geo| + geo.bbox.present? ? geo.type = :bbox.to_s : '' + geo.bbox.present? ? geo.bbox = "#{test_box[:label]} (#{test_box[:bbox]})" : '' + end assign(:form, form) render inline: form_template end