abongo 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/abongo.rb +6 -0
- data/lib/abongo/version.rb +1 -1
- data/test/test_abongo.rb +9 -0
- metadata +2 -2
data/lib/abongo.rb
CHANGED
@@ -159,6 +159,12 @@ class Abongo
|
|
159
159
|
tests_and_alternatives
|
160
160
|
end
|
161
161
|
|
162
|
+
def self.is_human?(identity = nil)
|
163
|
+
identity ||= Abongo.identity
|
164
|
+
participant = Abongo.participants.find_one(:identity => identity)
|
165
|
+
return !!(participant && participant["human"])
|
166
|
+
end
|
167
|
+
|
162
168
|
def self.human!(identity = nil)
|
163
169
|
identity ||= Abongo.identity
|
164
170
|
begin
|
data/lib/abongo/version.rb
CHANGED
data/test/test_abongo.rb
CHANGED
@@ -281,6 +281,15 @@ class TestAbongo < Test::Unit::TestCase
|
|
281
281
|
assert_equal(1, alternative['conversions'])
|
282
282
|
end
|
283
283
|
|
284
|
+
def test_is_human
|
285
|
+
Abongo.identity = 'ident'
|
286
|
+
Abongo.options[:count_humans_only] = true
|
287
|
+
assert_equal("alt1", Abongo.test('test_test', ['alt1', 'alt2']))
|
288
|
+
assert !Abongo.is_human?
|
289
|
+
Abongo.human!
|
290
|
+
assert Abongo.is_human?
|
291
|
+
end
|
292
|
+
|
284
293
|
def test_count_humans_only_without_conversion_before_marked_human
|
285
294
|
Abongo.identity = 'ident'
|
286
295
|
Abongo.options[:count_humans_only] = true
|