Commit a09323c9 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Fix broken specs

parent 4231cfeb
......@@ -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
......
......@@ -14,6 +14,7 @@ require 'rails_helper'
RSpec.describe AbuseReport, type: :model do
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment