Skip to content

Commit

Permalink
Deprecate full_url_for_element helper
Browse files Browse the repository at this point in the history
Please implement your own unique DOM ID for your elements and
pass it as anchor to your URLs.
  • Loading branch information
tvdeyen committed Sep 4, 2022
1 parent 040062f commit 5a7287e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/helpers/alchemy/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show_alchemy_page_url(page, optional_params = {})
def show_page_path_params(page, optional_params = {})
raise ArgumentError, "Page is nil" if page.nil?

url_params = {urlname: page.urlname}.update(optional_params)
url_params = { urlname: page.urlname }.update(optional_params)
prefix_locale? ? url_params.update(locale: page.language_code) : url_params
end

Expand All @@ -35,8 +35,11 @@ def download_alchemy_attachment_url(attachment)
end

# Returns the full url containing host, page and anchor for the given element
# @deprecated
def full_url_for_element(element)
"#{current_server}/#{element.page.urlname}##{element.dom_id}"
end

deprecate :full_url_for_element, deprecator: Alchemy::Deprecation
end
end
6 changes: 6 additions & 0 deletions spec/helpers/alchemy/url_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ module Alchemy
end

describe "#full_url_for_element" do
around do |example|
Alchemy::Deprecation.silence do
example.run
end
end

subject { full_url_for_element(element) }

let(:element) { create(:alchemy_element, name: "headline") }
Expand Down

0 comments on commit 5a7287e

Please sign in to comment.