groovehq 1.0.2 → 1.0.3

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: 43f043143339184bc705dda2e5fa561531a5c010
4
- data.tar.gz: d0a3a58f8a05e824e43b49a0c2614d085814ef5f
3
+ metadata.gz: f1d33c98f5eeed19a68361f560b4144aa2d62b5e
4
+ data.tar.gz: 8f7114a49e403d5400483235fbe06f8813cb5b9d
5
5
  SHA512:
6
- metadata.gz: c049b74da9379131aa2e86f4a40c30096a29ee2492e73bb0b09330b10b226df377fbcd0b27e8629ad402854fbe511fc6ceda7408e724c6665aa1486baf754321
7
- data.tar.gz: 796ae8ac97aebf7902d6750577e34dc96426278131fce0790d1b75ab3d4d945e2077466308ed798784d9a662bd87dc955a30c0562bf70edbdf4396aec2fa6e8f
6
+ metadata.gz: 17d1e534f9be1813e1a14d2ec9af872e9d795db2253fcd16f4e702a74d742fa1c4461abb20634a3a8b0f0704836500e8c40bc5bbb3a4759d5d4c7fd323de7cee
7
+ data.tar.gz: caf3432e838bfc7dea918292024db05dc050e59e54e0e17d2c723ae0e635aa8ee28023b3bc3d92d99f80469bd1ddc4c107d08ffa97f565bd9668078a0fc420c7
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .ruby-gemset
16
+ .ruby-version
@@ -36,7 +36,7 @@ module GrooveHQ
36
36
  end
37
37
 
38
38
  def update_ticket_priority(ticket_number, priority)
39
- put("/tickets/#{ticket_number}/assignee", priority: priority)
39
+ put("/tickets/#{ticket_number}/priority", priority: priority)
40
40
  end
41
41
 
42
42
  def update_ticket_assigned_group(ticket_number, assigned_group)
@@ -10,8 +10,8 @@ module GrooveHQ
10
10
 
11
11
  data = data.with_indifferent_access
12
12
 
13
- links = data.delete(:links) { Hash.new }
14
- links[:self] = data.delete(:href) if data.has_key?(:href)
13
+ links = data.delete(:links) { ActiveSupport::HashWithIndifferentAccess.new }
14
+ links[:self] = { href: data.delete(:href) } if data.has_key?(:href)
15
15
 
16
16
  @data = OpenStruct.new(data.with_indifferent_access)
17
17
 
@@ -20,7 +20,7 @@ module GrooveHQ
20
20
 
21
21
  def parse_links(links)
22
22
  (links || {}).each_with_object({}) do |(relation, value), result|
23
- result[relation] = Relation.new(@client, value["href"])
23
+ result[relation] = Relation.new(@client, value[:href])
24
24
  end
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module GrooveHQ
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -3,14 +3,28 @@ require 'spec_helper'
3
3
  describe GrooveHQ::Client::Connection do
4
4
 
5
5
  let(:client) { GrooveHQ::Client.new("phantogram") }
6
+ let(:api_groovehq_url) { "https://api.groovehq.com/v1" }
7
+
8
+ before(:each) do
9
+ stub_request(:get, "#{api_groovehq_url}#{resource_path}").to_return(body: response)
10
+ end
11
+
12
+ subject { client.get(resource_path) }
13
+
14
+ context "empty response" do
15
+
16
+ let(:resource_path) { "/tickets" }
17
+ let(:response) { '' }
18
+
19
+ it "returns nil" do
20
+ expect(subject).to eql(nil)
21
+ end
6
22
 
7
- it "returns nil for empty response" do
8
- stub_request(:get, "https://api.groovehq.com/v1/tickets").to_return(body: "")
9
- expect(client.get("/tickets")).to eql(nil)
10
23
  end
11
24
 
12
25
  context "nested hash as response with single root key" do
13
26
 
27
+ let(:resource_path) { "/tickets/1" }
14
28
  let(:response) do
15
29
  {
16
30
  ticket: {
@@ -25,38 +39,32 @@ describe GrooveHQ::Client::Connection do
25
39
  }.to_json
26
40
  end
27
41
 
28
- before(:each) do
29
- stub_request(:get, "https://api.groovehq.com/v1/tickets/1").to_return(body: response)
30
- end
31
-
32
42
  it "returns resource for single root key" do
33
- expect(client.get("/tickets/1")).to be_instance_of(GrooveHQ::Resource)
43
+ expect(subject).to be_instance_of(GrooveHQ::Resource)
34
44
  end
35
45
 
36
46
  it "returns resource with correct relations" do
37
- expect(client.get("/tickets/1").rels[:assignee].href).to eql("https://api.groovehq.com/v1/agents/matt@groovehq.com")
47
+ expect(subject.rels[:assignee].href).to eql("https://api.groovehq.com/v1/agents/matt@groovehq.com")
38
48
  end
39
49
 
40
50
  end
41
51
 
42
52
  context "single key-value pair in response" do
43
53
 
54
+ let(:resource_path) { "/tickets/1/state" }
44
55
  let(:response) do
45
56
  { state: "open" }.to_json
46
57
  end
47
58
 
48
- before(:each) do
49
- stub_request(:get, "https://api.groovehq.com/v1/tickets/1/state").to_return(body: response)
50
- end
51
-
52
59
  it "returns response as it is" do
53
- expect(client.get("/tickets/1/state")).to eql "open"
60
+ expect(subject).to eql "open"
54
61
  end
55
62
 
56
63
  end
57
64
 
58
65
  context "multiple root key-value pairs in response" do
59
66
 
67
+ let(:resource_path) { "/tickets/count" }
60
68
  let(:response) do
61
69
  {
62
70
  "728525" => 1,
@@ -65,18 +73,15 @@ describe GrooveHQ::Client::Connection do
65
73
  }.to_json
66
74
  end
67
75
 
68
- before(:each) do
69
- stub_request(:get, "https://api.groovehq.com/v1/tickets/count").to_return(body: response)
70
- end
71
-
72
76
  it "returns response as it is" do
73
- expect(client.get("/tickets/count").data.to_h.keys.count).to eql 3
77
+ expect(subject.data.to_h.keys.count).to eql 3
74
78
  end
75
79
 
76
80
  end
77
81
 
78
82
  context "array of hashes in response" do
79
83
 
84
+ let(:resource_path) { "/tickets" }
80
85
  let(:response) do
81
86
  {
82
87
  tickets: [
@@ -93,16 +98,12 @@ describe GrooveHQ::Client::Connection do
93
98
  }.to_json
94
99
  end
95
100
 
96
- before(:each) do
97
- stub_request(:get, "https://api.groovehq.com/v1/tickets").to_return(body: response)
98
- end
99
-
100
101
  it "builds array of resources from response" do
101
- expect(client.get("/tickets").data[:collection].count).to eql 3
102
+ expect(subject.data[:collection].count).to eql 3
102
103
  end
103
104
 
104
105
  it "returns relations for pagination" do
105
- expect(client.get("/tickets").rels[:next]).to be_instance_of(GrooveHQ::Relation)
106
+ expect(subject.rels[:next]).to be_instance_of(GrooveHQ::Relation)
106
107
  end
107
108
 
108
109
  end
@@ -7,7 +7,7 @@ describe GrooveHQ::Resource do
7
7
  context "#data" do
8
8
 
9
9
  it "returns empty data for invalid input" do
10
- resource = GrooveHQ::ResourceCollection.new(self, "")
10
+ resource = GrooveHQ::ResourceCollection.new(client, "")
11
11
  expect(resource.count).to eql(0)
12
12
  end
13
13
 
@@ -15,7 +15,7 @@ describe GrooveHQ::Resource do
15
15
  data = {
16
16
  tickets: [ { name: "When I am small" } ]
17
17
  }
18
- resource = GrooveHQ::ResourceCollection.new(self, data)
18
+ resource = GrooveHQ::ResourceCollection.new(client, data)
19
19
  expect(resource.first.name).to eql "When I am small"
20
20
  end
21
21
 
@@ -35,7 +35,7 @@ describe GrooveHQ::Resource do
35
35
  }
36
36
  }
37
37
  }
38
- resource = GrooveHQ::ResourceCollection.new(self, data)
38
+ resource = GrooveHQ::ResourceCollection.new(client, data)
39
39
  expect(resource.rels[:next]).to be_instance_of(GrooveHQ::Relation)
40
40
  end
41
41
 
@@ -7,7 +7,7 @@ describe GrooveHQ::Resource do
7
7
  context "#data" do
8
8
 
9
9
  it "returns empty data for invalid input" do
10
- resource = GrooveHQ::Resource.new(self, "")
10
+ resource = GrooveHQ::Resource.new(client, "")
11
11
  expect(resource.data.to_h).to eql({})
12
12
  end
13
13
 
@@ -15,7 +15,7 @@ describe GrooveHQ::Resource do
15
15
  data = {
16
16
  name: "When I am small"
17
17
  }
18
- resource = GrooveHQ::Resource.new(self, data)
18
+ resource = GrooveHQ::Resource.new(client, data)
19
19
  expect(resource.data[:name]).to eql "When I am small"
20
20
  end
21
21
 
@@ -23,7 +23,7 @@ describe GrooveHQ::Resource do
23
23
  data = {
24
24
  name: "When I am small"
25
25
  }
26
- resource = GrooveHQ::Resource.new(self, data)
26
+ resource = GrooveHQ::Resource.new(client, data)
27
27
  expect(resource.name).to eql "When I am small"
28
28
  end
29
29
  end
@@ -38,16 +38,18 @@ describe GrooveHQ::Resource do
38
38
  }
39
39
  }
40
40
  }
41
- resource = GrooveHQ::Resource.new(self, data)
41
+ resource = GrooveHQ::Resource.new(client, data)
42
42
  expect(resource.rels[:assignee]).to be_instance_of(GrooveHQ::Relation)
43
+ expect(resource.rels[:assignee].href).to eq("https://api.groovehq.com/v1/agents/matt@groovehq.com")
43
44
  end
44
45
 
45
46
  it "parses self relation correctly" do
46
47
  data = {
47
48
  href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
48
49
  }
49
- resource = GrooveHQ::Resource.new(self, data)
50
+ resource = GrooveHQ::Resource.new(client, data)
50
51
  expect(resource.rels[:self]).to be_instance_of(GrooveHQ::Relation)
52
+ expect(resource.rels[:self].href).to eq("https://api.groovehq.com/v1/agents/matt@groovehq.com")
51
53
  end
52
54
 
53
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groovehq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Shirinkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-12 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.8
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Client library for GrooveHQ API.
@@ -128,4 +128,3 @@ test_files:
128
128
  - spec/groovehq/resource_collection_spec.rb
129
129
  - spec/groovehq/resource_spec.rb
130
130
  - spec/spec_helper.rb
131
- has_rdoc: