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 Element.available scope #2372

Merged
merged 1 commit into from
Sep 4, 2022
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
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