Refactor API CORS specs
This commit is contained in:
parent
c1477a2e89
commit
c1393b8f8f
@ -12,36 +12,27 @@ describe 'API cross origin request' do
|
||||
end
|
||||
|
||||
it 'responds to preflight request' do
|
||||
@integration_session.send(
|
||||
:process,
|
||||
:options,
|
||||
api_playlists_path(format: :json),
|
||||
nil,
|
||||
'Origin' => origin
|
||||
options api_playlists_path(format: :json), nil, 'Origin' => origin
|
||||
expect(response.headers).to include(
|
||||
'Access-Control-Allow-Origin' => origin,
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE',
|
||||
'Access-Control-Allow-Headers' =>
|
||||
'Content-Type, Content-Length, X-Requested-With'
|
||||
)
|
||||
|
||||
expect(response.headers['Access-Control-Allow-Origin']).to eq origin
|
||||
expect(response.headers['Access-Control-Allow-Credentials']).to eq 'true'
|
||||
expect(response.headers['Access-Control-Allow-Methods'])
|
||||
.to eq 'GET, POST, PUT, DELETE'
|
||||
expect(response.headers['Access-Control-Allow-Headers'])
|
||||
.to eq 'Content-Type, Content-Length, X-Requested-With'
|
||||
end
|
||||
|
||||
it 'responds to basic request' do
|
||||
# FIXME: replace with a more stable/generic action
|
||||
get api_playlists_path(format: :json), nil, 'Origin' => origin
|
||||
|
||||
expect(response.headers['Access-Control-Allow-Origin']).to eq origin
|
||||
expect(response.headers['Access-Control-Allow-Credentials']).to eq 'true'
|
||||
expect(response.headers['Access-Control-Expose-Headers'])
|
||||
.to eq 'Content-Length'
|
||||
expect(response.headers).to include(
|
||||
'Access-Control-Allow-Origin' => origin,
|
||||
'Access-Control-Allow-Credentials' => 'true',
|
||||
'Access-Control-Expose-Headers' => 'Content-Length'
|
||||
)
|
||||
end
|
||||
|
||||
it 'responds to request without origin' do
|
||||
# FIXME: replace with a more stable/generic action
|
||||
get api_playlists_path(format: :json)
|
||||
|
||||
get api_playlists_path format: :json
|
||||
expect(response.headers['Access-Control-Allow-Origin']).to eq ''
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,8 @@
|
||||
module AcceptanceHelpers
|
||||
def options path, options = nil, headers = nil
|
||||
@integration_session.send :process, :options, path, options, headers
|
||||
end
|
||||
|
||||
def sign_in
|
||||
create :user do |o|
|
||||
visit new_session_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user