validation_auditor 0.2.0 → 0.2.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
  SHA1:
3
- metadata.gz: 8664c5178740a633a0bb4aaa9a45759f42d89172
4
- data.tar.gz: 30bfae7d982876df10bed64f044e6b23f7c8fb97
3
+ metadata.gz: df3fdbc82541c85c7c13bddebe3a18a4a7b8d50e
4
+ data.tar.gz: 698944970c971bf99d30eeec61782f75496e6c3d
5
5
  SHA512:
6
- metadata.gz: 230cc22ca8f65f389fd187f78f41a126e0dae8270a2f9d019b2ca9d8f52792c705c8e0a9e7041f0aaccbd703dcdc401b91f765366e3a58e65ee677d4e9130583
7
- data.tar.gz: 94dbfbff65772ff7a50b9d275db2365f07bfc4caf3122808ebcc9127bf024bb6ebc2f8db29bbe4d928e6923056ebe3fda055c4bc85534b8f0cc00d9cf08edf2f
6
+ metadata.gz: bf9fd4135a3a550911658e1670a1bfa16080503dbca7a683c0da183da04553149cb4a0d65267430dd2267b2e1a3e525ff659b88eeea7328e42dbdba7e5cae96a
7
+ data.tar.gz: 0b93eba5ec3321b8fb09cf5b9e31ea695312a9daf08a31ceb637a083649c770a618b17f555d6adf4a299cbf18185154ca3c7ee63a543eda015de669724417352
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## validation_auditor 0.2.1 (Sep 5, 2014) ##
2
+
3
+ * When cleaning params to save them as yaml, also clean each element of arrays.
4
+
1
5
  ## validation_auditor 0.2.0 (Jul 23, 2014) ##
2
6
 
3
7
  * Respect the filter_parameters configuration from Rails.
@@ -41,18 +41,20 @@ module ValidationAuditor
41
41
  end
42
42
 
43
43
  # Clean parameters before storing them in the database.
44
- def self.clean_params(params)
45
- cleaned_params = {}
46
- params.each do |k, v|
47
- cleaned_params[k] = if v.is_a? Hash
48
- clean_params(v) # clean params recursively.
49
- elsif v.is_a? ActionDispatch::Http::UploadedFile
50
- v.inspect # UploadedFiles cannot be yaml-serialized, so, we replace them with a string.
51
- else
52
- v
53
- end
44
+ def self.clean_params(param)
45
+ if param.is_a? Hash
46
+ cleaned_params = {}
47
+ param.each do |k, v|
48
+ cleaned_params[k] = clean_params(v) # clean each value
49
+ end
50
+ cleaned_params
51
+ elsif param.is_a? Array
52
+ param.map { |v| clean_params(v) } # clean each value
53
+ elsif param.is_a? ActionDispatch::Http::UploadedFile
54
+ param.inspect # UploadedFiles cannot be yaml-serialized, so, we replace them with a string.
55
+ else
56
+ param
54
57
  end
55
- cleaned_params
56
58
  end
57
59
  end
58
60
 
@@ -2,5 +2,5 @@
2
2
  # Copyright © 2014, Watu
3
3
 
4
4
  module ValidationAuditor
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
@@ -40,9 +40,11 @@ class ControllerTest < ActionController::TestCase
40
40
  end
41
41
 
42
42
  should "clean params" do
43
- cleaned_params = ValidationAuditor::Controller.clean_params({name: "John Doe", deep: {structure: {with: {file: ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt"))}}}})
43
+ cleaned_params = ValidationAuditor::Controller.clean_params({name: "John Doe", deep: {structure: {with: {file: ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt")), and_files: [ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt"))]}}}})
44
44
  assert_equal "John Doe", cleaned_params[:name]
45
45
  assert cleaned_params[:deep][:structure][:with][:file].is_a? String
46
+ assert cleaned_params[:deep][:structure][:with][:and_files].is_a? Array
47
+ assert cleaned_params[:deep][:structure][:with][:and_files].first.is_a? String
46
48
  end
47
49
 
48
50
  should "not create a validation audit due to no validation failing when creating a new record" do
@@ -65,7 +67,7 @@ class ControllerTest < ActionController::TestCase
65
67
 
66
68
  should "create a validation audit even when an uploaded file is in the params" do
67
69
  assert_difference "ValidationAuditor::ValidationAudit.count" => +1 do
68
- post :create, audited_record: {name: "John Doe"}, deep: {structure: {with: {file: ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt"))}}} # Missing email and a deep structure with a file in it.
70
+ post :create, audited_record: {name: "John Doe"}, deep: {structure: {with: {file: ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt")), and_files: [ActionDispatch::Http::UploadedFile.new(tempfile: Tempfile.new("test.txt"))]}}} # Missing email and a deep structure with a file in it.
69
71
  end
70
72
  audit = ValidationAuditor::ValidationAudit.order(:id).last
71
73
  assert_nil audit.record # New records cannot be referenced because they don't exist...
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validation_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - J. Pablo Fernández
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord