agilibox 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1f9e1e1f46c5f26fe0edd774de3846728c97da48f5c8775c545af68d3006229
4
- data.tar.gz: 3e899b4b070824794a6f4aee29f505ed8526b0efe40f444742db8ddb039f8c15
3
+ metadata.gz: 13838c6239bbcb5c4638ea7ae6b0c941bb9f534f8d4d0a80d42e7032bc8101f8
4
+ data.tar.gz: 5a5574853314ad1f5eb4cb59da239dab07f42d65adc2226d344e1eacd1687cbb
5
5
  SHA512:
6
- metadata.gz: 267b793e760c52549bdae5a0d2f47a1570ad29414caf73ee07764840bfb90b1869e0b7be58c002cbdc2d4e3641ff5c099fdd549f1fb01d7a811e0d3c487b125c
7
- data.tar.gz: c8bc95032ce6266d6ec0cc6edb8b61ba052261e9817fa6e9422c5fcbf7bcc96ba4c7ce65e205da181dd585a14d9dc64997caf7926f57b9a849e1ce8a5fb78ba8
6
+ metadata.gz: d9f95ad166c9bb997141683ac6cdd34633d002bf0859e967b0ed2fe9eff090d8b3b994c3f21e5e72843b82cd0aa94ba5ae62a30535b17fa15a3f7f2620c93b65
7
+ data.tar.gz: 26df1371c8c6aa014790618229d63807bfc472662b0b955bcd68e579d17fac805e7668b8d2aac9cab5e58b38b62405582526d1615b96b6cf96d3e0c0525c3836
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 1.9.1
6
+ - Add ErrorsMiddleware
7
+
5
8
  ## 1.9.0
6
9
  - Remove phantomjs/poltergeist support
7
10
  - BackUrlConcern transforms absolute URLs to relative
@@ -12,6 +12,10 @@ module Agilibox
12
12
  Mime::Type.register "application/vnd.ms-excel", :xls
13
13
  Mime::Type.register "application/vnd.ms-excel", :xlsx
14
14
  end
15
+
16
+ # initializer "agilibox_errors_middleware" do
17
+ # require "agilibox/errors_middleware"
18
+ # end
15
19
  end
16
20
  end
17
21
 
@@ -0,0 +1,37 @@
1
+ class Agilibox::ErrorsMiddleware
2
+ MAINTENANCE_ERRORS = [
3
+ PG::ConnectionBad,
4
+ PG::UnableToSend,
5
+ ]
6
+
7
+ NOT_ACCEPTABLE_ERRORS = [
8
+ ActionController::UnknownFormat,
9
+ ActionController::UnknownHttpMethod,
10
+ ActionView::MissingTemplate,
11
+ ]
12
+
13
+ def initialize(app)
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ @app.call(env)
19
+ rescue *MAINTENANCE_ERRORS
20
+ respond_with 503, "Maintenance en cours."
21
+ rescue *NOT_ACCEPTABLE_ERRORS
22
+ respond_with 406, "Not acceptable."
23
+ end
24
+
25
+ private
26
+
27
+ def respond_with(status, body)
28
+ [status, {"Content-Type" => "text/plain; charset=UTF-8"}, [body]]
29
+ end
30
+ end
31
+
32
+ stack = Rails.configuration.middleware
33
+ mw = Agilibox::ErrorsMiddleware
34
+ stack.unshift(mw)
35
+ stack.insert_after(ActionDispatch::DebugExceptions, mw) if defined?(ActionDispatch::DebugExceptions)
36
+ stack.insert_after(Bugsnag::Rack, mw) if defined?(Bugsnag::Rack)
37
+ stack.use(mw)
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.9.0"
2
+ VERSION = "1.9.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilibox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -217,6 +217,7 @@ files:
217
217
  - lib/agilibox/cucumber_helpers/zonebie.rb
218
218
  - lib/agilibox/engine.rb
219
219
  - lib/agilibox/engine_file.rb
220
+ - lib/agilibox/errors_middleware.rb
220
221
  - lib/agilibox/form_back_url.rb
221
222
  - lib/agilibox/rspec.rb
222
223
  - lib/agilibox/test_helpers.rb