auto_strip_attributes 2.4.0 → 2.5.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
  SHA1:
3
- metadata.gz: d58364e7bfb8fa25863e584c90647d420866a120
4
- data.tar.gz: 71e36458fb5db6d524bbd9190afdad815ea61b10
3
+ metadata.gz: 48197936732130b189671f33be5dd01d1b81330c
4
+ data.tar.gz: ce19242658ff02bbceaf8526879a6ada25ab5b7a
5
5
  SHA512:
6
- metadata.gz: 4ac067485bacc17e0bf9a445468a85563e135fa144f974a07416cbc80813542a16d2468094332d3b7fea1bd9b61b68131a07196e4d67092333dd7641e53216b0
7
- data.tar.gz: c90837187b66e9e7c508ae74e4a70329d2a9a3fe1e38a34934b52db31003e3ced4291fd0f6d846d3a6cf16239364fdbc204381d0c6e550e7ee86e6bb091c3616
6
+ metadata.gz: 420d3331984a65b6a4b5caf91fec7986ed3152408e84b0fd256602030dad8ed74be928a1efe448b4ac985bbcd073eb69c7f5b8925322204c9e0135f50a8d3206
7
+ data.tar.gz: d5cd9d48fa2aec7dad753a1cca1158003bab2d0b8c88ac114a87577017445346be8ae7fced6cadf476f98150f033f8625c6f27eba5b4ffaf8f975bd5ec385af7
@@ -4,11 +4,11 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.2.9
6
6
  - 2.3.1
7
- - 2.4.3
8
- - 2.5.0
7
+ - 2.4.4
8
+ - 2.5.1
9
9
  env:
10
10
  - "RAILS_VERSION=4.2"
11
11
  - "RAILS_VERSION=5.0"
12
12
  - "RAILS_VERSION=5.1"
13
- - "RAILS_VERSION=5.2.0.rc2"
13
+ - "RAILS_VERSION=5.2"
14
14
 
@@ -1,5 +1,9 @@
1
1
  ## [Master]
2
2
 
3
+ ## [2.5]
4
+
5
+ - Support for callback options (e.g. if: -> ...) (thnks to [watsonjon](https://github.com/holli/auto_strip_attributes/pull/28)
6
+
3
7
  ## [2.4]
4
8
 
5
9
  - Using `ActiveSupport.on_load(:active_record)` instead of direct `extend`. ([#26](https://github.com/holli/auto_strip_attributes/commit/02431f07fcd880baaa352fc3e5a47d07c6d3935d))
@@ -12,7 +12,7 @@ module AutoStripAttributes
12
12
  virtual = options.delete(:virtual)
13
13
 
14
14
  attributes.each do |attribute|
15
- before_validation do |record|
15
+ before_validation(options) do |record|
16
16
  if virtual
17
17
  value = record.public_send(attribute)
18
18
  else
@@ -1,3 +1,3 @@
1
1
  module AutoStripAttributes
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -49,6 +49,27 @@ describe AutoStripAttributes do
49
49
  assert Object.const_defined?(:AutoStripAttributes)
50
50
  end
51
51
 
52
+ describe "Basic attribute with default options and conditional evaluation" do
53
+ class MockRecordBasic < MockRecordParent
54
+ attr_accessor :boo
55
+ auto_strip_attributes :boo, if: ->(record) { record[:boo] == " bbb \t" }
56
+ end
57
+
58
+ it "should not strip when conditional is not met" do
59
+ @record = MockRecordBasic.new()
60
+ @record.boo = " aaa \t"
61
+ @record.valid?
62
+ @record.boo.must_equal " aaa \t"
63
+ end
64
+
65
+ it "should strip when conditional is met" do
66
+ @record = MockRecordBasic.new()
67
+ @record.boo = " bbb \t"
68
+ @record.valid?
69
+ @record.boo.must_equal "bbb"
70
+ end
71
+ end
72
+
52
73
  describe "Basic attribute with default options" do
53
74
  class MockRecordBasic < MockRecordParent
54
75
  attr_accessor :foo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_strip_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olli Huotari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2018-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord