freckle-api 0.1.4 → 0.1.5

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: f3e2563370fad1e5235ee5a79352315f23b6cc7f
4
- data.tar.gz: a474067bd722bdf90e12c2de78dd4de5ae5b80d1
3
+ metadata.gz: 722cc9425f3940d4a4f45c47ca976b16ca8429b5
4
+ data.tar.gz: 4b2de4c97f60b9b381a3b259dc905456cfe3ec96
5
5
  SHA512:
6
- metadata.gz: 97831ce5d8b1bb2e3b63d57c19ef313d74a42435876b79451c213cb48c930c02ae2d9f7e962eedad5d5f4c4ea89a318dd1478ed8523dea691f2644c778c1df33
7
- data.tar.gz: 063d36bcf21c2302705c00fb4e8e011026a913fe5312dd9b87d27cba745614fa9939b9503f119191340a49447ebc2669c092272f057c265868dee4faa49e7059
6
+ metadata.gz: 39335e3e8d2b0610c573a4019d15d88ab5a920e643a3121baa4795a967db34d48e51e4a2e3c7124c18c6773cea1e1892f8eb729c9af50f36dd846d26501fdfe2
7
+ data.tar.gz: 585fbddfbd618017c53c42d0540fa9bcfb5f07b4db486b6849e593e9df4f338f86557512b1658c2811495fc56cb7691a28be041db07c32add48cd02100de1a38
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # freckle-api
2
+
3
+ **Note** Back at work and terribly busy after the Christmas holidays, so I
4
+ won't be working on this for a week or two, but it's certainly not abandoned!
5
+
2
6
  Freckle API client for v2.
3
7
 
4
8
  [![Gem Version](https://badge.fury.io/rb/freckle-api.svg)](https://badge.fury.io/rb/freckle-api)
@@ -42,8 +42,8 @@ class FreckleApi
42
42
  request(:get, self.class.uri('timers'), coerce_to: Timer)
43
43
  end
44
44
 
45
- def request(method, uri, parse: true, coerce_to: Hash, params: {})
46
- request = build_request(method, uri, params)
45
+ def request(method, uri, parse: true, coerce_to: Hash, params: {}, body: {})
46
+ request = build_request(method, uri, params: params, body: body)
47
47
  response = send_request(request, uri)
48
48
 
49
49
  parse ? JSON.parse(response.body, object_class: coerce_to) : response
@@ -51,9 +51,10 @@ class FreckleApi
51
51
 
52
52
  private
53
53
 
54
- def build_request(method, uri, params: {})
54
+ def build_request(method, uri, params: {}, body: {})
55
55
  http_class(method).new(uri.path, headers).tap do |request|
56
56
  request.set_form_data(params)
57
+ request.body = body.to_json if request.request_body_permitted?
57
58
  end
58
59
  end
59
60
 
@@ -14,8 +14,14 @@ class FreckleApi
14
14
  update api.request(:put, timer_uri(:pause))
15
15
  end
16
16
 
17
- def log!(api, entry_date: nil, minutes: nil, description: nil)
18
- response = api.request(:put, timer_uri(:log), parse: false)
17
+ def log!(api, entry_date: nil, minutes: nil, description: '')
18
+ puts description
19
+ response = api.request(:put,
20
+ timer_uri(:log),
21
+ parse: false,
22
+ body: {
23
+ description: description
24
+ })
19
25
 
20
26
  response.code.to_i == 204
21
27
  end
@@ -1,3 +1,3 @@
1
1
  class FreckleApi
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -0,0 +1,60 @@
1
+ RSpec.describe FreckleApi::Timer do
2
+ include_context 'api'
3
+ let(:timer) { api.timer(existing_project_id) }
4
+
5
+ describe '#pause!' do
6
+ context 'when the timer is running' do
7
+ before do
8
+ stub_get_timer(existing_project_id)
9
+ stub_put_timer_event(existing_project_id, :pause)
10
+
11
+ timer.pause!(api)
12
+ end
13
+
14
+ it 'pauses the timer' do
15
+ expect(timer.state).to eq :paused
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '#start!' do
21
+ context 'when the timer is paused' do
22
+ before do
23
+ stub_get_timer(existing_project_id, file: 'pause')
24
+ stub_put_timer_event(existing_project_id, :start)
25
+
26
+ timer.start!(api)
27
+ end
28
+
29
+ it 'starts the timer' do
30
+ expect(timer.state).to eq :running
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '#log!' do
36
+ context 'when the timer is running' do
37
+ before do
38
+ stub_get_timer(existing_project_id)
39
+ stub_put_timer_log(existing_project_id)
40
+ end
41
+
42
+ let(:result) { timer.log!(api) }
43
+
44
+ it 'logs the timer, returning true' do
45
+ expect(result).to eq true
46
+ end
47
+
48
+ it 'no longer exists' do
49
+ result
50
+
51
+ stub_api(:get, "projects/#{existing_project_id}/timer", status: 404)
52
+
53
+ expect(timer.reload!(api)).to be_nil
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#discard!' do
59
+ end
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freckle-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Schembri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -112,6 +112,7 @@ files:
112
112
  - lib/freckle_api/timer.rb
113
113
  - lib/freckle_api/user.rb
114
114
  - lib/freckle_api/version.rb
115
+ - spec/freckle_api/project_spec.rb
115
116
  - spec/freckle_api/timer_spec.rb
116
117
  - spec/freckle_api_spec.rb
117
118
  - spec/spec_helper.rb
@@ -142,6 +143,7 @@ signing_key:
142
143
  specification_version: 4
143
144
  summary: Client for Freckle's API V2.
144
145
  test_files:
146
+ - spec/freckle_api/project_spec.rb
145
147
  - spec/freckle_api/timer_spec.rb
146
148
  - spec/freckle_api_spec.rb
147
149
  - spec/spec_helper.rb