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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a2f6790466c52e2e681c7e53b7a3e8fc29f5dc1
4
- data.tar.gz: 6015b3bb3d1832f80f9e168393d972d5208a7321
3
+ metadata.gz: ec52af43b94624ba574121ddc20c67122af07443
4
+ data.tar.gz: 58d118d71ca4c3ca733cb260982a668dd1405a2d
5
5
  SHA512:
6
- metadata.gz: c43c8cd42ba7798599e98c691fdbaf14b40b679af3d8e1462ef0535b2e378f4484dbe667753f190e1b9d9646d404411144904d357dcc248522c1869f8c427388
7
- data.tar.gz: abf45a7742b76c76f65763ebf155d5980855f54d4d4f22c0dcf1a78fde43a1634f7df51481c0adca1bab1c0b2ce770d6fb897d14b766e4a2af73f2900fd6d20d
6
+ metadata.gz: a523a8b581d190db8b59d995c0b28ffdc31b1a1d656a79f65e3bb347a7359eec8d9a6518ae2c2ce4c8bd7491198a81cfe2d7ebc6ee5c8fede44d604379a81205
7
+ data.tar.gz: e3987aa9562a81a22efbf3cb45f09d7293cb67c97de027b96b70725d32fe63deac4020f79d6709dfb37c7c690de4ade0ad768cd739ca5d25dda86c25558430a2
@@ -10,4 +10,7 @@ require 'warehouse/checks_follow_history'
10
10
  module GrowViral
11
11
  module Warehouse
12
12
  end
13
+
14
+ class HandleNotUidError < RuntimeError
15
+ end
13
16
  end
@@ -5,10 +5,13 @@ module GrowViral
5
5
  new(*args).exists?
6
6
  end
7
7
 
8
- attr_reader :handle, :following_handle, :config
9
- def initialize(handle, following_handle, deps)
10
- @handle = handle
11
- @following_handle = following_handle
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?handle=#{handle}&following_handle=#{following_handle}")
28
+ @uri ||= URI.parse("#{config.host}/follows?uid=#{uid}&following_uid=#{following_uid}")
26
29
  end
27
30
  end
28
31
  end
@@ -7,12 +7,12 @@ module GrowViral
7
7
  @config = Configuration.new(env)
8
8
  end
9
9
 
10
- def register_follow!(handle, following_handle)
11
- RegistersFollows.register(handle, following_handle, config: config)
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?(handle, following_handle)
15
- ChecksFollowHistory.exists?(handle, following_handle, config: config)
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 :handle, :following_handle, :config
9
- def initialize(handle, following_handle, deps)
10
- @handle = handle
11
- @following_handle = following_handle
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
- "handle" => handle,
27
- "following_handle" => following_handle
29
+ "uid" => uid,
30
+ "following_uid" => following_uid
28
31
  }
29
32
  end
30
33
  end
@@ -1,5 +1,5 @@
1
1
  module GrowViral
2
2
  module Warehouse
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -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
- handle = "foobar"
6
- following_handle = "barfoo"
15
+ uid = 328383
16
+ following_uid = 4843432
7
17
 
8
- uri = URI.parse("http://localhost:3000/follows?handle=#{handle}&following_handle=#{following_handle}")
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?(handle, following_handle)
23
+ assert client.has_follow_history?(uid, following_uid)
14
24
  end
15
25
 
16
26
  def test_false_for_404
17
- handle = "foobar"
18
- following_handle = "barfoo"
27
+ uid = 3478823
28
+ following_uid = 4939383
19
29
 
20
- uri = URI.parse("http://localhost:3000/follows?handle=#{handle}&following_handle=#{following_handle}")
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?(handle, following_handle)
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
- handle = "foobar"
6
- following_handle = "barfoo"
15
+ uid = 23432423
16
+ following_uid = 342423
7
17
 
8
18
  input = {
9
- "handle" => handle,
10
- "following_handle" => following_handle,
19
+ "uid" => uid,
20
+ "following_uid" => following_uid,
11
21
  }
12
22
 
13
23
  output = {
14
- "handle" => handle,
15
- "following_handle" => following_handle,
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!(handle, following_handle)
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.3
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-22 00:00:00.000000000 Z
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler