growviral-warehouse 0.0.3 → 0.0.4
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/lib/growviral/warehouse.rb +3 -0
- data/lib/warehouse/checks_follow_history.rb +8 -5
- data/lib/warehouse/client.rb +4 -4
- data/lib/warehouse/registers_followers.rb +9 -6
- data/lib/warehouse/version.rb +1 -1
- data/test/checks_follow_history_test.rb +18 -8
- data/test/registers_followers_test.rb +17 -7
- 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: ec52af43b94624ba574121ddc20c67122af07443
|
|
4
|
+
data.tar.gz: 58d118d71ca4c3ca733cb260982a668dd1405a2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a523a8b581d190db8b59d995c0b28ffdc31b1a1d656a79f65e3bb347a7359eec8d9a6518ae2c2ce4c8bd7491198a81cfe2d7ebc6ee5c8fede44d604379a81205
|
|
7
|
+
data.tar.gz: e3987aa9562a81a22efbf3cb45f09d7293cb67c97de027b96b70725d32fe63deac4020f79d6709dfb37c7c690de4ade0ad768cd739ca5d25dda86c25558430a2
|
data/lib/growviral/warehouse.rb
CHANGED
|
@@ -5,10 +5,13 @@ module GrowViral
|
|
|
5
5
|
new(*args).exists?
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
attr_reader :
|
|
9
|
-
def initialize(
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
attr_reader :uid, :following_uid, :config
|
|
9
|
+
def initialize(uid, following_uid, deps)
|
|
10
|
+
raise HandleNotUidError unless uid.is_a? Numeric
|
|
11
|
+
raise HandleNotUidError unless following_uid.is_a? Numeric
|
|
12
|
+
|
|
13
|
+
@uid = uid
|
|
14
|
+
@following_uid = following_uid
|
|
12
15
|
@config = deps[:config]
|
|
13
16
|
end
|
|
14
17
|
|
|
@@ -22,7 +25,7 @@ module GrowViral
|
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
def uri
|
|
25
|
-
@uri ||= URI.parse("#{config.host}/follows?
|
|
28
|
+
@uri ||= URI.parse("#{config.host}/follows?uid=#{uid}&following_uid=#{following_uid}")
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
end
|
data/lib/warehouse/client.rb
CHANGED
|
@@ -7,12 +7,12 @@ module GrowViral
|
|
|
7
7
|
@config = Configuration.new(env)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def register_follow!(
|
|
11
|
-
RegistersFollows.register(
|
|
10
|
+
def register_follow!(uid, following_uid)
|
|
11
|
+
RegistersFollows.register(uid, following_uid, config: config)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def has_follow_history?(
|
|
15
|
-
ChecksFollowHistory.exists?(
|
|
14
|
+
def has_follow_history?(uid, following_uid)
|
|
15
|
+
ChecksFollowHistory.exists?(uid, following_uid, config: config)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -5,10 +5,13 @@ module GrowViral
|
|
|
5
5
|
new(*args).register
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
attr_reader :
|
|
9
|
-
def initialize(
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
attr_reader :uid, :following_uid, :config
|
|
9
|
+
def initialize(uid, following_uid, deps)
|
|
10
|
+
raise HandleNotUidError unless uid.is_a? Numeric
|
|
11
|
+
raise HandleNotUidError unless following_uid.is_a? Numeric
|
|
12
|
+
|
|
13
|
+
@uid = uid
|
|
14
|
+
@following_uid = following_uid
|
|
12
15
|
@config = deps[:config]
|
|
13
16
|
end
|
|
14
17
|
|
|
@@ -23,8 +26,8 @@ module GrowViral
|
|
|
23
26
|
|
|
24
27
|
def form_data
|
|
25
28
|
{
|
|
26
|
-
"
|
|
27
|
-
"
|
|
29
|
+
"uid" => uid,
|
|
30
|
+
"following_uid" => following_uid
|
|
28
31
|
}
|
|
29
32
|
end
|
|
30
33
|
end
|
data/lib/warehouse/version.rb
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
require_relative 'test_helper'
|
|
2
2
|
|
|
3
3
|
class ChecksFollowHistoryTest < Minitest::Test
|
|
4
|
+
def test_raises_for_a_handle
|
|
5
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
|
6
|
+
assert_raises(GrowViral::HandleNotUidError) { client.has_follow_history?("string", 2312422) }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_raises_for_a_following_handle
|
|
10
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
|
11
|
+
assert_raises(GrowViral::HandleNotUidError) { client.has_follow_history?(837373, "string") }
|
|
12
|
+
end
|
|
13
|
+
|
|
4
14
|
def test_true_for_200
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
uid = 328383
|
|
16
|
+
following_uid = 4843432
|
|
7
17
|
|
|
8
|
-
uri = URI.parse("http://localhost:3000/follows?
|
|
18
|
+
uri = URI.parse("http://localhost:3000/follows?uid=#{uid}&following_uid=#{following_uid}")
|
|
9
19
|
|
|
10
20
|
Net::HTTP.expects(:get_response).with(uri).returns(mock(code: '200'))
|
|
11
21
|
|
|
12
22
|
client = GrowViral::Warehouse::Client.new(:development)
|
|
13
|
-
assert client.has_follow_history?(
|
|
23
|
+
assert client.has_follow_history?(uid, following_uid)
|
|
14
24
|
end
|
|
15
25
|
|
|
16
26
|
def test_false_for_404
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
uid = 3478823
|
|
28
|
+
following_uid = 4939383
|
|
19
29
|
|
|
20
|
-
uri = URI.parse("http://localhost:3000/follows?
|
|
30
|
+
uri = URI.parse("http://localhost:3000/follows?uid=#{uid}&following_uid=#{following_uid}")
|
|
21
31
|
|
|
22
32
|
Net::HTTP.expects(:get_response).with(uri).returns(mock(code: '404'))
|
|
23
33
|
|
|
24
34
|
client = GrowViral::Warehouse::Client.new(:development)
|
|
25
|
-
refute client.has_follow_history?(
|
|
35
|
+
refute client.has_follow_history?(uid, following_uid)
|
|
26
36
|
end
|
|
27
37
|
end
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
require_relative 'test_helper'
|
|
2
2
|
|
|
3
3
|
class RegistersFollowersTest < Minitest::Test
|
|
4
|
+
def test_raises_for_a_handle
|
|
5
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
|
6
|
+
assert_raises(GrowViral::HandleNotUidError) { client.register_follow!("string", 2312422) }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_raises_for_a_following_handle
|
|
10
|
+
client = GrowViral::Warehouse::Client.new(:development)
|
|
11
|
+
assert_raises(GrowViral::HandleNotUidError) { client.register_follow!(972822, "string") }
|
|
12
|
+
end
|
|
13
|
+
|
|
4
14
|
def test_response_is_correct
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
uid = 23432423
|
|
16
|
+
following_uid = 342423
|
|
7
17
|
|
|
8
18
|
input = {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
19
|
+
"uid" => uid,
|
|
20
|
+
"following_uid" => following_uid,
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
output = {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
24
|
+
"uid" => uid,
|
|
25
|
+
"following_uid" => following_uid,
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
uri = URI.parse("http://localhost:3000/follows")
|
|
19
29
|
Net::HTTP.expects(:post_form).with(uri, input).returns(mock(body: output.to_json))
|
|
20
30
|
|
|
21
31
|
client = GrowViral::Warehouse::Client.new(:development)
|
|
22
|
-
actual = client.register_follow!(
|
|
32
|
+
actual = client.register_follow!(uid, following_uid)
|
|
23
33
|
|
|
24
34
|
assert_equal output, actual
|
|
25
35
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: growviral-warehouse
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Walker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-12-
|
|
11
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|