debian-mirror-gitlab/spec/controllers/admin/spam_logs_controller_spec.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2016-04-02 18:10:28 +05:30
require 'spec_helper'
describe Admin::SpamLogsController do
let(:admin) { create(:admin) }
let(:user) { create(:user) }
let!(:first_spam) { create(:spam_log, user: user) }
let!(:second_spam) { create(:spam_log, user: user) }
before do
sign_in(admin)
end
describe '#index' do
it 'lists all spam logs' do
get :index
2016-08-24 12:49:21 +05:30
expect(response).to have_http_status(200)
2016-04-02 18:10:28 +05:30
end
end
describe '#destroy' do
it 'removes only the spam log when removing log' do
expect { delete :destroy, id: first_spam.id }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy
2016-08-24 12:49:21 +05:30
expect(response).to have_http_status(200)
2016-04-02 18:10:28 +05:30
end
it 'removes user and his spam logs when removing the user' do
delete :destroy, id: first_spam.id, remove_user: true
expect(flash[:notice]).to eq "User #{user.username} was successfully removed."
2016-08-24 12:49:21 +05:30
expect(response).to have_http_status(302)
2016-04-02 18:10:28 +05:30
expect(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end