From a4b73373e79c74fc49b8a22c45f3b3bcea5ce3eb Mon Sep 17 00:00:00 2001 From: rhymes Date: Mon, 30 Nov 2020 14:50:13 +0100 Subject: [PATCH] rubocop -a (#11674) --- app/models/follow.rb | 2 +- .../20201118141822_gradual_article_cache_bust.rb | 6 ++++-- spec/requests/stories_show_spec.rb | 12 +++++++----- spec/system/comments/user_edits_a_comment_spec.rb | 4 ++-- .../comments/user_views_article_comments_spec.rb | 6 ++++-- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/models/follow.rb b/app/models/follow.rb index c1bda3b51..b4de39690 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -28,10 +28,10 @@ class Follow < ApplicationRecord counter_culture :follower, column_name: proc { |follow| COUNTER_CULTURE_COLUMN_NAME_BY_TYPE[follow.followable_type] }, column_names: COUNTER_CULTURE_COLUMNS_NAMES + before_save :calculate_points after_create :send_email_notification before_destroy :modify_chat_channel_status after_save :touch_follower - before_save :calculate_points after_create_commit :create_chat_channel validates :blocked, inclusion: { in: [true, false] } diff --git a/lib/data_update_scripts/20201118141822_gradual_article_cache_bust.rb b/lib/data_update_scripts/20201118141822_gradual_article_cache_bust.rb index 8c2d92300..4aec04fd7 100644 --- a/lib/data_update_scripts/20201118141822_gradual_article_cache_bust.rb +++ b/lib/data_update_scripts/20201118141822_gradual_article_cache_bust.rb @@ -11,11 +11,13 @@ module DataUpdateScripts # It only busts the "?i=i" variant of the path which is the "internal nav" version, aka the page when swapped # with internal navigation, not the one landed on directly (which wouldn't have cache mismatches) - Article.published.order("hotness_score DESC").limit(1500).select(:path).each_with_index do |article, index| + relation = Article.published.order(hotness_score: :desc).select(:path) + + relation.limit(1500).each_with_index do |article, index| n = index + 300 # + 300 gives the server time to boot up BustCachePathWorker.set(queue: :high_priority).perform_in(n.seconds, "#{article.path}?i=i") end - Article.published.order("hotness_score DESC").offset(1500).limit(3000).select(:path).each_with_index do |article, index| + relation.offset(1500).limit(3000).each_with_index do |article, index| n = (index * 3) + 450 BustCachePathWorker.set(queue: :medium_priority).perform_in(n.seconds, "#{article.path}?i=i") end diff --git a/spec/requests/stories_show_spec.rb b/spec/requests/stories_show_spec.rb index da1ecaf7c..883aed5ff 100644 --- a/spec/requests/stories_show_spec.rb +++ b/spec/requests/stories_show_spec.rb @@ -22,8 +22,9 @@ RSpec.describe "StoriesShow", type: :request do it "preserves internal nav param (i=i) upon redirect" do old_path = article.path article.update(organization: org) - get old_path + "?i=i" - expect(response.body).to redirect_to "#{article.path}?i=i" + + get "#{old_path}?i=i" + expect(response.body).to redirect_to "#{article.path}?i=i" expect(response).to have_http_status(:moved_permanently) end @@ -31,15 +32,16 @@ RSpec.describe "StoriesShow", type: :request do old_path = article.path article.update(organization: org) get old_path - expect(response.body).not_to redirect_to "#{article.path}?i=i" + expect(response.body).not_to redirect_to "#{article.path}?i=i" expect(response).to have_http_status(:moved_permanently) end it "does not have ?i=i on redirects without that precise param" do old_path = article.path article.update(organization: org) - get old_path + "?i=j" - expect(response.body).to redirect_to article.path + + get "#{old_path}?i=j" + expect(response.body).to redirect_to article.path expect(response.body).not_to redirect_to "#{article.path}?i=j" expect(response.body).not_to redirect_to "#{article.path}?i=j" end diff --git a/spec/system/comments/user_edits_a_comment_spec.rb b/spec/system/comments/user_edits_a_comment_spec.rb index 13945cdd7..47154019f 100644 --- a/spec/system/comments/user_edits_a_comment_spec.rb +++ b/spec/system/comments/user_edits_a_comment_spec.rb @@ -28,7 +28,7 @@ RSpec.describe "Editing A Comment", type: :system, js: true do visit article.path.to_s wait_for_javascript - click_on(class: 'comment__dropdown-trigger') + click_on(class: "comment__dropdown-trigger") click_link("Edit") assert_updated end @@ -42,7 +42,7 @@ RSpec.describe "Editing A Comment", type: :system, js: true do wait_for_javascript - click_on(class: 'comment__dropdown-trigger') + click_on(class: "comment__dropdown-trigger") click_link("Edit") assert_updated end diff --git a/spec/system/comments/user_views_article_comments_spec.rb b/spec/system/comments/user_views_article_comments_spec.rb index 5f31d6537..bbf6a327c 100644 --- a/spec/system/comments/user_views_article_comments_spec.rb +++ b/spec/system/comments/user_views_article_comments_spec.rb @@ -26,7 +26,8 @@ RSpec.describe "Visiting article comments", type: :system, js: true do end it "displays grandchild comments" do - expect(page).to have_selector(".comment--deep-2#comment-node-#{grandchild_comment.id}", visible: :visible, count: 1) + expect(page).to have_selector(".comment--deep-2#comment-node-#{grandchild_comment.id}", visible: :visible, + count: 1) end end @@ -42,7 +43,8 @@ RSpec.describe "Visiting article comments", type: :system, js: true do end it "displays grandchild comments" do - expect(page).to have_selector(".comment--deep-2#comment-node-#{grandchild_comment.id}", visible: :visible, count: 1) + expect(page).to have_selector(".comment--deep-2#comment-node-#{grandchild_comment.id}", visible: :visible, + count: 1) end end end