introspective_grape 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 6af99e9a2be82ee669829ac17f9e84b767d74e12
4
- data.tar.gz: eac78da439dd9c35844cbafd0cfd23428c3500de
3
+ metadata.gz: c030a296ffbf221b0efa559f3e7e6ab2d30afae4
4
+ data.tar.gz: 9eb9b3edc3fa75e0204de34d1b704700ed08f621
5
5
  SHA512:
6
- metadata.gz: 4531fc66b10fd1f3e84778572f7ba2c0e6d9a6c27f902ae6d13ebe55da68c6ab87ad6f19a6e37883678fc3bddcaeeab4f31cc790509c9ab9041249b36ac0aafd
7
- data.tar.gz: 82660a9b2cd9683e78b4f2aacb11430e66a9a68a171f0ab3fdb4811613f264d4ebea20d51a9d0b27f3dbd7af5fa363ed3d2f76180755a8abb07246a30759111c
6
+ metadata.gz: 1423ab9e477c4f022d0ddcb424ffccca23a778d393eb43cbaa060b86a5e11d366130227230686aedb4258a139d68577adfbde889531d4a6606e0d0938a477c8b
7
+ data.tar.gz: c683edd9b8fc4733e0cc05901e77775c4ef9a40997c44d8a81a7e5d357918decd12f0142e30fd9ec770a768db950e1928d4fcc263490a77527cb64bea4402994
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ 0.2.3 10/21/2016
3
+ ==============
4
+ ### Bug Fix
5
+
6
+ We have to modify request.params and then re-assign @params to request.params before
7
+ validation in order to work with Grape's habit of mucking with both independently.
8
+
9
+ This makes Grape validations work properly again against camel inputs.
10
+
2
11
  0.2.2 10/20/2016
3
12
  ==============
4
13
 
@@ -52,11 +52,16 @@ module IntrospectiveGrape
52
52
  self.send(IntrospectiveGrape::API.authentication_method(self))
53
53
  end
54
54
 
55
- child.after_validation do
56
- # Convert incoming camel case params to snake case: grape will totally blow this
57
- # if the params hash does not come back as a Hashie::Mash.
58
- @params = (params||Hashie::Mash.new).with_snake_keys if IntrospectiveGrape.config.camelize_parameters
59
- end
55
+ child.before_validation do
56
+ # We have to snake case the Rack params then re-assign @params to the
57
+ # request.params, because of the I-think-very-goofy-and-inexplicable
58
+ # way Grape interacts with both independently of each other
59
+ (params.try(:with_snake_keys)||{}).each do |k,v|
60
+ request.delete_param(k.camelize(:lower))
61
+ request.update_param(k, v)
62
+ end
63
+ @params = request.params
64
+ end if IntrospectiveGrape.config.camelize_parameters
60
65
  end
61
66
 
62
67
  # We will probably need before and after hooks eventually, but haven't yet...
@@ -1,3 +1,3 @@
1
1
  module IntrospectiveGrape
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.2.3".freeze
3
3
  end
data/spec/rails_helper.rb CHANGED
@@ -3,6 +3,7 @@ Coveralls.wear!('rails')
3
3
  ENV["RAILS_ENV"] = 'test'
4
4
  require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
+ #require 'byebug'
6
7
  require 'support/request_helpers'
7
8
  require 'support/pundit_helpers'
8
9
  Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: introspective_grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Buermann