Enable Layout/AlignParameters (#2340)

Check if the parameters on a multi-line method call or definition are aligned.

Resolves: #2021
This commit is contained in:
cyrillefr 2019-04-09 00:47:34 +02:00 committed by Ben Halpern
parent 36a21cd0f2
commit 4fd66372dc
53 changed files with 322 additions and 328 deletions

View file

@ -79,9 +79,3 @@ Rails/OutputSafety:
- 'app/models/message.rb'
- 'app/views/api/v0/articles/show.json.jbuilder'
- 'app/views/articles/feed.rss.builder'
Layout/AlignParameters:
Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
Enabled: false

View file

@ -12,7 +12,7 @@ class BlackBox
two_day_bonus = usable_date > 48.hours.ago ? 330 : 0
four_day_bonus = usable_date > 96.hours.ago ? 330 : 0
FunctionCaller.new("blackbox-production-articleHotness",
{ article: article, user: article.user }.to_json).call +
{ article: article, user: article.user }.to_json).call +
reaction_points + recency_bonus + super_recent_bonus + super_super_recent_bonus + today_bonus + two_day_bonus + four_day_bonus
end
@ -30,7 +30,7 @@ class BlackBox
return 100 unless story.user
FunctionCaller.new("blackbox-production-spamScore",
{ story: story, user: story.user }.to_json).call
{ story: story, user: story.user }.to_json).call
end
private

View file

@ -26,7 +26,7 @@ class GoogleAnalytics
def get_feed_impression_info
requests = @article_ids.map do |id|
make_report_request("ga:eventAction==featured-feed-impression;ga:eventLabel==articles-#{id}",
"ga:totalEvents")
"ga:totalEvents")
end
results = fetch_all_results(requests)
@article_ids.zip(results).to_h
@ -35,7 +35,7 @@ class GoogleAnalytics
def get_feed_click_info
requests = @article_ids.map do |id|
make_report_request("ga:eventAction==featured-feed-click;ga:eventLabel==articles-#{id}",
"ga:totalEvents")
"ga:totalEvents")
end
results = fetch_all_results(requests)
@article_ids.zip(results).to_h

View file

@ -3,8 +3,8 @@ module Api
class ArticlesController < ApiController
before_action :set_cache_control_headers, only: [:index]
caches_action :show,
cache_path: proc { |c| c.params.permit! },
expires_in: 5.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 5.minutes
respond_to :json
before_action :cors_preflight_check

View file

@ -3,13 +3,13 @@ module Api
class CommentsController < ApplicationController
# before_action :set_cache_control_headers, only: [:index, :show]
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
caches_action :show,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
def index

View file

@ -2,8 +2,8 @@ module Api
module V0
class PodcastEpisodesController < ApiController
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
before_action :cors_preflight_check

View file

@ -3,8 +3,8 @@ module Api
class TagsController < ApplicationController
# before_action :set_cache_control_headers, only: [:index]
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
def index

View file

@ -2,8 +2,8 @@ module Api
module V0
class VideosController < ApiController
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json
before_action :cors_preflight_check

View file

@ -132,7 +132,7 @@ class ChatChannelsController < ApplicationController
current_user.
chat_channel_memberships.includes(:chat_channel).
where("has_unopened_messages = ? OR status = ?",
true, "pending").
true, "pending").
where(show_global_badge_notification: true).
order("chat_channel_memberships.updated_at DESC")
else

View file

@ -2,8 +2,8 @@ class FollowedArticlesController < ApplicationController
# No authorization required for entirely public controller
caches_action :index,
cache_path: proc { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?}" },
expires_in: 35.minutes
cache_path: proc { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?}" },
expires_in: 35.minutes
def index
@articles = if current_user

View file

@ -10,7 +10,7 @@ class GithubReposController < ApplicationController
redirect_to "/settings/integrations", notice: "GitHub repo added"
else
redirect_to "/settings/integrations",
error: "There was an error adding your Github repo"
error: "There was an error adding your Github repo"
end
end
@ -22,7 +22,7 @@ class GithubReposController < ApplicationController
redirect_to "/settings/integrations", notice: "GitHub repo added"
else
redirect_to "/settings/integrations",
error: "There was an error removing your Github repo"
error: "There was an error removing your Github repo"
end
end

View file

@ -39,18 +39,18 @@ module Internal
def event_params
params.require(:event).permit(:title,
:category,
:event_date,
:starts_at,
:ends_at,
:location_name,
:cover_image,
:location_url,
:description_markdown,
:published,
:host_name,
:profile_image,
:live_now)
:category,
:event_date,
:starts_at,
:ends_at,
:location_name,
:cover_image,
:location_url,
:description_markdown,
:published,
:host_name,
:profile_image,
:live_now)
end
end
end

View file

@ -117,16 +117,16 @@ class Internal::UsersController < Internal::ApplicationController
def user_params
params.require(:user).permit(:seeking_mentorship,
:offering_mentorship,
:quick_match,
:new_note,
:add_mentor,
:add_mentee,
:note_for_current_role,
:mentorship_note,
:user_status,
:toggle_mentorship,
:pro,
:merge_user_id)
:offering_mentorship,
:quick_match,
:new_note,
:add_mentor,
:add_mentee,
:note_for_current_role,
:mentorship_note,
:user_status,
:toggle_mentorship,
:pro,
:merge_user_id)
end
end

View file

@ -12,13 +12,13 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def failure
logger.error "Omniauth failure",
omniauth_failure: {
error: request.env["omniauth.error"]&.inspect,
error_type: request.env["omniauth.error.type"].to_s,
auth: request.env["omniauth.auth"],
provider: request.env["omniauth.strategy"].to_s,
cookie: request.env["rack.request.cookie_hash"]
}
omniauth_failure: {
error: request.env["omniauth.error"]&.inspect,
error_type: request.env["omniauth.error.type"].to_s,
auth: request.env["omniauth.auth"],
provider: request.env["omniauth.strategy"].to_s,
cookie: request.env["rack.request.cookie_hash"]
}
super
end

View file

@ -20,10 +20,10 @@ class PodcastEpisodesController < ApplicationController
def podcast_episode_params
params.require(:podcast_episode).permit(:title,
:body,
:image,
:social_image,
:remote_social_image_url,
:quote)
:body,
:image,
:social_image,
:remote_social_image_url,
:quote)
end
end

View file

@ -2,7 +2,7 @@ class PusherController < ApplicationController
def auth
if valid_channel
response = Pusher.authenticate(params[:channel_name], params[:socket_id],
user_id: current_user.id) # => required
user_id: current_user.id) # => required
render json: response
else
render json: { text: "Forbidden", status: "403" }

View file

@ -42,7 +42,7 @@ class StripeActiveCardsController < ApplicationController
customer.sources.retrieve(params[:id]).delete
customer.save
redirect_to "/settings/billing",
notice: "Your card has been successfully removed."
notice: "Your card has been successfully removed."
else
redirect_to "/settings/billing", flash: { error:
"Can't remove card if you have an active membership. Please cancel your membership first." }

View file

@ -66,7 +66,7 @@ class UsersController < ApplicationController
identity_username = "#{provider}_username".to_sym
@user.update(identity_username => nil)
redirect_to "/settings/#{@tab}",
notice: "Your #{provider.capitalize} account was successfully removed."
notice: "Your #{provider.capitalize} account was successfully removed."
else
flash[:error] = "An error occurred. Please try again or send an email to: yo@dev.to"
redirect_to "/settings/#{@tab}"
@ -93,7 +93,7 @@ class UsersController < ApplicationController
if (@organization = Organization.find_by(secret: params[:org_secret]))
current_user.update(organization_id: @organization.id)
redirect_to "/settings/organization",
notice: "You have joined the #{@organization.name} organization."
notice: "You have joined the #{@organization.name} organization."
else
not_found
end
@ -103,7 +103,7 @@ class UsersController < ApplicationController
authorize User
current_user.update(organization_id: nil, org_admin: nil)
redirect_to "/settings/organization",
notice: "You have left your organization."
notice: "You have left your organization."
end
def add_org_admin
@ -112,7 +112,7 @@ class UsersController < ApplicationController
user.update(org_admin: true)
user.add_role :analytics_beta_tester if user.organization.approved
redirect_to "/settings/organization",
notice: "#{user.name} is now an admin."
notice: "#{user.name} is now an admin."
end
def remove_org_admin
@ -120,7 +120,7 @@ class UsersController < ApplicationController
authorize user
user.update(org_admin: false)
redirect_to "/settings/organization",
notice: "#{user.name} is no longer an admin."
notice: "#{user.name} is no longer an admin."
end
def remove_from_org
@ -128,7 +128,7 @@ class UsersController < ApplicationController
authorize user
user.update(organization_id: nil)
redirect_to "/settings/organization",
notice: "#{user.name} is no longer part of your organization."
notice: "#{user.name} is no longer part of your organization."
end
def signout_confirm; end

View file

@ -108,14 +108,14 @@ module ApplicationHelper
quality = "auto"
cl_image_path(url,
type: "fetch",
width: width,
height: height,
crop: "imagga_scale",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
width: width,
height: height,
crop: "imagga_scale",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
end
def cloud_social_image(article)
@ -126,14 +126,14 @@ module ApplicationHelper
return src if src.start_with? "https://res.cloudinary.com/"
cl_image_path(src,
type: "fetch",
width: "1000",
height: "500",
crop: "imagga_scale",
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
width: "1000",
height: "500",
crop: "imagga_scale",
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
end
end
@ -159,12 +159,12 @@ module ApplicationHelper
def sanitize_rendered_markdown(processed_html)
ActionController::Base.helpers.sanitize processed_html.html_safe,
scrubber: RenderedMarkdownScrubber.new
scrubber: RenderedMarkdownScrubber.new
end
def sanitized_sidebar(text)
ActionController::Base.helpers.sanitize simple_format(text),
tags: %w[p b i em strike strong u br]
tags: %w[p b i em strike strong u br]
end
def track_split_version(url, version)
@ -173,11 +173,11 @@ module ApplicationHelper
def follow_button(followable, style = "full")
tag :button, # Yikes
class: "cta follow-action-button",
data: {
info: { id: followable.id, className: followable.class.name, style: style }.to_json,
"follow-action-button" => true
}
class: "cta follow-action-button",
data: {
info: { id: followable.id, className: followable.class.name, style: style }.to_json,
"follow-action-button" => true
}
end
def user_colors_style(user)

View file

@ -7,9 +7,9 @@ class CacheBuster
return unless Rails.env.production?
HTTParty.post("https://api.fastly.com/purge/https://dev.to#{path}",
headers: { "Fastly-Key" => ApplicationConfig["FASTLY_API_KEY"] })
headers: { "Fastly-Key" => ApplicationConfig["FASTLY_API_KEY"] })
HTTParty.post("https://api.fastly.com/purge/https://dev.to#{path}?i=i",
headers: { "Fastly-Key" => ApplicationConfig["FASTLY_API_KEY"] })
headers: { "Fastly-Key" => ApplicationConfig["FASTLY_API_KEY"] })
end
def bust_comment(commentable, username)

View file

@ -14,7 +14,7 @@ class CouponGenerator
def lambda_generated_code
response = FunctionCaller.new("blackbox-production-couponCode",
{ inputNumber: id, version: version }.to_json).call
{ inputNumber: id, version: version }.to_json).call
response.to_s(36)
end
end

View file

@ -1,6 +1,6 @@
class EmailLogic
attr_reader :open_percentage, :last_email_sent_at,
:days_until_next_email, :articles_to_send
:days_until_next_email, :articles_to_send
def initialize(user)
@user = user

View file

@ -28,11 +28,11 @@ class GeneratedImage
def cloudinary_generated_url(path)
cl_image_path("https://dev.to/social_previews#{path}",
gravity: "north",
height: 400,
width: 800,
crop: "fill",
sign_url: true,
type: "url2png")
gravity: "north",
height: 400,
width: 800,
crop: "fill",
sign_url: true,
type: "url2png")
end
end

View file

@ -42,8 +42,8 @@ class MarkdownParser
br ul ol li small sup sub img a span hr blockquote kbd]
allowed_attributes = %w[href strong em ref rel src title alt class]
ActionController::Base.helpers.sanitize markdown.render(@content).html_safe,
tags: allowed_tags,
attributes: allowed_attributes
tags: allowed_tags,
attributes: allowed_attributes
end
def evaluate_limited_markdown
@ -54,8 +54,8 @@ class MarkdownParser
allowed_tags = %w[strong i u b em p br code]
allowed_attributes = %w[href strong em ref rel src title alt class]
ActionController::Base.helpers.sanitize markdown.render(@content).html_safe,
tags: allowed_tags,
attributes: allowed_attributes
tags: allowed_tags,
attributes: allowed_attributes
end
def tags_used
@ -165,13 +165,13 @@ class MarkdownParser
"auto"
end
cl_image_path(source,
type: "fetch",
width: width,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true).gsub(",", "%2C")
type: "fetch",
width: width,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true).gsub(",", "%2C")
end
def wrap_all_images_in_links(html)

View file

@ -10,14 +10,14 @@ class ProfileImage
def get(width = 120)
cl_image_path(get_link,
type: "fetch",
crop: "fill",
width: width,
height: width,
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
crop: "fill",
width: width,
height: width,
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
end
def get_link

View file

@ -33,7 +33,7 @@ class GistTag < LiquidTagBase
input_no_space
else
raise StandardError,
"Invalid Gist link: #{link} Links must follow this format: https://gist.github.com/username/gist_id"
"Invalid Gist link: #{link} Links must follow this format: https://gist.github.com/username/gist_id"
end
end

View file

@ -25,13 +25,13 @@ class PodcastTag < LiquidTagBase
</a>
<a href="/#{@podcast.slug}">
#{cl_image_tag(@podcast.image_url,
type: 'fetch',
crop: 'fill',
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
class: 'tinyimage')}
type: 'fetch',
crop: 'fill',
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
class: 'tinyimage')}
<h1 class="podcastliquidtag__info__podcasttitle">#{@podcast.title}</h1>
</a>
@ -42,14 +42,14 @@ class PodcastTag < LiquidTagBase
<img class="button play-butt" id="play-butt-#{episode.slug}" src="/assets/playbutt.png"/>
<img class="button pause-butt" id="pause-butt-#{episode.slug}" src="/assets/pausebutt.png"/>
#{cl_image_tag(@podcast.image_url,
type: 'fetch',
crop: 'fill',
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
class: 'podcastliquidtag__podcastimage',
id: "podcastimage-#{episode.slug}")}
type: 'fetch',
crop: 'fill',
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
class: 'podcastliquidtag__podcastimage',
id: "podcastimage-#{episode.slug}")}
</div>
#{render_hidden_audio}
</div>
@ -72,15 +72,15 @@ class PodcastTag < LiquidTagBase
<div id="progressBar" class="audio-player-display">
<a href="/#{@podcast.slug}/#{@episode.slug}">
#{cl_image_tag(@episode.image_url || @podcast.image_url,
type: 'fetch',
crop: 'fill',
width: 420,
height: 420,
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
id: 'episode-profile-image')}
type: 'fetch',
crop: 'fill',
width: 420,
height: 420,
quality: 'auto',
sign_url: true,
flags: 'progressive',
fetch_format: 'auto',
id: 'episode-profile-image')}
<img id="animated-bars" src="/assets/animated-bars.gif" />
</a>
<span id="barPlayPause">

View file

@ -77,23 +77,23 @@ class Article < ApplicationRecord
scope :limited_column_select, lambda {
select(:path, :title, :id,
:comments_count, :positive_reactions_count, :cached_tag_list,
:main_image, :main_image_background_hex_color, :updated_at, :slug,
:video, :user_id, :organization_id, :video_source_url, :video_code,
:video_thumbnail_url, :video_closed_caption_track_url, :language,
:experience_level_rating, :experience_level_rating_distribution,
:published_at, :crossposted_at, :boost_states, :description, :reading_time, :video_duration_in_seconds)
:comments_count, :positive_reactions_count, :cached_tag_list,
:main_image, :main_image_background_hex_color, :updated_at, :slug,
:video, :user_id, :organization_id, :video_source_url, :video_code,
:video_thumbnail_url, :video_closed_caption_track_url, :language,
:experience_level_rating, :experience_level_rating_distribution,
:published_at, :crossposted_at, :boost_states, :description, :reading_time, :video_duration_in_seconds)
}
scope :limited_columns_internal_select, lambda {
select(:path, :title, :id, :featured, :approved, :published,
:comments_count, :positive_reactions_count, :cached_tag_list,
:main_image, :main_image_background_hex_color, :updated_at, :boost_states,
:video, :user_id, :organization_id, :video_source_url, :video_code,
:video_thumbnail_url, :video_closed_caption_track_url, :social_image,
:published_from_feed, :crossposted_at, :published_at, :featured_number,
:live_now, :last_buffered, :facebook_last_buffered, :created_at, :body_markdown,
:email_digest_eligible, :processed_html)
:comments_count, :positive_reactions_count, :cached_tag_list,
:main_image, :main_image_background_hex_color, :updated_at, :boost_states,
:video, :user_id, :organization_id, :video_source_url, :video_code,
:video_thumbnail_url, :video_closed_caption_track_url, :social_image,
:published_from_feed, :crossposted_at, :published_at, :featured_number,
:live_now, :last_buffered, :facebook_last_buffered, :created_at, :body_markdown,
:email_digest_eligible, :processed_html)
}
scope :boosted_via_additional_articles, lambda {
@ -107,14 +107,14 @@ class Article < ApplicationRecord
algoliasearch per_environment: true, auto_remove: false, enqueue: :trigger_delayed_index do
attribute :title
add_index "searchables",
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
attributes :title, :tag_list, :main_image, :id, :reading_time, :score,
:featured, :published, :published_at, :featured_number,
:comments_count, :reactions_count, :positive_reactions_count,
:path, :class_name, :user_name, :user_username, :comments_blob,
:body_text, :tag_keywords_for_search, :search_score, :readable_publish_date, :flare_tag
:featured, :published, :published_at, :featured_number,
:comments_count, :reactions_count, :positive_reactions_count,
:path, :class_name, :user_name, :user_username, :comments_blob,
:body_text, :tag_keywords_for_search, :search_score, :readable_publish_date, :flare_tag
attribute :user do
{ username: user.username,
name: user.name,
@ -139,12 +139,12 @@ class Article < ApplicationRecord
end
add_index "ordered_articles",
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
attributes :title, :path, :class_name, :comments_count, :reading_time, :language,
:tag_list, :positive_reactions_count, :id, :hotness_score, :score, :readable_publish_date, :flare_tag, :user_id,
:organization_id, :cloudinary_video_url, :video_duration_in_minutes, :experience_level_rating, :experience_level_rating_distribution
:tag_list, :positive_reactions_count, :id, :hotness_score, :score, :readable_publish_date, :flare_tag, :user_id,
:organization_id, :cloudinary_video_url, :video_duration_in_minutes, :experience_level_rating, :experience_level_rating_distribution
attribute :published_at_int do
published_at.to_i
end

View file

@ -17,8 +17,8 @@ class BadgeAchievement < ApplicationRecord
parsed_markdown = MarkdownParser.new(rewarding_context_message_markdown)
html = parsed_markdown.finalize
final_html = ActionController::Base.helpers.sanitize html,
tags: %w[strong em i b u a code],
attributes: %w[href name]
tags: %w[strong em i b u a code],
attributes: %w[href name]
self.rewarding_context_message = final_html
end

View file

@ -21,9 +21,9 @@ class ChatChannel < ApplicationRecord
algoliasearch index_name: "SecuredChatChannel_#{Rails.env}" do
attribute :id, :viewable_by, :slug, :channel_type,
:channel_name, :channel_users, :last_message_at, :status,
:messages_count, :channel_human_names, :channel_mod_ids, :pending_users_select_fields,
:description
:channel_name, :channel_users, :last_message_at, :status,
:messages_count, :channel_human_names, :channel_mod_ids, :pending_users_select_fields,
:description
searchableAttributes %i[channel_name channel_slug channel_human_names]
attributesForFaceting ["filterOnly(viewable_by)", "filterOnly(status)", "filterOnly(channel_type)"]
ranking ["desc(last_message_at)"]

View file

@ -37,14 +37,14 @@ class Comment < ApplicationRecord
algoliasearch per_environment: true, enqueue: :trigger_delayed_index do
attribute :id
add_index "ordered_comments",
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
attributes :id, :user_id, :commentable_id, :commentable_type, :id_code_generated, :path,
:id_code, :readable_publish_date, :parent_id, :positive_reactions_count, :created_at
:id_code, :readable_publish_date, :parent_id, :positive_reactions_count, :created_at
attribute :body_html do
HTML_Truncator.truncate(processed_html,
500, ellipsis: '<a class="comment-read-more" href="' + path + '">... Read Entire Comment</a>')
500, ellipsis: '<a class="comment-read-more" href="' + path + '">... Read Entire Comment</a>')
end
attribute :url do
path

View file

@ -13,8 +13,8 @@ class DisplayAd < ApplicationRecord
markdown = Redcarpet::Markdown.new(renderer)
initial_html = markdown.render(body_markdown)
stripped_html = ActionController::Base.helpers.sanitize initial_html.html_safe,
tags: %w[a em i b u br img h1 h2 h3 h4 div],
attributes: %w[href target src height width style]
tags: %w[a em i b u br img h1 h2 h3 h4 div],
attributes: %w[href target src height width style]
html = stripped_html.delete("\n")
self.processed_html = MarkdownParser.new(html).prefix_all_images(html, 350)
end

View file

@ -77,12 +77,12 @@ class HtmlVariant < ApplicationRecord
"auto"
end
cl_image_path(source,
type: "fetch",
width: width,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true).gsub(",", "%2C")
type: "fetch",
width: width,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true).gsub(",", "%2C")
end
end

View file

@ -1,7 +1,7 @@
class JobOpportunity < ApplicationRecord
has_many :articles
validates :remoteness,
inclusion: { in: %w[on_premise fully_remote remote_optional on_premise_flexible] }
inclusion: { in: %w[on_premise fully_remote remote_optional on_premise_flexible] }
def remoteness_in_words
phrases = {
"on_premise" => "In Office",

View file

@ -36,7 +36,7 @@ class Organization < ApplicationRecord
allow_blank: true }
validates :tech_stack, :story, length: { maximum: 640 }
validates :cta_button_url,
url: { allow_blank: true, no_local: true, schemes: %w[https http] }
url: { allow_blank: true, no_local: true, schemes: %w[https http] }
validates :cta_button_text, length: { maximum: 20 }
validates :cta_body_markdown, length: { maximum: 256 }
before_save :remove_at_from_usernames

View file

@ -28,13 +28,13 @@ class PodcastEpisode < ApplicationRecord
algoliasearch per_environment: true do
attribute :id
add_index "searchables",
id: :index_id,
per_environment: true do
id: :index_id,
per_environment: true do
attribute :title, :body, :quote, :summary, :subtitle, :website_url,
:published_at, :comments_count, :path, :class_name,
:user_name, :user_username, :published, :comments_blob,
:body_text, :tag_list, :tag_keywords_for_search,
:positive_reactions_count, :search_score
:published_at, :comments_count, :path, :class_name,
:user_name, :user_username, :published, :comments_blob,
:body_text, :tag_list, :tag_keywords_for_search,
:positive_reactions_count, :search_score
attribute :user do
{ name: podcast.name,
username: user_username,
@ -168,13 +168,13 @@ class PodcastEpisode < ApplicationRecord
cloudinary_img_src = ActionController::Base.helpers.
cl_image_path(img_src,
type: "fetch",
width: 725,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
width: 725,
crop: "limit",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
self.processed_html = processed_html.gsub(img_src, cloudinary_img_src)
end
end

View file

@ -5,9 +5,9 @@ class Reaction < ApplicationRecord
belongs_to :user
counter_culture :reactable,
column_name: proc { |model|
model.points.positive? ? "positive_reactions_count" : "reactions_count"
}
column_name: proc { |model|
model.points.positive? ? "positive_reactions_count" : "reactions_count"
}
counter_culture :user
validates :category, inclusion: { in: CATEGORIES }

View file

@ -19,9 +19,9 @@ class Tag < ActsAsTaggableOn::Tag
mount_uploader :social_image, ProfileImageUploader
validates :text_color_hex,
format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_nil: true
format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_nil: true
validates :bg_color_hex,
format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_nil: true
format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_nil: true
validate :validate_alias
before_validation :evaluate_markdown

View file

@ -37,20 +37,20 @@ class User < ApplicationRecord
has_many :html_variants, dependent: :destroy
has_many :page_views
has_many :mentor_relationships_as_mentee,
class_name: "MentorRelationship", foreign_key: "mentee_id", inverse_of: :mentee
class_name: "MentorRelationship", foreign_key: "mentee_id", inverse_of: :mentee
has_many :mentor_relationships_as_mentor,
class_name: "MentorRelationship", foreign_key: "mentor_id", inverse_of: :mentor
class_name: "MentorRelationship", foreign_key: "mentor_id", inverse_of: :mentor
has_many :mentors,
through: :mentor_relationships_as_mentee,
source: :mentor
through: :mentor_relationships_as_mentee,
source: :mentor
has_many :mentees,
through: :mentor_relationships_as_mentor,
source: :mentee
through: :mentor_relationships_as_mentor,
source: :mentee
mount_uploader :profile_image, ProfileImageUploader
devise :omniauthable, :rememberable,
:registerable, :database_authenticatable, :confirmable
:registerable, :database_authenticatable, :confirmable
validates :email,
uniqueness: { allow_blank: true, case_sensitive: false },
length: { maximum: 50 },
@ -70,64 +70,64 @@ class User < ApplicationRecord
validates :text_color_hex, format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_blank: true
validates :bg_color_hex, format: /\A#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, allow_blank: true
validates :website_url, :employer_url, :mastodon_url,
url: { allow_blank: true, no_local: true, schemes: %w[https http] }
url: { allow_blank: true, no_local: true, schemes: %w[https http] }
validates :facebook_url,
format: /\A(http(s)?:\/\/)?(www.facebook.com|facebook.com)\/.*\Z/,
allow_blank: true
format: /\A(http(s)?:\/\/)?(www.facebook.com|facebook.com)\/.*\Z/,
allow_blank: true
validates :stackoverflow_url,
allow_blank: true,
format:
/\A(http(s)?:\/\/)?(www.stackoverflow.com|stackoverflow.com|www.stackexchange.com|stackexchange.com)\/.*\Z/
allow_blank: true,
format:
/\A(http(s)?:\/\/)?(www.stackoverflow.com|stackoverflow.com|www.stackexchange.com|stackexchange.com)\/.*\Z/
validates :behance_url,
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.behance.net|behance.net)\/.*\Z/
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.behance.net|behance.net)\/.*\Z/
validates :linkedin_url,
allow_blank: true,
format:
/\A(http(s)?:\/\/)?(www.linkedin.com|linkedin.com|[A-Za-z]{2}.linkedin.com)\/.*\Z/
allow_blank: true,
format:
/\A(http(s)?:\/\/)?(www.linkedin.com|linkedin.com|[A-Za-z]{2}.linkedin.com)\/.*\Z/
validates :dribbble_url,
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.dribbble.com|dribbble.com)\/.*\Z/
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.dribbble.com|dribbble.com)\/.*\Z/
validates :medium_url,
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.medium.com|medium.com)\/.*\Z/
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.medium.com|medium.com)\/.*\Z/
validates :gitlab_url,
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.gitlab.com|gitlab.com)\/.*\Z/
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.gitlab.com|gitlab.com)\/.*\Z/
validates :shirt_gender,
inclusion: { in: %w[unisex womens],
message: "%{value} is not a valid shirt style" },
allow_blank: true
inclusion: { in: %w[unisex womens],
message: "%{value} is not a valid shirt style" },
allow_blank: true
validates :shirt_size,
inclusion: { in: %w[xs s m l xl 2xl 3xl 4xl],
message: "%{value} is not a valid size" },
allow_blank: true
inclusion: { in: %w[xs s m l xl 2xl 3xl 4xl],
message: "%{value} is not a valid size" },
allow_blank: true
validates :tabs_or_spaces,
inclusion: { in: %w[tabs spaces],
message: "%{value} is not a valid answer" },
allow_blank: true
inclusion: { in: %w[tabs spaces],
message: "%{value} is not a valid answer" },
allow_blank: true
validates :editor_version,
inclusion: { in: %w[v1 v2],
message: "%{value} must be either v1 or v2" }
inclusion: { in: %w[v1 v2],
message: "%{value} must be either v1 or v2" }
validates :config_theme,
inclusion: { in: %w[default night_theme],
message: "%{value} must be either default or night theme" }
inclusion: { in: %w[default night_theme],
message: "%{value} must be either default or night theme" }
validates :config_font,
inclusion: { in: %w[default sans_serif comic_sans],
message: "%{value} must be either default or sans serif" }
inclusion: { in: %w[default sans_serif comic_sans],
message: "%{value} must be either default or sans serif" }
validates :shipping_country,
length: { in: 2..2 },
allow_blank: true
length: { in: 2..2 },
allow_blank: true
validates :website_url, :employer_name, :employer_url,
length: { maximum: 100 }
length: { maximum: 100 }
validates :employment_title, :education, :location,
length: { maximum: 100 }
length: { maximum: 100 }
validates :mostly_work_with, :currently_learning,
:currently_hacking_on, :available_for,
length: { maximum: 500 }
length: { maximum: 500 }
validates :mentee_description, :mentor_description,
length: { maximum: 1000 }
length: { maximum: 1000 }
validates :inbox_type, inclusion: { in: %w[open private] }
validate :conditionally_validate_summary
validate :validate_mastodon_url
@ -156,19 +156,19 @@ class User < ApplicationRecord
algoliasearch per_environment: true, enqueue: :trigger_delayed_index do
attribute :name
add_index "searchables",
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
id: :index_id,
per_environment: true,
enqueue: :trigger_delayed_index do
attribute :user do
{ username: user.username,
name: user.username,
profile_image_90: profile_image_90 }
end
attribute :title, :path, :tag_list, :main_image, :id,
:featured, :published, :published_at, :featured_number, :comments_count,
:reactions_count, :positive_reactions_count, :class_name, :user_name,
:user_username, :comments_blob, :body_text, :tag_keywords_for_search,
:search_score, :hotness_score
:featured, :published, :published_at, :featured_number, :comments_count,
:reactions_count, :positive_reactions_count, :class_name, :user_name,
:user_username, :comments_blob, :body_text, :tag_keywords_for_search,
:search_score, :hotness_score
searchableAttributes ["unordered(title)",
"body_text",
"tag_list",

View file

@ -3,8 +3,8 @@ class ApplicationObserver < ActiveRecord::Observer
return unless activity.user.warned == true
SlackBot.delay.ping "@#{activity.user.username} just posted.\nThey've been warned since #{activity.user.roles.where(name: 'warned')[0].updated_at.strftime('%d %B %Y')}\nhttps://dev.to#{activity.path}",
channel: "warned-user-activity",
username: "sloan_watch_bot",
icon_emoji: ":sloan:"
channel: "warned-user-activity",
username: "sloan_watch_bot",
icon_emoji: ":sloan:"
end
end

View file

@ -4,9 +4,9 @@ class ArticleObserver < ApplicationObserver
if article.published && article.published_at > 30.seconds.ago
SlackBot.delay.ping "New Article Published: #{article.title}\nhttps://dev.to#{article.path}",
channel: "activity",
username: "article_bot",
icon_emoji: ":writing_hand:"
channel: "activity",
username: "article_bot",
icon_emoji: ":writing_hand:"
end
warned_user_ping(article)

View file

@ -17,8 +17,8 @@ xml.rss version: "2.0" do
xml.link "https://dev.to#{article.path}"
xml.guid "https://dev.to#{article.path}"
xml.description sanitize article.processed_html.html_safe,
tags: %w[strong em a table tbody thead tfoot th tr td col colgroup del p h1 h2 h3 h4 h5 h6 blockquote iframe time div span i em u b ul ol li dd dl dt q code pre img sup cite center br small],
attributes: %w[href strong em class ref rel src title alt colspan height width size rowspan span value start data-conversation data-lang id]
tags: %w[strong em a table tbody thead tfoot th tr td col colgroup del p h1 h2 h3 h4 h5 h6 blockquote iframe time div span i em u b ul ol li dd dl dt q code pre img sup cite center br small],
attributes: %w[href strong em class ref rel src title alt colspan height width size rowspan span value start data-conversation data-lang id]
end
end
end

View file

@ -123,5 +123,5 @@ Rails.application.configure do
}
config.middleware.use Rack::HostRedirect,
"practicaldev.herokuapp.com" => "dev.to"
"practicaldev.herokuapp.com" => "dev.to"
end

View file

@ -262,6 +262,6 @@ Devise.setup do |config|
# config.omniauth_path_prefix = '/my_engine/users/auth'
config.omniauth :github,
ApplicationConfig["GITHUB_KEY"], ApplicationConfig["GITHUB_SECRET"], scope: "user:email"
ApplicationConfig["GITHUB_KEY"], ApplicationConfig["GITHUB_SECRET"], scope: "user:email"
config.omniauth :twitter, ApplicationConfig["TWITTER_KEY"], ApplicationConfig["TWITTER_SECRET"]
end

View file

@ -2,9 +2,9 @@ Rails.application.configure do
config.serviceworker.routes.draw do
# map to assets implicitly
match "/serviceworker.js",
headers: { "Cache-Control" => "public, max-age=8000, s-max-age=20000, no-cache" }
headers: { "Cache-Control" => "public, max-age=8000, s-max-age=20000, no-cache" }
match "/manifest.json",
headers: { "Cache-Control" => "public, max-age=8000, s-max-age=20000, no-cache" }
headers: { "Cache-Control" => "public, max-age=8000, s-max-age=20000, no-cache" }
# Examples
#
# map to a named asset explicitly

View file

@ -9,7 +9,7 @@ RSpec.describe "ArticleMutes", type: :request do
it "returns 302 upon success" do
article = create(:article, user: user)
patch "/article_mutes/#{article.id}",
params: { article: { receive_notifications: false } }
params: { article: { receive_notifications: false } }
expect(response).to have_http_status(:found)
end
end

View file

@ -14,8 +14,8 @@ RSpec.describe "BufferUpdates", type: :request do
it "creates buffer update for tweet if tweet params are passed" do
post "/buffer_updates",
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
expect(BufferUpdate.all.size).to eq(2)
expect(BufferUpdate.last.body_text).to start_with("This is the text!!!!")
expect(BufferUpdate.last.status).to eq("pending")
@ -23,15 +23,15 @@ RSpec.describe "BufferUpdates", type: :request do
it "creates buffer update with link" do
post "/buffer_updates",
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
expect(BufferUpdate.first.body_text).to include(article.path)
end
it "creates buffer hashtag" do
post "/buffer_updates",
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
expect(BufferUpdate.first.body_text).to include("#DEVCommunity")
end
@ -40,8 +40,8 @@ RSpec.describe "BufferUpdates", type: :request do
create(:tag, name: "rails")
tag = create(:tag, buffer_profile_id_code: "placeholder", name: "ruby")
post "/buffer_updates",
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
expect(BufferUpdate.all.size).to eq(3)
expect(BufferUpdate.second.tag_id).to eq(tag.id)
expect(BufferUpdate.last.social_service_name).to eq("facebook")
@ -57,8 +57,8 @@ RSpec.describe "BufferUpdates", type: :request do
it "rejects buffer update for non-trusted user" do
expect do
post "/buffer_updates",
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
params:
{ buffer_update: { body_text: "This is the text!!!!", tag_id: "javascript", article_id: article.id } }
end.to raise_error(Pundit::NotAuthorizedError)
end
end

View file

@ -98,8 +98,8 @@ RSpec.describe "ChatChannels", type: :request do
describe "POST /chat_channels" do
it "creates chat_channel for current user" do
post "/chat_channels",
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channel" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channel" } },
headers: { HTTP_ACCEPT: "application/json" }
expect(ChatChannel.last.slug).to eq("hello-channel")
expect(ChatChannel.last.active_users).to include(user)
end
@ -107,8 +107,8 @@ RSpec.describe "ChatChannels", type: :request do
it "returns errors if channel is invalid" do
# slug should be taken
post "/chat_channels",
params: { chat_channel: { channel_name: "HEy hey hoho", slug: chat_channel.slug } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { channel_name: "HEy hey hoho", slug: chat_channel.slug } },
headers: { HTTP_ACCEPT: "application/json" }
expect(response.body).to include("Slug has already been taken")
end
end
@ -117,23 +117,23 @@ RSpec.describe "ChatChannels", type: :request do
it "updates channel for valid user" do
user.add_role(:super_admin)
put "/chat_channels/#{chat_channel.id}",
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channelly" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channelly" } },
headers: { HTTP_ACCEPT: "application/json" }
expect(ChatChannel.last.slug).to eq("hello-channelly")
end
it "dissallows invalid users" do
expect do
put "/chat_channels/#{chat_channel.id}",
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channelly" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channelly" } },
headers: { HTTP_ACCEPT: "application/json" }
end.to raise_error(Pundit::NotAuthorizedError)
end
it "returns errors if channel is invalid" do
# slug should be taken
user.add_role(:super_admin)
put "/chat_channels/#{chat_channel.id}",
params: { chat_channel: { channel_name: "HEy hey hoho", slug: invite_channel.slug } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { channel_name: "HEy hey hoho", slug: invite_channel.slug } },
headers: { HTTP_ACCEPT: "application/json" }
expect(response.body).to include("Slug has already been taken")
end
end
@ -142,8 +142,8 @@ RSpec.describe "ChatChannels", type: :request do
it "raises NotAuthorizedError if user is not logged in" do
expect do
post "/chat_channels/#{chat_channel.id}/moderate",
params: { chat_channel: { command: "/ban huh" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { command: "/ban huh" } },
headers: { HTTP_ACCEPT: "application/json" }
end.to raise_error(Pundit::NotAuthorizedError)
end
@ -151,8 +151,8 @@ RSpec.describe "ChatChannels", type: :request do
sign_in user
expect do
post "/chat_channels/#{chat_channel.id}/moderate",
params: { chat_channel: { command: "/ban huh" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { chat_channel: { command: "/ban huh" } },
headers: { HTTP_ACCEPT: "application/json" }
end.to raise_error(Pundit::NotAuthorizedError)
end
@ -165,13 +165,13 @@ RSpec.describe "ChatChannels", type: :request do
it "enforces chat_channel_params on ban" do
post "/chat_channels/#{chat_channel.id}/moderate",
params: { chat_channel: { command: "/ban #{test_subject.username}" } }
params: { chat_channel: { command: "/ban #{test_subject.username}" } }
expect(response.status).to eq(200)
end
it "enforces chat_channel_params on unban" do
post "/chat_channels/#{chat_channel.id}/moderate",
params: { chat_channel: { command: "/unban #{test_subject.username}" } }
params: { chat_channel: { command: "/unban #{test_subject.username}" } }
expect(response.status).to eq(200)
end
end
@ -192,19 +192,19 @@ RSpec.describe "ChatChannels", type: :request do
describe "POST /chat_channels/create_chat" do
it "creates open chat with user who has open inbox" do
post "/chat_channels/create_chat",
params: { user_id: user_open_inbox.id }
params: { user_id: user_open_inbox.id }
expect(response.status).to eq(200)
end
it "does not create for non-open inbox user" do
post "/chat_channels/create_chat",
params: { user_id: user_closed_inbox.id }
params: { user_id: user_closed_inbox.id }
expect(response.status).to eq(400)
end
it "creates ensures new chat channel is created for targeted user" do
post "/chat_channels/create_chat",
params: { user_id: user_open_inbox.id }
params: { user_id: user_open_inbox.id }
expect(user_open_inbox.chat_channel_memberships.size).to eq(1)
end
end
@ -213,13 +213,13 @@ RSpec.describe "ChatChannels", type: :request do
it "blocks successfully when user has permissions" do
direct_channel.add_users [user]
post "/chat_channels/block_chat",
params: { chat_id: direct_channel.id }
params: { chat_id: direct_channel.id }
expect(response.status).to eq(200)
end
it "makes chat channel have status of blocked" do
direct_channel.add_users [user]
post "/chat_channels/block_chat",
params: { chat_id: direct_channel.id }
params: { chat_id: direct_channel.id }
expect(direct_channel.reload.status).to eq("blocked")
end
it "does not block when channel is open" do

View file

@ -78,8 +78,8 @@ RSpec.describe "Comments", type: :request do
describe "POST /comments/preview" do
it "returns 401 if user is not logged in" do
post "/comments/preview",
params: { comment: { body_markdown: "hi" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { comment: { body_markdown: "hi" } },
headers: { HTTP_ACCEPT: "application/json" }
expect(response).to have_http_status(:unauthorized)
end
@ -87,8 +87,8 @@ RSpec.describe "Comments", type: :request do
before do
login_as user
post "/comments/preview",
params: { comment: { body_markdown: "hi" } },
headers: { HTTP_ACCEPT: "application/json" }
params: { comment: { body_markdown: "hi" } },
headers: { HTTP_ACCEPT: "application/json" }
end
it "returns 200 on good request" do

View file

@ -13,7 +13,7 @@ RSpec.describe "Following/Unfollowing", type: :request do
it "updates user to offer mentorship" do
user.follow(tag)
put "/follows/#{Follow.last.id}",
params: { follow: { points: 3.0 } }
params: { follow: { points: 3.0 } }
expect(Follow.last.points).to eq(3.0)
end
@ -21,7 +21,7 @@ RSpec.describe "Following/Unfollowing", type: :request do
user_2.follow(tag)
expect do
put "/follows/#{Follow.last.id}",
params: { follow: { points: 3.0 } }
params: { follow: { points: 3.0 } }
end.to raise_error(Pundit::NotAuthorizedError)
end
end

View file

@ -13,33 +13,33 @@ RSpec.describe "InternalBufferUpdates", type: :request do
describe "POST /internal/buffer_updates" do
it "creates buffer update for tweet if tweet params are passed" do
post "/internal/buffer_updates",
params:
{ social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test" }
params:
{ social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test" }
expect(BufferUpdate.all.size).to eq(1)
post "/internal/buffer_updates",
params: { social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test!" }
params: { social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test!" }
expect(BufferUpdate.all.size).to eq(2)
expect(BufferUpdate.last.article_id).to eq(article.id)
end
it "updates last buffered at" do
post "/internal/buffer_updates",
params:
{ social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test" }
params:
{ social_channel: "main_twitter", article_id: article.id, tweet: "Hello this is a test" }
expect(article.reload.last_buffered).not_to eq(nil)
end
it "updates last buffered at with satellite buffer" do
post "/internal/buffer_updates",
params:
{ social_channel: "satellite_twitter", article_id: article.id, tweet: "Hello this is a test" }
params:
{ social_channel: "satellite_twitter", article_id: article.id, tweet: "Hello this is a test" }
expect(article.reload.last_buffered).not_to eq(nil)
end
it "updates last facebook buffered at" do
post "/internal/buffer_updates",
params:
{ social_channel: "facebook", article_id: article.id, tweet: "Hello this is a test" }
params:
{ social_channel: "facebook", article_id: article.id, tweet: "Hello this is a test" }
expect(article.reload.facebook_last_buffered).not_to eq(nil)
end
end

View file

@ -10,13 +10,13 @@ RSpec.describe "VideoStatesUpdate", type: :request do
it "updates video state" do
input = JSON.unparse(input: { key: article.video_code })
post "/video_states?key=#{authorized_user.secret}",
params: { Message: input }.to_json
params: { Message: input }.to_json
expect(Article.last.video_state).to eq("COMPLETED")
end
it "rejects non-authorized users" do
post "/video_states?key=#{regular_user.secret}",
params: { input: { key: article.video_code } }
params: { input: { key: article.video_code } }
expect(response).to have_http_status(:unprocessable_entity)
end
end

View file

@ -6,10 +6,10 @@ Capybara.default_max_wait_time = 5
Capybara.register_driver :headless_chrome do |app|
Capybara::Selenium::Driver.new app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1400,2000] },
)
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w[headless disable-gpu no-sandbox window-size=1400,2000] },
)
end
RSpec.configure do |config|