Fix broken specs
This commit is contained in:
parent
4231cfeba5
commit
a09323c9f5
2 changed files with 7 additions and 10 deletions
|
@ -6,7 +6,7 @@ class Admin::AbuseReportsController < Admin::ApplicationController
|
|||
def destroy
|
||||
abuse_report = AbuseReport.find(params[:id])
|
||||
|
||||
abuse_report.remove_user if params[:remove_user]
|
||||
abuse_report.remove_user(current_user) if params[:remove_user]
|
||||
abuse_report.destroy
|
||||
|
||||
render nothing: true
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AbuseReport, type: :model do
|
||||
subject { create(:abuse_report) }
|
||||
subject { create(:abuse_report) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it { expect(subject).to be_valid }
|
||||
|
||||
|
@ -31,17 +32,13 @@ RSpec.describe AbuseReport, type: :model do
|
|||
|
||||
describe '#remove_user' do
|
||||
it 'blocks the user' do
|
||||
report = build(:abuse_report)
|
||||
|
||||
allow(report.user).to receive(:destroy)
|
||||
|
||||
expect { report.remove_user }.to change { report.user.blocked? }.to(true)
|
||||
expect { subject.remove_user(user) }.to change { subject.user.blocked? }.to(true)
|
||||
end
|
||||
|
||||
it 'removes the user' do
|
||||
report = build(:abuse_report)
|
||||
it 'lets a worker delete the user' do
|
||||
expect(DeleteUserWorker).to receive(:perform_async).with(user.id, subject.user.id, force: true)
|
||||
|
||||
expect { report.remove_user }.to change { User.count }.by(-1)
|
||||
subject.remove_user(user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue