Sha256: c88f780d544f6fde39ec835d227e1fc27259b6db2ed528c07e48a088739cc23b

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe <%= app_name.classify %>::Application do
  include Rack::Test::Methods

  context 'CORS' do
    include_context 'with a running app'

    it 'supports options' do
      options '/', {},
              'HTTP_ORIGIN' => 'http://cors.example.com',
              'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'Origin, Accept, Content-Type',
              'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'GET'

      expect(response_code).to eq 200
      expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://cors.example.com'
      expect(last_response.headers['Access-Control-Expose-Headers']).to eq ''
    end

    it 'includes Access-Control-Allow-Origin in the response' do
      get '/', {}, 'HTTP_ORIGIN' => 'http://cors.example.com'
      expect(response_code).to eq 200
      expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://cors.example.com'
    end

    it 'includes Access-Control-Allow-Origin in errors' do
      get '/invalid', {}, 'HTTP_ORIGIN' => 'http://cors.example.com'
      expect(response_code).to eq 404
      expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://cors.example.com'
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gris-0.6.8 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.7 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.6 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.5 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.2 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.1 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.6.0 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.9 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.8 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.7 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.6 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.5 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.4 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.3 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt
gris-0.5.2 lib/gris/generators/templates/scaffold/spec/endpoints/cors_spec.rb.tt