sanitize_model_attributes 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b2e5b9b8da92accad375b1e726b3c9783d7cbb
4
- data.tar.gz: f1142ba1bb9786886b9ea5a69c6d4892d0c7257d
3
+ metadata.gz: 75eb387490b5f093275db37d0a93246fc9521e67
4
+ data.tar.gz: 2136438a78bf9c3505712ad6782f0f4639a0787a
5
5
  SHA512:
6
- metadata.gz: 1fa243a3749d09ce84992c856b40305c2b9f8f6746df543c4b692e5ea0deac428b53befe2e16a5ebd3befa21f5e1d8d307a90ec9d444b700b0a4f5103221a25d
7
- data.tar.gz: 5109a7ae854884f5802498ce15e635e069ef53878f1668ab6e11240059189a7f207bb0033b9580416a81c6fcf8a4d4709ee76cd445dd0141cc2a1d4d2d43c676
6
+ metadata.gz: 03afd16138a392b3a8c6de7ab0300cfebcd3e383f5d1798e340ca735e6d719e0f34c01dff7d241f207f5ad418997923daf10807ee961dc230636d817af59b6cf
7
+ data.tar.gz: 0991d808fccac688f835079a7d5fd46d977c7111c7edf39971711e43646158e014df68fabc595b2e419c333be99efbe782b102c270c601e4009e52198b82d564
@@ -1,3 +1,3 @@
1
1
  module SanitizeModelAttributes
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -13,7 +13,8 @@ module SanitizeModelAttributes
13
13
  args.each do |attribute_name|
14
14
  self.class_eval do
15
15
  define_method "#{attribute_name}=".to_sym do |attribute_value|
16
- write_attribute attribute_name.to_sym, Sanitize.fragment(attribute_value)
16
+ attribute_value = Sanitize.fragment(attribute_value) unless attribute_value.frozen?
17
+ write_attribute attribute_name.to_sym, attribute_value
17
18
  end
18
19
  end
19
20
  end
@@ -31,4 +31,15 @@ class TestString < Minitest::Test
31
31
  instance.name = '<strong>hogehoge</strong>'
32
32
  assert_equal 'hogehoge', instance.instance_variable_get(:@name)
33
33
  end
34
+
35
+ def test_to_skip_frozen_string
36
+ instance = @klass.new
37
+
38
+ def instance.write_attribute(name, value)
39
+ instance_variable_set("@#{name}".to_sym, value)
40
+ end
41
+
42
+ instance.name = '<strong>hogehoge</strong>'.freeze
43
+ assert_equal '<strong>hogehoge</strong>', instance.instance_variable_get(:@name)
44
+ end
34
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanitize_model_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi CHIBA