0
0
Fork 0

Autofix Rubocop RSpec/LeadingSubject (#23670)

This commit is contained in:
Nick Schonning 2023-02-19 23:24:14 -05:00 committed by GitHub
parent 4ea1e0fceb
commit 4552685f6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 256 additions and 338 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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!

View file

@ -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 }

View file

@ -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

View file

@ -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

View file

@ -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)