quiet_safari 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/quiet_safari.rb +33 -0
- data/lib/quiet_safari/version.rb +13 -0
- data/spec/quiet_safari_spec.rb +75 -0
- data/spec/spec_helper.rb +88 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 051cc441a2b0111537de1f6a805be1e7d1a98a2e
|
4
|
+
data.tar.gz: 5292bc813a3d4d36531d38cf6417ddbd6754e15f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd1ee12ff5b3581b8fcc5cfc4518a066a762e84bfd08f4eee527a183b096eb4d8486d4e6d453be24a97d3028e439ca5fba68341cc6716631e5916c7793afead2
|
7
|
+
data.tar.gz: e96182f3e3f37b0862960174bd26084f8cc084e016a871950d469de638d21460de565293b67a7b5e943d07d997ffa52e120ede60689606ff920222cb6cbaa099
|
data/lib/quiet_safari.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'quiet_safari/version'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module QuietSafari
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
APPL = /apple-touch-icon(-precomposed)?\.png/
|
7
|
+
KEY = 'quiet_safari.old_rails_log_level'
|
8
|
+
|
9
|
+
initializer 'quiet_safari' do |app|
|
10
|
+
app.config.quiet_safari = true
|
11
|
+
|
12
|
+
next if Rails::Rack::Logger.instance_methods.include?(:call_with_quiet_safari)
|
13
|
+
|
14
|
+
Rails::Rack::Logger.class_eval do
|
15
|
+
def call_with_quiet_safari(env)
|
16
|
+
begin
|
17
|
+
if Rails.application.config.quiet_safari && env['PATH_INFO'] =~ APPL
|
18
|
+
env[KEY] = Rails.logger.level
|
19
|
+
Rails.logger.level = Logger::UNKNOWN
|
20
|
+
end
|
21
|
+
|
22
|
+
call_without_quiet_safari(env)
|
23
|
+
ensure
|
24
|
+
Rails.logger.level = env[KEY] if env[KEY]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
alias :call_without_quiet_safari :call
|
29
|
+
alias :call :call_with_quiet_safari
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rails'
|
4
|
+
require 'rails/all'
|
5
|
+
|
6
|
+
require 'quiet_safari'
|
7
|
+
|
8
|
+
RSpec.describe QuietSafari do
|
9
|
+
def app
|
10
|
+
@app ||= Class.new(Rails::Application) do
|
11
|
+
config.active_support.deprecation = :notify
|
12
|
+
config.secret_token = '685e1a60792fa0d036a82a52c0f97e42'
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
initialize!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:request) { Rack::MockRequest.env_for(path) }
|
20
|
+
let(:response) { StringIO.new }
|
21
|
+
|
22
|
+
before do
|
23
|
+
Rails.logger = Logger.new(response)
|
24
|
+
Rails.logger.formatter = lambda { |s, d, p, m| "#{m}\n" }
|
25
|
+
end
|
26
|
+
|
27
|
+
shared_examples_for 'a quiet request' do
|
28
|
+
before { app.config.quiet_safari = true }
|
29
|
+
|
30
|
+
it 'does not output errors' do
|
31
|
+
app.call request
|
32
|
+
|
33
|
+
expect(response.string).to be_empty
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'configured to be quiet' do
|
38
|
+
context 'requesting /apple-touch-icon.png' do
|
39
|
+
let(:path) { '/apple-touch-icon.png' }
|
40
|
+
|
41
|
+
it_behaves_like 'a quiet request'
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'requesting /apple-touch-icon-precomposed.png' do
|
45
|
+
let(:path) { '/apple-touch-icon-precomposed.png' }
|
46
|
+
|
47
|
+
it_behaves_like 'a quiet request'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
shared_examples_for 'a noisy request' do
|
52
|
+
before { app.config.quiet_safari = false }
|
53
|
+
|
54
|
+
it 'outputs errors' do
|
55
|
+
app.call request
|
56
|
+
|
57
|
+
expect(response.string).to include("Started GET \"#{path}\"")
|
58
|
+
expect(response.string).to include('ActionController::RoutingError')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'not configured to be quiet' do
|
63
|
+
context 'requesting /apple-touch-icon.png' do
|
64
|
+
let(:path) { '/apple-touch-icon.png' }
|
65
|
+
|
66
|
+
it_behaves_like 'a noisy request'
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'requesting /apple-touch-icon-precomposed.png' do
|
70
|
+
let(:path) { '/apple-touch-icon-precomposed.png' }
|
71
|
+
|
72
|
+
it_behaves_like 'a noisy request'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# rspec-expectations config goes here. You can use an alternate
|
22
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
23
|
+
# assertions if you prefer.
|
24
|
+
config.expect_with :rspec do |expectations|
|
25
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
26
|
+
# and `failure_message` of custom matchers include text for helper methods
|
27
|
+
# defined using `chain`, e.g.:
|
28
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
29
|
+
# # => "be bigger than 2 and smaller than 4"
|
30
|
+
# ...rather than:
|
31
|
+
# # => "be bigger than 2"
|
32
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
36
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
37
|
+
config.mock_with :rspec do |mocks|
|
38
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
39
|
+
# a real object. This is generally recommended, and will default to
|
40
|
+
# `true` in RSpec 4.
|
41
|
+
mocks.verify_partial_doubles = true
|
42
|
+
end
|
43
|
+
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
52
|
+
# recommended. For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# be too noisy due to issues in dependencies.
|
60
|
+
config.warnings = true
|
61
|
+
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print the 10 slowest examples and example groups at the
|
73
|
+
# end of the spec run, to help surface which specs are running
|
74
|
+
# particularly slow.
|
75
|
+
config.profile_examples = 10
|
76
|
+
|
77
|
+
# Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# order dependency and want to debug it, you can fix the order by providing
|
79
|
+
# the seed, which is printed after each run.
|
80
|
+
# --seed 1234
|
81
|
+
config.order = :random
|
82
|
+
|
83
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
+
# test failures related to randomization by passing the same `--seed` value
|
86
|
+
# as the one that triggered the failure.
|
87
|
+
Kernel.srand config.seed
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quiet_safari
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Celis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
description: |
|
42
|
+
Get rid of ActionController::RoutingErrors that happen when Safari requests PNGs
|
43
|
+
that don't exist, such as `apple-touch-icon.png` or, of course, the illustrious
|
44
|
+
`apple-touch-icon-precomposed.png`. Because who cares?
|
45
|
+
email:
|
46
|
+
- me@davidcel.is
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- lib/quiet_safari.rb
|
52
|
+
- lib/quiet_safari/version.rb
|
53
|
+
- spec/quiet_safari_spec.rb
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
homepage: https://github.com/davidcelis/quiet_safari
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Because who cares about the apple-touch-icon?
|
79
|
+
test_files:
|
80
|
+
- spec/quiet_safari_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
has_rdoc:
|