Merge pull request #5 from twitter/bmaland_patches
Better support for sinatra
This commit is contained in:
Коммит
b70d490810
|
@ -31,7 +31,7 @@ class ContentSecurityPolicyController < ActionController::Base
|
|||
|
||||
head :ok
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn "Unable to POST CSP report to #{report_uri} because #{e}"
|
||||
Rails.logger.warn("Unable to POST CSP report to #{report_uri} because #{e}") if defined?(Rails.logger)
|
||||
head :bad_request
|
||||
end
|
||||
|
||||
|
|
|
@ -23,11 +23,13 @@ else
|
|||
end
|
||||
end
|
||||
|
||||
if defined?(ActiveSupport::Dependencies)
|
||||
if ActiveSupport::Dependencies.autoload_paths
|
||||
ActiveSupport::Dependencies.autoload_paths << File.expand_path(File.join("..", "..", "..", "app", "controllers"), __FILE__)
|
||||
else
|
||||
ActiveSupport::Dependencies.autoload_paths = [File.expand_path(File.join("..", "..", "..", "app", "controllers"), __FILE__)]
|
||||
end
|
||||
end
|
||||
|
||||
if defined? ActionController::Routing
|
||||
ActionController::Routing::RouteSet::Mapper.send :include, ::SecureHeaders::Routing::MapperExtensions
|
||||
|
|
|
@ -39,6 +39,7 @@ describe ContentSecurityPolicyController do
|
|||
it "makes a POST request" do
|
||||
Net::HTTP.stub(:new).and_return(request)
|
||||
request.should_receive(:request).with(instance_of(::Net::HTTP::Post))
|
||||
params.stub(:to_json)
|
||||
subject.scribe
|
||||
end
|
||||
|
||||
|
@ -60,7 +61,7 @@ describe ContentSecurityPolicyController do
|
|||
end
|
||||
|
||||
it "logs errors when it cannot forward the CSP report" do
|
||||
class Rails; end
|
||||
class Rails; def logger; end; end
|
||||
logger = double(:repond_to? => true)
|
||||
Rails.stub(:logger).and_return(logger)
|
||||
|
||||
|
|
|
@ -11,42 +11,6 @@ end
|
|||
Spork.prefork do
|
||||
require 'pry'
|
||||
require 'rspec'
|
||||
|
||||
# Need these features from Rails, stubbing various features from various versions
|
||||
class ApplicationController; end
|
||||
|
||||
module ActionController
|
||||
module Routing
|
||||
class Routes
|
||||
def self.draw; end
|
||||
end
|
||||
|
||||
module RouteSet; class Mapper; end; end
|
||||
end
|
||||
end
|
||||
|
||||
module ActiveSupport
|
||||
class JSON
|
||||
def self.encode obj, options = nil; end
|
||||
end
|
||||
|
||||
module Dependencies
|
||||
class << self
|
||||
attr_accessor :autoload_paths
|
||||
autoload_paths = []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Object
|
||||
def try(*a, &b); end
|
||||
|
||||
def to_json(options = nil); end
|
||||
end
|
||||
|
||||
class NilClass
|
||||
def try(*args); end
|
||||
end
|
||||
end
|
||||
|
||||
Spork.each_run do
|
||||
|
|
Загрузка…
Ссылка в новой задаче