about summary refs log tree commit diff
path: root/spec/controllers
diff options
context:
space:
mode:
authorNick Schonning <nschonni@gmail.com>2023-02-19 20:28:40 -0500
committerGitHub <noreply@github.com>2023-02-20 02:28:40 +0100
commit21bf32635687770bc0026d769a69f49b89f8a0a2 (patch)
tree9fde82eedc10fe01b9450a2591fc2f530f29c1d6 /spec/controllers
parent597767a9f7ca846be9fbca826aba362f8387a60f (diff)
Autofix Rubocop Rails/Pluck (#23730)
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/api/v1/notifications_controller_spec.rb12
-rw-r--r--spec/controllers/api/v1/suggestions_controller_spec.rb2
-rw-r--r--spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb2
3 files changed, 8 insertions, 8 deletions
diff --git a/spec/controllers/api/v1/notifications_controller_spec.rb b/spec/controllers/api/v1/notifications_controller_spec.rb
index 46e177c0e..22ebfa3dd 100644
--- a/spec/controllers/api/v1/notifications_controller_spec.rb
+++ b/spec/controllers/api/v1/notifications_controller_spec.rb
@@ -70,19 +70,19 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
       end
 
       it 'includes reblog' do
-        expect(body_as_json.map { |x| x[:type] }).to include 'reblog'
+        expect(body_as_json.pluck(:type)).to include 'reblog'
       end
 
       it 'includes mention' do
-        expect(body_as_json.map { |x| x[:type] }).to include 'mention'
+        expect(body_as_json.pluck(:type)).to include 'mention'
       end
 
       it 'includes favourite' do
-        expect(body_as_json.map { |x| x[:type] }).to include 'favourite'
+        expect(body_as_json.pluck(:type)).to include 'favourite'
       end
 
       it 'includes follow' do
-        expect(body_as_json.map { |x| x[:type] }).to include 'follow'
+        expect(body_as_json.pluck(:type)).to include 'follow'
       end
     end
 
@@ -125,7 +125,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
 
       it 'returns everything but excluded type' do
         expect(body_as_json.size).to_not eq 0
-        expect(body_as_json.map { |x| x[:type] }.uniq).to_not include 'mention'
+        expect(body_as_json.pluck(:type).uniq).to_not include 'mention'
       end
     end
 
@@ -139,7 +139,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
       end
 
       it 'returns only requested type' do
-        expect(body_as_json.map { |x| x[:type] }.uniq).to eq ['mention']
+        expect(body_as_json.pluck(:type).uniq).to eq ['mention']
       end
     end
   end
diff --git a/spec/controllers/api/v1/suggestions_controller_spec.rb b/spec/controllers/api/v1/suggestions_controller_spec.rb
index 7805b6b4f..35ba155e7 100644
--- a/spec/controllers/api/v1/suggestions_controller_spec.rb
+++ b/spec/controllers/api/v1/suggestions_controller_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe Api::V1::SuggestionsController, type: :controller do
       json = body_as_json
 
       expect(json.size).to be >= 1
-      expect(json.map { |i| i[:id] }).to include(*[bob, jeff].map { |i| i.id.to_s })
+      expect(json.pluck(:id)).to include(*[bob, jeff].map { |i| i.id.to_s })
     end
   end
 end
diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb
index c3156c4e9..f060c3a4b 100644
--- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb
+++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb
@@ -140,7 +140,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
           it 'includes existing credentials in list of excluded credentials' do
             get :options
 
-            excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].map { |credential| credential['id'] }
+            excluded_credentials_ids = JSON.parse(response.body)['excludeCredentials'].pluck('id')
             expect(excluded_credentials_ids).to match_array(user.webauthn_credentials.pluck(:external_id))
           end
         end