Merge pull request #5 from twitter/bmaland_patches

Better support for sinatra
This commit is contained in:
Neil Matatall 2013-01-26 00:09:11 -08:00
Родитель d7588b8eec f43a46d92d
Коммит b70d490810
4 изменённых файлов: 9 добавлений и 42 удалений

Просмотреть файл

@ -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