Skip to content

Commit

Permalink
Merge pull request #321 from YukiWatanabe824/feat/add_request_spec
Browse files Browse the repository at this point in the history
リクエストスペックの追加
  • Loading branch information
YukiWatanabe824 authored Jun 8, 2024
2 parents b45dad9 + 748790c commit cd64013
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")

# using devise (auth) helper
config.include Devise::Test::IntegrationHelpers, type: :request
end
49 changes: 49 additions & 0 deletions spec/requests/admin_user_authorizations_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

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 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

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
end

0 comments on commit cd64013

Please sign in to comment.