-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate Blacklight::Engine.config access without top-level key
- Loading branch information
Showing
6 changed files
with
129 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
module Blacklight | ||
module Deprecations | ||
module EngineConfiguration | ||
# rubocop:disable Style/RedundantSelf, Style/HashSyntax | ||
# @deprecated | ||
def bookmarks_http_method | ||
self.blacklight.bookmarks_http_method | ||
end | ||
deprecation_deprecate bookmarks_http_method: 'Moved to `blacklight.bookmarks_http_method`' | ||
|
||
# @deprecated | ||
def bookmarks_http_method=(val) | ||
self.blacklight.bookmarks_http_method = val | ||
end | ||
deprecation_deprecate :'bookmarks_http_method=' => 'Moved to `blacklight.bookmarks_http_method=`' | ||
|
||
# @deprecated | ||
def email_regexp | ||
self.blacklight.email_regexp | ||
end | ||
deprecation_deprecate email_regexp: 'Moved to `blacklight.email_regexp`' | ||
|
||
# @deprecated | ||
def email_regexp=(val) | ||
self.blacklight.email_regexp = val | ||
end | ||
deprecation_deprecate :'email_regexp=' => 'Moved to `blacklight.email_regexp=`' | ||
|
||
# @deprecated | ||
def facet_missing_param | ||
self.blacklight.facet_missing_param | ||
end | ||
deprecation_deprecate facet_missing_param: 'Moved to `blacklight.facet_missing_param`' | ||
|
||
# @deprecated | ||
def facet_missing_param=(val) | ||
self.blacklight.facet_missing_param = val | ||
end | ||
deprecation_deprecate :'facet_missing_param=' => 'Moved to `blacklight.facet_missing_param=`' | ||
|
||
# @deprecated | ||
def sms_mappings | ||
self.blacklight.sms_mappings | ||
end | ||
deprecation_deprecate sms_mappings: 'Moved to `blacklight.sms_mappings`' | ||
|
||
# @deprecated | ||
def sms_mappings=(val) | ||
self.blacklight.sms_mappings = val | ||
end | ||
deprecation_deprecate :'sms_mappings=' => 'Moved to `blacklight.sms_mappings=`' | ||
# rubocop:enable Style/RedundantSelf, Style/HashSyntax | ||
|
||
def self.deprecate_in(object) | ||
class << object | ||
extend Deprecation | ||
self.deprecation_horizon = 'blacklight 8.0' | ||
|
||
include Blacklight::Deprecations::EngineConfiguration | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Blacklight::Engine do | ||
[:bookmarks_http_method, :email_regexp, :facet_missing_param, :sms_mappings].each do |dep_key| | ||
describe "config.#{dep_key}" do | ||
subject { described_class.config } | ||
|
||
let(:unlikely_value) { 'unlikely value' } | ||
|
||
it 'is deprecated' do | ||
allow(Deprecation).to receive(:warn) | ||
subject.send(dep_key) | ||
expect(Deprecation).to have_received(:warn) | ||
end | ||
|
||
it 'delegates to config.blacklight' do | ||
allow(subject.blacklight).to receive(dep_key).and_return(unlikely_value) | ||
expect(subject.send(dep_key)).to eql(unlikely_value) | ||
end | ||
end | ||
|
||
describe "config.#{dep_key}=" do | ||
subject { described_class.config } | ||
|
||
let(:unlikely_value) { 'unlikely value' } | ||
|
||
it 'is deprecated' do | ||
allow(Deprecation).to receive(:warn) | ||
allow(subject.blacklight).to receive(:"#{dep_key}=").with(unlikely_value) | ||
subject.send(:"#{dep_key}=", unlikely_value) | ||
expect(Deprecation).to have_received(:warn) | ||
end | ||
|
||
it 'delegates to config.blacklight' do | ||
allow(subject.blacklight).to receive(:"#{dep_key}=").with(unlikely_value) | ||
subject.send(:"#{dep_key}=", unlikely_value) | ||
expect(subject.blacklight).to have_received(:"#{dep_key}=").with(unlikely_value) | ||
end | ||
end | ||
end | ||
end |