/vendor/bundle/jruby/2.1/gems/rack-protection-1.5.3/spec/frame_options_spec.rb
https://github.com/delowong/logstash · Ruby · 39 lines · 28 code · 9 blank · 2 comment · 4 complexity · 80defb5557373b1165a05ac67ee44072 MD5 · raw file
- require File.expand_path('../spec_helper.rb', __FILE__)
- describe Rack::Protection::FrameOptions do
- it_behaves_like "any rack application"
- it 'should set the X-Frame-Options' do
- get('/', {}, 'wants' => 'text/html').headers["X-Frame-Options"].should == "SAMEORIGIN"
- end
- it 'should not set the X-Frame-Options for other content types' do
- get('/', {}, 'wants' => 'text/foo').headers["X-Frame-Options"].should be_nil
- end
- it 'should allow changing the protection mode' do
- # I have no clue what other modes are available
- mock_app do
- use Rack::Protection::FrameOptions, :frame_options => :deny
- run DummyApp
- end
- get('/', {}, 'wants' => 'text/html').headers["X-Frame-Options"].should == "DENY"
- end
- it 'should allow changing the protection mode to a string' do
- # I have no clue what other modes are available
- mock_app do
- use Rack::Protection::FrameOptions, :frame_options => "ALLOW-FROM foo"
- run DummyApp
- end
- get('/', {}, 'wants' => 'text/html').headers["X-Frame-Options"].should == "ALLOW-FROM foo"
- end
- it 'should not override the header if already set' do
- mock_app with_headers("X-Frame-Options" => "allow")
- get('/', {}, 'wants' => 'text/html').headers["X-Frame-Options"].should == "allow"
- end
- end