Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21 from p0deje/spec_fix
Browse files Browse the repository at this point in the history
Fix specs
  • Loading branch information
rkh committed May 12, 2012
2 parents f1c8b55 + 552b61f commit 4c46c41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
rvm:
---
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- rbx
- rbx-2.0
- rbx-18mode
- rbx-19mode
- jruby
- ruby-head
notifications:
recipients:
notifications:
recipients:
- k.haase@finn.de
15 changes: 7 additions & 8 deletions spec/http_origin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
describe Rack::Protection::HttpOrigin do
it_behaves_like "any rack application"

before(:each) do
mock_app do
use Rack::Protection::HttpOrigin
run DummyApp
end
end

%w(GET HEAD POST PUT DELETE).each do |method|
it "accepts #{method} requests with no Origin" do
send(method.downcase, '/').should be_ok
Expand All @@ -11,20 +18,12 @@

%w(GET HEAD).each do |method|
it "accepts #{method} requests with non-whitelisted Origin" do
mock_app do
use Rack::Protection::HttpOrigin
run DummyApp
end
send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com').should be_ok
end
end

%w(POST PUT DELETE).each do |method|
it "denies #{method} requests with non-whitelisted Origin" do
mock_app do
use Rack::Protection::HttpOrigin
run DummyApp
end
send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com').should_not be_ok
end

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def prepare_session(env)
module DummyApp
def self.call(env)
Thread.current[:last_env] = env
[200, {'Content-Type' => 'text/plain'}, ['ok']]
body = (env['REQUEST_METHOD'] == 'HEAD' ? '' : 'ok')
[200, {'Content-Type' => 'text/plain'}, [body]]
end
end

Expand Down

0 comments on commit 4c46c41

Please sign in to comment.