agilibox 1.9.0 → 1.9.6

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: 910653d569b2435173e10da0415be0a35356421d5e6fcd112b8653c0b39f2854
4
+ data.tar.gz: 2d67a98fe71852d8746be01fe140826183eaf12d42a6099ce5175bfac15e296d
5
5
  SHA512:
6
- metadata.gz: 267b793e760c52549bdae5a0d2f47a1570ad29414caf73ee07764840bfb90b1869e0b7be58c002cbdc2d4e3641ff5c099fdd549f1fb01d7a811e0d3c487b125c
7
- data.tar.gz: c8bc95032ce6266d6ec0cc6edb8b61ba052261e9817fa6e9422c5fcbf7bcc96ba4c7ce65e205da181dd585a14d9dc64997caf7926f57b9a849e1ce8a5fb78ba8
6
+ metadata.gz: 2b5db5518d98aa662b3bef973bce64adb438beff835276b02d679aa9cba8714f71178fa3510792589b602439fd162f26f161679b2c5063ebd375b3b72a2618ce
7
+ data.tar.gz: 37e954d5f9c4e1a767c91e999327ac32b64f9a984153c1cccf4273423d6b1818e89b3dcab08a056889decd6e72abd84672bfd94bb05c1b2207cc7a640efa44de
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## v1.9.6
6
+ - Fix info helper with false
7
+ - Update Rubocop + fix offences
8
+
9
+ ## 1.9.5
10
+ - Fix warnings on Rails 6
11
+
12
+ ## 1.9.4
13
+ - Cucumber : disable Zonebie
14
+
15
+ ## 1.9.3
16
+ - No change
17
+
18
+ ## 1.9.2
19
+ - ErrorsMiddleware improvements
20
+
21
+ ## 1.9.1
22
+ - Add ErrorsMiddleware
23
+
5
24
  ## 1.9.0
6
25
  - Remove phantomjs/poltergeist support
7
26
  - BackUrlConcern transforms absolute URLs to relative
@@ -37,7 +37,7 @@ module Agilibox::ApiControllerConcern
37
37
  end
38
38
 
39
39
  def json_error_string_for_model(object)
40
- json_errors_hash_for_model(object).values.map { |e| e[:full_message] }.join(", ")
40
+ json_errors_hash_for_model(object).values.pluck(:full_message).join(", ")
41
41
  end
42
42
 
43
43
  def render_not_found
@@ -13,7 +13,7 @@ module Agilibox::BackUrlConcern
13
13
  default_back_url,
14
14
  main_app.try(:root_path),
15
15
  "/",
16
- ].select(&:present?).first
16
+ ].find(&:present?)
17
17
 
18
18
  uri = URI.parse(url)
19
19
  uri.host = nil
@@ -43,7 +43,7 @@ class Agilibox::SmallData::Filter
43
43
  end
44
44
 
45
45
  def respond_to_missing?(method, *)
46
- strategies.key?(method.to_s) || strategies.key?(method.to_s.chomp("="))
46
+ super || strategies.key?(method.to_s) || strategies.key?(method.to_s.chomp("="))
47
47
  end
48
48
 
49
49
  def read
@@ -2,6 +2,7 @@ class Agilibox::SmallData::FilterStrategyByKeyValue < ::Agilibox::SmallData::Fil
2
2
  attr_reader :key
3
3
 
4
4
  def initialize(key = nil)
5
+ super()
5
6
  @key = key
6
7
  end
7
8
 
@@ -13,8 +13,8 @@ module Agilibox::BootstrapHelper
13
13
  end
14
14
 
15
15
  def bs_progress_bar(percentage)
16
- content_tag(:div, class: "progress") do
17
- content_tag(:div, class: "progress-bar", style: "width:#{percentage}%") do
16
+ tag.div(class: "progress") do
17
+ tag.div(class: "progress-bar", style: "width:#{percentage}%") do
18
18
  "#{percentage}%"
19
19
  end
20
20
  end
@@ -7,7 +7,7 @@ module Agilibox::FiltersHelper
7
7
  text = options.delete(:text) || t("actions.filter")
8
8
  icon = options.delete(:icon) || :filter
9
9
 
10
- content_tag(:button, options) do
10
+ tag.button(options) do
11
11
  icon(icon) + " " + text
12
12
  end
13
13
  end
@@ -20,7 +20,7 @@ module Agilibox::FiltersHelper
20
20
  text = options.delete(:text) || t("actions.reset")
21
21
  icon = options.delete(:icon) || :undo
22
22
 
23
- content_tag(:button, options) do
23
+ tag.button(options) do
24
24
  icon(icon) + " " + text
25
25
  end
26
26
  end
@@ -15,7 +15,7 @@ module Agilibox::FontAwesomeHelper
15
15
 
16
16
  attributes = options.merge(class: css_classes.sort.join(" ")).sort.to_h
17
17
 
18
- content_tag(:span, attributes) {}
18
+ tag.span(attributes) {}
19
19
  end
20
20
 
21
21
  class << self
@@ -21,13 +21,13 @@ module Agilibox::FormHelper
21
21
  submit_action = :save
22
22
  end
23
23
 
24
- content_tag("div", class: "actions form-actions") do
25
- submit = content_tag(:button, type: :submit, class: "btn btn-sm btn-success form-submit") do
26
- content_tag(:span, class: "fa fa-save") {} + " " + ta(submit_action)
24
+ tag.div(class: "actions form-actions") do
25
+ submit = tag.button(type: :submit, class: "btn btn-sm btn-success form-submit") do
26
+ tag.span(class: "fa fa-save") {} + " " + ta(submit_action)
27
27
  end
28
28
 
29
- cancel = content_tag("a", href: back_url, class: "btn btn-primary btn-sm form-cancel") do
30
- content_tag(:span, class: "fa fa-times") {} + " " + ta(:cancel)
29
+ cancel = tag.a(href: back_url, class: "btn btn-primary btn-sm form-cancel") do
30
+ tag.span(class: "fa fa-times") {} + " " + ta(:cancel)
31
31
  end
32
32
 
33
33
  cancel = "" if back_url == false
@@ -5,7 +5,7 @@ module Agilibox::PaginationHelper
5
5
  end
6
6
 
7
7
  def pagination_infos(collection)
8
- content_tag(:p, class: "pagination-infos") { page_entries_info(collection) }
8
+ tag.p(class: "pagination-infos") { page_entries_info(collection) }
9
9
  end
10
10
 
11
11
  def pagination_and_infos(collection)
@@ -1,6 +1,10 @@
1
1
  module Agilibox::RoutesHelper
2
2
  def engine_polymorphic_path(obj, opts = {})
3
- engine = obj.class.parents[-2]
3
+ if Rails::VERSION::STRING >= "6.0.0"
4
+ engine = obj.class.module_parents[-2]
5
+ else
6
+ engine = obj.class.parents[-2]
7
+ end
4
8
 
5
9
  if engine.nil?
6
10
  routes = main_app
@@ -38,7 +38,7 @@ module Agilibox::SortingHelper
38
38
 
39
39
  if sort_param.present?
40
40
  if sort_param.start_with?("-")
41
- column = sort_param[1..-1].to_sym
41
+ column = sort_param[1..].to_sym
42
42
  direction = :desc
43
43
  else
44
44
  column = sort_param.to_sym
@@ -93,13 +93,16 @@ module Agilibox::TextHelper
93
93
  value = value_or_options
94
94
  end
95
95
 
96
+ value = t("yes") if value == true
97
+ value = t("no") if value == false
98
+
96
99
  if value.blank?
97
100
  value = options[:default]
98
101
  return if value == :hide
99
102
  end
100
103
 
101
104
  label = options[:label] || object.t(attribute)
102
- tag = options[:tag] || :div
105
+ info_tag = options[:tag] || :div
103
106
  separator = options[:separator] || " : "
104
107
  separator = " :<br/>".html_safe if separator == :br
105
108
  helper = options[:helper]
@@ -108,8 +111,6 @@ module Agilibox::TextHelper
108
111
  klass = object.is_a?(Module) ? object : object.class
109
112
  object_type = klass.to_s.split("::").last.underscore
110
113
 
111
- value = t("yes") if value == true
112
- value = t("no") if value == false
113
114
  value = object.tv(attribute) if nested
114
115
  value = send(helper, value) if helper
115
116
  value = number(value) if value.is_a?(Numeric)
@@ -117,10 +118,10 @@ module Agilibox::TextHelper
117
118
  value = l(value) if value.is_a?(Date)
118
119
  value = value.to_s
119
120
 
120
- html_label = content_tag(:strong, class: "info-label") { label }
121
+ html_label = tag.strong(class: "info-label") { label }
121
122
  span_css_class = "info-value #{object_type}-#{attribute}"
122
- html_value = content_tag(:span, class: span_css_class) { value }
123
- separator_html = content_tag(:span, class: "info-separator") { separator }
123
+ html_value = tag.span(class: span_css_class) { value }
124
+ separator_html = tag.span(class: "info-separator") { separator }
124
125
 
125
126
  if value.blank?
126
127
  container_css_class = "info blank"
@@ -128,7 +129,7 @@ module Agilibox::TextHelper
128
129
  container_css_class = "info"
129
130
  end
130
131
 
131
- content_tag(tag, class: container_css_class) do
132
+ content_tag(info_tag, class: container_css_class) do
132
133
  [html_label, separator_html, html_value].join.html_safe
133
134
  end
134
135
  end # def info
@@ -138,7 +139,7 @@ module Agilibox::TextHelper
138
139
  return "" if object.tag_list.empty?
139
140
 
140
141
  object.tag_list.map { |tag|
141
- content_tag(:span, class: "tag label label-primary") {
142
+ tag.span(class: "tag label label-primary") {
142
143
  "#{icon :tag} #{tag}".html_safe
143
144
  }
144
145
  }.join(" ").html_safe
@@ -3,6 +3,7 @@ class Agilibox::FCM::Notifier < Agilibox::Service
3
3
 
4
4
  # rubocop:disable Metrics/ParameterLists
5
5
  def initialize(to:, title: nil, body:, badge: 0, sound: "default", data: {})
6
+ super()
6
7
  @to = to
7
8
  @title = title
8
9
  @body = body
@@ -39,7 +39,7 @@ class Agilibox::FCM::Request < Agilibox::Service
39
39
  end
40
40
 
41
41
  def errors
42
- response_json[:results].map { |r| r[:error] }.compact
42
+ response_json[:results].pluck(:error).compact
43
43
  end
44
44
 
45
45
  def invalid_token?
@@ -18,6 +18,6 @@ class Agilibox::MiniModelSerializer::Serializer < Agilibox::MiniModelSerializer:
18
18
  end
19
19
 
20
20
  def respond_to_missing?(m, *)
21
- object.respond_to?(m, true)
21
+ super || object.respond_to?(m, true)
22
22
  end
23
23
  end
@@ -6,7 +6,7 @@ class Agilibox::PhoneNumberSanitizer
6
6
  end
7
7
 
8
8
  def call
9
- phone_number.to_s.gsub(/[^0-9\+]+/, "").presence
9
+ phone_number.to_s.gsub(/[^0-9+]+/, "").presence
10
10
  end
11
11
 
12
12
  def self.call(*args)
@@ -36,7 +36,7 @@ class Agilibox::SMS::ApplicationSMS
36
36
  end
37
37
 
38
38
  def respond_to_missing?(m, *)
39
- public_instance_methods.include?(m)
39
+ super || public_instance_methods.include?(m)
40
40
  end
41
41
  end # class << self
42
42
  end
@@ -1,8 +1,8 @@
1
1
  module Agilibox::ActiveModelCustomErrorMessages
2
2
  def full_message(attribute, message)
3
- return message[1..-1] if message[0] == "^"
3
+ return message[1..] if message[0] == "^"
4
4
  super(attribute, message)
5
5
  end
6
6
  end
7
7
 
8
- ActiveModel::Errors.send(:prepend, Agilibox::ActiveModelCustomErrorMessages)
8
+ ActiveModel::Errors.prepend(Agilibox::ActiveModelCustomErrorMessages)
@@ -2,7 +2,7 @@ module Agilibox::ActiveModelTypeCast
2
2
  module Decimal
3
3
  def cast_value(value)
4
4
  if value.is_a?(String)
5
- super value.tr(",", ".").gsub(/[^-0-9\.]/, "")
5
+ super value.tr(",", ".").gsub(/[^-0-9.]/, "")
6
6
  else
7
7
  super value
8
8
  end
@@ -46,7 +46,7 @@ module Agilibox::ActiveModelTypeCast
46
46
  end
47
47
  end
48
48
 
49
- ActiveModel::Type::Date.send(:prepend, Agilibox::ActiveModelTypeCast::Date)
50
- ActiveModel::Type::Boolean.send(:prepend, Agilibox::ActiveModelTypeCast::Boolean)
51
- ActiveModel::Type::Decimal.send(:prepend, Agilibox::ActiveModelTypeCast::Decimal)
52
- ActiveModel::Type::Float.send(:prepend, Agilibox::ActiveModelTypeCast::Decimal)
49
+ ActiveModel::Type::Date.prepend(Agilibox::ActiveModelTypeCast::Date)
50
+ ActiveModel::Type::Boolean.prepend(Agilibox::ActiveModelTypeCast::Boolean)
51
+ ActiveModel::Type::Decimal.prepend(Agilibox::ActiveModelTypeCast::Decimal)
52
+ ActiveModel::Type::Float.prepend(Agilibox::ActiveModelTypeCast::Decimal)
@@ -1 +1,4 @@
1
- Zonebie.set_random_timezone
1
+ # Temporairement désactiver en attendant de trouver une solution.
2
+ # Zonebie change la TZ sur les steps mais pas sur l'application,
3
+ # du coup on casse des tests alors que l'implémentation est bonne.
4
+ # Zonebie.set_random_timezone
@@ -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,47 @@
1
+ class Agilibox::ErrorsMiddleware
2
+ MAINTENANCE_ERRORS = [
3
+ "ActiveRecord::ConnectionTimeoutError",
4
+ "connections on port 5432",
5
+ "PG::UnableToSend",
6
+ ]
7
+
8
+ NOT_ACCEPTABLE_ERRORS = [
9
+ "ActionController::BadRequest",
10
+ "ActionController::UnknownFormat",
11
+ "ActionController::UnknownHttpMethod",
12
+ "ActionView::MissingTemplate",
13
+ ]
14
+
15
+ def initialize(app)
16
+ @app = app
17
+ end
18
+
19
+ def call(env)
20
+ @app.call(env)
21
+ rescue StandardError => e
22
+ error = "#{e.class} : #{e.message}"
23
+
24
+ if MAINTENANCE_ERRORS.any? { |pattern| error.match?(pattern) }
25
+ return respond_with 503, "Maintenance en cours."
26
+ end
27
+
28
+ if NOT_ACCEPTABLE_ERRORS.any? { |pattern| error.match?(pattern) }
29
+ return respond_with 406, "Not acceptable."
30
+ end
31
+
32
+ raise e
33
+ end
34
+
35
+ private
36
+
37
+ def respond_with(status, body)
38
+ [status, {"Content-Type" => "text/plain; charset=UTF-8"}, [body]]
39
+ end
40
+ end
41
+
42
+ stack = Rails.configuration.middleware
43
+ mw = Agilibox::ErrorsMiddleware
44
+ stack.unshift(mw)
45
+ stack.insert_after(ActionDispatch::DebugExceptions, mw) if defined?(ActionDispatch::DebugExceptions)
46
+ stack.insert_after(Bugsnag::Rack, mw) if defined?(Bugsnag::Rack)
47
+ stack.use(mw)
@@ -15,4 +15,4 @@ module Agilibox::FormBackUrl
15
15
  end
16
16
  end
17
17
 
18
- ActionView::Helpers::FormTagHelper.send(:prepend, Agilibox::FormBackUrl)
18
+ ActionView::Helpers::FormTagHelper.prepend(Agilibox::FormBackUrl)
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.9.0"
2
+ VERSION = "1.9.6"
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2020-09-29 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
@@ -227,7 +228,7 @@ homepage: https://github.com/agilidee/agilibox
227
228
  licenses:
228
229
  - MIT
229
230
  metadata: {}
230
- post_install_message:
231
+ post_install_message:
231
232
  rdoc_options: []
232
233
  require_paths:
233
234
  - lib
@@ -243,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
244
  version: '0'
244
245
  requirements: []
245
246
  rubygems_version: 3.0.3
246
- signing_key:
247
+ signing_key:
247
248
  specification_version: 4
248
249
  summary: Agilibox
249
250
  test_files: []