acts-as-taggable-array-on 0.4.1 → 0.4.2

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: 9a9425d37517e5fe36a4248c6dc73d7b07f624ed
4
- data.tar.gz: 7dfb8aba8ed94a45b021a386022e4817f06c015b
3
+ metadata.gz: a77a0ec0610eefe1f30f46cdceea0506283044dc
4
+ data.tar.gz: d3a309690f4f0277752d68c270f937a6c67a66d1
5
5
  SHA512:
6
- metadata.gz: ced512be1adc28265254dab4f10950f3c14d537efd63d686b87c4a4282c427116ad7cc0666214a6b4dc1cd2e4ad716aaaec08ae459b351bd7736f3c7d7f2d524
7
- data.tar.gz: 48fe26c163b62f53f243e053d677c1fe19a1cb9dfa3b434fa5fe78cfc3be6ae9be86b55afbbf72cd3c8c3e75f5af0933290366dde2f4ec9409d08a3c3f85563b
6
+ metadata.gz: dfef9bc472538240ea718500f4f3295c3bdf684ede2e4d35d81055406a8ab51040d7a8dd864ab30264d7bbed12c8055a6e3a3e36406ec54c522ee3287306a23a
7
+ data.tar.gz: 5a7de21d8081ad1dfc2916cdb0e7f19c4c14219fb8f89ad619d069e2e7d636715f5b1d143dc9b677edb95a8ac2091e5e90d8809b19690e0be4fca7ad4722ebf9
data/README.md CHANGED
@@ -53,6 +53,14 @@ end
53
53
 
54
54
  acts_as_taggable_array_on defines 4 scope and 2 class methods as below.
55
55
 
56
+ ### types
57
+
58
+ currently, these types supported
59
+
60
+ - varchar[]
61
+ - text[]
62
+ - integer[]
63
+
56
64
  ### scopes
57
65
 
58
66
  - with_any_#{tag_name}
@@ -6,7 +6,7 @@ module ActsAsTaggableArrayOn
6
6
  base.extend(ClassMethod)
7
7
  end
8
8
 
9
- TYPE_MATCHER = { string: 'varchar', text: 'text' }
9
+ TYPE_MATCHER = { string: 'varchar', text: 'text', integer: 'integer' }
10
10
 
11
11
  module ClassMethod
12
12
  def acts_as_taggable_array_on(*tag_def)
@@ -1,3 +1,3 @@
1
1
  module ActsAsTagPgarray
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -2,12 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe ActsAsTaggableArrayOn::Taggable do
4
4
  before do
5
- @user1 = User.create name: 'Tom', colors: ['red', 'blue'], sizes: ['medium', 'large']
6
- @user2 = User.create name: 'Ken', colors: ['black', 'white', 'red'], sizes: ['small', 'large']
7
- @user3 = User.create name: 'Joe', colors: ['black', 'blue'], sizes: ['small', 'medium', 'large']
5
+ @user1 = User.create name: 'Tom', colors: ['red', 'blue'], sizes: ['medium', 'large'], codes: [456, 789]
6
+ @user2 = User.create name: 'Ken', colors: ['black', 'white', 'red'], sizes: ['small', 'large'], codes: [123, 789]
7
+ @user3 = User.create name: 'Joe', colors: ['black', 'blue'], sizes: ['small', 'medium', 'large'], codes: [123, 456, 789]
8
8
 
9
9
  User.acts_as_taggable_array_on :colors
10
10
  User.acts_as_taggable_array_on :sizes
11
+ User.acts_as_taggable_array_on :codes
11
12
  end
12
13
 
13
14
  describe "#acts_as_taggable_array_on" do
@@ -32,6 +33,13 @@ describe ActsAsTaggableArrayOn::Taggable do
32
33
  expect(User.without_all_sizes('medium')).to match_array([@user2])
33
34
  end
34
35
 
36
+ it "should work with ::integer typed array" do
37
+ expect(User.with_any_codes([123])).to match_array([@user2,@user3])
38
+ expect(User.with_all_codes([123, 789])).to match_array([@user2,@user3])
39
+ expect(User.without_any_codes(456)).to match_array([@user2])
40
+ expect(User.without_all_codes(456)).to match_array([@user2])
41
+ end
42
+
35
43
  describe "#with_any_tags" do
36
44
  it "returns users having any tags of args" do
37
45
  expect(User.with_any_colors(['red', 'blue'])).to match_array([@user1,@user2,@user3])
@@ -39,6 +39,7 @@ def create_database
39
39
  t.string :name
40
40
  t.string :colors, array: true, default: []
41
41
  t.text :sizes, array:true, default: []
42
+ t.integer :codes, array: true, default: []
42
43
  t.timestamps null: true
43
44
  end
44
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-array-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuya Miyamoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord