Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated methods #1300

Merged
merged 5 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## 4.0.0.rc2 (2017-08-17)

* Removed deprecated `:image_size` option from `EssencePicture`
Use `:size` instead.
* Remove deprecated `take_me_for_preview` content definition option
Use `as_element_title` instead.
* Removed deprecated picture url helpers `show_alchemy_picture_path` and `show_alchemy_picture_url`
Use `picture.url` instead.
* Removed deprecated pages helper module.
* Removed deprecated translation methods `_t` and `Alchemy::I18n.t`.
Use `Alchemy.t` instead.
* Removed deprecated `redirect_index` configuration
Use `redirect_to_public_child` configuration instead.

Expand Down
6 changes: 0 additions & 6 deletions app/controllers/alchemy/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ def not_found_error!(msg = "Not found \"#{request.fullpath}\"")
raise ActionController::RoutingError, msg
end

# Shortcut for Alchemy::I18n.translate method
def _t(key, *args)
ActiveSupport::Deprecation.warn("Alchemys `_t` method is deprecated! Use `Alchemy.t` instead.", caller.unshift)
Alchemy.t(key, *args)
end

# Store current request path into session,
# so we can later redirect to it.
def store_location
Expand Down
5 changes: 0 additions & 5 deletions app/helpers/alchemy/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

module Alchemy
module BaseHelper
def _t(key, *args)
ActiveSupport::Deprecation.warn("Alchemys `_t` method is deprecated! Use `Alchemy.t` instead.", caller.unshift)
Alchemy.t(key, *args)
end

# An alias for truncate.
# Left here for downwards compatibilty.
def shorten(text, length)
Expand Down
56 changes: 0 additions & 56 deletions app/helpers/alchemy/deprecated_pages_helper.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/helpers/alchemy/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Alchemy
module PagesHelper
include Alchemy::BaseHelper
include Alchemy::ElementsHelper
include Alchemy::DeprecatedPagesHelper

def picture_essence_caption(content)
content.try(:essence).try(:caption)
Expand Down
30 changes: 0 additions & 30 deletions app/helpers/alchemy/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,6 @@ def show_alchemy_page_url(page, optional_params = {})
alchemy.show_page_url(show_page_path_params(page, optional_params))
end

# This helper returns a path to picture for use inside a image_tag helper.
#
# Any additional options are passed to the url_helper, so you can add arguments to your url.
#
# Example:
#
# <%= image_tag show_alchemy_picture_path(picture, size: '320x200', format: :png) %>
#
# @deprecated Use Alchemy::Picture#url instead
#
def show_alchemy_picture_path(picture, optional_params = {})
ActiveSupport::Deprecation.warn("`show_alchemy_picture_path` helper is deprecated and will be removed in Alchemy 4.0. Please use the `picture.url` method instead.")
picture.url(optional_params)
end

# This helper returns an url to picture for use inside a image_tag helper.
#
# Any additional options are passed to the url_helper, so you can add arguments to your url.
#
# Example:
#
# <%= image_tag show_alchemy_picture_url(picture, size: '320x200', format: :png) %>
#
# @deprecated Use Alchemy::Picture#url instead
#
def show_alchemy_picture_url(picture, optional_params = {})
ActiveSupport::Deprecation.warn("`show_alchemy_picture_url` helper is deprecated and will be removed in Alchemy 4.0. Please use the `picture.url` method instead.")
picture.url(optional_params)
end

# Returns the correct params-hash for passing to show_page_path
def show_page_path_params(page, optional_params = {})
raise ArgumentError, 'Page is nil' if page.nil?
Expand Down
5 changes: 1 addition & 4 deletions app/models/alchemy/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ def linked?

# Returns true if this content should be taken for element preview.
def preview_content?
if definition['take_me_for_preview']
ActiveSupport::Deprecation.warn("Content definition's `take_me_for_preview` key is deprecated. Please use `as_element_title` instead.")
end
!!definition['take_me_for_preview'] || !!definition['as_element_title']
!!definition['as_element_title']
end

# Proxy method that returns the preview text from essence.
Expand Down
7 changes: 0 additions & 7 deletions app/models/alchemy/essence_picture_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ class EssencePictureView
def initialize(content, options = {}, html_options = {})
@content = content
@options = DEFAULT_OPTIONS.merge(content.settings).merge(options)
if @options[:image_size].present?
ActiveSupport::Deprecation.warn(
"Passing `image_size` to EssencePicture is deprecated. Please use `size` instead.",
caller.unshift
)
@options[:size] = @options.delete(:image_size)
end
@html_options = html_options
@essence = content.essence
@picture = essence.picture
Expand Down
5 changes: 0 additions & 5 deletions lib/alchemy/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ def t(msg, *args)

module I18n
class << self
def t(msg, *args)
ActiveSupport::Deprecation.warn('`Alchemy::I18n.t` is deprecated! Use `Alchemy.t` instead.', caller.unshift)
Alchemy::I18n.translate(msg, *args)
end

# Alchemy translation methods
#
# Instead of having to translate strings and defining a default value:
Expand Down
21 changes: 1 addition & 20 deletions spec/models/alchemy/content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,26 +265,7 @@ module Alchemy
end
end

context 'defined as preview content via take_me_for_preview' do
before do
expect(content).to receive(:definition).at_least(:once).and_return({
'take_me_for_preview' => true
})
end

it "returns true" do
ActiveSupport::Deprecation.silence do
expect(content.preview_content?).to be true
end
end

it "display deprecation warning" do
expect(ActiveSupport::Deprecation).to receive(:warn)
content.preview_content?
end
end

context 'defined as preview content via as_element_title' do
context 'defined as preview content' do
before do
expect(content).to receive(:definition).at_least(:once).and_return({
'as_element_title' => true
Expand Down