}.freeze
# Generates a set of social share buttons based on the specified options.
- def render_social_share_buttons(opts = {})
+ def social_share_buttons(opts = {})
sites = opts.fetch(:allow_sites, [])
valid_sites, invalid_sites = filter_allowed_sites(sites)
<% end %>
<%= render @entry %>
-<%= render_social_share_buttons({
- :title => @entry.title,
- :url => diary_entry_url(@entry.user, @entry)
- }) %>
+<%= social_share_buttons({
+ :title => @entry.title,
+ :url => diary_entry_url(@entry.user, @entry)
+ }) %>
<div id="comments" class="comments mb-3 overflow-hidden">
<div class="row border-bottom border-secondary-subtle">
}
end
- def test_render_social_share_buttons_with_valid_sites
- result = render_social_share_buttons(@options)
+ def test_social_share_buttons_with_valid_sites
+ result = social_share_buttons(@options)
assert_includes result, "x"
assert_includes result, "facebook"
assert_includes result, "linkedin"
def test_render_social_share_buttons_with_invalid_site
@options[:allow_sites] << "invalid_site"
- result = render_social_share_buttons(@options)
+ result = social_share_buttons(@options)
assert_not_includes result, "invalid_site"
end
- def test_render_social_share_buttons_with_no_sites
+ def test_social_share_buttons_with_no_sites
@options[:allow_sites] = []
- result = render_social_share_buttons(@options)
+ result = social_share_buttons(@options)
SocialShareButtonHelper::SOCIAL_SHARE_CONFIG.each_key do |site|
assert_includes result, site.to_s # Convert symbol to string
end