0
0
Fork 0

Fix RSpec/ExpectChange cop (#25101)

This commit is contained in:
Matt Jankowski 2023-05-24 05:23:40 -04:00 committed by GitHub
parent 1caa5ff39e
commit d2e5430d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 24 additions and 41 deletions

View file

@ -19,7 +19,7 @@ RSpec.describe Admin::AccountModerationNotesController do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: 'test content' } } }
it 'successfully creates a note' do
expect { subject }.to change { AccountModerationNote.count }.by(1)
expect { subject }.to change(AccountModerationNote, :count).by(1)
expect(subject).to redirect_to admin_account_path(target_account.id)
end
end
@ -28,7 +28,7 @@ RSpec.describe Admin::AccountModerationNotesController do
let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } }
it 'falls to create a note' do
expect { subject }.to_not change { AccountModerationNote.count }
expect { subject }.to_not change(AccountModerationNote, :count)
expect(subject).to render_template 'admin/accounts/show'
end
end
@ -41,7 +41,7 @@ RSpec.describe Admin::AccountModerationNotesController do
let(:account) { Fabricate(:account) }
it 'destroys note' do
expect { subject }.to change { AccountModerationNote.count }.by(-1)
expect { subject }.to change(AccountModerationNote, :count).by(-1)
expect(subject).to redirect_to admin_account_path(target_account.id)
end
end

View file

@ -42,7 +42,7 @@ describe Admin::CustomEmojisController do
let(:params) { { shortcode: 'test', image: image } }
it 'creates custom emoji' do
expect { subject }.to change { CustomEmoji.count }.by(1)
expect { subject }.to change(CustomEmoji, :count).by(1)
end
end

View file

@ -26,7 +26,7 @@ describe Admin::InvitesController do
subject { post :create, params: { invite: { max_uses: '10', expires_in: 1800 } } }
it 'succeeds to create a invite' do
expect { subject }.to change { Invite.count }.by(1)
expect { subject }.to change(Invite, :count).by(1)
expect(subject).to redirect_to admin_invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end

View file

@ -25,7 +25,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_resolve: nil } }
it 'creates a report note and resolves report' do
expect { subject }.to change { ReportNote.count }.by(1)
expect { subject }.to change(ReportNote, :count).by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_reports_path
end
@ -35,7 +35,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not resolve report' do
expect { subject }.to change { ReportNote.count }.by(1)
expect { subject }.to change(ReportNote, :count).by(1)
expect(report.reload).to_not be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -50,7 +50,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id }, create_and_unresolve: nil } }
it 'creates a report note and unresolves report' do
expect { subject }.to change { ReportNote.count }.by(1)
expect { subject }.to change(ReportNote, :count).by(1)
expect(report.reload).to_not be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -60,7 +60,7 @@ describe Admin::ReportNotesController do
let(:params) { { report_note: { content: 'test content', report_id: report.id } } }
it 'creates a report note and does not unresolve report' do
expect { subject }.to change { ReportNote.count }.by(1)
expect { subject }.to change(ReportNote, :count).by(1)
expect(report.reload).to be_action_taken
expect(subject).to redirect_to admin_report_path(report)
end
@ -85,7 +85,7 @@ describe Admin::ReportNotesController do
let!(:report_note) { Fabricate(:report_note) }
it 'deletes note' do
expect { subject }.to change { ReportNote.count }.by(-1)
expect { subject }.to change(ReportNote, :count).by(-1)
expect(subject).to redirect_to admin_report_path(report_note.report)
end
end

View file

@ -22,7 +22,7 @@ RSpec.describe AccountableConcern do
it 'creates Admin::ActionLog' do
expect do
hoge.log_action(:create, target)
end.to change { Admin::ActionLog.count }.by(1)
end.to change(Admin::ActionLog, :count).by(1)
end
end
end

View file

@ -52,7 +52,7 @@ describe InvitesController do
end
it 'succeeds to create a invite' do
expect { subject }.to change { Invite.count }.by(1)
expect { subject }.to change(Invite, :count).by(1)
expect(subject).to redirect_to invites_path
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
end

View file

@ -134,7 +134,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
end
it 'does not change webauthn_id' do
expect { get :options }.to_not change { user.webauthn_id }
expect { get :options }.to_not change(user, :webauthn_id)
end
it 'includes existing credentials in list of excluded credentials' do
@ -238,7 +238,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
expect do
post :create, params: { credential: new_webauthn_credential, nickname: nickname }
end.to_not change { user.webauthn_id }
end.to_not change(user, :webauthn_id)
end
end