stronger_parameters 2.14.0 → 2.17.0

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: ca4cebd1c17a7cb7e68ae01c2fa676c492ab16cbf11998e563e0520c7c0f3bc5
4
- data.tar.gz: 5a2b40548e74d16db1cdc99426bc44db551c2430a1c1bad8e2425566e18cff43
3
+ metadata.gz: 29a714a242ff378f5bf21a4a131c2c1e985e07d99a6698ec74a9c09009d201c6
4
+ data.tar.gz: eb48fa058692ca09457c04f2dd29ddb0addeb90cf40d17496c1eb62f7b2a53b3
5
5
  SHA512:
6
- metadata.gz: 13c0e6268b1a9e6567f874c131a038b947047f277db0f581d8f775da9da23ff2170fc1a3a8df8bcd1bedb21cfbbb030f89a4ec55685956be3e4e48176ee20f72
7
- data.tar.gz: 0eee3ab73de87a06429c6a86242261fc3344d267de36aa26c2921c594aeed36866ac939b303254927cafd284edca2f05408a81b04ea2393fbc89621dd9a07a19
6
+ metadata.gz: bc0642f85f672bf56faf7e139e1ea895206a6985f7b8b7a4c5034e1bd023696af0796307fa478007c462c39f2d3dc47fdc769269990e4b0c5be51691709e0d54
7
+ data.tar.gz: 133a07b885c0a2d7612e5a8b46c9c53b05534a9be921738a571f910ea6de9c166bebb1891640537e707aa5c6b96fec234cddccde2a860b03d6e0cbff9d5da3d6
@@ -7,6 +7,8 @@ module StrongerParameters
7
7
  FALSE_VALUES = [false, 'false', '0', 0].freeze
8
8
 
9
9
  def value(v)
10
+ v = v.downcase if v.is_a? String
11
+
10
12
  return true if TRUE_VALUES.include?(v)
11
13
 
12
14
  return false if FALSE_VALUES.include?(v)
@@ -6,8 +6,7 @@ module StrongerParameters
6
6
  module PermittedParameters
7
7
  def self.included(klass)
8
8
  klass.extend ClassMethods
9
- method = (klass.respond_to?(:before_action) ? :before_action : :before_filter)
10
- klass.public_send method, :permit_parameters
9
+ klass.before_action :permit_parameters
11
10
  end
12
11
 
13
12
  def self.sugar(value)
@@ -91,7 +90,7 @@ module StrongerParameters
91
90
 
92
91
  return if log_unpermitted
93
92
 
94
- (ActionPack::VERSION::MAJOR >= 5 ? params.send(:parameters) : params).replace(permitted_params)
93
+ params.send(:parameters).replace(permitted_params)
95
94
  params.permit!
96
95
  request.params.replace(permitted_params)
97
96
 
@@ -129,7 +128,7 @@ module StrongerParameters
129
128
  end
130
129
 
131
130
  def flat_keys(hash)
132
- hash = hash.send(:parameters) if ActionPack::VERSION::MAJOR >= 5 && hash.is_a?(ActionController::Parameters)
131
+ hash = hash.send(:parameters) if hash.is_a?(ActionController::Parameters)
133
132
  hash.flat_map { |k, v| v.is_a?(Hash) ? flat_keys(v).map { |x| "#{k}.#{x}" }.push(k) : k }
134
133
  end
135
134
  end
@@ -2,6 +2,7 @@
2
2
  require 'action_pack'
3
3
 
4
4
  require 'action_controller/base'
5
+ require 'action_controller/api'
5
6
  require 'action_controller/metal/strong_parameters'
6
7
 
7
8
  require 'stronger_parameters/constraints'
@@ -109,7 +110,7 @@ module StrongerParameters
109
110
  end
110
111
 
111
112
  def datetime_iso8601
112
- DateTimeIso8601Constraint.new
113
+ DateTimeIso8601Constraint.new # uncovered
113
114
  end
114
115
 
115
116
  def file
@@ -154,7 +155,7 @@ module StrongerParameters
154
155
  elsif constraint.required?
155
156
  result = InvalidValue.new(nil, 'must be present')
156
157
  else
157
- next
158
+ next # uncovered
158
159
  end
159
160
 
160
161
  if result.is_a?(InvalidValue)
@@ -190,8 +191,11 @@ module StrongerParameters
190
191
  # TODO: this is not consistent with the behavior of raising ActionController::UnpermittedParameters
191
192
  # should have the same render vs raise behavior in test/dev ... see permitted_parameters_test.rb
192
193
  rescue_from(StrongerParameters::InvalidParameter) do |e|
193
- type = (ActiveSupport::VERSION::MAJOR < 5 ? :text : :plain)
194
- render type => e.message, :status => :bad_request
194
+ if request.format.to_s.include?('json')
195
+ render json: { error: e.message }, status: :bad_request
196
+ else
197
+ render plain: e.message, status: :bad_request
198
+ end
195
199
  end
196
200
  end
197
201
  end
@@ -199,3 +203,4 @@ end
199
203
 
200
204
  ActionController::Parameters.include StrongerParameters::Parameters
201
205
  ActionController::Base.include StrongerParameters::ControllerSupport
206
+ ActionController::API.include StrongerParameters::ControllerSupport
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module StrongerParameters
3
- VERSION = '2.14.0'
3
+ VERSION = '2.17.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stronger_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,20 +142,20 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '4.2'
145
+ version: '5.0'
146
146
  - - "<"
147
147
  - !ruby/object:Gem::Version
148
- version: '6.2'
148
+ version: '7.1'
149
149
  type: :runtime
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: '4.2'
155
+ version: '5.0'
156
156
  - - "<"
157
157
  - !ruby/object:Gem::Version
158
- version: '6.2'
158
+ version: '7.1'
159
159
  description:
160
160
  email:
161
161
  - mick@zendesk.com
@@ -190,7 +190,8 @@ files:
190
190
  homepage: https://github.com/zendesk/stronger_parameters
191
191
  licenses:
192
192
  - Apache License Version 2.0
193
- metadata: {}
193
+ metadata:
194
+ rubygems_mfa_required: 'true'
194
195
  post_install_message:
195
196
  rdoc_options: []
196
197
  require_paths:
@@ -199,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
200
  requirements:
200
201
  - - ">="
201
202
  - !ruby/object:Gem::Version
202
- version: 2.5.0
203
+ version: 2.7.0
203
204
  required_rubygems_version: !ruby/object:Gem::Requirement
204
205
  requirements:
205
206
  - - ">="
206
207
  - !ruby/object:Gem::Version
207
208
  version: '0'
208
209
  requirements: []
209
- rubygems_version: 3.0.3.1
210
+ rubygems_version: 3.1.6
210
211
  signing_key:
211
212
  specification_version: 4
212
213
  summary: Type checking and type casting of parameters for Action Pack