">
diff --git a/app/views/articles/tags/_meta.html.erb b/app/views/articles/tags/_meta.html.erb
index 747ddff25..30e92c1a0 100644
--- a/app/views/articles/tags/_meta.html.erb
+++ b/app/views/articles/tags/_meta.html.erb
@@ -20,8 +20,8 @@
<% if @tag_model %>
-
-
+
+
<% else %>
diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb
index 548cf0571..75567c968 100644
--- a/app/views/comments/index.html.erb
+++ b/app/views/comments/index.html.erb
@@ -28,8 +28,8 @@
<% end %>
<% if @commentable.class.name == "Article" %>
-
-
+
+
<% end %>
<% end %>
diff --git a/app/views/users/_meta.html.erb b/app/views/users/_meta.html.erb
index b76e7acf1..f8247d161 100644
--- a/app/views/users/_meta.html.erb
+++ b/app/views/users/_meta.html.erb
@@ -5,7 +5,7 @@
-
+
@@ -14,5 +14,5 @@
-
+
<%= auto_discovery_link_tag(:rss, "https://dev.to/feed/#{@user.username}", title: "The Practical Dev RSS Feed") %>
diff --git a/config/routes.rb b/config/routes.rb
index b6507cb18..a3d3b0e54 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -160,10 +160,10 @@ Rails.application.routes.draw do
post "/pusher/auth" => "pusher#auth"
- get "/social_previews/article/:id" => "social_previews#article"
- get "/social_previews/user/:id" => "social_previews#user"
- get "/social_previews/organization/:id" => "social_previews#organization"
- get "/social_previews/tag/:id" => "social_previews#tag"
+ get "/social_previews/article/:id" => "social_previews#article", as: :article_social_preview
+ get "/social_previews/user/:id" => "social_previews#user", as: :user_social_preview
+ get "/social_previews/organization/:id" => "social_previews#organization", as: :organization_social_preview
+ get "/social_previews/tag/:id" => "social_previews#tag", as: :tag_social_preview
### Subscription vanity url
post "membership-action" => "stripe_subscriptions#create"
diff --git a/spec/helpers/social_image_helper_spec.rb b/spec/helpers/social_image_helper_spec.rb
new file mode 100644
index 000000000..0e1cc703e
--- /dev/null
+++ b/spec/helpers/social_image_helper_spec.rb
@@ -0,0 +1,54 @@
+require "rails_helper"
+
+describe SocialImageHelper do
+ let(:user) { create(:user) }
+ let(:article) { create(:article, main_image: nil) }
+
+ describe ".user_social_image_url" do
+ it "returns social preview path for newer users" do
+ url = helper.user_social_image_url(user)
+
+ expect(url).to eq user_social_preview_url(user, format: :png)
+ end
+
+ it "returns Organization social preview path for Orgs" do
+ organization = create(:organization)
+
+ url = helper.user_social_image_url(organization)
+
+ expect(url).to eq organization_social_preview_url(organization, format: :png)
+ end
+
+ it "returns older url2png image if already generated" do
+ user.updated_at = SocialImageHelper::SOCIAL_PREVIEW_MIGRATION_DATETIME - 1.week
+
+ url = helper.user_social_image_url(user)
+
+ expect(url).to eq GeneratedImage.new(user).social_image
+ end
+ end
+
+ describe ".article_social_image_url" do
+ it "returns social preview path for newer articles" do
+ url = helper.article_social_image_url(article)
+
+ expect(url).to eq article_social_preview_url(article, format: :png)
+ end
+
+ it "returns the main image if set" do
+ article.main_image = Faker::CryptoCoin.url_logo
+
+ url = helper.article_social_image_url(article)
+
+ expect(url).to match(/#{article.main_image}/)
+ end
+
+ it "returns older url2png image if already generated" do
+ article.updated_at = SocialImageHelper::SOCIAL_PREVIEW_MIGRATION_DATETIME - 1.week
+
+ url = helper.article_social_image_url(article)
+
+ expect(url).to eq GeneratedImage.new(article).social_image
+ end
+ end
+end