diff --git a/Gemfile b/Gemfile index 6918a672eb..870abf17c7 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,8 @@ group :test do gem 'chromedriver-helper' gem 'database_cleaner' gem 'factory_girl_rails' + # rack-test >= 0.71 does not work with older Capybara versions (< 2.17). See #214 for more details + gem 'rack-test', '0.7.0' gem 'rails-controller-testing' gem 'selenium-webdriver' gem 'webmock' @@ -79,7 +81,7 @@ end gem 'blacklight', '~> 6.7' gem 'blacklight_oai_provider', '~> 6.0' -gem 'hyrax', '2.0.2' +gem 'hyrax', '2.1.0' gem 'rsolr', '~> 2.0' gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 553efa512d..4af66cfa3e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.4) - actionpack (= 5.1.4) + actioncable (5.1.6) + actionpack (= 5.1.6) nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) + actionmailer (5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.4) - actionview (= 5.1.4) - activesupport (= 5.1.4) + actionpack (5.1.6) + actionview (= 5.1.6) + activesupport (= 5.1.6) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.4) - activesupport (= 5.1.4) + actionview (5.1.6) + activesupport (= 5.1.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -45,24 +45,20 @@ GEM rails (>= 4.2) active_encode (0.1.1) activesupport - active_fedora-noid (2.2.0) - active-fedora (>= 9.7, < 12) - noid (~> 0.9) - rails (>= 5.0.0, < 6) - activejob (5.1.4) - activesupport (= 5.1.4) + activejob (5.1.6) + activesupport (= 5.1.6) globalid (>= 0.3.6) - activemodel (5.1.4) - activesupport (= 5.1.4) - activerecord (5.1.4) - activemodel (= 5.1.4) - activesupport (= 5.1.4) + activemodel (5.1.6) + activesupport (= 5.1.6) + activerecord (5.1.6) + activemodel (= 5.1.6) + activesupport (= 5.1.6) arel (~> 8.0) - activerecord-import (0.22.0) + activerecord-import (0.24.0) activerecord (>= 3.2) - activesupport (5.1.4) + activesupport (5.1.6) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) addressable (2.5.2) @@ -80,13 +76,13 @@ GEM execjs awesome_nested_set (3.1.4) activerecord (>= 4.0.0, < 5.3) - aws-sdk (2.10.84) - aws-sdk-resources (= 2.10.84) - aws-sdk-core (2.10.84) + aws-sdk (2.11.76) + aws-sdk-resources (= 2.11.76) + aws-sdk-core (2.11.76) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.10.84) - aws-sdk-core (= 2.10.84) + aws-sdk-resources (2.11.76) + aws-sdk-core (= 2.11.76) aws-sigv4 (1.0.2) babel-source (5.8.35) babel-transpiler (0.7.0) @@ -96,7 +92,7 @@ GEM i18n bcrypt (3.1.11) bindex (0.5.0) - blacklight (6.12.0) + blacklight (6.15.0) bootstrap-sass (~> 3.2) deprecation globalid @@ -110,7 +106,7 @@ GEM blacklight (~> 6.0) cancancan (~> 1.8) deprecation (~> 1.0) - blacklight-gallery (0.9.0) + blacklight-gallery (0.10.0) blacklight (~> 6.3) bootstrap-sass (~> 3.0) openseadragon (>= 0.2.0) @@ -147,7 +143,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carrierwave (1.2.1) + carrierwave (1.2.2) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) @@ -176,7 +172,7 @@ GEM activesupport (>= 3.0) deep_merge (~> 1.1.1) dry-validation (~> 0.10.4) - connection_pool (2.2.1) + connection_pool (2.2.2) coveralls (0.8.21) json (>= 1.8, < 3) simplecov (~> 0.14.1) @@ -186,7 +182,7 @@ GEM crack (0.4.3) safe_yaml (~> 1.0.0) crass (1.0.4) - daemons (1.2.5) + daemons (1.2.6) database_cleaner (1.6.1) declarative (0.0.10) declarative-option (0.1.0) @@ -214,26 +210,26 @@ GEM dry-container (0.6.0) concurrent-ruby (~> 1.0) dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.1) + dry-core (0.4.7) concurrent-ruby (~> 1.0) - dry-equalizer (0.2.0) + dry-equalizer (0.2.1) + dry-inflector (0.1.2) dry-logic (0.4.2) dry-container (~> 0.2, >= 0.2.6) dry-core (~> 0.2) dry-equalizer (~> 0.2) - dry-struct (0.4.0) - dry-core (~> 0.4, >= 0.4.1) + dry-struct (0.5.0) + dry-core (~> 0.4, >= 0.4.3) dry-equalizer (~> 0.2) - dry-types (~> 0.12, >= 0.12.2) + dry-types (~> 0.13) ice_nine (~> 0.11) - dry-types (0.12.2) + dry-types (0.13.2) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1) dry-container (~> 0.3) - dry-core (~> 0.2, >= 0.2.1) + dry-core (~> 0.4, >= 0.4.4) dry-equalizer (~> 0.2) + dry-inflector (~> 0.1, >= 0.1.2) dry-logic (~> 0.4, >= 0.4.2) - inflecto (~> 0.0.0, >= 0.0.2) dry-validation (0.10.7) concurrent-ruby (~> 1.0) dry-configurable (~> 0.1, >= 0.1.3) @@ -245,12 +241,12 @@ GEM json thread thread_safe - ebnf (1.1.1) - rdf (~> 2.2) + ebnf (1.1.2) + rdf (>= 2.2, < 4.0) sxp (~> 1.0) equivalent-xml (0.6.0) nokogiri (>= 1.4.3) - erubi (1.7.0) + erubi (1.7.1) erubis (2.7.0) et-orbi (1.1.6) tzinfo @@ -269,7 +265,7 @@ GEM fcrepo_wrapper (0.9.0) ruby-progressbar ffi (1.9.18) - flipflop (2.3.1) + flipflop (2.4.0) activesupport (>= 4.0) flot-rails (0.0.7) jquery-rails @@ -280,15 +276,15 @@ GEM raabro (~> 1.1) globalid (0.4.1) activesupport (>= 4.2.0) - google-api-client (0.19.8) + google-api-client (0.23.0) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.5, < 0.7.0) httpclient (>= 2.8.1, < 3.0) mime-types (~> 3.0) representable (~> 3.0) retriable (>= 2.0, < 4.0) - google_drive (2.1.9) - google-api-client (>= 0.11.0, < 0.20.0) + google_drive (2.1.3) + google-api-client (>= 0.11.0, < 1.0.0) googleauth (>= 0.5.0, < 1.0.0) nokogiri (>= 1.5.3, < 2.0.0) googleauth (0.6.2) @@ -317,15 +313,15 @@ GEM mime-types (~> 3.0) multi_xml (>= 0.5.2) httpclient (2.8.3) - hydra-access-controls (10.5.0) + hydra-access-controls (10.5.1) active-fedora (>= 10.0.0, < 12) activesupport (>= 4, < 6) blacklight (>= 5.16) blacklight-access_controls (~> 0.6) cancancan (~> 1.8) deprecation (~> 1.0) - hydra-core (10.5.0) - hydra-access-controls (= 10.5.0) + hydra-core (10.5.1) + hydra-access-controls (= 10.5.1) railties (>= 4.0.0, < 6) hydra-derivatives (3.4.1) active-fedora (>= 11.3.1, < 13) @@ -335,7 +331,7 @@ GEM deprecation mime-types (> 2.0, < 4.0) mini_magick (>= 3.2, < 5) - hydra-editor (3.3.2) + hydra-editor (4.0.2) active-fedora (>= 9.0.0) almond-rails (~> 0.1) cancancan (~> 1.8) @@ -344,9 +340,9 @@ GEM sprockets-es6 hydra-file_characterization (0.3.3) activesupport (>= 3.0.0) - hydra-head (10.5.0) - hydra-access-controls (= 10.5.0) - hydra-core (= 10.5.0) + hydra-head (10.5.1) + hydra-access-controls (= 10.5.1) + hydra-core (= 10.5.1) rails (>= 3.2.6) hydra-pcdm (0.11.0) active-fedora (>= 10, < 13) @@ -356,12 +352,11 @@ GEM hydra-file_characterization (~> 0.3, >= 0.3.3) hydra-pcdm (>= 0.9) om (~> 3.1) - hyrax (2.0.2) + hyrax (2.1.0) active-fedora (~> 11.5, >= 11.5.2) - active_fedora-noid (~> 2.0, >= 2.0.2) almond-rails (~> 0.1) awesome_nested_set (~> 3.1) - blacklight (~> 6.9) + blacklight (~> 6.14) blacklight-gallery (~> 0.7) breadcrumbs_on_rails (~> 3.0) browse-everything (>= 0.10.5) @@ -374,21 +369,24 @@ GEM flot-rails (~> 0.0.6) font-awesome-rails (~> 4.2) hydra-derivatives (~> 3.3) - hydra-editor (~> 3.3) + hydra-editor (>= 3.3, < 5.0) hydra-head (>= 10.5.0) hydra-works (~> 0.16) + iiif_manifest (>= 0.3, < 0.5) jquery-datatables-rails (~> 3.4) - jquery-ui-rails (~> 5.0) + jquery-ui-rails (~> 6.0) json-schema kaminari_route_prefix (~> 0.1.1) legato (~> 0.3) linkeddata mailboxer (~> 0.12) - nest (~> 2.0) + nest (~> 3.1) + noid-rails (~> 3.0.0) oauth oauth2 (~> 1.2) posix-spawn power_converter (~> 0.1, >= 0.1.2) + pul_uv_rails (~> 2.0) qa (~> 2.0) rails (~> 5.0) rails_autolink (~> 1.1) @@ -396,11 +394,12 @@ GEM redis-namespace (~> 1.5) redlock (>= 0.1.2) retriable (>= 2.9, < 4.0) + samvera-nesting_indexer (~> 2.0) select2-rails (~> 3.5) signet simple_form (~> 3.2, <= 3.5.0) tinymce-rails (~> 4.1) - i18n (0.9.1) + i18n (0.9.5) concurrent-ruby (~> 1.0) i18n-debug (1.1.0) i18n (< 1) @@ -422,33 +421,32 @@ GEM iiif_manifest (0.3.0) activesupport (>= 4) iiif-presentation (~> 0.2.0) - inflecto (0.0.2) io-like (0.3.0) is_it_working (1.1.0) iso-639 (0.2.8) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) - jmespath (1.3.1) + jmespath (1.4.0) jquery-datatables-rails (3.4.0) actionpack (>= 3.1) jquery-rails railties (>= 3.1) sass-rails - jquery-rails (4.3.1) + jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) json (2.1.0) - json-ld (2.1.7) + json-ld (2.2.1) multi_json (~> 1.12) - rdf (~> 2.2, >= 2.2.8) - json-ld-preloaded (2.2.2) - json-ld (~> 2.1, >= 2.1.5) - multi_json (~> 1.11) - rdf (~> 2.2) + rdf (>= 2.2.8, < 4.0) + json-ld-preloaded (2.2.3) + json-ld (>= 2.2, < 4.0) + multi_json (~> 1.12) + rdf (>= 2.2, < 4.0) json-schema (2.8.0) addressable (>= 2.4) jwt (1.5.6) @@ -472,7 +470,7 @@ GEM rdf-xsd (>= 2.2, < 4.0) sparql (>= 2.2, < 4.0) sxp (~> 1.0) - ldp (0.7.0) + ldp (0.7.2) deprecation faraday http_logger @@ -538,21 +536,24 @@ GEM mini_magick (4.8.0) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.10.3) + minitest (5.11.3) mods (2.1.0) iso-639 nokogiri nom-xml (~> 0.6.0) - multi_json (1.12.2) + multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.0.0) - nest (2.1.0) + nest (3.1.1) redic net-http-persistent (3.0.0) connection_pool (~> 2.2) - nio4r (2.1.0) + nio4r (2.3.1) noid (0.9.0) - nokogiri (1.8.2) + noid-rails (3.0.0) + actionpack (>= 5.0.0, < 6) + noid (~> 0.9) + nokogiri (1.8.3) mini_portile2 (~> 2.3.0) nom-xml (0.6.0) activesupport (>= 3.2.18) @@ -574,7 +575,7 @@ GEM activesupport nokogiri (>= 1.4.2) solrizer (~> 3.3) - openseadragon (0.4.0) + openseadragon (0.5.0) rails (> 3.2.0) orm_adapter (0.5.0) os (0.9.6) @@ -585,7 +586,8 @@ GEM posix-spawn (0.3.13) power_converter (0.1.2) powerpack (0.1.1) - public_suffix (3.0.1) + public_suffix (3.0.2) + pul_uv_rails (2.0.1) puma (3.9.1) qa (2.0.1) activerecord-import @@ -600,17 +602,17 @@ GEM rack rack-test (0.7.0) rack (>= 1.0, < 3) - rails (5.1.4) - actioncable (= 5.1.4) - actionmailer (= 5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) - activemodel (= 5.1.4) - activerecord (= 5.1.4) - activesupport (= 5.1.4) + rails (5.1.6) + actioncable (= 5.1.6) + actionmailer (= 5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) + activemodel (= 5.1.6) + activerecord (= 5.1.6) + activesupport (= 5.1.6) bundler (>= 1.3.0) - railties (= 5.1.4) + railties (= 5.1.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) @@ -623,15 +625,15 @@ GEM loofah (~> 2.2, >= 2.2.2) rails_autolink (1.1.6) rails (> 3.1) - railties (5.1.4) - actionpack (= 5.1.4) - activesupport (= 5.1.4) + railties (5.1.6) + actionpack (= 5.1.6) + activesupport (= 5.1.6) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) rake - rake (12.3.0) + rake (12.3.1) rb-fsevent (0.9.8) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) @@ -640,8 +642,8 @@ GEM link_header (~> 0.0, >= 0.0.8) rdf-aggregate-repo (2.2.1) rdf (>= 2.2, < 4.0) - rdf-isomorphic (2.0.0) - rdf (~> 2.0) + rdf-isomorphic (2.2.0) + rdf (>= 2.0, < 4.0) rdf-json (2.2.0) rdf (>= 2.2, < 4.0) rdf-microdata (2.2.3) @@ -681,11 +683,11 @@ GEM rdf-turtle (>= 2.2, < 4.0) rdf-trix (2.2.1) rdf (>= 2.2, < 4.0) - rdf-turtle (2.2.1) + rdf-turtle (2.2.2) ebnf (~> 1.1) - rdf (~> 2.2) - rdf-vocab (2.2.8) - rdf (~> 2.2) + rdf (>= 2.2, < 4.0) + rdf-vocab (2.2.9) + rdf (>= 2.2, < 4.0) rdf-xsd (2.2.1) rdf (>= 2.2, < 4.0) redic (1.5.0) @@ -706,7 +708,7 @@ GEM riiif (1.4.4) railties (>= 4.2, < 6) rolify (5.1.0) - rsolr (2.1.0) + rsolr (2.2.1) builder (>= 2.1.2) faraday (>= 0.9.0) rspec (3.6.0) @@ -748,6 +750,8 @@ GEM ruby_dep (1.5.0) rubyzip (1.2.1) safe_yaml (1.0.4) + samvera-nesting_indexer (2.0.0) + dry-equalizer sass (3.4.25) sass-rails (5.0.7) railties (>= 4.0.0, < 6) @@ -769,11 +773,11 @@ GEM faraday (>= 0.7.6, < 1.0) shex (0.5.1) ebnf (~> 1.1) - json-ld (~> 2.1) - json-ld-preloaded (~> 2.1) - rdf (~> 2.2) - rdf-xsd (~> 2.2) - sparql (~> 2.2) + json-ld (>= 2.2, < 4.0) + json-ld-preloaded (>= 2.2, < 4.0) + rdf (>= 2.2, < 4.0) + rdf-xsd (>= 2.2, < 4.0) + sparql (>= 2.2, < 4.0) sxp (~> 1.0) sidekiq (5.0.3) concurrent-ruby (~> 1.0) @@ -801,7 +805,7 @@ GEM httmultiparty httparty (>= 0.11.0) oauth2 (>= 0.9.2) - slop (4.6.0) + slop (4.6.2) solr_wrapper (2.0.0) faraday retriable @@ -840,8 +844,8 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) stomp (1.4.4) - sxp (1.0.0) - rdf (~> 2.0) + sxp (1.0.1) + rdf (>= 2.2, < 4.0) temple (0.8.0) term-ansicolor (1.6.0) tins (~> 1.0) @@ -852,7 +856,7 @@ GEM thread_safe (0.3.6) tilt (2.0.8) tins (1.14.0) - tinymce-rails (4.7.9) + tinymce-rails (4.7.13) railties (>= 3.1.1) turbolinks (5.0.1) turbolinks-source (~> 5) @@ -861,7 +865,7 @@ GEM actionpack (>= 3.1) jquery-rails railties (>= 3.1) - tzinfo (1.2.4) + tzinfo (1.2.5) thread_safe (~> 0.1) uber (0.1.0) uglifier (3.2.0) @@ -928,6 +932,7 @@ DEPENDENCIES mods (~> 2.1) pg puma (~> 3.7) + rack-test (= 0.7.0) rails (~> 5.1.1) rails-controller-testing riiif (~> 1.1) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ed808999f4..bab830966d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,7 +1,7 @@ # TODO: move to hyrax? class AdminController < ApplicationController before_action :ensure_admin! - layout 'dashboard' + layout 'hyrax/dashboard' private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3b483c2ea0..e99b6785a0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -20,6 +20,7 @@ class ApplicationController < ActionController::Base before_action :require_active_account!, if: :multitenant? before_action :set_account_specific_connections! + skip_after_action :discard_flash_if_xhr before_action :set_raven_context diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 854694bb50..3d7d5bc12a 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -3,7 +3,7 @@ # existing users class RolesController < ApplicationController load_and_authorize_resource :user, parent: false - layout 'dashboard' + layout 'hyrax/dashboard' before_action do authorize! :manage, Role diff --git a/app/controllers/sites_controller.rb b/app/controllers/sites_controller.rb index 5dc6a3b3cd..eb824538d7 100644 --- a/app/controllers/sites_controller.rb +++ b/app/controllers/sites_controller.rb @@ -1,7 +1,7 @@ class SitesController < ApplicationController before_action :set_site load_and_authorize_resource instance_variable: :site, class: 'Site' # descendents still auth Site - layout 'dashboard' + layout 'hyrax/dashboard' def update params.require(:remove_banner_image) diff --git a/app/controllers/status_controller.rb b/app/controllers/status_controller.rb index a55b7fdf97..de5d5839af 100644 --- a/app/controllers/status_controller.rb +++ b/app/controllers/status_controller.rb @@ -1,5 +1,5 @@ class StatusController < ApplicationController - layout 'dashboard' + layout 'hyrax/dashboard' before_action do authorize! :read, :admin_dashboard diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..a009ace51c --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/jobs/import_work_from_purl_job.rb b/app/jobs/import_work_from_purl_job.rb index 675ee517d6..bff4df934f 100644 --- a/app/jobs/import_work_from_purl_job.rb +++ b/app/jobs/import_work_from_purl_job.rb @@ -42,6 +42,8 @@ def process_attributes(attributes) # rename :rights to :license attributes[:license] = attributes.delete(:rights) + attributes[:collection][:collection_type] ||= Hyrax::CollectionType.find_or_create_default_collection_type + process_collection(attributes) filenames = attributes.delete(:files) attributes[:remote_files] = filenames.map do |name| @@ -63,7 +65,8 @@ def process_attributes(attributes) visibility id collection - files] + files + collection_type] def process_collection(attributes) # rename :collection to :member_of_collection_ids diff --git a/db/migrate/20180524010238_create_collection_types.hyrax.rb b/db/migrate/20180524010238_create_collection_types.hyrax.rb new file mode 100644 index 0000000000..80a5a4455e --- /dev/null +++ b/db/migrate/20180524010238_create_collection_types.hyrax.rb @@ -0,0 +1,17 @@ +class CreateCollectionTypes < ActiveRecord::Migration[5.1] + def change + create_table :hyrax_collection_types do |t| + t.string :title + t.text :description + t.string :machine_id + t.boolean :nestable, null: false, default: true + t.boolean :discovery, null: false, default: true + t.boolean :sharing, null: false, default: true + t.boolean :multiple_membership, null: false, default: true + t.boolean :require_membership, null: false, default: false + t.boolean :workflow, null: false, default: false + t.boolean :visibility, null: false, default: false + end + add_index :hyrax_collection_types, :machine_id + end +end diff --git a/db/migrate/20180524010239_update_collection_type_column_names.hyrax.rb b/db/migrate/20180524010239_update_collection_type_column_names.hyrax.rb new file mode 100644 index 0000000000..01078fe455 --- /dev/null +++ b/db/migrate/20180524010239_update_collection_type_column_names.hyrax.rb @@ -0,0 +1,9 @@ +class UpdateCollectionTypeColumnNames < ActiveRecord::Migration[5.1] + def change + rename_column :hyrax_collection_types, :discovery, :discoverable + rename_column :hyrax_collection_types, :sharing, :sharable + rename_column :hyrax_collection_types, :multiple_membership, :allow_multiple_membership + rename_column :hyrax_collection_types, :workflow, :assigns_workflow + rename_column :hyrax_collection_types, :visibility, :assigns_visibility + end +end diff --git a/db/migrate/20180524010240_update_collection_type_column_options.hyrax.rb b/db/migrate/20180524010240_update_collection_type_column_options.hyrax.rb new file mode 100644 index 0000000000..9d4ad46f32 --- /dev/null +++ b/db/migrate/20180524010240_update_collection_type_column_options.hyrax.rb @@ -0,0 +1,17 @@ +class UpdateCollectionTypeColumnOptions < ActiveRecord::Migration[5.1] + def up + change_column :hyrax_collection_types, :title, :string, unique: true + change_column :hyrax_collection_types, :machine_id, :string, unique: true + + remove_index :hyrax_collection_types, :machine_id + add_index :hyrax_collection_types, :machine_id, unique: true + end + + def down + change_column :hyrax_collection_types, :title, :string + change_column :hyrax_collection_types, :machine_id, :string + + remove_index :hyrax_collection_types, :machine_id + add_index :hyrax_collection_types, :machine_id + end +end diff --git a/db/migrate/20180524010241_create_collection_branding_infos.hyrax.rb b/db/migrate/20180524010241_create_collection_branding_infos.hyrax.rb new file mode 100644 index 0000000000..2e84b08ee9 --- /dev/null +++ b/db/migrate/20180524010241_create_collection_branding_infos.hyrax.rb @@ -0,0 +1,15 @@ +class CreateCollectionBrandingInfos < ActiveRecord::Migration[5.1] + def change + create_table :collection_branding_infos do |t| + t.string :collection_id + t.string :role + t.string :local_path + t.string :alt_text + t.string :target_url + t.integer :height + t.integer :width + + t.timestamps + end + end +end diff --git a/db/migrate/20180524010242_create_collection_type_participants.hyrax.rb b/db/migrate/20180524010242_create_collection_type_participants.hyrax.rb new file mode 100644 index 0000000000..cf234d7808 --- /dev/null +++ b/db/migrate/20180524010242_create_collection_type_participants.hyrax.rb @@ -0,0 +1,11 @@ +class CreateCollectionTypeParticipants < ActiveRecord::Migration[5.1] + def change + create_table :collection_type_participants do |t| + t.references :hyrax_collection_type, foreign_key: true, index: {:name => "hyrax_collection_type_id"} + t.string :agent_type + t.string :agent_id + t.string :access + t.timestamps + end + end +end diff --git a/db/migrate/20180524010243_rename_admin_set_id_to_source_id.hyrax.rb b/db/migrate/20180524010243_rename_admin_set_id_to_source_id.hyrax.rb new file mode 100644 index 0000000000..7510a56a71 --- /dev/null +++ b/db/migrate/20180524010243_rename_admin_set_id_to_source_id.hyrax.rb @@ -0,0 +1,5 @@ +class RenameAdminSetIdToSourceId < ActiveRecord::Migration[5.1] + def change + rename_column :permission_templates, :admin_set_id, :source_id + end +end diff --git a/db/migrate/20180524010244_add_collection_type_sharing_options.hyrax.rb b/db/migrate/20180524010244_add_collection_type_sharing_options.hyrax.rb new file mode 100644 index 0000000000..88aac630a4 --- /dev/null +++ b/db/migrate/20180524010244_add_collection_type_sharing_options.hyrax.rb @@ -0,0 +1,5 @@ +class AddCollectionTypeSharingOptions < ActiveRecord::Migration[5.1] + def change + add_column :hyrax_collection_types, :share_applies_to_new_works, :boolean, null: false, default: true + end +end diff --git a/db/migrate/20180524010245_add_unique_constraint_to_permission_template_accesses.hyrax.rb b/db/migrate/20180524010245_add_unique_constraint_to_permission_template_accesses.hyrax.rb new file mode 100644 index 0000000000..046a274813 --- /dev/null +++ b/db/migrate/20180524010245_add_unique_constraint_to_permission_template_accesses.hyrax.rb @@ -0,0 +1,8 @@ +class AddUniqueConstraintToPermissionTemplateAccesses < ActiveRecord::Migration[5.1] + def change + add_index :permission_template_accesses, + [:permission_template_id, :agent_id, :agent_type, :access], + unique: true, + name: 'uk_permission_template_accesses' + end +end diff --git a/db/migrate/20180524010246_add_branding_to_collection_type.hyrax.rb b/db/migrate/20180524010246_add_branding_to_collection_type.hyrax.rb new file mode 100644 index 0000000000..07ed867675 --- /dev/null +++ b/db/migrate/20180524010246_add_branding_to_collection_type.hyrax.rb @@ -0,0 +1,5 @@ +class AddBrandingToCollectionType < ActiveRecord::Migration[5.1] + def change + add_column :hyrax_collection_types, :brandable, :boolean, null: false, default: true + end +end diff --git a/db/migrate/20180524010247_add_badge_color_to_collection_types.hyrax.rb b/db/migrate/20180524010247_add_badge_color_to_collection_types.hyrax.rb new file mode 100644 index 0000000000..8a8333897a --- /dev/null +++ b/db/migrate/20180524010247_add_badge_color_to_collection_types.hyrax.rb @@ -0,0 +1,5 @@ +class AddBadgeColorToCollectionTypes < ActiveRecord::Migration[5.1] + def change + add_column :hyrax_collection_types, :badge_color, :string, default: '#663333' + end +end diff --git a/db/schema.rb b/db/schema.rb index 15c572eba2..eff6f86ae5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -59,6 +59,28 @@ t.index ["file_set_id", "file_id"], name: "by_file_set_id_and_file_id" end + create_table "collection_branding_infos", force: :cascade do |t| + t.string "collection_id" + t.string "role" + t.string "local_path" + t.string "alt_text" + t.string "target_url" + t.integer "height" + t.integer "width" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "collection_type_participants", force: :cascade do |t| + t.bigint "hyrax_collection_type_id" + t.string "agent_type" + t.string "agent_id" + t.string "access" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["hyrax_collection_type_id"], name: "hyrax_collection_type_id" + end + create_table "content_blocks", id: :serial, force: :cascade do |t| t.string "name" t.text "value" @@ -160,6 +182,23 @@ t.datetime "updated_at", null: false end + create_table "hyrax_collection_types", force: :cascade do |t| + t.string "title" + t.text "description" + t.string "machine_id" + t.boolean "nestable", default: true, null: false + t.boolean "discoverable", default: true, null: false + t.boolean "sharable", default: true, null: false + t.boolean "allow_multiple_membership", default: true, null: false + t.boolean "require_membership", default: false, null: false + t.boolean "assigns_workflow", default: false, null: false + t.boolean "assigns_visibility", default: false, null: false + t.boolean "share_applies_to_new_works", default: true, null: false + t.boolean "brandable", default: true, null: false + t.string "badge_color", default: "#663333" + t.index ["machine_id"], name: "index_hyrax_collection_types_on_machine_id", unique: true + end + create_table "hyrax_features", id: :serial, force: :cascade do |t| t.string "key", null: false t.boolean "enabled", default: false, null: false @@ -261,16 +300,17 @@ t.string "access" t.datetime "created_at" t.datetime "updated_at" + t.index ["permission_template_id", "agent_id", "agent_type", "access"], name: "uk_permission_template_accesses", unique: true end create_table "permission_templates", id: :serial, force: :cascade do |t| - t.string "admin_set_id" + t.string "source_id" t.string "visibility" t.datetime "created_at" t.datetime "updated_at" t.date "release_date" t.string "release_period" - t.index ["admin_set_id"], name: "index_permission_templates_on_admin_set_id", unique: true + t.index ["source_id"], name: "index_permission_templates_on_source_id", unique: true end create_table "proxy_deposit_requests", id: :serial, force: :cascade do |t| @@ -656,6 +696,7 @@ add_foreign_key "accounts", "endpoints", column: "fcrepo_endpoint_id", on_delete: :nullify add_foreign_key "accounts", "endpoints", column: "redis_endpoint_id", on_delete: :nullify add_foreign_key "accounts", "endpoints", column: "solr_endpoint_id", on_delete: :nullify + add_foreign_key "collection_type_participants", "hyrax_collection_types" add_foreign_key "content_blocks", "sites" add_foreign_key "curation_concerns_operations", "users" add_foreign_key "mailboxer_conversation_opt_outs", "mailboxer_conversations", column: "conversation_id", name: "mb_opt_outs_on_conversations_id" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..e55fbf2fe9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,209 @@ +version: '2' + +volumes: + fcrepo: + solr: + db: + redis: + zk1: + zk2: + zk3: + zkconf: + app: + +networks: + external: + internal: + +services: + zoo1: + image: zookeeper + restart: always + environment: + - ZOO_MY_ID=1 + - ZOO_SERVERS=server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 + expose: + - 2181 + - 2888 + - 3888 + volumes: + - zk1:/data + - zkconf:/conf + networks: + internal: + aliases: + - zookeeper_cluster + zoo2: + image: zookeeper + restart: always + environment: + - ZOO_MY_ID=2 + - ZOO_SERVERS=server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 + expose: + - 2181 + - 2888 + - 3888 + volumes: + - zk2:/data + - zkconf:/conf + networks: + internal: + aliases: + - zookeeper_cluster + zoo3: + image: zookeeper + restart: always + environment: + - ZOO_MY_ID=3 + - ZOO_SERVERS=server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 + expose: + - 2181 + - 2888 + - 3888 + volumes: + - zk3:/data + - zkconf:/conf + networks: + internal: + aliases: + - zookeeper_cluster + + solr: + image: solr + command: solr -c -f -z zookeeper_cluster:2181 + depends_on: + - zoo1 + - zoo2 + - zoo3 + expose: + - 8983 + volumes: + - .:/app + - solr:/opt/solr/server/solr + networks: + internal: + + fcrepo: + image: cbeer/fcrepo4:4.7 + expose: + - 8080 + volumes: + - fcrepo:/data + environment: + - JAVA_OPTS=${JAVA_OPTS} -Dfcrepo.modeshape.configuration="classpath:/config/file-simple/repository.json" -Dfcrepo.object.directory="/data/objects" -Dfcrepo.binary.directory="/data/binaries" + networks: + internal: + + db: + image: postgres + volumes: + - db:/var/lib/postgresql/data + networks: + internal: + + app: + build: . + environment: + - REDIS_HOST=redis + - DATABASE_URL=postgresql://postgres@db/postgres + - FEDORA_URL=http://fcrepo:8080/fcrepo/rest + - SOLR_URL=http://solr:8983/solr/ + - SETTINGS__ACTIVE_JOB__QUEUE_ADAPTER=sidekiq + - SETTINGS__MULTITENANCY__ADMIN_ONLY_TENANT_CREATION=false + - SETTINGS__SOLR__URL=http://solr:8983/solr/ + - SETTINGS__ZOOKEEPER__CONNECTION_STR=zookeeper_cluster:2181/configs + - RAILS_ENV=production + - RAILS_SERVE_STATIC_FILES=true + - RAILS_LOG_TO_STDOUT=true + - SECRET_KEY_BASE=asdf + - RAILS_CACHE_STORE_URL=memcache +# version and location of fits are set in Dockerfile: + - LD_LIBRARY_PATH=/opt/fits-1.0.5/tools/mediainfo/linux + volumes: + - app:/data/tmp/uploads + networks: + internal: + + web: + extends: + service: app + command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails server -p 3000 -b '0.0.0.0'" + depends_on: + - db + - solr + - fcrepo + - redis + - zoo1 + - zoo2 + - zoo3 + - memcache + - db_migrate + expose: + - 3000 + + workers: + extends: + service: app + command: bundle exec sidekiq + environment: + - SETTINGS__FITS_PATH=/opt/fits-1.0.5/fits.sh + depends_on: + - db + - solr + - fcrepo + - redis + - zoo1 + - zoo2 + - zoo3 + - initialize_app + - db_migrate + + initialize_app: + extends: + service: app + restart: on-failure + command: bundle exec rails zookeeper:upload + depends_on: + - zoo1 + - zoo2 + - zoo3 + + db_migrate: + extends: + service: app + restart: on-failure + command: bundle exec rails db:migrate + depends_on: + - db + + lb: + image: dockercloud/haproxy:1.5.3 + links: + - web + environment: + - DOCKER_TLS_VERIFY + - DOCKER_HOST + - DOCKER_CERT_PATH + ports: + - 8080:80 + - 8443:443 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + # You must uncomment this line if and only if you are running docker-machine + # - $DOCKER_CERT_PATH:$DOCKER_CERT_PATH + networks: + internal: + external: + + redis: + image: redis:3 + command: redis-server + volumes: + - redis:/data + networks: + internal: + + memcache: + image: memcached + networks: + internal: diff --git a/lib/importer/factory/object_factory.rb b/lib/importer/factory/object_factory.rb index ae7d78b41a..451fc04dd4 100644 --- a/lib/importer/factory/object_factory.rb +++ b/lib/importer/factory/object_factory.rb @@ -34,7 +34,7 @@ def update end def create_attributes - transform_attributes + { collection_type: collection_type }.merge(transform_attributes) end def update_attributes @@ -58,6 +58,10 @@ def search_by_identifier klass.where(query).first end + def collection_type + @collection_type ||= Hyrax::CollectionType.find_or_create_default_collection_type + end + # An ActiveFedora bug when there are many habtm <-> has_many associations means they won't all get saved. # https://github.com/projecthydra/active_fedora/issues/874 # 2+ years later, still open! diff --git a/lib/tasks/upgrade.rake b/lib/tasks/upgrade.rake new file mode 100644 index 0000000000..9b917112b2 --- /dev/null +++ b/lib/tasks/upgrade.rake @@ -0,0 +1,30 @@ +require 'fileutils' + +namespace :hyku do + namespace :upgrade do + desc 'Clean up migration duplications between new hyrax migrations and existing migrations' + task 'clean_migrations', [:datestub] => [:environment] do |_cmd, args| + unless args.datestub + error_message = <<-MESSAGE + Requires a partial date match that is the date that `hyrax:install:migrations` + was run like `rails hyku:upgrade:clean_migrations[20180524]` + MESSAGE + raise ArgumentError, error_message + end + Dir.chdir(Rails.root.join('db', 'migrate')) do + Dir.glob("#{args.datestub}*") do |file| + core = file.split(".")[0].split("_")[1..-1].join("_") + matches = Dir.glob("*#{core}.rb") + + Dir.glob("*#{core}.blacklight.rb") + + Dir.glob("*#{core}.sufia.rb") + + Dir.glob("*#{core}.curation_concerns.rb") + + if matches.present? + FileUtils.rm(file) + puts "Removed: #{file}" + end + end + end + end + end +end diff --git a/solr/config/solrconfig.xml b/solr/config/solrconfig.xml index a05a5b1f2e..6c761fd247 100644 --- a/solr/config/solrconfig.xml +++ b/solr/config/solrconfig.xml @@ -283,7 +283,8 @@ --> - + + last_modified diff --git a/spec/controllers/admin/group_users_controller_spec.rb b/spec/controllers/admin/group_users_controller_spec.rb index b09784a3ee..9cec0e3000 100644 --- a/spec/controllers/admin/group_users_controller_spec.rb +++ b/spec/controllers/admin/group_users_controller_spec.rb @@ -15,7 +15,7 @@ describe 'GET #index' do subject { get :index, params: { group_id: group.id } } - it { is_expected.to render_template('layouts/dashboard') } + it { is_expected.to render_template('layouts/hyrax/dashboard') } it { is_expected.to render_template('admin/groups/users') } end diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index 17d319c9e6..9c9a2304fb 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -13,7 +13,7 @@ describe 'GET #index' do subject { get :index } - it { is_expected.to render_template('layouts/dashboard') } + it { is_expected.to render_template('layouts/hyrax/dashboard') } it { is_expected.to render_template('admin/groups/index') } end diff --git a/spec/factories/collection_types.rb b/spec/factories/collection_types.rb new file mode 100644 index 0000000000..4c273208b2 --- /dev/null +++ b/spec/factories/collection_types.rb @@ -0,0 +1,113 @@ +FactoryGirl.define do + factory :collection_type, class: Hyrax::CollectionType do + sequence(:title) { |n| "Collection Type #{n}" } + sequence(:machine_id) { |n| "title_#{n}" } + + description 'Collection type with all options' + nestable true + discoverable true + sharable true + brandable true + share_applies_to_new_works true + allow_multiple_membership true + require_membership false + assigns_workflow false + assigns_visibility false + + transient do + creator_user nil + creator_group nil + manager_user nil + manager_group nil + end + + after(:create) do |collection_type, evaluator| + if evaluator.creator_user + attributes = { hyrax_collection_type_id: collection_type.id, + access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS, + agent_id: evaluator.creator_user, + agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE } + create(:collection_type_participant, attributes) + end + + if evaluator.creator_group + attributes = { hyrax_collection_type_id: collection_type.id, + access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS, + agent_id: evaluator.creator_group, + agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE } + create(:collection_type_participant, attributes) + end + + if evaluator.manager_user + attributes = { hyrax_collection_type_id: collection_type.id, + access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS, + agent_id: evaluator.manager_user, + agent_type: Hyrax::CollectionTypeParticipant::USER_TYPE } + create(:collection_type_participant, attributes) + end + + if evaluator.manager_group + attributes = { hyrax_collection_type_id: collection_type.id, + access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS, + agent_id: evaluator.manager_group, + agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE } + create(:collection_type_participant, attributes) + end + end + + trait :nestable do + nestable true + end + + trait :not_nestable do + nestable false + end + + trait :discoverable do + discoverable true + end + + trait :not_discoverable do + discoverable false + end + + trait :brandable do + brandable true + end + + trait :not_brandable do + brandable false + end + + trait :sharable do + sharable true + share_applies_to_new_works true + end + + trait :sharable_no_work_permissions do + sharable true + share_applies_to_new_works false + end + + trait :not_sharable do + sharable false + share_applies_to_new_works false + end + + trait :allow_multiple_membership do + allow_multiple_membership true + end + + trait :not_allow_multiple_membership do + allow_multiple_membership false + end + end + + factory :user_collection_type, class: Hyrax::CollectionType do + initialize_with { Hyrax::CollectionType.find_or_create_default_collection_type } + end + + factory :admin_set_collection_type, class: Hyrax::CollectionType do + initialize_with { Hyrax::CollectionType.find_or_create_admin_set_type } + end +end diff --git a/spec/factories/collections.rb b/spec/factories/collections.rb index 7755f03b16..7b5a7f4884 100644 --- a/spec/factories/collections.rb +++ b/spec/factories/collections.rb @@ -1,13 +1,57 @@ FactoryGirl.define do + # TODO: swap this out for hyrax's collection_lw factory :collection do transient do - user { FactoryGirl.create(:user) } + user { create(:user) } + # allow defaulting to default user collection + collection_type_settings nil + with_permission_template false + create_access false + with_nesting_attributes nil end + sequence(:title) { |n| ["Collection Title #{n}"] } - title ["Test title"] + after(:build) do |collection, evaluator| + collection.apply_depositor_metadata(evaluator.user.user_key) + if evaluator.collection_type_settings.present? + collection.collection_type = create(:collection_type, *evaluator.collection_type_settings) + elsif collection.collection_type_gid.nil? + collection.collection_type = create(:user_collection_type) + end - after(:build) do |work, evaluator| - work.apply_depositor_metadata(evaluator.user) + # if requested, create a solr document and add the nesting fields into it + # when a nestable collection is built. This reduces the need to use + # create and :with_nested_indexing for nested collection testing + if evaluator.with_nesting_attributes.present? && collection.nestable? + Hyrax::Adapters::NestingIndexAdapter.add_nesting_attributes( + solr_doc: evaluator.to_solr, + ancestors: evaluator.with_nesting_attributes[:ancestors], + parent_ids: evaluator.with_nesting_attributes[:parent_ids], + pathnames: evaluator.with_nesting_attributes[:pathnames], + depth: evaluator.with_nesting_attributes[:depth] + ) + end + end + + after(:create) do |collection, evaluator| + # create the permission template if it was requested, OR if nested reindexing is included + # (so we can apply the user's permissions). Nested indexing requires that the user's permissions + # be saved on the Fedora object... if simply in local memory, they are lost when the adapter + # pulls the object from Fedora to reindex. + if evaluator.with_permission_template || + evaluator.create_access || + RSpec.current_example.metadata[:with_nested_reindexing] + attributes = { source_id: collection.id } + access = evaluator.create_access || RSpec.current_example.metadata[:with_nested_reindexing] + attributes[:manage_users] = CollectionFactoryHelper.user_managers(evaluator.with_permission_template, + evaluator.user, + access) + if evaluator.with_permission_template.respond_to?(:merge) + attributes = evaluator.with_permission_template.merge(attributes) + end + create(:permission_template, attributes) unless Hyrax::PermissionTemplate.find_by(source_id: collection.id) + collection.reset_access_controls! + end end end end diff --git a/spec/features/admin_dashboard_spec.rb b/spec/features/admin_dashboard_spec.rb index 78cce2995a..1f4182f4a0 100644 --- a/spec/features/admin_dashboard_spec.rb +++ b/spec/features/admin_dashboard_spec.rb @@ -18,7 +18,6 @@ expect(page).to have_link('Appearance') expect(page).to have_link('Content Blocks') expect(page).to have_link('Technical') - expect(page).to have_link('Administrative Sets') expect(page).to have_link('Manage groups') expect(page).to have_link('Manage users') expect(page).to have_link('Reports') diff --git a/spec/jobs/import_work_from_purl_job_spec.rb b/spec/jobs/import_work_from_purl_job_spec.rb index 90e47adfcf..874d6cece4 100644 --- a/spec/jobs/import_work_from_purl_job_spec.rb +++ b/spec/jobs/import_work_from_purl_job_spec.rb @@ -6,7 +6,7 @@ stub_request(:get, "https://purl.stanford.edu/bc390xk2647.xml") .to_return(status: 200, body: purl_xml) ActiveFedora::Base.find(druid).destroy(eradicate: true) if ActiveFedora::Base.exists? druid - Hyrax::PermissionTemplate.create!(admin_set_id: AdminSet::DEFAULT_ID) + Hyrax::PermissionTemplate.create!(source_id: AdminSet::DEFAULT_ID) # Don't call load_workflows until the PermissionTemplate has been created Hyrax::Workflow::WorkflowImporter.load_workflows end diff --git a/spec/tasks/rake_spec.rb b/spec/tasks/rake_spec.rb index 00dd60a6a7..646831fd95 100644 --- a/spec/tasks/rake_spec.rb +++ b/spec/tasks/rake_spec.rb @@ -5,6 +5,19 @@ Rails.application.load_tasks end + describe "hyku:upgrade:clean_migrations" do + it 'requires a datesub argument' + + it 'removes unnecessary migrations' do + original_migrations = Dir.glob(Rails.root.join('db', 'migrate', '*.rb')) + time = Time.now.utc.strftime("%Y%m%d%H") + run_task('hyrax:install:migrations') + run_task('hyku:upgrade:clean_migrations', time) + new_migrations = Dir.glob(Rails.root.join('db', 'migrate', '*.rb')) + expect(new_migrations).to eq(original_migrations) + end + end + describe "superadmin:grant" do let!(:user1) { FactoryGirl.create(:user) } let!(:user2) { FactoryGirl.create(:user) }