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