custom_audience 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/custom_audience.rb +3 -1
- data/lib/custom_audience/version.rb +1 -1
- data/spec/custom_audience_spec.rb +13 -0
- metadata +3 -3
data/lib/custom_audience.rb
CHANGED
@@ -65,7 +65,9 @@ module CustomAudience
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def add_users
|
68
|
-
|
68
|
+
users.each_slice(1000) do |slice|
|
69
|
+
graph.put_connections id, 'users', users: JSON.dump(slice.map {|user| {"id" => user } })
|
70
|
+
end
|
69
71
|
end
|
70
72
|
|
71
73
|
def all
|
@@ -131,5 +131,18 @@ describe CustomAudience::CustomAudience do
|
|
131
131
|
|
132
132
|
subject.save
|
133
133
|
end
|
134
|
+
|
135
|
+
it "adds users in batches of 1000 if there are more" do
|
136
|
+
batch1 = 1.upto(1000).to_a
|
137
|
+
batch2 = 1001.upto(2000).to_a
|
138
|
+
|
139
|
+
subject.users = (batch1 + batch2)
|
140
|
+
subject.stubs(exists?: true, id: 1)
|
141
|
+
|
142
|
+
api.expects(:put_connections).with(1, 'users', users: batch1.map {|i| {"id" => i}}.to_json)
|
143
|
+
api.expects(:put_connections).with(1, 'users', users: batch2.map {|i| {"id" => i}}.to_json)
|
144
|
+
|
145
|
+
subject.save
|
146
|
+
end
|
134
147
|
end
|
135
148
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_audience
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
segments:
|
141
141
|
- 0
|
142
|
-
hash:
|
142
|
+
hash: -2413186198060959413
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
none: false
|
145
145
|
requirements:
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
segments:
|
150
150
|
- 0
|
151
|
-
hash:
|
151
|
+
hash: -2413186198060959413
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
154
|
rubygems_version: 1.8.24
|