auto_strip_attributes 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGELOG.md +4 -0
- data/lib/auto_strip_attributes.rb +1 -1
- data/lib/auto_strip_attributes/version.rb +1 -1
- data/test/auto_strip_attributes_test.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48197936732130b189671f33be5dd01d1b81330c
|
4
|
+
data.tar.gz: ce19242658ff02bbceaf8526879a6ada25ab5b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 420d3331984a65b6a4b5caf91fec7986ed3152408e84b0fd256602030dad8ed74be928a1efe448b4ac985bbcd073eb69c7f5b8925322204c9e0135f50a8d3206
|
7
|
+
data.tar.gz: d5cd9d48fa2aec7dad753a1cca1158003bab2d0b8c88ac114a87577017445346be8ae7fced6cadf476f98150f033f8625c6f27eba5b4ffaf8f975bd5ec385af7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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))
|
@@ -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
|
+
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-
|
11
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|