1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/spec/requests/users/destroy_spec.rb

62 lines
1.3 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'DELETE /users' do
def make_request
delete '/users'
end
before do
2018-12-07 20:14:03 -05:00
sign_in current_account.user if current_account&.user
end
context 'when guest account is authenticated' do
let(:current_account) { create :guest_account }
specify do
expect { make_request }.not_to change(User, :count)
end
context 'after request' do
before { make_request }
specify do
expect(response).to redirect_to new_user_session_url
end
end
end
2018-12-07 20:14:03 -05:00
context 'when usual account is authenticated' do
let(:current_account) { create :usual_account }
specify do
expect { make_request }.not_to change(User, :count)
end
context 'after request' do
before { make_request }
specify do
expect(response).to have_http_status :method_not_allowed
end
end
end
2018-12-07 20:14:03 -05:00
context 'when superuser account is authenticated' do
let(:current_account) { create :superuser_account }
specify do
2018-12-07 20:14:03 -05:00
expect { make_request }.not_to change(User, :count)
end
context 'after request' do
before { make_request }
specify do
expect(response).to have_http_status :method_not_allowed
end
end
end
end