Upgrade Rubocop to 0.81 (#7219)

* Upgrade rubocop to 0.81.0

* Reordered rubocop file and updated it

* Regenerate todo

* Correct some things

* Fix specs
This commit is contained in:
rhymes 2020-04-11 10:10:04 +02:00 committed by GitHub
parent 61bb4b42ac
commit 34848a4209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 414 additions and 189 deletions

View file

@ -1,3 +1,5 @@
# TODO: [@thepracticaldev/oss] test cops that are commented out
inherit_from: .rubocop_todo.yml
require:
@ -5,19 +7,6 @@ require:
- rubocop-rails
- rubocop-rspec
# our custom config
# TODO: Uncomment it after fix rubocop-todo RSpec/MultipleExpectations
RSpec/DescribeClass:
Exclude:
- spec/requests/**/*
- spec/system/**/*
- spec/tasks/**/*
RSpec/ExampleLength:
Max: 15
#############################
AllCops:
Exclude:
- bin/**/*
@ -27,148 +16,75 @@ AllCops:
- tmp/**/*
DisplayStyleGuide: true
ExtraDetails: true
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7
Lint/AmbiguousBlockAssociation:
Exclude:
- "spec/**/*"
#################### Layout ###########################
Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: false
Metrics/ClassLength:
Description: 'Avoid classes longer than 100 lines of code.'
Enabled: false
Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false
# TODO: Uncomment it after fix rubocop-todo Metrics/BlockLength
Metrics/BlockLength:
CountComments: false # count full line comments?
# Max: 25
ExcludedMethods: []
Exclude:
- 'spec/**/*'
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: true
Max: 13
Metrics/PerceivedComplexity:
Enabled: true
Max: 14
Metrics/MethodLength:
Description: 'Avoid methods longer than 10 lines of code.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
Enabled: false
Metrics/ParameterLists:
Description: 'Avoid parameter lists longer than three or four parameters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
Enabled: false
Naming/PredicateName:
Description: 'Check the names of predicate methods.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
ForbiddenPrefixes:
- is_
Exclude:
- spec/**/*
# Style
Style/AsciiComments:
Description: 'Use only ascii symbols in comments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
Enabled: false
Style/CollectionMethods:
Enabled: true
PreferredMethods:
find: detect
inject: reduce
collect: map
find_all: select
Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Style/Encoding:
Description: 'Use UTF-8 as the source file encoding.'
Enabled: false
Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition from Ruby 2.3.0 to Ruby 3.0.
Enabled: false
# https://github.com/rubocop-hq/rubocop/blob/master/manual/cops_style.md#stylehashsyntax
Style/HashSyntax:
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
Style/IfUnlessModifier:
Description: >-
Favor modifier if/unless usage when you have a
single-line body.
Enabled: false
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
Enabled: false
Style/RegexpLiteral:
Description: 'Use / or %r around regular expressions.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
Enabled: false
Style/SingleLineBlockParams:
Description: 'Enforces the names of some block params.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
Enabled: false
Style/StringLiterals:
Description: 'Checks if uses of quotes match the configured preference.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
EnforcedStyle: double_quotes
Enabled: true
Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
EnforcedStyleForMultiline: comma
Enabled: true
Style/TrailingCommaInArrayLiteral:
Description: 'Checks for trailing comma in array literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
EnforcedStyleForMultiline: comma
Enabled: true
Rails/FilePath:
EnforcedStyle: slashes
# Layout
# Layout/ClassStructure:
# Description: 'Enforces a configured order of definitions within a class body.'
# StyleGuide: '#consistent-classes'
# Enabled: false
Layout/DotPosition:
Description: 'Checks the position of the dot in multi-line method calls.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
StyleGuide: '#consistent-multi-line-chains'
# TODO: [@thepracticaldev/oss] enable leading?
EnforcedStyle: trailing
# # TODO: Uncomment this after fixing Layout/LineLength in .rubocop_todo.yml
# Layout/LineLength:
# Description: 'Limit lines to 100 characters.'
# Max: 100
# Layout/FirstArrayElementLineBreak:
# Description: >-
# Checks for a line break before the first element in a
# multi-line array.
# Enabled: false
# Layout/FirstHashElementLineBreak:
# Description: >-
# Checks for a line break before the first element in a
# multi-line hash.
# Enabled: false
# Layout/FirstMethodArgumentLineBreak:
# Description: >-
# Checks for a line break before the first argument in a
# multi-line method call.
# Enabled: false
# Layout/FirstMethodParameterLineBreak:
# Description: >-
# Checks for a line break before the first parameter in a
# multi-line method parameter definition.
# Enabled: false
# Layout/HeredocArgumentClosingParenthesis:
# Description: >-
# Checks for the placement of the closing parenthesis in a
# method call that passes a HEREDOC string as an argument.
# Enabled: false
# StyleGuide: '#heredoc-argument-closing-parentheses'
# Layout/MultilineArrayLineBreaks:
# Description: >-
# Checks that each item in a multi-line array literal
# starts on a separate line.
# Enabled: false
# Layout/MultilineAssignmentLayout:
# Description: 'Check for a newline after the assignment operator in multi-line assignments.'
# StyleGuide: '#indent-conditional-assignment'
# Enabled: false
# Layout/MultilineHashKeyLineBreaks:
# Description: >-
# Checks that each item in a multi-line hash literal
# starts on a separate line.
# Enabled: false
# Layout/MultilineMethodArgumentLineBreaks:
# Description: >-
# Checks that each argument in a multi-line method call
# starts on a separate line.
# Enabled: false
Layout/MultilineOperationIndentation:
Description: >-
@ -184,17 +100,291 @@ Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
# Rails
#################### Lint ##################################
Rails:
Lint/AmbiguousBlockAssociation:
Description: >-
Checks for ambiguous block association with method when param passed without
parentheses.
StyleGuide: '#syntax'
Enabled: true
Exclude:
- "spec/**/*"
# Lint/HeredocMethodCallPosition:
# Description: >-
# Checks for the ordering of a method call where
# the receiver of the call is a HEREDOC.
# Enabled: false
# Lint/NumberConversion:
# Description: 'Checks unsafe usage of number conversion methods.'
# Enabled: false
Lint/RaiseException:
Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
StyleGuide: '#raise-exception'
Enabled: true
Rails/HasAndBelongsToMany:
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
Lint/StructNewOverride:
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
Enabled: true
#################### Metrics ###############################
Metrics/BlockLength:
Description: 'Avoid long blocks with many lines.'
Enabled: true
Exclude:
- 'spec/**/*'
Metrics/ClassLength:
Description: 'Avoid classes longer than 100 lines of code.'
Enabled: false
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: true
Max: 13
Metrics/MethodLength:
Description: 'Avoid methods longer than 10 lines of code.'
StyleGuide: '#short-methods'
Enabled: false
Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false
Metrics/ParameterLists:
Description: 'Avoid parameter lists longer than three or four parameters.'
StyleGuide: '#too-many-params'
Enabled: false
Metrics/PerceivedComplexity:
Description: >-
A complexity metric geared towards measuring complexity for a
human reader.
Enabled: true
Max: 14
#################### Naming ##############################
Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
StyleGuide: '#accessor_mutator_method_names'
Enabled: false
Naming/PredicateName:
Description: 'Check the names of predicate methods.'
StyleGuide: '#bool-methods-qmark'
Enabled: true
ForbiddenPrefixes:
- is_
Exclude:
- spec/**/*
#################### Style ###############################
Style/AsciiComments:
Description: 'Use only ascii symbols in comments.'
StyleGuide: '#english-comments'
Enabled: false
# Style/AutoResourceCleanup:
# Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
# Enabled: false
Style/CollectionMethods:
Description: 'Preferred collection methods.'
StyleGuide: '#map-find-select-reduce-include-size'
Enabled: true
PreferredMethods:
find: detect
# Style/ConstantVisibility:
# Description: >-
# Check that class- and module constants have
# visibility declarations.
# Enabled: false
# Style/DateTime:
# Description: 'Use Time over DateTime.'
# StyleGuide: '#no-datetime'
# Enabled: false
Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Style/Encoding:
Description: 'Use UTF-8 as the source file encoding.'
Enabled: false
Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition to frozen string literals by default.
Enabled: true
EnforcedStyle: never
Style/HashSyntax:
Description: >-
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
{ :a => 1, :b => 2 }.
StyleGuide: '#hash-literals'
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
Style/HashEachMethods:
Description: 'Use Hash#each_key and Hash#each_value.'
StyleGuide: '#hash-each'
Enabled: true
Style/HashTransformKeys:
Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
StyleGuide: '#hash-transform-methods'
Enabled: true
Style/HashTransformValues:
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
StyleGuide: '#hash-transform-methods'
Enabled: true
Style/IfUnlessModifier:
Description: >-
Favor modifier if/unless usage when you have a
single-line body.
StyleGuide: '#if-as-a-modifier'
Enabled: false
# Style/ImplicitRuntimeError:
# Description: >-
# Use `raise` or `fail` with an explicit exception class and
# message, rather than just a message.
# Enabled: false
# Style/InlineComment:
# Description: 'Avoid trailing inline comments.'
# Enabled: false
# Style/IpAddresses:
# Description: "Don't include literal IP addresses in code."
# Enabled: false
# Style/MethodCallWithArgsParentheses:
# Description: 'Use parentheses for method calls with arguments.'
# StyleGuide: '#method-invocation-parens'
# Enabled: false
# Style/MethodCalledOnDoEndBlock:
# Description: 'Avoid chaining a method call on a do...end block.'
# StyleGuide: '#single-line-blocks'
# Enabled: false
# Style/OptionHash:
# Description: "Don't use option hashes when you can use keyword arguments."
# Enabled: false
Style/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: '#no-nested-conditionals'
Enabled: false
Style/RegexpLiteral:
Description: 'Use / or %r around regular expressions.'
StyleGuide: '#percent-r'
Enabled: false
Style/ReturnNil:
Description: 'Use return instead of return nil.'
Enabled: true
# Style/Send:
# Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
# StyleGuide: '#prefer-public-send'
# Enabled: false
Style/SingleLineBlockParams:
Description: 'Enforces the names of some block params.'
Enabled: true
Style/StringLiterals:
Description: 'Checks if uses of quotes match the configured preference.'
StyleGuide: '#consistent-string-literals'
Enabled: true
EnforcedStyle: double_quotes
ConsistentQuotesInMultiline: true
Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: '#no-trailing-params-comma'
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
Description: 'Checks for trailing comma in array literals.'
StyleGuide: '#no-trailing-array-commas'
Enabled: true
EnforcedStyleForMultiline: comma
# Style/TrailingCommaInBlockArgs:
# Description: 'Checks for useless trailing commas in block arguments.'
# Enabled: false
# Performance cops from rubocop-performance
# https://github.com/rubocop-hq/rubocop-performance/blob/master/config/default.yml
Performance/CaseWhenSplat:
Description: >-
Reordering `when` conditions with a splat to the end
of the `when` branches can improve performance.
Enabled: true
Performance/ChainArrayAllocation:
Description: >-
Instead of chaining array methods that allocate new arrays, mutate an
existing array.
Reference: 'https://twitter.com/schneems/status/1034123879978029057'
Enabled: false
Performance/OpenStruct:
Description: 'Use `Struct` instead of `OpenStruct`.'
Enabled: true
Rails/FilePath:
EnforcedStyle: slashes
# Rails cops from rubocop-rails
# https://github.com/rubocop-hq/rubocop-rails/blob/master/config/default.yml
# TODO: [@thepracticaldev/oss] enable these Rails cops
Rails/HasManyOrHasOneDependent:
Description: 'Define the dependent option to the has_many and has_one associations.'
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
Enabled: false
Rails/SaveBang:
Description: 'Identifies possible cases where Active Record save! or related should be used.'
StyleGuide: 'https://rails.rubystyle.guide#save-bang'
Enabled: false
Rails/SkipsModelValidations:
Description: >-
Use methods that skips model validations with caution.
See reference for more information.
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: false
# RSpec cops from rubocop-rspec
# https://github.com/rubocop-hq/rubocop-rspec/blob/master/config/default.yml
RSpec/DescribeClass:
Description: Check that the first argument to the top level describe is a constant.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
RSpec/ExampleLength:
Description: Checks for long examples.
Enabled: true
Max: 15
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength

View file

@ -7,13 +7,14 @@ require:
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-04-02 16:59:26 +0200 using RuboCop version 0.79.0.
# on 2020-04-10 18:48:51 +0200 using RuboCop version 0.81.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 252
# Offense count: 257
# Configuration parameters: IgnoredMethods.
Metrics/AbcSize:
Max: 75
@ -23,23 +24,49 @@ Metrics/AbcSize:
Metrics/BlockLength:
Max: 62
# Offense count: 11
Performance/OpenStruct:
Exclude:
- 'app/black_box/google_analytics.rb'
- 'app/models/article.rb'
- 'app/models/organization.rb'
- 'app/services/aws/fake_client.rb'
- 'app/services/notifications/reactions/send.rb'
- 'spec/labor/badge_rewarder_spec.rb'
- 'spec/models/github_repo_spec.rb'
- 'spec/requests/github_repos_spec.rb'
# Offense count: 3
RSpec/DescribeClass:
Exclude:
- 'spec/requests/api/v0/classified_listings_spec.rb'
- 'spec/system/user_logs_in_with_twitter_spec.rb'
- 'spec/tasks/broadcasts_spec.rb'
# Offense count: 2
# Configuration parameters: Max.
RSpec/ExampleLength:
Exclude:
- 'spec/models/comment_spec.rb'
- 'spec/requests/display_ad_events_spec.rb'
# Offense count: 739
# Offense count: 762
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 8
Max: 10
# Offense count: 1
RSpec/SubjectStub:
Exclude:
- 'spec/models/article_spec.rb'
# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/role.rb'
# Offense count: 3
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
@ -47,7 +74,7 @@ Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/application_helper.rb'
# Offense count: 11
# Offense count: 12
Rails/OutputSafety:
Exclude:
- 'app/helpers/application_helper.rb'
@ -58,7 +85,7 @@ Rails/OutputSafety:
- 'app/models/display_ad.rb'
- 'app/models/message.rb'
# Offense count: 26
# Offense count: 25
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
@ -71,7 +98,14 @@ Rails/UniqueValidationWithoutIndex:
Style/ClassAndModuleChildren:
Enabled: false
# Offense count: 4586
# Offense count: 3
# Configuration parameters: Methods.
# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
Style/SingleLineBlockParams:
Exclude:
- 'app/labor/markdown_fixer.rb'
# Offense count: 4684
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https

View file

@ -656,6 +656,7 @@ GEM
retriable (3.1.2)
reverse_markdown (2.0.0)
nokogiri
rexml (3.2.4)
rolify (5.2.0)
rouge (3.17.0)
rspec (3.9.0)
@ -681,13 +682,14 @@ GEM
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.9.2)
rubocop (0.79.0)
rubocop (0.81.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-performance (1.5.2)
rubocop (>= 0.71.0)
rubocop-rails (2.5.2)
@ -823,7 +825,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.1)
unicode-display_width (1.7.0)
unicode_plot (0.0.4)
enumerable-statistics (>= 2.0.1)
uniform_notifier (1.13.0)

View file

@ -65,10 +65,10 @@ class Api::V0::ApiController < ApplicationController
def authenticate_with_api_key
api_key = request.headers["api-key"]
return nil unless api_key
return unless api_key
api_secret = ApiSecret.includes(:user).find_by(secret: api_key)
return nil unless api_secret
return unless api_secret
# guard against timing attacks
# see <https://www.slideshare.net/NickMalcolm/timing-attacks-and-ruby-on-rails>

View file

@ -9,13 +9,15 @@ class Internal::ConfigsController < Internal::ApplicationController
def create
clean_up_params
config_params.keys.each do |key|
if config_params[key].respond_to?(:to_h)
SiteConfig.public_send("#{key}=", config_params[key].to_h) unless config_params[key].empty?
config_params.each do |key, value|
if value.respond_to?(:to_h)
SiteConfig.public_send("#{key}=", value.to_h) unless value.empty?
else
SiteConfig.public_send("#{key}=", config_params[key].strip) unless config_params[key].nil?
SiteConfig.public_send("#{key}=", value.strip) unless value.nil?
end
end
bust_relevant_caches
redirect_to internal_config_path, notice: "Site configuration was successfully updated."
end

View file

@ -14,11 +14,11 @@ class Internal::UsersController < Internal::ApplicationController
end
return if params[:search].blank?
@users = @users.where('users.name ILIKE :search OR
@users = @users.where("users.name ILIKE :search OR
users.username ILIKE :search OR
users.github_username ILIKE :search OR
users.email ILIKE :search OR
users.twitter_username ILIKE :search', search: "%#{params[:search].strip}%")
users.twitter_username ILIKE :search", search: "%#{params[:search].strip}%")
end
def edit

View file

@ -15,7 +15,7 @@ module Redcarpet
def link(link, _title, content)
# Probably not the best fix but it does it's job of preventing
# a nested links.
return nil if /<a\s.+\/a>/.match?(content)
return if /<a\s.+\/a>/.match?(content)
link_attributes = ""
@options[:link_attributes]&.each do |attribute, value|

View file

@ -49,6 +49,7 @@ class HtmlVariant < ApplicationRecord
def no_edits
return if group == "campaign"
published_and_approved = (approved && (html_changed? || name_changed? || group_changed?)) && persisted?
errors.add(:base, "cannot change once published and approved") if published_and_approved
end

View file

@ -88,7 +88,7 @@ class PodcastEpisode < ApplicationRecord
end
def path
return nil unless podcast&.slug
return unless podcast&.slug
"/#{podcast.slug}/#{slug}"
end

View file

@ -1,7 +1,5 @@
# frozen_string_literal: true
class ArticleWithVideoCreationService
VIDEO_SERVICE_URL = "https://dw71fyauz7yz9.cloudfront.net"
VIDEO_SERVICE_URL = "https://dw71fyauz7yz9.cloudfront.net".freeze
def initialize(article_params, current_user)
@article_params = article_params

View file

@ -11,6 +11,7 @@ module Articles
new(*args).call
end
# rubocop:disable Metrics/CyclomaticComplexity
def call
rate_limiter = RateLimitChecker.new(user)
raise if rate_limiter.limit_by_action("article_update")
@ -53,6 +54,7 @@ module Articles
article.decorate
end
# rubocop:enable Metrics/CyclomaticComplexity
private

View file

@ -1,5 +1,3 @@
# frozen_string_literal: true
# send notifications about the new comment
module Notifications

View file

@ -80,7 +80,7 @@ class RssReader
return nil unless real_link.include?("gist.github.com")
iframe.name = "p"
iframe.keys.each { |attr| iframe.remove_attribute(attr) }
iframe.keys.each { |attr| iframe.remove_attribute(attr) } # rubocop:disable Style/HashEachMethods
iframe.inner_html = "{% gist #{real_link} %}"
end
end
@ -116,7 +116,7 @@ class RssReader
if /youtube\.com/.match?(iframe.attributes["src"].value)
iframe.name = "p"
youtube_id = iframe.attributes["src"].value.scan(/embed%2F(.{4,11})/).flatten.first
iframe.keys.each { |attr| iframe.remove_attribute(attr) }
iframe.keys.each { |attr| iframe.remove_attribute(attr) } # rubocop:disable Style/HashEachMethods
iframe.inner_html = "{% youtube #{youtube_id} %}"
end
end

View file

@ -29,7 +29,7 @@ module Users
# available twitter languages
# https://developer.twitter.com/en/docs/developer-utilities/supported-languages/api-reference/get-help-languages
def language_from_twitter(identity)
return nil unless identity
return unless identity
twitter_lang = identity.auth_data_dump["extra"]["raw_info"]["lang"]
return "en" if twitter_lang == "en-gb"

View file

@ -50,7 +50,7 @@ module Metrics
user_ids_by_day = ids_by_day.map { |a| a & user_ids }
distinct_user_values = user_ids_by_day.flatten.group_by(&:itself).transform_values(&:count).values
distinct_counts = distinct_user_values.group_by(&:itself).transform_values(&:count)
distinct_counts.keys.each do |key|
distinct_counts.each_key do |key|
DatadogStatsClient.count("users.active_days_past_week", distinct_counts[key], tags: { resource: "users", group: group, day_count: key })
end
end

View file

@ -1,5 +1,3 @@
# frozen_string_literal: true
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (requires ORM extensions installed).
# Check the list of supported ORMs here: https://github.com/doorkeeper-gem/doorkeeper#orms

View file

@ -1,5 +1,3 @@
# frozen_string_literal: true
ruby_version = File.read(
File.join(File.dirname(File.dirname(__FILE__)), ".ruby-version"),
).strip

View file

@ -74,7 +74,7 @@ RSpec.describe "/internal/config", type: :request do
end
it "updates social_media_handles" do
expected_handle = {"facebook"=>"tpd", "github"=>"", "instagram"=>"", "twitch"=>"", "twitter"=>""}
expected_handle = { "facebook" => "tpd", "github" => "", "instagram" => "", "twitch" => "", "twitter" => "" }
post "/internal/config", params: { site_config: { social_media_handles: expected_handle },
confirmation: confirmation_message }
expect(SiteConfig.social_media_handles[:facebook]).to eq("tpd")

View file

@ -30,12 +30,12 @@ RSpec.describe "/internal/reactions", type: :request do
it "returns HTTP Status 200 upon status update" do
put "/internal/reactions/#{reaction.id}", params: { id: reaction.id, status: "confirmed" }
expect(response).to have_http_status(200)
expect(response).to have_http_status(:ok)
end
it "returns HTTP Status 422 upon status update failure" do
put "/internal/reactions/#{reaction.id}", params: { id: reaction.id, status: "confirmedsssss" }
expect(response).to have_http_status(422)
expect(response).to have_http_status(:unprocessable_entity)
end
it "returns expected JSON upon status update" do

View file

@ -44,7 +44,8 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do
end.to change(user.notifications, :count).by(0)
end
it "sends only 1 notification at a time, in the correct order" do # rubocop:disable RSpec/MultipleExpectations, RSpec/ExampleLength
# rubocop:disable RSpec/ExampleLength
it "sends only 1 notification at a time, in the correct order" do
user.update!(created_at: 1.day.ago)
expect { sidekiq_perform_enqueued_jobs { described_class.call(user.id) } }.to change(user.notifications, :count).by(1)
@ -67,6 +68,7 @@ RSpec.describe Broadcasts::WelcomeNotification::Generator, type: :service do
expect(user.notifications.last.notifiable).to eq(discuss_and_ask_broadcast)
Timecop.return
end
# rubocop:enable RSpec/ExampleLength
end
describe "#send_welcome_notification" do