debian-mirror-gitlab/spec/requests/api/v3/broadcast_messages_spec.rb

33 lines
910 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe API::V3::BroadcastMessages do
2018-03-17 18:26:18 +05:30
set(:user) { create(:user) }
set(:admin) { create(:admin) }
2017-08-17 22:00:37 +05:30
describe 'DELETE /broadcast_messages/:id' do
2018-03-17 18:26:18 +05:30
set(:message) { create(:broadcast_message) }
2017-08-17 22:00:37 +05:30
it 'returns a 401 for anonymous users' do
delete v3_api("/broadcast_messages/#{message.id}"),
attributes_for(:broadcast_message)
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(401)
2017-08-17 22:00:37 +05:30
end
it 'returns a 403 for users' do
delete v3_api("/broadcast_messages/#{message.id}", user),
attributes_for(:broadcast_message)
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(403)
2017-08-17 22:00:37 +05:30
end
it 'deletes the broadcast message for admins' do
expect do
delete v3_api("/broadcast_messages/#{message.id}", admin)
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(200)
2017-08-17 22:00:37 +05:30
end.to change { BroadcastMessage.count }.by(-1)
end
end
end