Enabled rubocop/lint (#2130)

* WIP: Enabled rubocop/lint

* FIX: Fixed failing test

* FIX: Small change to return

* FIX: Changed indent
This commit is contained in:
Tim Lange 2019-03-21 15:53:44 +01:00 committed by Ben Halpern
parent f70852d547
commit 3494264404
54 changed files with 49 additions and 212 deletions

View file

@ -247,107 +247,6 @@ Layout/InitialIndentation:
Checks the indentation of the first non-blank non-comment line in a file.
Enabled: false
# Lint
Lint/AmbiguousOperator:
Description: >-
Checks for ambiguous operators in the first argument of a
method invocation without parentheses.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
Enabled: false
Lint/AmbiguousRegexpLiteral:
Description: >-
Checks for ambiguous regexp literals in the first argument of
a method invocation without parenthesis.
Enabled: false
Lint/AssignmentInCondition:
Description: "Don't use assignment in conditions."
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
Enabled: false
Lint/CircularArgumentReference:
Description: "Don't refer to the keyword argument in the default value."
Enabled: false
Lint/DeprecatedClassMethods:
Description: 'Check for deprecated class method calls.'
Enabled: false
Lint/DuplicatedKey:
Description: 'Check for duplicate keys in hash literals.'
Enabled: false
Lint/EachWithObjectArgument:
Description: 'Check for immutable argument given to each_with_object.'
Enabled: false
Lint/ElseLayout:
Description: 'Check for odd code arrangement in an else block.'
Enabled: false
Lint/FormatParameterMismatch:
Description: 'The number of parameters to format/sprint must match the fields.'
Enabled: false
Lint/HandleExceptions:
Description: "Don't suppress exception."
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
Enabled: false
Lint/LiteralAsCondition:
Description: 'Checks of literals used in conditions.'
Enabled: false
Lint/LiteralInInterpolation:
Description: 'Checks for literals used in interpolation.'
Enabled: false
Lint/Loop:
Description: >-
Use Kernel#loop with break rather than begin/end/until or
begin/end/while for post-loop tests.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
Enabled: false
Lint/NestedMethodDefinition:
Description: 'Do not use nested method definitions.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
Enabled: false
Lint/NonLocalExitFromIterator:
Description: 'Do not use return in iterator to cause non-local exit.'
Enabled: false
Lint/ParenthesesAsGroupedExpression:
Description: >-
Checks for method calls with a space before the opening
parenthesis.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
Enabled: false
Lint/RequireParentheses:
Description: >-
Use parentheses in the method call to avoid confusion
about precedence.
Enabled: false
Lint/UnderscorePrefixedVariableName:
Description: 'Do not use prefix `_` for a variable that is used.'
Enabled: false
Lint/UnneededCopDisableDirective:
Description: >-
Checks for rubocop:disable comments that can be removed.
Note: this cop is not disabled when disabling all cops.
It must be explicitly disabled.
Enabled: false
Lint/Void:
Description: 'Possible use of operator/literal/variable in void context.'
Enabled: false
# Performance
Performance/CaseWhenSplat:

View file

@ -1,4 +1,3 @@
# rubocop:disable LineLength
source "https://rubygems.org"
ruby "2.6.1"
@ -157,4 +156,3 @@ group :test do
gem "webmock", "~> 3.5"
gem "zonebie", "~> 0.6.1"
end
# rubocop:enable LineLength

View file

@ -15,9 +15,9 @@ class ArticlesController < ApplicationController
page(params[:page].to_i).per(12)
if params[:username]
if @user = User.find_by_username(params[:username])
if (@user = User.find_by_username(params[:username]))
@articles = @articles.where(user_id: @user.id)
elsif @user = Organization.find_by_slug(params[:username])
elsif (@user = Organization.find_by_slug(params[:username]))
@articles = @articles.where(organization_id: @user.id).includes(:user)
else
render body: nil
@ -129,7 +129,7 @@ class ArticlesController < ApplicationController
Notification.remove_all_without_delay(notifiable_id: @article.id, notifiable_type: "Article", action: "Published")
path = "/#{@article.username}/#{@article.slug}?preview=#{@article.password}"
end
redirect_to (params[:destination] || path)
redirect_to(params[:destination] || path)
else
render :edit
end

View file

@ -91,9 +91,9 @@ class CommentsController < ApplicationController
github_username: current_user.github_username
}
}
elsif @comment = Comment.where(body_markdown: @comment.body_markdown,
commentable_id: @comment.commentable.id,
ancestry: @comment.ancestry)[1]
elsif (@comment = Comment.where(body_markdown: @comment.body_markdown,
commentable_id: @comment.commentable.id,
ancestry: @comment.ancestry)[1])
@comment.destroy
render json: { status: "comment already exists" }
return

View file

@ -20,9 +20,9 @@ class StoriesController < ApplicationController
def show
@story_show = true
add_param_context(:username, :slug)
if @article = Article.find_by_path("/#{params[:username].downcase}/#{params[:slug]}")&.decorate
if (@article = Article.find_by_path("/#{params[:username].downcase}/#{params[:slug]}")&.decorate)
handle_article_show
elsif @article = Article.find_by_slug(params[:slug])&.decorate
elsif (@article = Article.find_by_slug(params[:slug])&.decorate)
handle_possible_redirect
else
@podcast = Podcast.find_by_slug(params[:username]) || not_found
@ -58,7 +58,7 @@ class StoriesController < ApplicationController
if @user&.articles&.find_by_slug(params[:slug])
redirect_to "/#{@user.username}/#{params[:slug]}"
return
elsif @organization = @article.organization
elsif (@organization = @article.organization)
redirect_to "/#{@organization.slug}/#{params[:slug]}"
return
end

View file

@ -90,7 +90,7 @@ class UsersController < ApplicationController
def join_org
authorize User
if @organization = Organization.find_by_secret(params[:org_secret])
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."

View file

@ -12,7 +12,8 @@ class VideoStatesController < ApplicationController
logger.info "VIDEO STATES: #{params}"
request_json = JSON.parse(request.raw_post, symbolize_names: true)
logger.info "VIDEO STATES: #{request_json}"
rescue StandardError
rescue StandardError => e
Rails.logger.warn(e)
end
request_json = JSON.parse(request.raw_post, symbolize_names: true)
message_json = JSON.parse(request_json[:Message], symbolize_names: true)

View file

@ -139,7 +139,7 @@ module ApplicationHelper
def tag_colors(tag)
Rails.cache.fetch("view-helper-#{tag}/tag_colors", expires_in: 5.hours) do
if found_tag = Tag.select(%i[bg_color_hex text_color_hex]).find_by_name(tag)
if (found_tag = Tag.select(%i[bg_color_hex text_color_hex]).find_by_name(tag))
{ background: found_tag.bg_color_hex, color: found_tag.text_color_hex }
else
{ background: "#d6d9e0", color: "#606570" }

View file

@ -14,7 +14,7 @@ class PodcastFeed
feed.items.first(num).each do |item|
if !existing_episode(item, podcast)
create_new_episode(item, podcast)
elsif ep = existing_episode(item, podcast).first
elsif (ep = existing_episode(item, podcast).first)
update_existing_episode(ep, item, podcast)
end
end

View file

@ -1,6 +1,6 @@
class NullTag < Liquid::Block
def initialize(_tag_name, _markup, _options)
raise StandardError, "Liquid##{_tag_name} tag is disabled"
def initialize(tag_name, _markup, _options)
raise StandardError, "Liquid##{tag_name} tag is disabled"
end
end

View file

@ -13,7 +13,7 @@ class PodcastTag < LiquidTagBase
def initialize(_tag_name, link, _tokens)
@episode = fetch_podcast(link)
@podcast
@podcast ||= Podcast.new
end
def render(_context)

View file

@ -410,8 +410,8 @@ class Article < ApplicationRecord
HTTParty.get(url).body.split("#EXTINF:").each do |chunk|
duration += chunk.split(",")[0].to_f
end
duration
self.video_duration_in_seconds = duration
duration
end
rescue StandardError => e
puts e.message

View file

@ -71,7 +71,7 @@ class ChatChannel < ApplicationRecord
slug = contrived_name.to_s.downcase.tr(" ", "-").gsub(/[^\w-]/, "").tr("_", "") + "-" + rand(100_000).to_s(26)
end
if channel = ChatChannel.find_by_slug(slug)
if (channel = ChatChannel.find_by_slug(slug))
channel.status = "active"
channel.save
else

View file

@ -20,7 +20,7 @@ class Mention < ApplicationRecord
mentions = []
doc.css(".comment-mentioned-user").each do |link|
username = link.text.gsub("@", "").downcase
if user = User.find_by_username(username)
if (user = User.find_by_username(username))
usernames << username
mentions << create_mention(user)
end

View file

@ -26,7 +26,7 @@ class Message < ApplicationRecord
where.not(user_id: user.id).pluck(:user_id)
PushNotificationSubscription.where(user_id: receiver_ids).find_each do |sub|
return if no_push_necessary?(sub)
break if no_push_necessary?(sub)
Webpush.payload_send(
endpoint: sub.endpoint,
@ -76,7 +76,7 @@ class Message < ApplicationRecord
doc = Nokogiri::HTML(html)
rich_style = "border: 1px solid #0a0a0a; border-radius: 3px; padding: 8px;"
doc.css("a").each do |a|
if article = rich_link_article(a)
if (article = rich_link_article(a))
html += "<a style='color: #0a0a0a' href='#{article.path}'
target='_blank' data-content='articles/#{article.id}'>
<h1 style='#{rich_style}' data-content='articles/#{article.id}'>

View file

@ -128,7 +128,8 @@ class PodcastEpisode < ApplicationRecord
cache_buster.bust("/" + podcast_slug)
cache_buster.bust("/pod")
cache_buster.bust(path)
rescue StandardError
rescue StandardError => e
Rails.logger.warn(e)
end
purge
purge_all

View file

@ -70,7 +70,6 @@ class User < ApplicationRecord
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] }
# rubocop:disable Metrics/LineLength
validates :facebook_url,
format: /\A(http(s)?:\/\/)?(www.facebook.com|facebook.com)\/.*\Z/,
allow_blank: true
@ -94,7 +93,6 @@ class User < ApplicationRecord
validates :gitlab_url,
allow_blank: true,
format: /\A(http(s)?:\/\/)?(www.gitlab.com|gitlab.com)\/.*\Z/
# rubocop:enable Metrics/LineLength
validates :shirt_gender,
inclusion: { in: %w[unisex womens],
message: "%{value} is not a valid shirt style" },

View file

@ -30,14 +30,14 @@ class ArticleApiIndexService
else
30
end
if user = User.find_by_username(username)
if (user = User.find_by_username(username))
user.articles.
where(published: true).
includes(:user).
order("published_at DESC").
page(page).
per(num)
elsif organization = Organization.find_by_slug(username)
elsif (organization = Organization.find_by_slug(username))
organization.articles.
where(published: true).
includes(:user).

View file

@ -67,7 +67,7 @@ class RssReader
possible_link = a_tag[0].inner_html
if /medium\.com\/media\/.+\/href/.match?(possible_link)
real_link = HTTParty.head(possible_link).request.last_uri.to_s
return unless real_link.include?("gist.github.com")
return nil unless real_link.include?("gist.github.com")
iframe.name = "p"
iframe.keys.each { |attr| iframe.remove_attribute(attr) }

View file

@ -14,11 +14,9 @@ json.canonical_url @article.processed_canonical_url
json.comments_count @article.comments_count
json.positive_reactions_count @article.positive_reactions_count
json.body_html @article.processed_html
json.ltag_style (@article.liquid_tags_used.map do |ltag|
Rails.application.assets["ltags/#{ltag}.css"].to_s.html_safe
end)
json.ltag_script (@article.liquid_tags_used.map { |ltag| ltag.script.html_safe })
json.body_html @article.processed_html
json.ltag_style(@article.liquid_tags_used.map { |ltag| Rails.application.assets["ltags/#{ltag}.css"].to_s.html_safe })
json.ltag_script(@article.liquid_tags_used.map { |ltag| ltag.script.html_safe })
json.user do
json.name @article.user.name

View file

@ -12,7 +12,7 @@ xml.rss version: "2.0" do
@articles.each do |article|
xml.item do
xml.title article.title
xml.author @user && @user.class.name == "User" ? @user.name : article.user.name
xml.author(@user && @user.class.name == "User" ? @user.name : article.user.name)
xml.pubDate article.published_at.to_s(:rfc822) if article.published_at
xml.link "https://dev.to#{article.path}"
xml.guid "https://dev.to#{article.path}"

View file

@ -1,4 +1,4 @@
json.array! (@chat_channels_memberships.sort_by { |m| m.chat_channel.last_message_at }.reverse!) do |membership|
json.array!(@chat_channels_memberships.sort_by { |m| m.chat_channel.last_message_at }.reverse!) do |membership|
json.id membership.chat_channel.id
membership.chat_channel.current_user = current_user
json.slug membership.chat_channel.slug

View file

@ -1,5 +1,3 @@
# rubocop:disable Metrics/BlockLength
#
def yarn_integrity_enabled?
ENV.fetch("YARN_INTEGRITY_ENABLED", "true") == "true"
end
@ -100,5 +98,3 @@ Rails.application.configure do
Bullet.console = true
end
end
# rubocop:enable Metrics/BlockLength

View file

@ -1,5 +1,3 @@
# rubocop:disable Metrics/BlockLength
Rails.application.configure do
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
@ -127,5 +125,3 @@ Rails.application.configure do
config.middleware.use Rack::HostRedirect,
"practicaldev.herokuapp.com" => "dev.to"
end
# rubocop:enable Metrics/BlockLength

View file

@ -127,7 +127,7 @@ podcast_objects = [
twitter_username: "CodingBlocks",
website_url: "http://codingblocks.net",
main_color_hex: "111111",
overcast_url: "https://overcast.fm/itunes769189585/coding-blocks-software-and-web-programming-security-best-practices-microsoft-net", # rubocop:disable Metrics/LineLength
overcast_url: "https://overcast.fm/itunes769189585/coding-blocks-software-and-web-programming-security-best-practices-microsoft-net",
android_url: "http://subscribeonandroid.com/feeds.podtrac.com/c8yBGHRafqhz",
image: Rack::Test::UploadedFile.new(image_file, "image/jpeg")
},
@ -139,7 +139,7 @@ podcast_objects = [
twitter_username: "TalkPython",
website_url: "https://talkpython.fm",
main_color_hex: "181a1c",
overcast_url: "https://overcast.fm/itunes979020229/talk-python-to-me-python-conversations-for-passionate-developers", # rubocop:disable Metrics/LineLength
overcast_url: "https://overcast.fm/itunes979020229/talk-python-to-me-python-conversations-for-passionate-developers",
android_url: "https://subscribeonandroid.com/talkpython.fm/episodes/rss",
image: Rack::Test::UploadedFile.new(image_file, "image/jpeg")
},
@ -147,7 +147,7 @@ podcast_objects = [
title: "Developer on Fire",
description: "",
feed_url: "http://developeronfire.com/rss.xml",
itunes_url: "https://itunes.apple.com/us/podcast/developer-on-fire/id1006105326", # rubocop:disable Metrics/LineLength
itunes_url: "https://itunes.apple.com/us/podcast/developer-on-fire/id1006105326",
slug: "developeronfire",
twitter_username: "raelyard",
website_url: "http://developeronfire.com",
@ -160,7 +160,7 @@ podcast_objects = [
title: "Building Programmers",
description: "",
feed_url: "https://building.fireside.fm/rss",
itunes_url: "https://itunes.apple.com/us/podcast/building-programmers/id1149043456", # rubocop:disable Metrics/LineLength
itunes_url: "https://itunes.apple.com/us/podcast/building-programmers/id1149043456",
slug: "buildingprogrammers",
twitter_username: "run_kmc",
website_url: "https://building.fireside.fm",
@ -181,7 +181,7 @@ p "7/9 Creating Broadcasts"
Broadcast.create!(
title: "Welcome Notification",
processed_html: "Welcome to dev.to! Start by introducing yourself in <a href='/welcome' data-no-instant>the welcome thread</a>.", # rubocop:disable Metrics/LineLength
processed_html: "Welcome to dev.to! Start by introducing yourself in <a href='/welcome' data-no-instant>the welcome thread</a>.",
type_of: "Onboarding",
sent: true,
)

View file

@ -1,4 +1,3 @@
# rubocop:disable Metrics/LineLength
# namespace :db do
#
# desc "Copy production database to local"
@ -29,4 +28,3 @@
# pg_restore --verbose --no-acl --no-owner -t articles -t users -t podcasts -t podcast_episodes -t sponsors -t identities -t organizations -h localhost -d PracticalDeveloper_development latest.dump
# rake db:migrate
# pg_restore --verbose --clean --no-acl --no-owner -t articles -t users -t podcasts -t podcast_episodes -t sponsors -t identities -t organizations -h localhost -d PracticalDeveloper_development latest.dump
# rubocop:enable Metrics/LineLength

View file

@ -18,7 +18,6 @@ RSpec.describe "Creating Comment", type: :feature, js: true do
expect(page).to have_text(raw_comment)
end
# rubocop:disable RSpec/ExampleLength
it "User fill out commen box then click previews and submit" do
visit user.path
visit article.path.to_s
@ -43,5 +42,4 @@ RSpec.describe "Creating Comment", type: :feature, js: true do
find(:xpath, "//div[contains(@class, 'reply-actions')]/input[@name='commit']").click
expect(page).to have_text(raw_comment)
end
# rubocop:enable RSpec/ExampleLength
end

View file

@ -8,7 +8,6 @@ RSpec.describe "Organization setting page(/settings/organization)", type: :featu
sign_in user
end
# rubocop:disable RSpec/ExampleLength
it "user creates an organization" do
visit "settings/organization"
fill_in "organization[name]", with: "Organization Name"
@ -33,5 +32,4 @@ RSpec.describe "Organization setting page(/settings/organization)", type: :featu
page.driver.browser.switch_to.alert.accept
expect(page).not_to have_text(user2.name)
end
# rubocop:enable RSpec/ExampleLength
end

View file

@ -1,4 +1,3 @@
# rubocop:disable Metrics/LineLength
# require "rails_helper"
# describe "User views and closes onboarding", type: :feature, js: true do

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe BadgeRewarder do
@ -120,5 +119,3 @@ RSpec.describe BadgeRewarder do
end
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -26,8 +26,8 @@ RSpec.describe FlareTag do
end
describe "#flare_tag_hash" do
let (:tag) { create(:tag, name: "ama", bg_color_hex: "#f3f3f3", text_color_hex: "#cccccc") }
let (:valid_article) { create(:article, tags: tag.name) }
let(:tag) { create(:tag, name: "ama", bg_color_hex: "#f3f3f3", text_color_hex: "#cccccc") }
let(:valid_article) { create(:article, tags: tag.name) }
it "returns nil if an article doesn't have a flare tag" do
expect(described_class.new(article).tag_hash).to be nil

View file

@ -87,7 +87,6 @@ RSpec.describe MailchimpBot do
expect(described_class.new(user).upsert_to_membership_newsletter).to be(false)
end
# rubocop:disable RSpec/ExampleLength
context "when user is a sustaining member" do
it "send proper information" do
user.update(monthly_dues: 2500, email_membership_newsletter: true)
@ -110,7 +109,6 @@ RSpec.describe MailchimpBot do
with(hash_including(body: hash_including(status: "unsubscribed")))
end
end
# rubocop:enable RSpec/ExampleLength
end
describe "#unsubscribe_all_newsletters" do

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe Article, type: :model do
@ -117,7 +116,7 @@ RSpec.describe Article, type: :model do
context "when unpublished" do
it "creates proper slug with this-is-the-slug format" do
expect(article0.slug).to match /(.*-){4,}/
expect(article0.slug).to match(/(.*-){4,}/)
end
it "modifies slug on create if proposed slug already exists on the user" do
@ -464,4 +463,3 @@ RSpec.describe Article, type: :model do
include_examples "#sync_reactions_count", :article
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe ChatChannel, type: :model do
@ -33,4 +32,3 @@ RSpec.describe ChatChannel, type: :model do
expect(chat_channel.channel_users.size).to eq(1)
end
end
# rubocop:enable RSpec/MultipleExpectations

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe Mention, type: :model do
@ -72,4 +71,3 @@ RSpec.describe Mention, type: :model do
expect(Mention.all.size).to eq(0)
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe Reaction, type: :model do
@ -85,4 +84,3 @@ RSpec.describe Reaction, type: :model do
end
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe User, type: :model do
@ -8,7 +7,7 @@ RSpec.describe User, type: :model do
let(:article) { create(:article, user_id: user.id) }
let(:tag) { create(:tag) }
let(:org) { create(:organization) }
let (:second_org) { create(:organization) }
let(:second_org) { create(:organization) }
before { mock_auth_hash }
@ -586,4 +585,3 @@ RSpec.describe User, type: :model do
end
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -22,7 +22,7 @@ RSpec.describe "AdditionalContentBoxes", type: :request do
it "returns boosted article if available" do
organization = create(:organization)
create(:article, published: true, featured: true)
boosted_sugg = create(:article, tags: [tag.name], featured: true, boosted_additional_articles: true, organization_id: organization.id) # rubocop:disable Metrics/LineLength
boosted_sugg = create(:article, tags: [tag.name], featured: true, boosted_additional_articles: true, organization_id: organization.id)
get "/additional_content_boxes?article_id=#{regular_article.id}&state=include_sponsors"
expect(response.body).to include CGI.escapeHTML(boosted_sugg.title)
end

View file

@ -31,7 +31,7 @@ RSpec.describe "ApiSecretsCreate", type: :request do
it "does not create the ApiSecret" do
expect { post "/users/api_secrets", params: { api_secret: invalid_params } }.
not_to (change { user.api_secrets.count })
not_to(change { user.api_secrets.count })
end
it "flashes an error message" do

View file

@ -10,7 +10,7 @@ RSpec.describe "ApiSecretsDestroy", type: :request do
context "when delete succeeds" do
it "deletes the ApiSecret for the user" do
expect { delete "/users/api_secrets", params: { id: api_secret.id } }.
to change { user.api_secrets.count }.by -1
to change { user.api_secrets.count }.by(-1)
end
it "flashes a notice" do
@ -28,7 +28,7 @@ RSpec.describe "ApiSecretsDestroy", type: :request do
it "does not delete the ApiSecret" do
expect { delete "/users/api_secrets", params: { id: api_secret.id } }.
not_to (change { user.api_secrets.count })
not_to(change { user.api_secrets.count })
end
it "flashes an error message" do

View file

@ -26,7 +26,6 @@ RSpec.describe "ArticlesApi", type: :request do
expect(JSON.parse(response.body).size).to eq(2)
end
# rubocop:disable RSpec/ExampleLength
it "returns organization articles if username param is present" do
org = create(:organization)
create(:article, user_id: user1.id)
@ -37,7 +36,6 @@ RSpec.describe "ArticlesApi", type: :request do
get "/api/articles?username=#{org.slug}"
expect(JSON.parse(response.body).size).to eq(2)
end
# rubocop:enable RSpec/ExampleLength
it "returns tag articles if tag param is present" do
article = create(:article)

View file

@ -15,7 +15,6 @@ RSpec.describe "ArticlesCreate", type: :request do
expect(Article.last.user_id).to eq(user.id)
end
# rubocop:disable RSpec/ExampleLength
it "creates article with front matter params" do
post "/articles", params: {
article: {
@ -61,5 +60,4 @@ RSpec.describe "ArticlesCreate", type: :request do
}
expect(Collection.last.slug).to eq("helloyo")
end
# rubocop:enable RSpec/ExampleLength
end

View file

@ -16,7 +16,6 @@ RSpec.describe "ArticlesUpdate", type: :request do
expect(Article.last.title).to eq(new_title)
end
# rubocop:disable RSpec/ExampleLength
it "does not create a job opportunity if no hiring tag" do
new_title = "NEW TITLE #{rand(100)}"
put "/articles/#{article.id}", params: {
@ -38,5 +37,4 @@ RSpec.describe "ArticlesUpdate", type: :request do
}
expect(Article.last.job_opportunity.remoteness).to eq("on_premise")
end
# rubocop:enable RSpec/ExampleLength
end

View file

@ -13,7 +13,6 @@ RSpec.describe "Blocks", type: :request do
end
end
# rubocop:disable RSpec/ExampleLength
describe "POST blocks" do
it "creates block from input data" do
post "/blocks", params: {
@ -38,7 +37,6 @@ RSpec.describe "Blocks", type: :request do
expect(Block.last.processed_css).to include("color: red")
end
end
# rubocop:enable RSpec/ExampleLength
describe "DELETE blocks" do
it "updates block from input data" do

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe "ChatChannelMemberships", type: :request do
@ -90,4 +89,3 @@ RSpec.describe "ChatChannelMemberships", type: :request do
end
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -50,7 +50,7 @@ RSpec.describe "ChatChannels", type: :request do
describe "get /chat_channels?state=pending" do
it "returns pending channels" do
ChatChannelMembership.create(chat_channel_id: invite_channel.id, user_id: user.id, status: "pending") # rubocop:disable Metrics/LineLength
ChatChannelMembership.create(chat_channel_id: invite_channel.id, user_id: user.id, status: "pending")
sign_in user
get "/chat_channels?state=pending"
expect(response.body).to include(invite_channel.slug)
@ -63,7 +63,7 @@ RSpec.describe "ChatChannels", type: :request do
end
it "returns no pending channels if not pending" do
ChatChannelMembership.create(chat_channel_id: invite_channel.id, user_id: user.id, status: "rejected") # rubocop:disable Metrics/LineLength
ChatChannelMembership.create(chat_channel_id: invite_channel.id, user_id: user.id, status: "rejected")
sign_in user
get "/chat_channels?state=pending"
expect(response.body).not_to include(invite_channel.slug)
@ -93,7 +93,6 @@ RSpec.describe "ChatChannels", type: :request do
end
describe "POST /chat_channels" do
# rubocop:disable RSpec/MultipleExpectations
it "creates chat_channel for current user" do
post "/chat_channels",
params: { chat_channel: { channel_name: "Hello Channel", slug: "hello-channel" } },
@ -101,7 +100,6 @@ RSpec.describe "ChatChannels", type: :request do
expect(ChatChannel.last.slug).to eq("hello-channel")
expect(ChatChannel.last.active_users).to include(user)
end
# rubocop:enable RSpec/MultipleExpectations
it "returns errors if channel is invalid" do
# slug should be taken
@ -146,7 +144,6 @@ RSpec.describe "ChatChannels", type: :request do
end.to raise_error(Pundit::NotAuthorizedError)
end
# rubocop:disable RSpec/ExampleLength
it "raises NotAuthorizedError if user is logged in but not authorized" do
sign_in user
expect do
@ -155,7 +152,6 @@ RSpec.describe "ChatChannels", type: :request do
headers: { HTTP_ACCEPT: "application/json" }
end.to raise_error(Pundit::NotAuthorizedError)
end
# rubocop:enable RSpec/ExampleLength
context "when user is logged-in and authorized" do
before do

View file

@ -79,7 +79,6 @@ RSpec.describe "StoriesShow", type: :request do
expect(response.body).not_to include html_variant.html
end
# rubocop:disable RSpec/ExampleLength
it "renders articles of long length without breaking" do
# This is a pretty weak test, just to exercise different lengths with no breakage
article.update(title: (0...75).map { rand(65..90).chr }.join)
@ -90,7 +89,6 @@ RSpec.describe "StoriesShow", type: :request do
get article.path
expect(response.body).to include "title"
end
# rubocop:enable RSpec/ExampleLength
end
context "when story is a user" do

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe "StripeSubscriptions", type: :request do
@ -170,4 +169,3 @@ RSpec.describe "StripeSubscriptions", type: :request do
end
end
end
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/MultipleExpectations
require "rails_helper"
RSpec.describe "ArticlesApi", type: :request do
@ -22,4 +21,3 @@ RSpec.describe "ArticlesApi", type: :request do
end
end
end
# rubocop:enable RSpec/MultipleExpectations

View file

@ -20,7 +20,6 @@ RSpec.describe "all routes", type: :routing do
)
end
# rubocop:disable RSpec/ExampleLength
it "renders a user's story successfully" do
expect(get: "/ben/this-is-a-slug").to route_to(
controller: "stories",
@ -29,7 +28,6 @@ RSpec.describe "all routes", type: :routing do
username: "ben",
)
end
# rubocop:enable RSpec/ExampleLength
context "when redirected routes" do
include RSpec::Rails::RequestExampleGroup

View file

@ -40,7 +40,7 @@ RSpec.describe MembershipService do
)
user_one.update(stripe_id_code: customer.id)
plan = Stripe::Plan.create(
id: "membership-#{1200}",
id: "membership-1200",
currency: "usd",
interval: "month",
name: "Monthly DEV Membership",

View file

@ -9,7 +9,7 @@ RSpec.describe Suggester::Articles::Boosted do
it "returns an article" do
user.follow(tag)
article2 = create(:article, tags: [tag.name], featured: true, boosted_additional_articles: true, organization_id: organization.id) # rubocop:disable Metrics/LineLength
article2 = create(:article, tags: [tag.name], featured: true, boosted_additional_articles: true, organization_id: organization.id)
suggested_id = described_class.new(tag.name, area: "additional_articles").suggest.id
expect(suggested_id).to eq article2.id
end

View file

@ -18,7 +18,6 @@ RSpec.describe Suggester::Articles::Classic do
expect(described_class.new(article).get).to eq []
end
# rubocop:disable RSpec/ExampleLength
it "returns single article if multiple qualify" do
user.follow(tag)
create(:reaction, user_id: user.id, reactable_id: article.id)
@ -31,5 +30,4 @@ RSpec.describe Suggester::Articles::Classic do
create(:reaction, user_id: user2.id, reactable_id: article2.id, category: "unicorn")
expect(described_class.new(article).get.first&.id).to eq article.id
end
# rubocop:enable RSpec/ExampleLength
end

View file

@ -1,4 +1,3 @@
# rubocop:disable RSpec/MultipleExpectations
require "rails_helper"
describe "articles/show", type: :view do
@ -49,7 +48,6 @@ describe "articles/show", type: :view do
expect(rendered).to have_css("input#submit-button")
end
# rubocop:disable RSpec/ExampleLength
it "shows user comments of the article" do
without_partial_double_verification do
allow(view).to receive(:comment_class) { |a, b| helper.comment_class(a, b) }
@ -61,7 +59,6 @@ describe "articles/show", type: :view do
expect(rendered).to have_text(comment1.body_html)
expect(rendered).to have_text(comment2.body_html)
end
# rubocop:enable RSpec/ExampleLength
end
# note fully implemented yet
@ -75,4 +72,3 @@ end
# end
#
# end
# rubocop:enable RSpec/MultipleExpectations