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 render_flash_notice helper #2857

Merged
merged 1 commit into from
May 2, 2024
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: 0 additions & 9 deletions app/helpers/alchemy/base_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ def render_message(type = :info, msg = nil, &blk)
render Alchemy::Admin::Message.new(msg || capture(&blk), type: type)
end

# Renders a dismissable growl message.
#
# @param [String] notice - The notice you want to display
# @param [Symbol] type - The type of this flash. Valid values are +:notice+ (default), +:warn+, +:info+ and +:error+
#
def render_flash_notice(notice, type = :notice)
render Alchemy::Admin::Message.new(notice, type: type, dismissable: true)
end

# Checks if the given argument is a String or a Page object.
# If a String is given, it tries to find the page via page_layout
# Logs a warning if no page is given.
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/partials/_flash_notices.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="flash_notices">
<% flash.keys.each do |flash_type| %>
<% if flash[flash_type.to_sym].present? %>
<%= render_flash_notice(flash[flash_type.to_sym], flash_type) %>
<%= render Alchemy::Admin::Message.new(flash[flash_type.to_sym], type: flash_type, dismissable: true) %>
<% end %>
<% end %>
</div>
22 changes: 0 additions & 22 deletions spec/helpers/alchemy/base_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,6 @@ module Alchemy
end
end

describe "#render_flash_notice" do
context "if no argument is passed" do
it "should render an alchemy-message with an check icon and the given content" do
expect(helper.render_flash_notice("my notice")).to eq <<~HTML
<alchemy-message type="notice" dismissable>
my notice
</alchemy-message>
HTML
end
end

context "if an argument is passed" do
it "should render the passed argument as the type for the message" do
expect(helper.render_flash_notice("A error", :error)).to eq <<~HTML
<alchemy-message type="error" dismissable>
A error
</alchemy-message>
HTML
end
end
end

describe "#page_or_find" do
let(:page) { create(:alchemy_page, :public) }

Expand Down