Routine rubocop fixes (#6138)
This commit is contained in:
parent
a56eb8fab0
commit
f3c2adfa45
14 changed files with 34 additions and 46 deletions
|
|
@ -7,17 +7,17 @@ require:
|
|||
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2020-01-27 18:38:25 +0100 using RuboCop version 0.79.0.
|
||||
# on 2020-02-18 09:06:00 +0100 using RuboCop version 0.79.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: 236
|
||||
# Offense count: 241
|
||||
Metrics/AbcSize:
|
||||
Max: 75
|
||||
|
||||
# Offense count: 13
|
||||
# Offense count: 10
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
# ExcludedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
|
|
@ -33,7 +33,7 @@ RSpec/ExampleLength:
|
|||
- 'spec/requests/api/v0/articles_spec.rb'
|
||||
- 'spec/requests/display_ad_events_spec.rb'
|
||||
|
||||
# Offense count: 500
|
||||
# Offense count: 559
|
||||
# Configuration parameters: AggregateFailuresByDefault.
|
||||
RSpec/MultipleExpectations:
|
||||
Max: 8
|
||||
|
|
@ -63,7 +63,7 @@ Rails/OutputSafety:
|
|||
- 'app/models/message.rb'
|
||||
- 'app/views/articles/feed.rss.builder'
|
||||
|
||||
# Offense count: 26
|
||||
# Offense count: 27
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
||||
# SupportedStyles: nested, compact
|
||||
|
|
@ -76,7 +76,7 @@ Style/GuardClause:
|
|||
Exclude:
|
||||
- 'app/models/article.rb'
|
||||
|
||||
# Offense count: 3566
|
||||
# Offense count: 3757
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ Rails.application.configure do
|
|||
# Debug is the default log_level, but can be changed per environment.
|
||||
config.log_level = :debug
|
||||
|
||||
# See <https://github.com/flyerhzm/bullet#configuration> for other config options
|
||||
config.after_initialize do
|
||||
# See <https://github.com/flyerhzm/bullet#configuration> for other Bullet config options
|
||||
Bullet.enable = true
|
||||
|
||||
Bullet.add_footer = true
|
||||
|
|
@ -117,19 +117,6 @@ Rails.application.configure do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Docker specific development configuration
|
||||
if File.file?("/.dockerenv")
|
||||
# Using shell tools so we don't need to require Socket and IPAddr
|
||||
host_ip = `/sbin/ip route|awk '/default/ { print $3 }'`.strip
|
||||
logger = Logger.new(STDOUT)
|
||||
logger.info "Whitelisting #{host_ip} for BetterErrors and Web Console"
|
||||
|
||||
if defined?(BetterErrors::Middleware)
|
||||
BetterErrors::Middleware.allow_ip!(host_ip)
|
||||
end
|
||||
config.web_console.whitelisted_ips << host_ip
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.routes.default_url_options = { host: Rails.application.config.app_domain }
|
||||
|
|
|
|||
13
config/initializers/docker.rb
Normal file
13
config/initializers/docker.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Docker specific development configuration
|
||||
if Rails.env.development? && File.file?("/.dockerenv")
|
||||
# Using shell tools so we don't need to require Socket and IPAddr
|
||||
host_ip = `/sbin/ip route|awk '/default/ { print $3 }'`.strip
|
||||
logger = Logger.new(STDOUT)
|
||||
logger.info "Whitelisting #{host_ip} for BetterErrors and Web Console"
|
||||
|
||||
if defined?(BetterErrors::Middleware)
|
||||
BetterErrors::Middleware.allow_ip!(host_ip)
|
||||
end
|
||||
|
||||
Rails.application.config.web_console.whitelisted_ips << host_ip
|
||||
end
|
||||
|
|
@ -96,7 +96,7 @@ num_articles.times do |i|
|
|||
|
||||
markdown = <<~MARKDOWN
|
||||
---
|
||||
title: #{Faker::Book.title} #{Faker::Lorem.sentence(word_count: 2).chomp(".")}
|
||||
title: #{Faker::Book.title} #{Faker::Lorem.sentence(word_count: 2).chomp('.')}
|
||||
published: true
|
||||
cover_image: #{Faker::Company.logo}
|
||||
tags: #{tags.join(', ')}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ desc "This task is called by the Heroku scheduler add-on"
|
|||
|
||||
task get_podcast_episodes: :environment do
|
||||
Podcast.published.select(:id).find_each do |podcast|
|
||||
Podcasts::GetEpisodesWorker.perform_async({ podcast_id: podcast.id, limit: 5 })
|
||||
Podcasts::GetEpisodesWorker.perform_async(podcast_id: podcast.id, limit: 5)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
trait :trusted do
|
||||
after(:build) { |user| user.add_role(:trusted) }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,10 +41,9 @@ RSpec.describe "Api::V0::ChatChannels", type: :request do
|
|||
get api_chat_channel_path(chat_channel.id)
|
||||
|
||||
response_channel = response.parsed_body
|
||||
expected_keys = %w[
|
||||
type_of id description channel_name username channel_users channel_mod_ids pending_users_select_fields
|
||||
]
|
||||
expect(response_channel.keys).to match_array(expected_keys)
|
||||
expect(response_channel.keys).to match_array(
|
||||
%w[type_of id description channel_name username channel_users channel_mod_ids pending_users_select_fields],
|
||||
)
|
||||
|
||||
%w[id description channel_name channel_mod_ids].each do |attr|
|
||||
expect(response_channel[attr]).to eq(chat_channel.public_send(attr))
|
||||
|
|
@ -57,17 +56,15 @@ RSpec.describe "Api::V0::ChatChannels", type: :request do
|
|||
it "returns the correct channel users representation" do
|
||||
get api_chat_channel_path(chat_channel.id)
|
||||
|
||||
response_channel = response.parsed_body
|
||||
response_channel_users = response_channel["channel_users"]
|
||||
response_channel_users = response.parsed_body["channel_users"]
|
||||
|
||||
membership = user.chat_channel_memberships.last
|
||||
expected_last_opened_at = Time.zone.parse(response_channel_users[user.username]["last_opened_at"]).to_i
|
||||
response_user = response_channel_users[user.username]
|
||||
|
||||
expect(response_user["profile_image"]).to eq(ProfileImage.new(user).get(width: 90))
|
||||
expect(response_user["darker_color"]).to eq(user.decorate.darker_color)
|
||||
expect(response_user["name"]).to eq(user.name)
|
||||
expect(expected_last_opened_at).to eq(membership.last_opened_at.to_i)
|
||||
expect(expected_last_opened_at).to eq(user.chat_channel_memberships.last.last_opened_at.to_i)
|
||||
expect(response_user["username"]).to eq(user.username)
|
||||
expect(response_user["id"]).to eq(user.id)
|
||||
end
|
||||
|
|
@ -80,8 +77,7 @@ RSpec.describe "Api::V0::ChatChannels", type: :request do
|
|||
|
||||
get api_chat_channel_path(chat_channel.id)
|
||||
|
||||
response_channel = response.parsed_body
|
||||
response_pending_user_select_fields = response_channel["pending_users_select_fields"].first
|
||||
response_pending_user_select_fields = response.parsed_body["pending_users_select_fields"].first
|
||||
|
||||
expected_updated_at = Time.zone.parse(response_pending_user_select_fields["updated_at"]).to_i
|
||||
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ RSpec.describe "ClassifiedListings", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
context "when deleting org listing" do
|
||||
context "when deleting draft org listing" do
|
||||
it "redirect to dashboard" do
|
||||
delete "/listings/#{org_listing_draft.id}"
|
||||
expect(response).to redirect_to("/listings/dashboard")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ RSpec.describe "/internal/config", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable RSpec/NestedGroups
|
||||
describe "POST internal/events" do
|
||||
context "when admin has typical admin permissions but not single resource" do
|
||||
before do
|
||||
|
|
@ -37,6 +38,7 @@ RSpec.describe "/internal/config", type: :request do
|
|||
before do
|
||||
sign_in(admin_plus_config)
|
||||
end
|
||||
|
||||
describe "staff" do
|
||||
it "does not allow the staff_user_id to be updated" do
|
||||
expect(SiteConfig.staff_user_id).to eq(1)
|
||||
|
|
@ -180,4 +182,5 @@ RSpec.describe "/internal/config", type: :request do
|
|||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable RSpec/NestedGroups
|
||||
end
|
||||
|
|
|
|||
|
|
@ -35,9 +35,7 @@ RSpec.shared_examples "PATCH /comments/:comment_id/hide or unhide" do |args|
|
|||
it "returns 200 on a good request" do
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
|
||||
context "when logged in as the commentable author" do
|
||||
it "displays having hidden comments if some unhidden" do
|
||||
sign_in commentable_author
|
||||
second_comment = create(:comment, commentable: article, user: commentable_author)
|
||||
|
|
|
|||
|
|
@ -123,14 +123,6 @@ RSpec.describe "UserProfiles", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /user" do
|
||||
it "renders to appropriate page" do
|
||||
user = create(:user)
|
||||
get "/#{user.username}"
|
||||
expect(response.body).to include CGI.escapeHTML(user.name)
|
||||
end
|
||||
end
|
||||
|
||||
describe "redirect to moderation" do
|
||||
it "redirects to admin" do
|
||||
user = create(:user)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ RSpec.describe Articles::Creator, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
context "when valid attributes" do
|
||||
context "when invalid attributes" do
|
||||
let(:invalid_attributes) { attributes_for(:article) }
|
||||
|
||||
before do
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ RSpec.shared_examples "GET /api/analytics/:endpoint authorization examples" do |
|
|||
end
|
||||
|
||||
context "when a valid token is given but the user is not a pro" do
|
||||
before { get "/api/analytics/#{endpoint}?#{params}", headers: { "api-key" => "abadskajdlsak" } }
|
||||
before { get "/api/analytics/#{endpoint}?#{params}", headers: { "api-key" => api_token.secret } }
|
||||
|
||||
it "renders an error message: 'unauthorized' in JSON" do
|
||||
expect(JSON.parse(response.body)["error"]).to eq "unauthorized"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue