ten_thousand_feet 0.0.2 → 0.0.11

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: 001042bedc132b62a277d47cfe33406c0dee57ee
4
- data.tar.gz: 0087ee0c7ff7f4227cf3a3e525da51c320076148
3
+ metadata.gz: 7c3589f4641fa90e473817a2deb78a8bf78780d8
4
+ data.tar.gz: d8abf62c7361715c08b9da991675ea955d9e6742
5
5
  SHA512:
6
- metadata.gz: f985b95d8cc93714fde312705fde1d3aaa807a9535535941ae8a9589e1ad62db130996e956ee5e182c575398f285e3fb67f80747e5b9c20260beab60a53632b7
7
- data.tar.gz: 328221c49b86ab803ea2a377c916bb94f6077f11ac4092646484dd8629272ec457f045f72d3a2669c9cc127fdd874d5eb1eb11c794acb6e72673595a4aaf2f34
6
+ metadata.gz: 2d4bf0a27af0ab3fbd4b70998675ef6878bd48d38dcb73e2be38904f262ff6fcb3f9c42d98eedcb976d23a48d32557a86e45b47d0f9f6d42a9d520c6b5d78512
7
+ data.tar.gz: e67a330998556910fc07401132b3c271a7ca963ceea5f767d43787fbf8a85bb27ce0c9301bf175e378ffae63968d5ff21bed3ba263c6d171d0040efd4e0007a4
data/.gitignore CHANGED
@@ -15,5 +15,3 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- auth.yml
19
- fixtures
data/README.md CHANGED
@@ -4,84 +4,15 @@ Ruby wrapper for the [10,000ft API (BETA)](http://10kft.github.io/api-documentat
4
4
 
5
5
  ## Installation
6
6
 
7
- gem 'ten_thousand_feet'
7
+ gem install 'ten_thousand_feet'
8
8
 
9
- Or
10
-
11
- gem install ten_thousand_feet
12
-
13
- ## Setup
9
+ ## Usage
14
10
 
15
11
  require 'ten_thousand_feet'
16
12
 
17
13
  # Initialize a new 10,000ft client
18
14
  client = TenThousandFeet.new(auth: YOUR_AUTH_TOKEN)
19
15
 
20
- # API Methods
21
- Note: 'options' will be different for each method. Check the official API documentation for a list of available options for each call.
22
-
23
- 'options' should be passed in as a hash:
24
-
25
- # user_id = 1969
26
- #
27
- # options = {
28
- # first_name: 'Austin',
29
- # last_name: 'Powers',
30
- # display_name: 'Austin Danger Powers'
31
- # }
32
- #
33
- # client.update_user(user_id, options)
34
-
35
- ## Users
36
-
37
- client.get_users(options)
38
- client.show_user(user_id, options)
39
- client.update_user(user_id, options)
40
- client.create_user(options)
41
-
42
- ## User Status
43
-
44
- client.get_user_statuses(user_id, options)
45
- client.create_user_status(user_id, options)
46
-
47
- ## Assignments
48
-
49
- client.get_assignments(user_id, options)
50
- client.show_assignment(assignment_id, user_id, options)
51
- client.create_assignment(project_id, user_id, options)
52
- client.delete_assignment(assignment_id, user_id, options)
53
-
54
- ## Projects
55
-
56
- client.get_projects(options)
57
- client.show_project(project_id, options)
58
- client.update_project(project_id, options)
59
- client.create_project(options)
60
- client.delete_project(project_id, options)
61
- client.get_project_time_entries(project_id, options)
62
- client.get_project_users(project_id, options)
63
-
64
- ## Phases
65
-
66
- client.get_phases(project_id, options)
67
- client.create_phases(project_id, options)
68
- client.update_phases(project_id, phase_id, options)
69
-
70
- ## Time Entries
71
-
72
- client.get_time_entries(user_id, options)
73
- client.show_time_entry(time_entry_id, user_id, options)
74
- client.update_time_entry(time_entry_id, user_id, options)
75
- client.create_time_entry(user_id, options)
76
- client.delete_time_entry(time_entry_id, user_id, project_id, options)
77
-
78
- ## To-Do
79
-
80
- * Budget Items
81
- * Budget Item Categories
82
- * Tags Per Project
83
- * Tags Per User
84
-
85
16
  ## Contributing
86
17
 
87
18
  1. Fork it
@@ -2,20 +2,22 @@ module TenThousandFeet
2
2
  module API
3
3
  module Users
4
4
 
5
- def get_users(options={})
6
- get("/users", options)
5
+ def get_users
6
+ get("/users", { auth: self.auth })
7
7
  end
8
8
 
9
- def show_user(id, options={})
10
- get("/users/#{id}", options)
9
+ def show_user(id)
10
+ get("/users/#{id}", { auth: self.auth })
11
11
  end
12
12
 
13
13
  def create_user(options={})
14
- post("/users", options)
14
+ default_options = { auth: self.auth }
15
+ post("/users/", default_options.merge(options))
15
16
  end
16
17
 
17
18
  def update_user(id, options={})
18
- put("/users/#{id}", options)
19
+ default_options = { auth: self.auth }
20
+ put("/users/#{id}", default_options.merge(options))
19
21
  end
20
22
 
21
23
  end
@@ -1,12 +1,5 @@
1
- require 'json'
2
- require 'rest-client'
3
-
4
1
  require 'ten_thousand_feet/api/users'
5
- require 'ten_thousand_feet/api/phases'
6
- require 'ten_thousand_feet/api/projects'
7
- require 'ten_thousand_feet/api/user_status'
8
- require 'ten_thousand_feet/api/assignments'
9
- require 'ten_thousand_feet/api/time_entries'
2
+ require 'json'
10
3
 
11
4
  module TenThousandFeet
12
5
  class Client
@@ -14,11 +7,6 @@ module TenThousandFeet
14
7
  attr_reader :auth
15
8
 
16
9
  include API::Users
17
- include API::Phases
18
- include API::Projects
19
- include API::UserStatus
20
- include API::Assignments
21
- include API::TimeEntries
22
10
 
23
11
  def initialize(options={})
24
12
  @auth = options[:auth]
@@ -28,34 +16,20 @@ module TenThousandFeet
28
16
  "https://vnext-api.10000ft.com/api/v1"
29
17
  end
30
18
 
31
- def default_options
32
- { auth: @auth }
33
- end
34
-
35
19
  def get(path, options = {})
36
- params = default_options.merge(options)
37
- response = RestClient.get(api_url + path, params)
38
-
39
- JSON.parse(response)
20
+ JSON.parse( RestClient.get(api_url + path, options) )
40
21
  end
41
22
 
42
23
  def post(path, options = {})
43
- params = default_options.merge(options)
44
- response = RestClient.post(api_url + path, params)
45
-
46
- JSON.parse(response)
24
+ JSON.parse( RestClient.post(api_url + path, options) )
47
25
  end
48
26
 
49
27
  def put(path, options = {})
50
- params = default_options.merge(options)
51
- response = RestClient.put(api_url + path, params)
52
-
53
- JSON.parse(response)
28
+ JSON.parse( RestClient.put(api_url + path, options) )
54
29
  end
55
30
 
56
31
  def delete(path, options = {})
57
- params = default_options.merge(options)
58
- RestClient.delete(api_url + path, params)
32
+ JSON.parse( RestClient.delete(api_url + path, options) )
59
33
  end
60
34
  end
61
35
  end
@@ -1,3 +1,3 @@
1
1
  module TenThousandFeet
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.11"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,15 +1,4 @@
1
1
  require 'pry'
2
2
  require 'rest-client'
3
3
  require 'ten_thousand_feet/client'
4
- require 'ten_thousand_feet'
5
- require 'yaml'
6
- require 'vcr'
7
- require 'webmock'
8
-
9
- $AUTH = YAML.load_file('auth.yml')
10
-
11
- VCR.configure do |c|
12
- c.cassette_library_dir = 'fixtures/vcr_cassettes'
13
- c.hook_into :webmock
14
- c.allow_http_connections_when_no_cassette = true
15
- end
4
+ require 'ten_thousand_feet'
@@ -4,31 +4,24 @@ module TenThousandFeet
4
4
  module API
5
5
  describe Users do
6
6
 
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:users) {
9
- VCR.use_cassette('users') do
10
- client.get_users
11
- end
12
- }
7
+ let!(:auth) { "Smg3M3czMiszU0djK0t3MytLV09OREFlWEdqa0JvRHFkRXdqcE9ueXFKRlVaK29heWpOYTY2RTM4eWJaCjdVc0pWbUhOUUc5ZEtMNkMyZURTMWJVeFNCdWpTMkhmUlpFTmtIMnBpd1Y0aSs5bk44RkZvMHZyMmg4MgpCaTdmdmhRcAo=" }
8
+ let!(:client) { TenThousandFeet.new({ auth: auth }) }
9
+ let!(:users) { client.get_users }
13
10
  let!(:user) { users['data'][0] }
14
11
  let!(:id) { user['id'] }
15
12
 
16
13
  describe '#get_users' do
17
14
  it 'retrieves a list of users' do
18
- VCR.use_cassette('get_users') do
19
- name = users['data'][0]['first_name']
20
- expect(name).to_not be_nil
21
- end
15
+ name = users['data'][0]['first_name']
16
+ expect(name).to_not be_nil
22
17
  end
23
18
  end
24
19
 
25
20
  describe '#show_users' do
26
21
  it 'retrieves details of a specific user' do
27
- VCR.use_cassette('show_users') do
28
- id = users['data'][0]['id']
29
- user = client.show_user(id)
30
- expect(user['id']).to eq id
31
- end
22
+ id = users['data'][0]['id']
23
+ user = client.show_user(id)
24
+ expect(user['id']).to eq id
32
25
  end
33
26
  end
34
27
 
@@ -42,25 +35,34 @@ module TenThousandFeet
42
35
  end
43
36
 
44
37
  it 'creates a new user' do
45
- VCR.use_cassette('create_user') do
46
- user_count_before = users['data'].count
47
- response = client.create_user(user_attributes)
38
+ user_count_before = users['data'].count
39
+ response = client.create_user(user_attributes)
48
40
 
49
- new_users = client.get_users
50
- user_count_after = new_users['data'].count
41
+ new_users = client.get_users
42
+ user_count_after = new_users['data'].count
51
43
 
52
- expect(user_count_after).to eq (user_count_before + 1)
53
- end
44
+ expect(user_count_after).to eq (user_count_before + 1)
54
45
  end
55
46
  end
56
47
 
57
48
  describe '#update_user' do
58
49
  context 'given a valid user' do
59
- it 'updates an attribute for the user' do
60
- name = "AustinPowers#{rand(0..100)}"
61
- response = client.update_user(id, { first_name: name })
62
- expect(response['first_name']).to eq name
50
+
51
+ context 'given valid params' do
52
+ it 'updates an attribute for the user' do
53
+ name = "AustinPowers#{rand(0..100)}"
54
+ response = client.update_user(id, { first_name: name })
55
+ expect(response['first_name']).to eq name
56
+ end
57
+ end
58
+
59
+ context 'given no params' do
60
+ it 'returns the user unchanged' do
61
+ response = client.update_user(id, {})
62
+ expect(response['first_name']).to eq user['first_name']
63
+ end
63
64
  end
65
+
64
66
  end
65
67
  end
66
68
  end
@@ -2,9 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  module TenThousandFeet
4
4
  describe Client do
5
+ let!(:auth) {
6
+ "Smg3M3czMiszU0djK0t3MytLV09OREFlWEdqa0JvRHFkRXdqcE9ueXFKRlVaK29heWpOYTY2RTM4eWJaCjdVc0pWbUhOUUc5ZEtMNkMyZURTMWJVeFNCdWpTMkhmUlpFTmtIMnBpd1Y0aSs5bk44RkZvMHZyMmg4MgpCaTdmdmhRcAo="
7
+ }
8
+
5
9
  it 'Sets the value of the auth token on the client' do
6
- client = TenThousandFeet.new({ auth: $AUTH })
7
- expect(client.auth).to eq $AUTH
10
+ client = TenThousandFeet.new({ auth: auth })
11
+ expect(client.auth).to eq auth
8
12
  end
9
13
  end
10
14
  end
@@ -26,5 +26,4 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "multi_json"
27
27
  spec.add_development_dependency "vcr"
28
28
  spec.add_development_dependency "pry"
29
- spec.add_development_dependency "webmock", "1.8.0"
30
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ten_thousand_feet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Suss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: webmock
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '='
130
- - !ruby/object:Gem::Version
131
- version: 1.8.0
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '='
137
- - !ruby/object:Gem::Version
138
- version: 1.8.0
139
125
  description: The 10,000ft Ruby API Client
140
126
  email:
141
127
  - susskyle@gmail.com
@@ -150,20 +136,10 @@ files:
150
136
  - README.md
151
137
  - Rakefile
152
138
  - lib/ten_thousand_feet.rb
153
- - lib/ten_thousand_feet/api/assignments.rb
154
- - lib/ten_thousand_feet/api/phases.rb
155
- - lib/ten_thousand_feet/api/projects.rb
156
- - lib/ten_thousand_feet/api/time_entries.rb
157
- - lib/ten_thousand_feet/api/user_status.rb
158
139
  - lib/ten_thousand_feet/api/users.rb
159
140
  - lib/ten_thousand_feet/client.rb
160
141
  - lib/ten_thousand_feet/version.rb
161
142
  - spec/spec_helper.rb
162
- - spec/ten_thousand_feet/api/assignment_spec.rb
163
- - spec/ten_thousand_feet/api/phases_spec.rb
164
- - spec/ten_thousand_feet/api/projects_spec.rb
165
- - spec/ten_thousand_feet/api/time_entries_spec.rb
166
- - spec/ten_thousand_feet/api/user_status_spec.rb
167
143
  - spec/ten_thousand_feet/api/users_spec.rb
168
144
  - spec/ten_thousand_feet/client_spec.rb
169
145
  - ten_thousand_feet.gemspec
@@ -193,10 +169,5 @@ specification_version: 4
193
169
  summary: Provides Ruby wrappers for the 10,000ft API.
194
170
  test_files:
195
171
  - spec/spec_helper.rb
196
- - spec/ten_thousand_feet/api/assignment_spec.rb
197
- - spec/ten_thousand_feet/api/phases_spec.rb
198
- - spec/ten_thousand_feet/api/projects_spec.rb
199
- - spec/ten_thousand_feet/api/time_entries_spec.rb
200
- - spec/ten_thousand_feet/api/user_status_spec.rb
201
172
  - spec/ten_thousand_feet/api/users_spec.rb
202
173
  - spec/ten_thousand_feet/client_spec.rb
@@ -1,23 +0,0 @@
1
- module TenThousandFeet
2
- module API
3
- module Assignments
4
-
5
- def get_assignments(user_id, options={})
6
- get("/users/#{user_id}/assignments", options)
7
- end
8
-
9
- def show_assignment(id, user_id, options={})
10
- get("/users/#{user_id}/assignments/#{id}", options)
11
- end
12
-
13
- def create_assignment(project_id, user_id, options={})
14
- post("/users/#{user_id}/assignments", options)
15
- end
16
-
17
- def delete_assignment(id, user_id, options={})
18
- delete("/users/#{user_id}/assignments/#{id}", options)
19
- end
20
-
21
- end
22
- end
23
- end
@@ -1,19 +0,0 @@
1
- module TenThousandFeet
2
- module API
3
- module Phases
4
-
5
- def get_phases(project_id, options={})
6
- get("/projects/#{project_id}/phases", options)
7
- end
8
-
9
- def create_phase(project_id, options={})
10
- post("/projects/#{project_id}/phases", options)
11
- end
12
-
13
- def update_phase(project_id, phase_id, options={})
14
- put("/projects/#{project_id}/phases/#{phase_id}", options)
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,35 +0,0 @@
1
- module TenThousandFeet
2
- module API
3
- module Projects
4
-
5
- def get_projects(options={})
6
- get("/projects", options)
7
- end
8
-
9
- def show_project(id, options={})
10
- get("/projects/#{id}", options)
11
- end
12
-
13
- def create_project(options={})
14
- post("/projects", options)
15
- end
16
-
17
- def update_project(id, options={})
18
- put("/projects/#{id}", options)
19
- end
20
-
21
- def delete_project(id, options={})
22
- delete("/projects/#{id}", options)
23
- end
24
-
25
- def get_project_time_entries(id, options={})
26
- get("/projects/#{id}/time_entries", options)
27
- end
28
-
29
- def get_project_users(id, options={})
30
- get("/projects/#{id}/users", options)
31
- end
32
-
33
- end
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- module TenThousandFeet
2
- module API
3
- module TimeEntries
4
-
5
- def get_time_entries(user_id, options={})
6
- get("/users/#{user_id}/time_entries", options)
7
- end
8
-
9
- def show_time_entry(id, user_id, options={})
10
- get("/users/#{user_id}/time_entries/#{id}", options)
11
- end
12
-
13
- def create_time_entry(user_id, options={})
14
- post("/users/#{user_id}/time_entries", options)
15
- end
16
-
17
- def update_time_entry(id, user_id, options={})
18
- put("/users/#{user_id}/time_entries/#{id}", options)
19
- end
20
-
21
- def delete_time_entry(id, user_id, project_id, options={})
22
- delete("projects/#{project_id}/users/#{user_id}/time_entries/#{id}", options)
23
- end
24
-
25
- end
26
- end
27
- end
@@ -1,15 +0,0 @@
1
- module TenThousandFeet
2
- module API
3
- module UserStatus
4
-
5
- def get_user_statuses(user_id, options={})
6
- get("/users/#{user_id}/statuses", options)
7
- end
8
-
9
- def create_user_status(user_id, options={})
10
- post("/users/#{user_id}/statuses", options)
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TenThousandFeet
4
- module API
5
- describe Assignments do
6
-
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:user) { client.get_users['data'][0] }
9
- let!(:projects) {
10
- VCR.use_cassette('projects') do
11
- client.get_projects
12
- end
13
- }
14
- let!(:project) { projects['data'][0] }
15
- let!(:assignments) {
16
- VCR.use_cassette('assignments') do
17
- client.get_assignments(user['id'])
18
- end
19
- }
20
- let!(:assignment) { assignments['data'][0] }
21
- let!(:id) { assignment['id'] }
22
-
23
- describe '#get_assignments' do
24
- it 'retrieves a list of assignments for a user' do
25
- VCR.use_cassette('get_assignments') do
26
- expect(assignments['data']).to_not be_nil
27
- end
28
- end
29
- end
30
-
31
- describe '#show_assignments' do
32
- it 'retrieves details of a assignment' do
33
- VCR.use_cassette('show_assignments') do
34
- id = assignments['data'][0]['id']
35
- assignment = client.show_assignment(id, user['id'])
36
- expect(assignment['id']).to eq id
37
- end
38
- end
39
- end
40
-
41
- describe '#create_assignment' do
42
- def assignment_attributes
43
- {
44
- project_id: project['id'],
45
- starts_at: '2013-10-10',
46
- ends_at: '2013-10-10'
47
- }
48
- end
49
-
50
- it 'creates a new assignment' do
51
- VCR.use_cassette('create_assignment') do
52
- assignment_count_before = assignments['data'].count
53
- response = client.create_assignment(project['id'], user['id'], assignment_attributes)
54
-
55
- new_assignments = client.get_assignments(user['id'])
56
- assignment_count_after = new_assignments['data'].count
57
-
58
- expect(assignment_count_after).to eq (assignment_count_before + 1)
59
- end
60
- end
61
- end
62
-
63
- describe '#delete_assignment' do
64
- context 'given a valid time entry' do
65
- it 'deletes the assignment' do
66
- VCR.use_cassette('delete_assignment') do
67
- response = client.delete_assignment(id, user['id'])
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TenThousandFeet
4
- module API
5
- describe Phases do
6
-
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:projects) {
9
- VCR.use_cassette('projects') do
10
- client.get_projects
11
- end
12
- }
13
- let!(:project) { projects['data'][0] }
14
- let!(:id) { project['id'] }
15
-
16
- describe '#get_phases' do
17
- it 'retrieves a list of phases for a given project' do
18
- VCR.use_cassette('get_phases') do
19
- phases = client.get_phases(id)
20
- expect(phases['data']).to_not be_nil
21
- end
22
- end
23
- end
24
-
25
- describe '#create_phase' do
26
- def phase_attributes
27
- {
28
- phase_name: 'Groovy baby',
29
- starts_at: '2014-09-15',
30
- ends_at: '2014-10-15'
31
- }
32
- end
33
-
34
- it 'creates a new phase for a given project' do
35
- VCR.use_cassette('create_phase') do
36
- response = client.create_phase(id, phase_attributes)
37
- phase = client.get_phases(id)
38
- expect(phase['data'][0]['phase_name']).to eq phase_attributes[:phase_name]
39
- end
40
- end
41
- end
42
-
43
- describe '#update_phase' do
44
- def phase_attributes
45
- {
46
- phase_name: 'Groovy baby',
47
- starts_at: '2014-09-15',
48
- ends_at: '2014-10-15'
49
- }
50
- end
51
-
52
- it 'updates a given phases attributes' do
53
- phase = client.create_phase(id, phase_attributes)
54
- phase_name = "#{rand(0..100)} So Groovy"
55
- response = client.update_phase(id, phase['id'], { phase_name: phase_name })
56
- expect(response['phase_name']).to eq phase_name
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,103 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TenThousandFeet
4
- module API
5
- describe Projects do
6
-
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:projects) {
9
- VCR.use_cassette('projects') do
10
- client.get_projects
11
- end
12
- }
13
- let!(:project) { projects['data'][0] }
14
- let!(:id) { project['id'] }
15
-
16
- describe '#get_projects' do
17
- it 'retrieves a list of projects' do
18
- VCR.use_cassette('get_projects') do
19
- name = projects['data'][0]['name']
20
- expect(name).to_not be_nil
21
- end
22
- end
23
- end
24
-
25
- describe '#show_projects' do
26
- it 'retrieves details of a specific project' do
27
- VCR.use_cassette('show_projects') do
28
- id = projects['data'][0]['id']
29
- project = client.show_project(id)
30
- expect(project['id']).to eq id
31
- end
32
- end
33
- end
34
-
35
- describe '#create_projects' do
36
- def project_attributes
37
- {
38
- name: '1 Billion Dollars',
39
- client: 'Dr. Evil'
40
- }
41
- end
42
-
43
- it 'creates a new project' do
44
- VCR.use_cassette('create_project') do
45
- project_count_before = projects['data'].count
46
- response = client.create_project(project_attributes)
47
-
48
- new_projects = client.get_projects
49
- project_count_after = new_projects['data'].count
50
-
51
- expect(project_count_after).to eq (project_count_before + 1)
52
- end
53
- end
54
- end
55
-
56
- describe '#update_project' do
57
- context 'given a valid project' do
58
- it 'updates an attribute for the project' do
59
- name = "#{rand(0..100)} Billion Dollars"
60
- response = client.update_project(id, { name: name })
61
- expect(response['name']).to eq name
62
- end
63
- end
64
- end
65
-
66
- describe '#delete_project' do
67
- context 'given a valid project' do
68
- def project_attributes
69
- {
70
- name: '1 Billion Dollars',
71
- client: 'Dr. Evil'
72
- }
73
- end
74
-
75
- it 'deletes a project' do
76
- VCR.use_cassette('delete_project') do
77
- new_project = client.create_project(project_attributes)
78
- response = client.delete_project(new_project['id'])
79
- end
80
- end
81
- end
82
- end
83
-
84
- describe '#get_project_time_entries' do
85
- it 'retrieves a list of time entries for a given project' do
86
- VCR.use_cassette('get_project_time_entries') do
87
- response = client.get_project_time_entries(id)
88
- expect(response['data']).to_not be_nil
89
- end
90
- end
91
- end
92
-
93
- describe '#get_project_time_users' do
94
- it 'retrieves a list of users for a given project' do
95
- VCR.use_cassette('get_project_time_users') do
96
- response = client.get_project_users(id)
97
- expect(response['data']).to_not be_nil
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
@@ -1,76 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TenThousandFeet
4
- module API
5
- describe TimeEntries do
6
-
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:user) { client.get_users['data'][0] }
9
- let!(:projects) {
10
- VCR.use_cassette('projects') do
11
- client.get_projects
12
- end
13
- }
14
- let!(:project) { projects['data'][0] }
15
- let!(:time_entries) {
16
- VCR.use_cassette('time_entries') do
17
- client.get_time_entries(user['id'])
18
- end
19
- }
20
- let!(:time_entry) { time_entries['data'][0] }
21
- let!(:id) { time_entry['id'] }
22
-
23
- describe '#get_time_entries' do
24
- it 'retrieves a list of time entries for a user' do
25
- VCR.use_cassette('get_time_entries') do
26
- hours = time_entries['data'][0]['hours']
27
- expect(hours).to_not be_nil
28
- end
29
- end
30
- end
31
-
32
- describe '#show_time_entries' do
33
- it 'retrieves details of a specific time entry' do
34
- VCR.use_cassette('show_time_entries') do
35
- id = time_entries['data'][0]['id']
36
- time_entry = client.show_time_entry(id, user['id'])
37
- expect(time_entry['id']).to eq id
38
- end
39
- end
40
- end
41
-
42
- describe '#create_time_entry' do
43
- #Required parameters: :date, :hours, :leave_type_id/:project_id/:assignable_id
44
- def time_entry_attributes
45
- {
46
- hours: 10,
47
- date: '2013-10-10',
48
- project_id: project['id']
49
- }
50
- end
51
-
52
- it 'creates a new project' do
53
- VCR.use_cassette('create_time_entry') do
54
- time_entry_count_before = time_entries['data'].count
55
- response = client.create_time_entry(user['id'], time_entry_attributes)
56
-
57
- new_time_entries = client.get_time_entries(user['id'])
58
- time_entry_count_after = new_time_entries['data'].count
59
-
60
- expect(time_entry_count_after).to eq (time_entry_count_before + 1)
61
- end
62
- end
63
- end
64
-
65
- describe '#update_time_entry' do
66
- context 'given a valid time entry' do
67
- it 'updates an attribute for the entry' do
68
- hours = rand(0..100)
69
- response = client.update_time_entry(id, user['id'], { hours: hours })
70
- expect(response['hours']).to eq hours
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module TenThousandFeet
4
- module API
5
- describe UserStatus do
6
-
7
- let!(:client) { TenThousandFeet.new({ auth: $AUTH }) }
8
- let!(:users) {
9
- VCR.use_cassette('users') do
10
- client.get_users
11
- end
12
- }
13
- let!(:user) { users['data'][0] }
14
- let!(:id) { user['id'] }
15
-
16
- describe '#get_user_statuses' do
17
- it 'retrieves a list of statuses for a given user' do
18
- VCR.use_cassette('get_user_statuses') do
19
- status = client.get_user_statuses(id)
20
- expect(status['data']).to_not be_nil
21
- end
22
- end
23
- end
24
-
25
- describe '#create_user_status' do
26
- def user_status_attributes
27
- {
28
- status: 'ITO'
29
- }
30
- end
31
-
32
- it 'creates a new status for a given user' do
33
- VCR.use_cassette('create_user_status') do
34
- response = client.create_user_status(id, user_status_attributes)
35
- status = client.get_user_statuses(id)
36
- expect(status['data'][0]['status']).to eq 'ITO'
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end