From aed41c323804ce0281d5fa459b7a4c7f4a72e831 Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Tue, 6 Apr 2021 16:57:59 -0400 Subject: [PATCH] Fix Ruby 2.7 kwargs' warnings & misc spec warnings (#13256) --- Gemfile | 2 +- Gemfile.lock | 4 +-- .../api/v0/organizations_controller.rb | 2 +- app/controllers/chat_channels_controller.rb | 6 ++-- app/controllers/comments_controller.rb | 2 +- app/controllers/github_repos_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/articles_helper.rb | 2 +- app/helpers/social_image_helper.rb | 2 +- app/mailers/application_mailer.rb | 10 +++--- app/queries/articles/active_threads_query.rb | 2 +- .../tags/_sidebar_additional.html.erb | 2 +- config/initializers/slack_notifier.rb | 8 ++++- lib/slack/notifier/util/link_formatter.rb | 13 ++++++++ spec/models/github_repo_spec.rb | 4 +-- ...pec.rb => user_subscription_sourceable.rb} | 0 .../articles/active_threads_query_spec.rb | 8 ++--- spec/requests/api/v0/listings_spec.rb | 30 +++++++++--------- spec/requests/email_subscriptions_spec.rb | 10 +++--- spec/requests/user/user_profile_spec.rb | 4 +-- .../user_views_podcast_comments_spec.rb | 1 + spec/uploaders/article_image_uploader_spec.rb | 2 +- vendor/cache/stripe-ruby-mock-3.0.1.gem | Bin 105472 -> 0 bytes vendor/cache/stripe-ruby-mock-3.1.0.rc2.gem | Bin 0 -> 111616 bytes 24 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 lib/slack/notifier/util/link_formatter.rb rename spec/models/shared_examples/{user_subscription_sourceable_spec.rb => user_subscription_sourceable.rb} (100%) delete mode 100644 vendor/cache/stripe-ruby-mock-3.0.1.gem create mode 100644 vendor/cache/stripe-ruby-mock-3.1.0.rc2.gem diff --git a/Gemfile b/Gemfile index 2daae25ee..05969aa3b 100644 --- a/Gemfile +++ b/Gemfile @@ -166,7 +166,7 @@ group :test do gem "shoulda-matchers", "~> 4.5.1", require: false # Simple one-liner tests for common Rails functionality gem "simplecov", "~> 0.21.2", require: false # Code coverage with a powerful configuration library and automatic merging of coverage across test suites gem "stackprof", "~> 0.2", require: false, platforms: :ruby # stackprof is a fast sampling profiler for ruby code, with cpu, wallclock and object allocation samplers - gem "stripe-ruby-mock", "~> 3.0", require: "stripe_mock" # A drop-in library to test stripe without hitting their servers + gem "stripe-ruby-mock", "3.1.0.rc2", require: "stripe_mock" # A drop-in library to test stripe without hitting their servers gem "test-prof", "~> 1.0" # Ruby Tests Profiling Toolbox gem "timecop", "~> 0.9" # A gem providing "time travel" and "time freezing" capabilities, making it dead simple to test time-dependent code gem "vcr", "~> 6.0" # Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests diff --git a/Gemfile.lock b/Gemfile.lock index 792670842..a13f2dad9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -760,7 +760,7 @@ GEM activerecord (>= 4.0, < 6.2) virtus stripe (5.32.1) - stripe-ruby-mock (3.0.1) + stripe-ruby-mock (3.1.0.rc2) dante (>= 0.2.0) multi_json (~> 1.0) stripe (> 5, < 6) @@ -979,7 +979,7 @@ DEPENDENCIES store_attribute (~> 0.8.1) storext (~> 3.3) stripe (~> 5.32) - stripe-ruby-mock (~> 3.0) + stripe-ruby-mock (= 3.1.0.rc2) strong_migrations (~> 0.7) test-prof (~> 1.0) timecop (~> 0.9) diff --git a/app/controllers/api/v0/organizations_controller.rb b/app/controllers/api/v0/organizations_controller.rb index 8b93e4a0a..d8c25b0e8 100644 --- a/app/controllers/api/v0/organizations_controller.rb +++ b/app/controllers/api/v0/organizations_controller.rb @@ -62,7 +62,7 @@ module Api .per(num) .decorate - render("api/v0/articles/index") + render "api/v0/articles/index", formats: :json end private diff --git a/app/controllers/chat_channels_controller.rb b/app/controllers/chat_channels_controller.rb index 780976345..9b75d8438 100644 --- a/app/controllers/chat_channels_controller.rb +++ b/app/controllers/chat_channels_controller.rb @@ -14,7 +14,7 @@ class ChatChannelsController < ApplicationController when "unopened" authorize ChatChannel @chat_channels_memberships = unopened_json_response - render "index.json" + render "index", formats: :json when "unopened_ids" authorize ChatChannel @unopened_ids = unopened_ids_response @@ -22,11 +22,11 @@ class ChatChannelsController < ApplicationController when "pending" authorize ChatChannel @chat_channels_memberships = pending_json_response - render "index.json" + render "index", formats: :json when "joining_request" authorize ChatChannel @chat_channels_memberships = joining_request_json_response - render "index.json" + render "index", formats: :json else skip_authorization render_channels_html diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index fec1cdf16..154626e34 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -79,7 +79,7 @@ class CommentsController < ApplicationController return end - render partial: "comments/comment.json" + render partial: "comments/comment", formats: :json elsif (comment = Comment.where( body_markdown: @comment.body_markdown, diff --git a/app/controllers/github_repos_controller.rb b/app/controllers/github_repos_controller.rb index 042890d65..3a7a8361f 100644 --- a/app/controllers/github_repos_controller.rb +++ b/app/controllers/github_repos_controller.rb @@ -24,7 +24,7 @@ class GithubReposController < ApplicationController return end - repo = GithubRepo.upsert(current_user, fetched_repo_params(fetched_repo)) + repo = GithubRepo.upsert(current_user, **fetched_repo_params(fetched_repo)) current_user.touch(:github_repos_updated_at) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c0fc32d6b..e1f426cf5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -76,7 +76,7 @@ module ApplicationHelper def optimized_image_tag(image_url, optimizer_options: {}, image_options: {}) image_options[:width] ||= optimizer_options[:width] image_options[:height] ||= optimizer_options[:height] - updated_image_url = Images::Optimizer.call(image_url, optimizer_options) + updated_image_url = Images::Optimizer.call(image_url, **optimizer_options) image_tag(updated_image_url, image_options) end diff --git a/app/helpers/articles_helper.rb b/app/helpers/articles_helper.rb index b680499b1..8e0320892 100644 --- a/app/helpers/articles_helper.rb +++ b/app/helpers/articles_helper.rb @@ -58,6 +58,6 @@ module ArticlesHelper end def active_threads(**options) - Articles::ActiveThreadsQuery.call(options) + Articles::ActiveThreadsQuery.call(**options) end end diff --git a/app/helpers/social_image_helper.rb b/app/helpers/social_image_helper.rb index ed204e1a4..3352d4b84 100644 --- a/app/helpers/social_image_helper.rb +++ b/app/helpers/social_image_helper.rb @@ -18,7 +18,7 @@ module SocialImageHelper end def article_social_image_url(article, **options) - Articles::SocialImage.new(article, options).url + Articles::SocialImage.new(article, **options).url end def comment_social_image_url(comment) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 17afa6b3d..1dce6e371 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -21,11 +21,11 @@ class ApplicationMailer < ActionMailer::Base end def generate_unsubscribe_token(id, email_type) - Rails.application.message_verifier(:unsubscribe).generate( - user_id: id, - email_type: email_type.to_sym, - expires_at: 31.days.from_now, - ) + Rails.application.message_verifier(:unsubscribe).generate({ + user_id: id, + email_type: email_type.to_sym, + expires_at: 31.days.from_now + }) end def use_custom_host diff --git a/app/queries/articles/active_threads_query.rb b/app/queries/articles/active_threads_query.rb index d45a700a2..b67314658 100644 --- a/app/queries/articles/active_threads_query.rb +++ b/app/queries/articles/active_threads_query.rb @@ -8,7 +8,7 @@ module Articles MINIMUM_SCORE = -4 - def self.call(relation: Article.published, options: {}) + def self.call(relation: Article.published, **options) options = DEFAULT_OPTIONS.merge(options) tags, time_ago, count = options.values_at(:tags, :time_ago, :count) diff --git a/app/views/articles/tags/_sidebar_additional.html.erb b/app/views/articles/tags/_sidebar_additional.html.erb index 2e18741ba..735b6d25b 100644 --- a/app/views/articles/tags/_sidebar_additional.html.erb +++ b/app/views/articles/tags/_sidebar_additional.html.erb @@ -2,7 +2,7 @@