Remove social_preview views (except articles) (#18523)
* Remove social_preview views (except articles) * Remove unreachable controller actions
This commit is contained in:
parent
895c40c2a7
commit
f97b5de96e
7 changed files with 0 additions and 607 deletions
|
|
@ -19,39 +19,6 @@ class SocialPreviewsController < ApplicationController
|
|||
set_respond "social_previews/articles/#{template}"
|
||||
end
|
||||
|
||||
def user
|
||||
@user = User.find(params[:id])
|
||||
@tag_badges = Badge.where(id: @user.badge_achievements.select(:badge_id))
|
||||
set_respond
|
||||
end
|
||||
|
||||
def listing
|
||||
@listing = Listing.find(params[:id]).decorate
|
||||
set_respond
|
||||
end
|
||||
|
||||
def organization
|
||||
@user = Organization.find(params[:id])
|
||||
@tag_badges = [] # Orgs don't have badges, but they could!
|
||||
set_respond "user"
|
||||
end
|
||||
|
||||
def tag
|
||||
@tag = Tag.find(params[:id])
|
||||
@compare_hex = Color::CompareHex.new([@tag.bg_color_hex || "#000000", @tag.text_color_hex || "#ffffff"])
|
||||
|
||||
set_respond
|
||||
end
|
||||
|
||||
def comment
|
||||
@comment = Comment.find(params[:id])
|
||||
|
||||
badge_ids = Tag.where(name: @comment.commentable&.decorate&.cached_tag_list_array).pluck(:badge_id)
|
||||
@tag_badges = Badge.where(id: badge_ids)
|
||||
|
||||
set_respond
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_respond(template = nil)
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
<% accent_color = Color::CompareHex.new([user_colors(@comment.user)[:bg], user_colors(@comment.user)[:text]]).biggest %>
|
||||
<% dark_color = Color::CompareHex.new([user_colors(@comment.user)[:bg], user_colors(@comment.user)[:text]]).brightness(0.8) %>
|
||||
<style>
|
||||
body {
|
||||
background: <%= accent_color %>;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-image: linear-gradient(to bottom, white -70%, <%= accent_color %>);
|
||||
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
|
||||
}
|
||||
|
||||
.preview-div-wrapper {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.preview-div {
|
||||
background: #fff;
|
||||
border: 0.25vw solid<%= dark_color %>;
|
||||
box-shadow: 0.8vw 1vw 0px <%= dark_color %>;
|
||||
width: 94vw;
|
||||
height: 45vw;
|
||||
margin: 2.25vw auto 5vw;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
border-radius: 0.3vw;
|
||||
border-top-left-radius: 2.3vw;
|
||||
border-top-right-radius: 2.3vw;
|
||||
}
|
||||
|
||||
.preview-info-header {
|
||||
color: black;
|
||||
margin: 2vw 2.5vw 0vw;
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, "Roboto", monospace;
|
||||
font-size: 3.5vw;
|
||||
width: 92%;
|
||||
border-bottom: 0.9vw solid <%= accent_color %>;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.preview-info-header img {
|
||||
height: 2.5vw;
|
||||
vertical-align: -0.15vw;
|
||||
margin-left: 1vw;
|
||||
margin-right: 0.5vw;
|
||||
}
|
||||
.title-area {
|
||||
position: absolute;
|
||||
bottom: 12vw;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
h2 {
|
||||
color: <%= dark_color %>;
|
||||
width: 94%;
|
||||
margin: 1.4vw auto;
|
||||
font-size: 3.6vw;
|
||||
}
|
||||
h1 {
|
||||
color: <%= dark_color %>;
|
||||
width: 94%;
|
||||
margin: 1vw auto;
|
||||
position: absolute;
|
||||
padding-left: 2.5%;
|
||||
top: 50%;
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
line-height: 1.05em;
|
||||
}
|
||||
|
||||
.preview-user {
|
||||
font-size: 3vw;
|
||||
position: absolute;
|
||||
color: <%= dark_color %>;
|
||||
left: 1.5vw;
|
||||
bottom: 1.25vw;
|
||||
padding: 0.8vw 2vw;
|
||||
padding-left: 0.8vw;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.preview-user img {
|
||||
border-radius: 100vw;
|
||||
height: 4.5vw;
|
||||
width: 4.5vw;
|
||||
vertical-align: -1.3vw;
|
||||
border: 0.25vw solid<%= dark_color %>;
|
||||
}
|
||||
|
||||
.badge-images {
|
||||
position: absolute;
|
||||
bottom: 1.4vw;
|
||||
right: 1.5vw;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.badge-images img {
|
||||
height: 6vw;
|
||||
right: 6vw;
|
||||
fill: <%= dark_color %>;
|
||||
margin-left: 0.5vw;
|
||||
transform: rotate(5deg);
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="preview-div-wrapper">
|
||||
<div class="preview-div">
|
||||
<% if @comment.title.size < 15 %>
|
||||
<% font_size = 12 %>
|
||||
<% elsif @comment.title.size < 30 %>
|
||||
<% font_size = 9.2 %>
|
||||
<% elsif @comment.title.size < 50 %>
|
||||
<% font_size = 8.3 %>
|
||||
<% else %>
|
||||
<% font_size = 15 - (((@comment.title.size**0.92) + 85) / 16) %>
|
||||
<% end %>
|
||||
<div class="title-area">
|
||||
<h2>re: <%= @comment.commentable&.title %></h2>
|
||||
<h1 style="font-size:<%= font_size %>vw;"><%= @comment.title %></h1>
|
||||
</div>
|
||||
<div class="preview-user">
|
||||
<img src="<%= @comment.user.profile_image_url_for(length: 90) %>" />
|
||||
<%= truncate @comment.user.name, length: 28 %>・<%= @comment.readable_publish_date %>
|
||||
</div>
|
||||
<div class="badge-images">
|
||||
<% @tag_badges.each do |badge| %>
|
||||
<%# Use a seed in Random so we don't break cache on every render %>
|
||||
<% not_so_rand = Random.new(badge.id + @comment.id) %>
|
||||
<img src="<%= badge.badge_image_url %>" style="transform: rotate(<%= not_so_rand.rand(-6..6) %>deg);" />
|
||||
<% end %>
|
||||
<img src="https://thepracticaldev.s3.amazonaws.com/i/bh2wmpcltaybu1xsnico.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
<style>
|
||||
body {
|
||||
background: white;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.preview-div-wrapper {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.preview-div {
|
||||
border: 0.25vw solid <%= @cat_color %>;
|
||||
box-shadow: 0.75vw .75vw 0px <%= @cat_color %>;
|
||||
width: 94vw;
|
||||
height: 46vw;
|
||||
margin: 1.2vw auto 1vw;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background-image: linear-gradient(to bottom, transparent 40%, <%= @cat_color %>);
|
||||
border-radius: 0.4vw;
|
||||
}
|
||||
|
||||
.preview-info-header {
|
||||
color: black;
|
||||
margin: 2vw auto 0vw;
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, "Roboto", monospace;
|
||||
font-size: 3.5vw;
|
||||
width: 92%;
|
||||
}
|
||||
|
||||
.preview-title{
|
||||
padding: 0 2vw;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: <%= @listing.social_preview_color(brightness: 0.70) %>;
|
||||
width: 92%;
|
||||
margin: 0;
|
||||
padding: 1vw;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
|
||||
}
|
||||
|
||||
.preview-body {
|
||||
font-size: 3.1vw;
|
||||
padding: 0 4vw;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
|
||||
color: <%= @listing.social_preview_color(brightness: 0.77) %>;
|
||||
}
|
||||
|
||||
.preview-category {
|
||||
font-size: 3.5vw;
|
||||
position: absolute;
|
||||
background: white;
|
||||
left: -2vw;
|
||||
bottom: 0vw;
|
||||
padding: 1vw 4vw;
|
||||
font-weight: 500;
|
||||
width: 100%;
|
||||
color: <%= @cat_color %>;
|
||||
}
|
||||
|
||||
.preview-dev-logo {
|
||||
position: absolute;
|
||||
bottom: -2.25vw;
|
||||
right: -3vw;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<div class="preview-div-wrapper">
|
||||
<div class="preview-div">
|
||||
<div class="preview-title">
|
||||
<% font_size = @listing.title.length > 65 ? 4 : 5 %>
|
||||
<h1 style="font-size:<%= font_size %>vw;"><%= @listing.title %> </h1>
|
||||
</div>
|
||||
<div class="preview-body">
|
||||
<%= sanitize_rendered_markdown(@listing.processed_html) %>
|
||||
</div>
|
||||
<div class="preview-category">
|
||||
<%= @listing.social_preview_category %>
|
||||
</div>
|
||||
<div class="preview-dev-logo">
|
||||
<%= inline_svg_tag("devlistings-horizontal.svg", class: "logo", size: "30vw*10vw", aria: false, title: t("views.listings.preview_icon")) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
<% accent_color = @compare_hex.biggest %>
|
||||
<% color = @compare_hex.brightness(1.4) %>
|
||||
<% dark_color = @compare_hex.brightness(0.7) %>
|
||||
<% not_so_rand = Random.new(@tag.id) # Using ID as seed ensures we get the same "random" numbers on each page load, Improves caching %>
|
||||
<style>
|
||||
body {
|
||||
background: white;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.preview-div-wrapper {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
background: <%= accent_color %>;
|
||||
}
|
||||
|
||||
.preview-div {
|
||||
background: #fff;
|
||||
border: 0.25vw solid<%= dark_color %>;
|
||||
box-shadow: 0.8vw 1vw 0px <%= dark_color %>;
|
||||
width: 94vw;
|
||||
height: 45vw;
|
||||
margin: 2.25vw auto 5vw;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
border-radius: 0.3vw;
|
||||
border-top-left-radius: 2.3vw;
|
||||
border-top-right-radius: 2.3vw;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: <%= dark_color %>;
|
||||
width: 92%;
|
||||
margin: 10vw auto 0vw;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
|
||||
font-size: <%= @tag.name.size > 10 ? "9.8" : "12" %>vw;
|
||||
}
|
||||
|
||||
h1 img {
|
||||
border-radius: 100vw;
|
||||
height: 15vw;
|
||||
width: 15vw;
|
||||
vertical-align: -4.3vw;
|
||||
border: 0.55vw solid<%= dark_color %>;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: black;
|
||||
width: 92%;
|
||||
margin: 0vw auto 1vw;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
|
||||
font-size: 6vw;
|
||||
}
|
||||
|
||||
.badge-images {
|
||||
position: absolute;
|
||||
bottom: 1.4vw;
|
||||
right: 1.5vw;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.badge-images img {
|
||||
height: 6vw;
|
||||
right: 6vw;
|
||||
fill: <%= dark_color %>;
|
||||
margin-left: 0.5vw;
|
||||
transform: rotate(5deg);
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="preview-div-wrapper">
|
||||
<div class="preview-div">
|
||||
<h1>
|
||||
#<%= @tag.name %>
|
||||
</h1>
|
||||
<% if @tag.pretty_name %>
|
||||
<h2>
|
||||
<%= @tag.pretty_name %>
|
||||
</h2>
|
||||
<% end %>
|
||||
<div class="badge-images">
|
||||
<% if @tag.badge_id %>
|
||||
<%# Use a seed in Random so we don't break cache on every render %>
|
||||
<% @badge = Badge.find(@tag.badge_id) %>
|
||||
<% not_so_rand = Random.new(@badge.id) %>
|
||||
<img src="<%= @badge.badge_image_url %>" style="transform: rotate(<%= not_so_rand.rand(-6..6) %>deg);" />
|
||||
<% end %>
|
||||
<img src="https://thepracticaldev.s3.amazonaws.com/i/bh2wmpcltaybu1xsnico.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
<% accent_color = Color::CompareHex.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).biggest %>
|
||||
<% dark_color = Color::CompareHex.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).brightness(0.8) %>
|
||||
<style>
|
||||
body {
|
||||
background: <%= accent_color %>;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-image: linear-gradient(to bottom, white -70%, <%= accent_color %>);
|
||||
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", "Roboto", sans-serif;
|
||||
}
|
||||
|
||||
.preview-div-wrapper {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.preview-div {
|
||||
background: #fff;
|
||||
border: 0.25vw solid<%= dark_color %>;
|
||||
box-shadow: 0.8vw 1vw 0px <%= dark_color %>;
|
||||
width: 94vw;
|
||||
height: 45vw;
|
||||
margin: 2.25vw auto 5vw;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
border-radius: 0.3vw;
|
||||
border-top-left-radius: 2.3vw;
|
||||
border-top-right-radius: 2.3vw;
|
||||
}
|
||||
|
||||
.preview-info-header {
|
||||
color: black;
|
||||
margin: 2vw 2.5vw 0vw;
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, "Roboto", monospace;
|
||||
font-size: 3.5vw;
|
||||
width: 92%;
|
||||
border-bottom: 0.9vw solid <%= accent_color %>;
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.title-area {
|
||||
position: absolute;
|
||||
bottom: 12vw;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 9vw;
|
||||
}
|
||||
h1 {
|
||||
color: <%= dark_color %>;
|
||||
width: 93%;
|
||||
margin: 1vw auto;
|
||||
position: absolute;
|
||||
padding-left: 3.5%;
|
||||
top: 50%;
|
||||
-ms-transform: translateY(-50%);
|
||||
transform: translateY(-50%);
|
||||
line-height: 1.05em;
|
||||
}
|
||||
|
||||
h1 img {
|
||||
border-radius: 100vw;
|
||||
height: 1.8em;
|
||||
width: 1.8em;
|
||||
vertical-align: -0.6em;
|
||||
border: 0.05em solid <%= accent_color %>;
|
||||
}
|
||||
|
||||
.preview-user {
|
||||
font-size: 3vw;
|
||||
position: absolute;
|
||||
color: <%= dark_color %>;
|
||||
left: 1.5vw;
|
||||
bottom: 1.25vw;
|
||||
padding: 0.8vw 2vw;
|
||||
padding-left: 0.8vw;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.preview-user img {
|
||||
border-radius: 100vw;
|
||||
height: 4.5vw;
|
||||
width: 4.5vw;
|
||||
vertical-align: -1.3vw;
|
||||
border: 0.25vw solid<%= dark_color %>;
|
||||
}
|
||||
|
||||
.badge-images {
|
||||
position: absolute;
|
||||
bottom: 1.4vw;
|
||||
right: 1.5vw;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.badge-images img {
|
||||
height: 6vw;
|
||||
right: 6vw;
|
||||
fill: <%= dark_color %>;
|
||||
margin-left: 0.5vw;
|
||||
transform: rotate(5deg);
|
||||
}
|
||||
</style>
|
||||
<div class="preview-div-wrapper">
|
||||
<div class="preview-div">
|
||||
<div class="title-area">
|
||||
<% if @user.name.size < 14 %>
|
||||
<% font_size = 8.3 %>
|
||||
<% elsif @user.name.size < 20 %>
|
||||
<% font_size = 6.4 %>
|
||||
<% else %>
|
||||
<% font_size = 4.6 %>
|
||||
<% end %>
|
||||
<h1 style="font-size:<%= font_size %>vw;">
|
||||
<img src="<%= @user.profile_image_url_for(length: 640) %>" alt="<%= @user.name %> profile image">
|
||||
<%= truncate @user.name, length: 32 %>
|
||||
<br />
|
||||
<span style="font-size: 0.4em;display: inline-block; margin-left: 5.4em; margin-top: -1.7em">@<%= @user.username %></span>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="badge-images">
|
||||
<% @tag_badges.each do |badge| %>
|
||||
<%# Use a seed in Random so we don't break cache on every render %>
|
||||
<% not_so_rand = Random.new(badge.id + @user.id) %>
|
||||
<img src="<%= badge.badge_image_url %>" style="transform: rotate(<%= not_so_rand.rand(-6..6) %>deg);" />
|
||||
<% end %>
|
||||
<img src="https://thepracticaldev.s3.amazonaws.com/i/bh2wmpcltaybu1xsnico.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -182,10 +182,6 @@ Rails.application.routes.draw do
|
|||
get "/internal/:path", to: redirect("/admin/%{path}")
|
||||
|
||||
get "/social_previews/article/:id", to: "social_previews#article", as: :article_social_preview
|
||||
get "/social_previews/user/:id", to: "social_previews#user", as: :user_social_preview
|
||||
get "/social_previews/organization/:id", to: "social_previews#organization", as: :organization_social_preview
|
||||
get "/social_previews/tag/:id", to: "social_previews#tag", as: :tag_social_preview
|
||||
get "/social_previews/comment/:id", to: "social_previews#comment", as: :comment_social_preview
|
||||
|
||||
get "/async_info/base_data", controller: "async_info#base_data", defaults: { format: :json }
|
||||
|
||||
|
|
|
|||
|
|
@ -38,131 +38,4 @@ RSpec.describe "SocialPreviews", type: :request do
|
|||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /social_previews/user/:id" do
|
||||
it "renders proper user name" do
|
||||
get "/social_previews/user/#{user.id}"
|
||||
expect(response.body).to include CGI.escapeHTML(user.name)
|
||||
end
|
||||
|
||||
it "renders consistent HTML between requests" do
|
||||
create(:badge_achievement, user: user)
|
||||
|
||||
# We use the HTML for caching. It needs to be deterministic (if data is unchanged, the HTML should be the same)
|
||||
get "/social_previews/user/#{user.id}"
|
||||
first_request_body = response.body
|
||||
|
||||
get "/social_previews/user/#{user.id}"
|
||||
second_request_body = response.body
|
||||
|
||||
expect(first_request_body).to eq second_request_body
|
||||
end
|
||||
|
||||
it "renders an image when requested and redirects to image url" do
|
||||
get "/social_previews/user/#{user.id}.png"
|
||||
|
||||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /social_previews/organization/:id" do
|
||||
it "renders proper organization name" do
|
||||
get "/social_previews/organization/#{organization.id}"
|
||||
expect(response.body).to include CGI.escapeHTML(organization.name)
|
||||
end
|
||||
|
||||
it "renders consistent HTML between requests" do
|
||||
# We use the HTML for caching. It needs to be deterministic (if data is unchanged, the HTML should be the same)
|
||||
get "/social_previews/organization/#{organization.id}"
|
||||
first_request_body = response.body
|
||||
|
||||
get "/social_previews/organization/#{organization.id}"
|
||||
second_request_body = response.body
|
||||
|
||||
expect(first_request_body).to eq second_request_body
|
||||
end
|
||||
|
||||
it "renders an image when requested and redirects to image url" do
|
||||
get "/social_previews/organization/#{organization.id}.png"
|
||||
|
||||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /social_previews/tag/:id" do
|
||||
it "renders proper tag name" do
|
||||
get "/social_previews/tag/#{tag.id}"
|
||||
expect(response.body).to include CGI.escapeHTML(tag.name)
|
||||
end
|
||||
|
||||
it "renders consistent HTML between requests" do
|
||||
# We use the HTML for caching. It needs to be deterministic (if data is unchanged, the HTML should be the same)
|
||||
get "/social_previews/tag/#{tag.id}"
|
||||
first_request_body = response.body
|
||||
|
||||
get "/social_previews/tag/#{tag.id}"
|
||||
second_request_body = response.body
|
||||
|
||||
expect(first_request_body).to eq second_request_body
|
||||
end
|
||||
|
||||
it "renders an image when requested and redirects to image url" do
|
||||
get "/social_previews/tag/#{tag.id}.png"
|
||||
|
||||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /social_previews/listing/:id" do
|
||||
let(:listing) { create(:listing, user_id: user.id) }
|
||||
|
||||
it "renders pretty category name" do
|
||||
get "/social_previews/listing/#{listing.id}"
|
||||
expect(response.body).to include CGI.escapeHTML("Education")
|
||||
end
|
||||
|
||||
it "renders consistent HTML between requests" do
|
||||
# We use the HTML for caching. It needs to be deterministic (if data is unchanged, the HTML should be the same)
|
||||
get "/social_previews/listing/#{listing.id}"
|
||||
first_request_body = response.body
|
||||
|
||||
get "/social_previews/listing/#{listing.id}"
|
||||
second_request_body = response.body
|
||||
|
||||
expect(first_request_body).to eq second_request_body
|
||||
end
|
||||
|
||||
it "renders and image when requested and redirects to image url" do
|
||||
get "/social_previews/listing/#{listing.id}.png"
|
||||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /social_previews/comment/:id" do
|
||||
it "renders proper comment name" do
|
||||
get "/social_previews/comment/#{comment.id}"
|
||||
expect(response.body).to include CGI.escapeHTML(comment.title)
|
||||
end
|
||||
|
||||
it "renders associated article name" do
|
||||
get "/social_previews/comment/#{comment.id}"
|
||||
expect(response.body).to include CGI.escapeHTML(comment.commentable.title)
|
||||
end
|
||||
|
||||
it "renders consistent HTML between requests" do
|
||||
# We use the HTML for caching. It needs to be deterministic (if data is unchanged, the HTML should be the same)
|
||||
get "/social_previews/comment/#{comment.id}"
|
||||
first_request_body = response.body
|
||||
|
||||
get "/social_previews/comment/#{comment.id}"
|
||||
second_request_body = response.body
|
||||
|
||||
expect(first_request_body).to eq second_request_body
|
||||
end
|
||||
|
||||
it "renders and image when requested and redirects to image url" do
|
||||
get "/social_previews/comment/#{comment.id}.png"
|
||||
expect(response).to redirect_to(image_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue