mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 12:23:46 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
34 lines
746 B
Ruby
34 lines
746 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Middleware::DiscoursePublicExceptions do
|
|
before do
|
|
@orig_logger = Rails.logger
|
|
Rails.logger = @fake_logger = FakeLogger.new
|
|
end
|
|
|
|
after do
|
|
Rails.logger = @orig_logger
|
|
end
|
|
|
|
def env(opts = {})
|
|
{
|
|
"HTTP_HOST" => "http://test.com",
|
|
"REQUEST_URI" => "/path?bla=1",
|
|
"REQUEST_METHOD" => "GET",
|
|
"rack.input" => ""
|
|
}.merge(opts)
|
|
end
|
|
|
|
it "should not log for invalid mime type requests" do
|
|
ex = Middleware::DiscoursePublicExceptions.new("/test")
|
|
|
|
ex.call(env(
|
|
"HTTP_ACCEPT" => "../broken../",
|
|
"action_dispatch.exception" => ActionController::RoutingError.new("abc")
|
|
))
|
|
|
|
expect(@fake_logger.warnings.length).to eq(0)
|
|
end
|
|
|
|
end
|