rspec - Rails capybara feature spec No 'Access-Control-Allow-Origin' -


i have feature spec, part of page load. hit local url more data.

i.e. using http://fullcalendar.io/ loads it's events via ajax

   events: {              url: 'calendar_events.json',              type: 'get',              error: function(response) {              ...             }}, 

i getting

xmlhttprequest cannot load http://localhost:3000/calendar_events.json?start=2014-01-20&end=2014-01-27. no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. response had http status code 404. 

not sure how resolve. tried adding

    response.headers['access-control-allow-origin'] = '*'     response.headers['access-control-allow-methods'] = 'post, put, delete, get, options'     response.headers['access-control-request-method'] = '*'     response.headers['access-control-allow-headers'] = 'origin, x-requested-with, content-type, accept, authorization' 

to before_filter on application controller see, still same issue.

note: using capybara-webkit

the best way set these in test environment, wouldn't want open origins in production.

test.rb

  config.action_dispatch.default_headers.merge!(   {       'access-control-allow-origin' => '*',       'access-control-allow-methods' => 'post, put, delete, get, options',       'access-control-max-age' => "1728000",      'access-control-allow-headers' =>'origin, x-requested-with, content-type, accept, authorization'   }) 

as issue suspect getting error after 'save_and_open_page' in case rendering error based on capybara asset_path , not actual problem test case.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -