gitlab-org--gitlab-foss/spec/requests/api/v3/broadcast_messages_spec.rb
Rémy Coutable 3914af2f71 Use set in some API specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-09-19 16:26:20 +02:00

32 lines
889 B
Ruby

require 'spec_helper'
describe API::V3::BroadcastMessages do
set(:user) { create(:user) }
set(:admin) { create(:admin) }
describe 'DELETE /broadcast_messages/:id' do
set(:message) { create(:broadcast_message) }
it 'returns a 401 for anonymous users' do
delete v3_api("/broadcast_messages/#{message.id}"),
attributes_for(:broadcast_message)
expect(response).to have_http_status(401)
end
it 'returns a 403 for users' do
delete v3_api("/broadcast_messages/#{message.id}", user),
attributes_for(:broadcast_message)
expect(response).to have_http_status(403)
end
it 'deletes the broadcast message for admins' do
expect do
delete v3_api("/broadcast_messages/#{message.id}", admin)
expect(response).to have_http_status(200)
end.to change { BroadcastMessage.count }.by(-1)
end
end
end