Skip to content

Commit

Permalink
リクエストスペック実装〜リファクタ
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiWatanabe824 committed Jun 7, 2024
1 parent 9f74da6 commit 748790c
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions spec/requests/admin_user_authorizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,46 @@
require 'rails_helper'

RSpec.describe 'AdminUserAuthorizations', type: :request do
let(:regular_user) { FactoryBot.create(:user, :not_admin_user) }
let(:other_user) { FactoryBot.create(:user, :admin_user) }
let(:spot) { FactoryBot.create(:spot, :make_by_standard_user) }

describe 'GET edit_admins_user_path' do
it 'regular user is denied access' do
user = FactoryBot.create(:user, :not_admin_user)
sign_in user
it 'regular user cant access to editer for admin' do
sign_in regular_user
get edit_admins_user_path(regular_user)
expect(response).to have_http_status '404'
end
end

describe 'DELETE admins_user_path' do
it 'regular user cant delete other user' do
sign_in regular_user
delete admins_user_path(other_user)
expect(response).to have_http_status '404'
end
end

describe 'PUT admins_user_path' do
it 'regular user cant edit myself by admins path' do
sign_in regular_user
put admins_user_path(regular_user)
expect(response).to have_http_status '404'
end
end

describe 'PUT admins_spot_path' do
it 'regular user cant edit myspot by admins path' do
sign_in regular_user
put admins_spot_path(spot)
expect(response).to have_http_status '404'
end
end

get edit_admins_user_path(user)
describe 'DELETE admins_spot_path' do
it 'regular user cant delete myspot by admins pass' do
sign_in regular_user
delete admins_spot_path(spot)
expect(response).to have_http_status '404'
end
end
Expand Down

0 comments on commit 748790c

Please sign in to comment.