Skip to content

Commit

Permalink
Merge pull request #5742 from samvera/remove-settings-attriutes
Browse files Browse the repository at this point in the history
remove deprecated class attribute from CollectionType
  • Loading branch information
cjcolvar authored Nov 30, 2022
2 parents 7356ffe + bcea7e1 commit 6c0e57f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 33 deletions.
16 changes: 0 additions & 16 deletions app/models/hyrax/collection_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ def title=(value)
assign_machine_id
end

# this class attribute is deprecated in favor of {.settings_attributes}
# these need to carefully align with boolean flag attributes/table columns,
# so making it settable is a liability. deprecating is challenging because
# +class_attribute+ calls +singleton_class.class_eval { redefine_method }+
# as the +name=+ implementation. there should be few callers outside hyrax.
class_attribute :collection_type_settings_methods, instance_writer: false
self.collection_type_settings_methods = SETTINGS_ATTRIBUTES

# These are provided as a convenience method based on prior design discussions.
alias_attribute :discovery, :discoverable
alias_attribute :sharing, :sharable
Expand Down Expand Up @@ -123,14 +115,6 @@ def collections(use_valkyrie: Hyrax.config.use_valkyrie?)
ActiveFedora::Base.where(Hyrax.config.collection_type_index_field.to_sym => to_global_id.to_s)
end

##
# @deprecated Use #collections.any? instead
#
# @return [Boolean] True if there is at least one collection of this type
def collections?
Deprecation.warn('Use #collections.any? instead.') && collections.any?
end

# @return [Boolean] True if this is the Admin Set type
def admin_set?
machine_id == ADMIN_SET_MACHINE_ID
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
end

it 'all settings are disabled', :js do
expect(exhibit_collection_type.collections?).to be true
expect(exhibit_collection_type.collections.any?).to be true

click_link('Settings', href: '#settings')

Expand Down
16 changes: 1 addition & 15 deletions spec/models/hyrax/collection_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
let!(:collection) { FactoryBot.valkyrie_create(:hyrax_collection, collection_type_gid: collection_type.to_global_id.to_s) }
end

describe '.collection_type_settings_methods' do
it 'lists collection settings methods' do # deprecated
expect(described_class.collection_type_settings_methods)
.to include(:nestable?, :discoverable?, :brandable?)
end
end

describe '#collection_type_settings_methods' do
it 'lists collection settings methods' do # deprecated
expect(collection_type.collection_type_settings_methods)
.to include(:nestable?, :discoverable?, :brandable?)
end
end

describe '.settings_attributes' do
it 'lists collection settings methods' do
expect(described_class.settings_attributes)
Expand Down Expand Up @@ -203,7 +189,7 @@
end
end

describe "collections?", :clean_repo do
describe "collections.any?", :clean_repo do
let(:collection_type) { FactoryBot.create(:collection_type) }

it 'returns true if there are any collections of this collection type' do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/matchers/collection_type_property_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

RSpec::Matchers.define :have_collections do
match do |actual|
actual&.collections?
actual&.collections&.any?
end
end

0 comments on commit 6c0e57f

Please sign in to comment.