You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diff --git a/spec/api/events_api_spec.rb b/spec/api/events_api_spec.rb
index 7f1c1d0..3f4f2ef 100644
--- a/spec/api/events_api_spec.rb+++ b/spec/api/events_api_spec.rb@@ -1,15 +1,32 @@
require 'rails_helper'
RSpec.describe '/api/events' do
++ context 'OPTIONS#preflight' do+ it 'responds with CORS headers' do+ options '/api/events/'++ expect(response).to have_http_status(:ok)+ expect(response.headers['Access-Control-Allow-Headers']).to eq 'Content-Type'+ # More like this expect(response.headers[...]).to eq ...+ expect(response.body).to eq ''+ end+ end+
context 'POST#create' do
context 'with correct paramaters' do
- xit 'creates a new event for the registered application' do+ it 'creates a new event for the registered application' do
user = create(:user)
application = create(:application)
params = { name: "the name of the event" }
+ headers = {+ 'Content-Type' => 'application/json',+ 'Accept' => 'application/json',+ 'Origin' => application.url+ }- post '/api/events/', params.to_json+ post '/api/events/', params.to_json, headers
json = JSON.parse(response.body)
expect(json).to eq("")
diff --git a/spec/controllers/api/events_controller_spec.rb b/spec/controllers/api/events_controller_spec.rb
index 345168b..cfb9d5f 100644
--- a/spec/controllers/api/events_controller_spec.rb+++ b/spec/controllers/api/events_controller_spec.rb@@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.describe API::EventsController, type: :controller do
describe "OPTIONS#preflight" do
it "returns status 200" do
- get :preflight+ process :preflight, 'OPTIONS'
expect(response).to have_http_status(200)
expect(response.headers["Access-Control-Allow-Headers"]).to eq("Content-Type")
end
diff --git a/spec/support/request_helper.rb b/spec/support/request_helper.rb
new file mode 100644
index 0000000..d63928b
--- /dev/null+++ b/spec/support/request_helper.rb@@ -0,0 +1,14 @@+module RequestHelper+ # Add support for testing `options` requests in RSpec.+ # See: https://github.com/rspec/rspec-rails/issues/925+ def options(*args)+ reset! unless integration_session+ integration_session.__send__(:process, :options, *args).tap do+ copy_session_variables!+ end+ end+end++RSpec.configure do |config|+ config.include RequestHelper, type: :request+end
\ No newline at end of file
The text was updated successfully, but these errors were encountered:
Notes:
The text was updated successfully, but these errors were encountered: