Skip to content

Commit

Permalink
Merge pull request #94 from alphagov/add-deprecation
Browse files Browse the repository at this point in the history
Deprecate the use of Plek.current
  • Loading branch information
kevindew authored Oct 3, 2022
2 parents 8f6f84e + ab0bcfb commit 0abe17c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Nothing yet.

# 4.1.0

* Deprecate usage of `Plek.current` this method will be removed in next
major version. This adds a warning for users.
* Remove public setter methods for `parent_domain` and `external_domain`.
These are not used anywhere so there are no API compatibility issues.
* Allow setting `GOVUK_APP_DOMAIN=""` (empty string). Similarly for
Expand Down
5 changes: 4 additions & 1 deletion lib/plek.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ class << self
# Plek.current.find('foo')
# as well as the new style:
# Plek.new.find('foo')
alias_method :current, :new
def current(...)
warn "Plek.current is deprecated and will be removed. Use Plek.new or Plek.find instead."
new(...)
end

# Convenience wrapper. The same as calling +Plek.new.find+.
# @see #find
Expand Down
6 changes: 5 additions & 1 deletion test/plek_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def test_should_return_dash_divided_source_in_production

def test_should_be_able_to_use_current_for_old_style_calls
ClimateControl.modify GOVUK_APP_DOMAIN: "foo.bar.baz" do
assert_equal Plek.new.find("foo"), Plek.current.find("foo")
old_style = nil
assert_output("", "Plek.current is deprecated and will be removed. Use Plek.new or Plek.find instead.\n") do
old_style = Plek.current.find("foo")
end
assert_equal Plek.new.find("foo"), old_style
end
end

Expand Down

0 comments on commit 0abe17c

Please sign in to comment.