remove jank, support sinatra better
now that we depend on active_support, we can remove some jank. While we're at it, remove rails-specific code
This commit is contained in:
Родитель
4d40200354
Коммит
3f04883d51
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require 'rubygems'
|
||||
require 'spork'
|
||||
require 'active_support'
|
||||
|
||||
unless Spork.using_spork?
|
||||
require 'simplecov'
|
||||
|
@ -11,42 +12,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче