Skip to content

Commit

Permalink
Remove Element.available scope
Browse files Browse the repository at this point in the history
Its deprecated in favor of `Element.published`
  • Loading branch information
tvdeyen committed Sep 3, 2022
1 parent feb5e6f commit 03d9b8e
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 18 deletions.
3 changes: 0 additions & 3 deletions app/models/alchemy/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class Element < BaseRecord
scope :published, -> { where(public: true) }
scope :hidden, -> { where(public: false) }
scope :not_restricted, -> { joins(:page).merge(Page.not_restricted) }
scope :available, -> { published }
scope :named, ->(names) { where(name: names) }
scope :excluded, ->(names) { where.not(name: names) }
scope :fixed, -> { where(fixed: true) }
Expand Down Expand Up @@ -178,8 +177,6 @@ def all_from_clipboard_for_parent_element(clipboard, parent_element)

all_from_clipboard(clipboard).where(name: parent_element.definition["nestable_elements"])
end

deprecate available: :published, deprecator: Alchemy::Deprecation
end

# Returns next public element from same page.
Expand Down
4 changes: 2 additions & 2 deletions lib/alchemy/upgrader/tasks/add_page_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def create_public_page_versions
Alchemy::Page.transaction do
page.versions.create!(
public_on: page.legacy_public_on,
public_until: page.legacy_public_until
public_until: page.legacy_public_until,
).tap do |version|
# We must not use .find_each here to not mess up the order of elements
page.draft_version.elements.not_nested.available.each do |element|
page.draft_version.elements.not_nested.published.each do |element|
Alchemy::Element.copy(element, page_version_id: version.id)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/alchemy/elements/templates/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<%- end -%>
<%- end -%>
<%- if @element['nestable_elements'].present? -%>
<%%= render <%= @element_name %>.nested_elements.available %>
<%%= render <%= @element_name %>.nested_elements.published %>
<%- end -%>
<%%- end -%>
<%%- end -%>
2 changes: 1 addition & 1 deletion lib/generators/alchemy/elements/templates/view.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
<%- end -%>
<%- end -%>
<%- if @element['nestable_elements'].present? -%>
= render <%= @element_name -%>.nested_elements.available
= render <%= @element_name -%>.nested_elements.published
<%- end -%>
2 changes: 1 addition & 1 deletion lib/generators/alchemy/elements/templates/view.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
<%- end -%>
<%- end -%>
<%- if @element['nestable_elements'].present? -%>
= render <%= @element_name -%>.nested_elements.available
= render <%= @element_name -%>.nested_elements.published
<%- end -%>
2 changes: 1 addition & 1 deletion lib/tasks/alchemy/thumbnails.rake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace :alchemy do
ingredient_pictures = Alchemy::Ingredients::Picture.
joins(:element).
preload({ related_object: :thumbs }).
merge(Alchemy::Element.available)
merge(Alchemy::Element.published)

if ENV["ELEMENTS"].present?
ingredient_pictures = ingredient_pictures.merge(
Expand Down
9 changes: 0 additions & 9 deletions spec/models/alchemy/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,4 @@ module Alchemy
element.reload.destroy!
end
end

describe ".available" do
subject { Alchemy::Element.available }

it "is deprecated" do
expect(Alchemy::Deprecation).to receive(:warn)
subject
end
end
end

0 comments on commit 03d9b8e

Please sign in to comment.