From 09c30ed107655af817cb8d54b74ba5325abe5d6f Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Thu, 16 Mar 2017 14:37:17 -0700 Subject: [PATCH] Use AdminSet::DEFAULT_ID from ASBehavior across app --- app/services/sufia/admin_set_create_service.rb | 8 +++----- lib/tasks/migrate.rake | 2 +- spec/services/sufia/admin_set_create_service_spec.rb | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/services/sufia/admin_set_create_service.rb b/app/services/sufia/admin_set_create_service.rb index c1c7650176..e99596ec3f 100644 --- a/app/services/sufia/admin_set_create_service.rb +++ b/app/services/sufia/admin_set_create_service.rb @@ -1,18 +1,16 @@ module Sufia # Creates AdminSets class AdminSetCreateService - DEFAULT_ID = 'admin_sets/default'.freeze - def self.create_default! - return if AdminSet.exists?(DEFAULT_ID) - admin_set = AdminSet.new(id: DEFAULT_ID, title: ['Default Admin Set']) + return if AdminSet.exists?(AdminSet::DEFAULT_ID) + admin_set = AdminSet.new(id: AdminSet::DEFAULT_ID, title: ['Default Admin Set']) begin new(admin_set, nil).create rescue ActiveFedora::IllegalOperation # It is possible that another thread created the AdminSet just before this method # was called, so ActiveFedora will raise IllegalOperation. In this case we can safely # ignore the error. - Rails.logger.error("AdminSet ID=#{DEFAULT_ID} may or may not have been created due to threading issues.") + Rails.logger.error("AdminSet ID=#{AdminSet::DEFAULT_ID} may or may not have been created due to threading issues.") end end diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 83f4be9037..520c514185 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -2,7 +2,7 @@ namespace :sufia do namespace :migrate do task move_all_works_to_admin_set: :environment do require 'sufia/move_all_works_to_admin_set' - MoveAllWorksToAdminSet.run(AdminSet.find(Sufia::DefaultAdminSetActor::DEFAULT_ID)) + MoveAllWorksToAdminSet.run(AdminSet.find(AdminSet::DEFAULT_ID)) end desc "Migrate workflow data from 7.3.0.rc1" diff --git a/spec/services/sufia/admin_set_create_service_spec.rb b/spec/services/sufia/admin_set_create_service_spec.rb index 7de317f036..300e4905e6 100644 --- a/spec/services/sufia/admin_set_create_service_spec.rb +++ b/spec/services/sufia/admin_set_create_service_spec.rb @@ -30,7 +30,7 @@ end describe '.create_default!' do - let(:default_admin_set_id) { 'admin_sets/default' } + let(:default_admin_set_id) { 'admin_set/default' } let(:permission_template) { Sufia::PermissionTemplate.find_by!(admin_set_id: default_admin_set_id) } # It is important to test the side-effects as a default admin set is a fundamental assumption for Sufia >= 7.3 it 'creates AdminSet, PermissionTemplate' do