1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/rack-protection/spec/json_csrf_spec.rb
2011-06-20 15:47:58 +02:00

23 lines
679 B
Ruby

require File.expand_path('../spec_helper.rb', __FILE__)
describe Rack::Protection::JsonCsrf do
it_behaves_like "any rack application"
describe 'json response' do
before do
mock_app { |e| [200, {'Content-Type' => 'application/json'}, []]}
end
it "denies get requests with json responses with a remote referrer" do
get('/', {}, 'HTTP_REFERER' => 'http://evil.com').should_not be_ok
end
it "accepts get requests with json responses with a local referrer" do
get('/', {}, 'HTTP_REFERER' => '/').should be_ok
end
it "accepts get requests with json responses with no referrer" do
get('/', {}).should be_ok
end
end
end