Skip to content

Commit

Permalink
Allow CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
Trung Lê committed Nov 28, 2015
1 parent 009b59b commit 4b1699f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/api_v1/controllers/institutions/index.rb
Expand Up @@ -8,6 +8,9 @@ def initialize(repository: InstitutionRepository)

def call(params)
@institutions = @repository.all
self.headers['Access-Control-Allow-Origin'] = '*'
self.headers['Access-Control-Allow-Methods'] = 'GET,HEAD,PUT,PATCH,POST,DELETE'

self.body = serialized_institutions
end

Expand Down
7 changes: 7 additions & 0 deletions spec/api_v1/controllers/institutions/index_spec.rb
Expand Up @@ -34,4 +34,11 @@
expect(response[0]).to eq(406)
expect(response[2]).to eq(["Not Acceptable"])
end

it "allow CORS" do
response = action.call({})

expect(response[1]['Access-Control-Allow-Origin']).to eq('*')
expect(response[1]['Access-Control-Allow-Methods']).to eq('GET,HEAD,PUT,PATCH,POST,DELETE')
end
end

0 comments on commit 4b1699f

Please sign in to comment.