about summary refs log tree commit diff
path: root/spec/controllers
diff options
context:
space:
mode:
authorNick Schonning <nschonni@gmail.com>2023-02-19 23:24:14 -0500
committerGitHub <noreply@github.com>2023-02-20 13:24:14 +0900
commit4552685f6bd400666ec4058783eeabb11568e575 (patch)
treeab708e0d54b9309f96ef0e4d17e8afd32221c5c6 /spec/controllers
parent4ea1e0fceb0c0c5fee014a99f81f8f13a16f6dde (diff)
Autofix Rubocop RSpec/LeadingSubject (#23670)
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/activitypub/collections_controller_spec.rb4
-rw-r--r--spec/controllers/activitypub/followers_synchronizations_controller_spec.rb4
-rw-r--r--spec/controllers/activitypub/inboxes_controller_spec.rb4
-rw-r--r--spec/controllers/activitypub/outboxes_controller_spec.rb4
-rw-r--r--spec/controllers/admin/invites_controller_spec.rb4
-rw-r--r--spec/controllers/auth/registrations_controller_spec.rb64
-rw-r--r--spec/controllers/well_known/webfinger_controller_spec.rb8
7 files changed, 46 insertions, 46 deletions
diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb
index 19c0e0a64..77901131e 100644
--- a/spec/controllers/activitypub/collections_controller_spec.rb
+++ b/spec/controllers/activitypub/collections_controller_spec.rb
@@ -35,11 +35,11 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do
   describe 'GET #show' do
     context 'when id is "featured"' do
       context 'without signature' do
-        let(:remote_account) { nil }
+        subject(:body) { body_as_json }
 
         subject(:response) { get :show, params: { id: 'featured', account_username: account.username } }
 
-        subject(:body) { body_as_json }
+        let(:remote_account) { nil }
 
         it 'returns http success' do
           expect(response).to have_http_status(200)
diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb
index 893c8e14f..6ec756d3c 100644
--- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb
+++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb
@@ -32,11 +32,11 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll
     end
 
     context 'with signature from example.com' do
-      let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
+      subject(:body) { body_as_json }
 
       subject(:response) { get :show, params: { account_username: account.username } }
 
-      subject(:body) { body_as_json }
+      let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
 
       it 'returns http success' do
         expect(response).to have_http_status(200)
diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb
index 7f4d6b2d3..8d4084648 100644
--- a/spec/controllers/activitypub/inboxes_controller_spec.rb
+++ b/spec/controllers/activitypub/inboxes_controller_spec.rb
@@ -22,10 +22,10 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do
       end
 
       context 'for a specific account' do
-        let(:account) { Fabricate(:account) }
-
         subject(:response) { post :create, params: { account_username: account.username }, body: '{}' }
 
+        let(:account) { Fabricate(:account) }
+
         context 'when account is permanently suspended' do
           before do
             account.suspend!
diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb
index f84a902ea..7369ee413 100644
--- a/spec/controllers/activitypub/outboxes_controller_spec.rb
+++ b/spec/controllers/activitypub/outboxes_controller_spec.rb
@@ -33,11 +33,11 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do
 
   describe 'GET #show' do
     context 'without signature' do
-      let(:remote_account) { nil }
+      subject(:body) { body_as_json }
 
       subject(:response) { get :show, params: { account_username: account.username, page: page } }
 
-      subject(:body) { body_as_json }
+      let(:remote_account) { nil }
 
       context 'with page not requested' do
         let(:page) { nil }
diff --git a/spec/controllers/admin/invites_controller_spec.rb b/spec/controllers/admin/invites_controller_spec.rb
index 1fb488742..92ec4e449 100644
--- a/spec/controllers/admin/invites_controller_spec.rb
+++ b/spec/controllers/admin/invites_controller_spec.rb
@@ -33,10 +33,10 @@ describe Admin::InvitesController do
   end
 
   describe 'DELETE #destroy' do
-    let!(:invite) { Fabricate(:invite, expires_at: nil) }
-
     subject { delete :destroy, params: { id: invite.id } }
 
+    let!(:invite) { Fabricate(:invite, expires_at: nil) }
+
     it 'expires invite' do
       expect(subject).to redirect_to admin_invites_path
       expect(invite.reload).to be_expired
diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb
index 52023eb2e..8cfb8e277 100644
--- a/spec/controllers/auth/registrations_controller_spec.rb
+++ b/spec/controllers/auth/registrations_controller_spec.rb
@@ -95,18 +95,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
     before { request.env['devise.mapping'] = Devise.mappings[:user] }
 
     context do
-      around do |example|
-        registrations_mode = Setting.registrations_mode
-        example.run
-        Setting.registrations_mode = registrations_mode
-      end
-
       subject do
         Setting.registrations_mode = 'open'
         request.headers['Accept-Language'] = accept_language
         post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
       end
 
+      around do |example|
+        registrations_mode = Setting.registrations_mode
+        example.run
+        Setting.registrations_mode = registrations_mode
+      end
+
       it 'redirects to setup' do
         subject
         expect(response).to redirect_to auth_setup_path
@@ -121,18 +121,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
     end
 
     context 'when user has not agreed to terms of service' do
-      around do |example|
-        registrations_mode = Setting.registrations_mode
-        example.run
-        Setting.registrations_mode = registrations_mode
-      end
-
       subject do
         Setting.registrations_mode = 'open'
         request.headers['Accept-Language'] = accept_language
         post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } }
       end
 
+      around do |example|
+        registrations_mode = Setting.registrations_mode
+        example.run
+        Setting.registrations_mode = registrations_mode
+      end
+
       it 'does not create user' do
         subject
         user = User.find_by(email: 'test@example.com')
@@ -141,18 +141,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
     end
 
     context 'approval-based registrations without invite' do
-      around do |example|
-        registrations_mode = Setting.registrations_mode
-        example.run
-        Setting.registrations_mode = registrations_mode
-      end
-
       subject do
         Setting.registrations_mode = 'approved'
         request.headers['Accept-Language'] = accept_language
         post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
       end
 
+      around do |example|
+        registrations_mode = Setting.registrations_mode
+        example.run
+        Setting.registrations_mode = registrations_mode
+      end
+
       it 'redirects to setup' do
         subject
         expect(response).to redirect_to auth_setup_path
@@ -168,12 +168,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
     end
 
     context 'approval-based registrations with expired invite' do
-      around do |example|
-        registrations_mode = Setting.registrations_mode
-        example.run
-        Setting.registrations_mode = registrations_mode
-      end
-
       subject do
         Setting.registrations_mode = 'approved'
         request.headers['Accept-Language'] = accept_language
@@ -181,6 +175,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
         post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
       end
 
+      around do |example|
+        registrations_mode = Setting.registrations_mode
+        example.run
+        Setting.registrations_mode = registrations_mode
+      end
+
       it 'redirects to setup' do
         subject
         expect(response).to redirect_to auth_setup_path
@@ -196,14 +196,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
     end
 
     context 'approval-based registrations with valid invite and required invite text' do
-      around do |example|
-        registrations_mode = Setting.registrations_mode
-        require_invite_text = Setting.require_invite_text
-        example.run
-        Setting.require_invite_text = require_invite_text
-        Setting.registrations_mode = registrations_mode
-      end
-
       subject do
         inviter = Fabricate(:user, confirmed_at: 2.days.ago)
         Setting.registrations_mode = 'approved'
@@ -213,6 +205,14 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
         post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
       end
 
+      around do |example|
+        registrations_mode = Setting.registrations_mode
+        require_invite_text = Setting.require_invite_text
+        example.run
+        Setting.require_invite_text = require_invite_text
+        Setting.registrations_mode = registrations_mode
+      end
+
       it 'redirects to setup' do
         subject
         expect(response).to redirect_to auth_setup_path
diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb
index 8574d369d..1ccfb218e 100644
--- a/spec/controllers/well_known/webfinger_controller_spec.rb
+++ b/spec/controllers/well_known/webfinger_controller_spec.rb
@@ -4,6 +4,10 @@ describe WellKnown::WebfingerController, type: :controller do
   render_views
 
   describe 'GET #show' do
+    subject do
+      get :show, params: { resource: resource }, format: :json
+    end
+
     let(:alternate_domains) { [] }
     let(:alice) { Fabricate(:account, username: 'alice') }
     let(:resource) { nil }
@@ -15,10 +19,6 @@ describe WellKnown::WebfingerController, type: :controller do
       Rails.configuration.x.alternate_domains = tmp
     end
 
-    subject do
-      get :show, params: { resource: resource }, format: :json
-    end
-
     shared_examples 'a successful response' do
       it 'returns http success' do
         expect(response).to have_http_status(200)