taskrabbit 0.0.7 → 0.0.8

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.
Files changed (48) hide show
  1. data/.env.example +15 -0
  2. data/.gitignore +1 -0
  3. data/.rvmrc +1 -1
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +2 -0
  6. data/lib/taskrabbit.rb +1 -0
  7. data/lib/taskrabbit/api.rb +1 -0
  8. data/lib/taskrabbit/offer.rb +15 -0
  9. data/lib/taskrabbit/smash.rb +17 -2
  10. data/lib/taskrabbit/task.rb +11 -1
  11. data/lib/taskrabbit/version.rb +1 -1
  12. data/spec/spec_helper.rb +8 -4
  13. data/spec/support/cassettes/account/no_user.yml +2 -2
  14. data/spec/support/cassettes/account/properties.yml +46 -27
  15. data/spec/support/cassettes/account/tasks.yml +10 -10
  16. data/spec/support/cassettes/account/with_user.yml +5 -5
  17. data/spec/support/cassettes/cities/all.yml +2 -2
  18. data/spec/support/cassettes/cities/find.yml +2 -2
  19. data/spec/support/cassettes/cities/properties.yml +2 -2
  20. data/spec/support/cassettes/errors/404.yml +28 -356
  21. data/spec/support/cassettes/locations/properties.yml +8 -8
  22. data/spec/support/cassettes/tasks/all.yml +2 -2
  23. data/spec/support/cassettes/tasks/create/default.yml +3 -3
  24. data/spec/support/cassettes/tasks/create/using_account.yml +3 -3
  25. data/spec/support/cassettes/tasks/create/with_invalid_params.yml +3 -3
  26. data/spec/support/cassettes/tasks/create/with_location.yml +3 -3
  27. data/spec/support/cassettes/tasks/create/with_times.yml +45 -0
  28. data/spec/support/cassettes/tasks/create/without_credit_card.yml +2 -2
  29. data/spec/support/cassettes/tasks/create/without_user.yml +2 -2
  30. data/spec/support/cassettes/tasks/delete.yml +6 -6
  31. data/spec/support/cassettes/tasks/find.yml +41 -26
  32. data/spec/support/cassettes/tasks/properties.yml +41 -26
  33. data/spec/support/cassettes/tasks/save.yml +6 -6
  34. data/spec/support/cassettes/tasks/update.yml +6 -6
  35. data/spec/support/cassettes/tasks/with_offers_properties.yml +45 -0
  36. data/spec/support/cassettes/tasks/without_client.yml +27 -23
  37. data/spec/support/cassettes/users/find.yml +61 -23
  38. data/spec/support/cassettes/users/properties.yml +35 -27
  39. data/spec/support/cassettes/users/tasks/all.yml +42 -27
  40. data/spec/taskrabbit/account_spec.rb +10 -10
  41. data/spec/taskrabbit/api_spec.rb +1 -1
  42. data/spec/taskrabbit/city_spec.rb +3 -3
  43. data/spec/taskrabbit/location_spec.rb +1 -1
  44. data/spec/taskrabbit/offer_spec.rb +23 -0
  45. data/spec/taskrabbit/smash_spec.rb +19 -0
  46. data/spec/taskrabbit/task_spec.rb +36 -22
  47. data/spec/taskrabbit/user_spec.rb +10 -10
  48. metadata +11 -3
@@ -44,6 +44,25 @@ describe Taskrabbit::Smash do
44
44
  subject.redirect?.should == true
45
45
  end
46
46
  end
47
+
48
+ describe "#filtered_options" do
49
+ it "returns a hash" do
50
+ Taskrabbit::Smash::filtered_options({}).should == {}
51
+ end
52
+
53
+ it "convert ints" do
54
+ Taskrabbit::Smash::filtered_options(
55
+ {:val => 'a', :time => Time.parse('2011-10-12')}
56
+ ).should == {:val => 'a', :time => 1318402800}
57
+ end
58
+
59
+ it "works for nested values" do
60
+ Taskrabbit::Smash::filtered_options(
61
+ {:a => {:val => 'a', :time => Time.parse('2011-10-12')}, :b => 'c'}
62
+ ).should == {:a => {:val => 'a', :time => 1318402800}, :b => 'c'}
63
+
64
+ end
65
+ end
47
66
 
48
67
  describe "#valid?" do
49
68
  it "should return true" do
@@ -6,29 +6,29 @@ describe Taskrabbit::Task do
6
6
 
7
7
  before :all do
8
8
  tr = Taskrabbit::Api.new
9
- VCR.use_cassette('tasks/properties', :record => :new_episodes) do
10
- @tr_task = tr.tasks.find(22545)
9
+ VCR.use_cassette('tasks/properties', :record => :none) do
10
+ @tr_task = tr.tasks.find(ENV['TASK_ID'])
11
11
  @tr_task.fetch
12
12
  end
13
13
  end
14
14
 
15
15
  subject { @tr_task }
16
16
 
17
- its(:id) { should == 22545 }
18
- its(:name) { should == "2 Hours of House Cleaning + 1 Hour of House Chores" }
17
+ its(:id) { should == ENV['TASK_ID'].to_i }
18
+ its(:name) { should == "House Cleaning" }
19
19
  its(:user) { should be_instance_of(Taskrabbit::User) }
20
- its(:runner) { should be_instance_of(Taskrabbit::User) }
20
+ its(:runner) { should be_nil }
21
21
  its(:runners) { should be_a(Taskrabbit::Collection) }
22
22
  its(:cost_in_cents) { should == 0 }
23
- its(:description) { should == '' }
23
+ its(:description) { should == 'I need to clean my house' }
24
24
  its(:private_description) { should == '' }
25
25
  its(:named_price) { should == nil }
26
26
  its(:charge_price) { should == nil }
27
27
  its(:cost_in_cents) { should == 0 }
28
28
  its(:private_runner) { should == false }
29
29
  its(:virtual) { should == false }
30
- its(:state) { should == 'closed' }
31
- its(:state_label) { should == 'closed' }
30
+ its(:state) { should == 'opened' }
31
+ its(:state_label) { should == 'posted' }
32
32
  its(:location_visits) { should be_nil }
33
33
  its(:city) { should be_instance_of(Taskrabbit::City) }
34
34
  its(:assign_by_time) { should be_instance_of(Time) }
@@ -55,7 +55,7 @@ describe Taskrabbit::Task do
55
55
  describe "#tasks" do
56
56
  it "should fetch tasks only once" do
57
57
  tr = Taskrabbit::Api.new
58
- VCR.use_cassette('tasks/all', :record => :new_episodes) do
58
+ VCR.use_cassette('tasks/all', :record => :none) do
59
59
  tr_tasks = nil
60
60
  expect { tr_tasks = tr.tasks }.to_not raise_error
61
61
  tr_tasks.first.should be_instance_of(Taskrabbit::Task)
@@ -66,7 +66,7 @@ describe Taskrabbit::Task do
66
66
 
67
67
  it "should refetch tasks if passed :reload => true" do
68
68
  tr = Taskrabbit::Api.new
69
- VCR.use_cassette('tasks/all', :record => :new_episodes) do
69
+ VCR.use_cassette('tasks/all', :record => :none) do
70
70
  tr_tasks = nil
71
71
  expect { tr_tasks = tr.tasks }.to_not raise_error
72
72
  tr_tasks.first.should be_instance_of(Taskrabbit::Task)
@@ -96,10 +96,10 @@ describe Taskrabbit::Task do
96
96
 
97
97
  it "should fetch tasks" do
98
98
  tr = Taskrabbit::Api.new
99
- VCR.use_cassette('tasks/find', :record => :new_episodes) do
99
+ VCR.use_cassette('tasks/find', :record => :none) do
100
100
  tr_task = nil
101
101
  expect {
102
- tr_task = tr.tasks.find(22545)
102
+ tr_task = tr.tasks.find(ENV['TASK_ID'])
103
103
  tr_task.name
104
104
  }.to_not raise_error
105
105
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -111,7 +111,7 @@ describe Taskrabbit::Task do
111
111
  describe "#delete!" do
112
112
  it "should request DELETE /tasks/#id" do
113
113
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
114
- VCR.use_cassette('tasks/delete', :record => :new_episodes) do
114
+ VCR.use_cassette('tasks/delete', :record => :none) do
115
115
  tr_task = nil
116
116
  tr_task = tr.tasks.create(valid_params)
117
117
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -134,7 +134,7 @@ describe Taskrabbit::Task do
134
134
 
135
135
  it "should create a new task if new" do
136
136
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
137
- VCR.use_cassette('tasks/save', :record => :new_episodes) do
137
+ VCR.use_cassette('tasks/save', :record => :none) do
138
138
  tr_task = nil
139
139
  tr_task = tr.tasks.new(valid_params)
140
140
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -147,7 +147,7 @@ describe Taskrabbit::Task do
147
147
 
148
148
  it "should update the task if existing" do
149
149
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
150
- VCR.use_cassette('tasks/update', :record => :new_episodes) do
150
+ VCR.use_cassette('tasks/update', :record => :none) do
151
151
  tr_task = tr.tasks.find(tr.tasks.create(valid_params).id)
152
152
  tr_task.name = "New Name"
153
153
  tr_task.save.should == true
@@ -160,7 +160,7 @@ describe Taskrabbit::Task do
160
160
  context "with valid params" do
161
161
  it "should return an error if the user is not logged in" do
162
162
  tr = Taskrabbit::Api.new
163
- VCR.use_cassette('tasks/create/without_user', :record => :new_episodes) do
163
+ VCR.use_cassette('tasks/create/without_user', :record => :none) do
164
164
  tr_task = nil
165
165
  expect { tr_task = tr.tasks.create(valid_params) }.to raise_error(Taskrabbit::Error, 'There must be an authenticated user for this action')
166
166
  tr_task.should be_nil
@@ -173,7 +173,7 @@ describe Taskrabbit::Task do
173
173
  context "with valid params" do
174
174
  it "should return an error if the user is not logged in" do
175
175
  tr = Taskrabbit::Api.new
176
- VCR.use_cassette('tasks/create/without_user', :record => :new_episodes) do
176
+ VCR.use_cassette('tasks/create/without_user', :record => :none) do
177
177
  tr_task = nil
178
178
  expect { tr_task = tr.tasks.create(valid_params) }.to raise_error(Taskrabbit::Error, 'There must be an authenticated user for this action')
179
179
  tr_task.should be_nil
@@ -182,7 +182,7 @@ describe Taskrabbit::Task do
182
182
 
183
183
  it "should create the task if the user is authenticated but does not have a credit card" do
184
184
  tr = Taskrabbit::Api.new(TR_USERS[:without_card][:secret])
185
- VCR.use_cassette('tasks/create/without_credit_card', :record => :new_episodes) do
185
+ VCR.use_cassette('tasks/create/without_credit_card', :record => :none) do
186
186
  tr_task = tr.tasks.new(valid_params)
187
187
  tr_task.save.should == false
188
188
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -193,7 +193,7 @@ describe Taskrabbit::Task do
193
193
 
194
194
  it "should create the task if the user is authenticated and has a credit card" do
195
195
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
196
- VCR.use_cassette('tasks/create/default', :record => :new_episodes) do
196
+ VCR.use_cassette('tasks/create/default', :record => :none) do
197
197
  tr_task = nil
198
198
  expect { tr_task = tr.tasks.create(valid_params) }.to_not raise_error
199
199
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -202,7 +202,7 @@ describe Taskrabbit::Task do
202
202
 
203
203
  it "should create the task using the account" do
204
204
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
205
- VCR.use_cassette('tasks/create/using_account', :record => :new_episodes) do
205
+ VCR.use_cassette('tasks/create/using_account', :record => :none) do
206
206
  tr_task = nil
207
207
  expect { tr_task = tr.account.tasks.create(valid_params) }.to_not raise_error
208
208
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -215,7 +215,7 @@ describe Taskrabbit::Task do
215
215
 
216
216
  it "should create the task if the user is authenticated and has a credit card" do
217
217
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
218
- VCR.use_cassette('tasks/create/with_invalid_params', :record => :new_episodes) do
218
+ VCR.use_cassette('tasks/create/with_invalid_params', :record => :none) do
219
219
  tr_task = nil
220
220
  tr_task = tr.tasks.create(invalid_params)
221
221
  tr_task.should be_instance_of(Taskrabbit::Task)
@@ -225,10 +225,24 @@ describe Taskrabbit::Task do
225
225
  end
226
226
  end
227
227
  end
228
+
229
+ it "should set the correct times" do
230
+ tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
231
+ VCR.use_cassette('tasks/create/with_times', :record => :none) do
232
+ tr_task = tr.tasks.new(valid_params)
233
+ tr_task.complete_by_time = Time.parse("2023-12-12 12:10")
234
+ tr_task.assign_by_time = Time.parse("2023-12-01 13:10")
235
+ expect { tr_task.save }.to_not raise_error
236
+
237
+ reloaded_task = tr.tasks.find(tr_task.id)
238
+ tr_task.complete_by_time.to_s.should == '2023-12-12 12:10:00 -0800'
239
+ tr_task.assign_by_time.to_s.should == '2023-12-01 13:10:00 -0800'
240
+ end
241
+ end
228
242
 
229
243
  it "should post locations" do
230
244
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
231
- VCR.use_cassette('tasks/create/with_location', :record => :new_episodes) do
245
+ VCR.use_cassette('tasks/create/with_location', :record => :none) do
232
246
  tr_task = nil
233
247
  params_with_locations = valid_params.merge({:other_locations_attributes => [
234
248
  {
@@ -6,7 +6,7 @@ describe Taskrabbit::User do
6
6
 
7
7
  before :all do
8
8
  tr = Taskrabbit::Api.new(TR_USERS[:with_card][:secret])
9
- VCR.use_cassette('users/properties', :record => :new_episodes) do
9
+ VCR.use_cassette('users/properties', :record => :none) do
10
10
  @user = tr.users.find(TR_USERS[:with_card][:id])
11
11
  @user.fetch
12
12
  end
@@ -15,17 +15,17 @@ describe Taskrabbit::User do
15
15
  subject { @user }
16
16
 
17
17
  its(:id) { should == TR_USERS[:with_card][:id] }
18
- its(:short_name) { should == "Bob" }
19
- its(:first_name) { should == "Bob" }
20
- its(:full_name) { should == "Bob Sponge" }
21
- its(:display_name) { should == "Bob S." }
18
+ its(:short_name) { should == "UserWith" }
19
+ its(:first_name) { should == "UserWith" }
20
+ its(:full_name) { should == "UserWith card" }
21
+ its(:display_name) { should == "UserWith c." }
22
22
  its(:runner) { should == false }
23
- its(:email) { should == 'bobsponge@example.com' }
23
+ its(:email) { should == 'userwithcard@taskrabbit.com' }
24
24
  its(:mobile_phone) { should == nil }
25
25
  its(:home_phone) { should == nil }
26
26
  its(:tasks) { should == Taskrabbit::Task }
27
27
  its(:city) { should be_instance_of(Taskrabbit::City) }
28
- its(:zip_code) { should == "64321" }
28
+ its(:zip_code) { should == "12345" }
29
29
  its(:locations) { should == Taskrabbit::Location }
30
30
  its(:links) { should be_instance_of(Hash) }
31
31
  end
@@ -34,11 +34,11 @@ describe Taskrabbit::User do
34
34
  describe "#find" do
35
35
  it "should fetch users" do
36
36
  tr = Taskrabbit::Api.new
37
- VCR.use_cassette('users/find', :record => :new_episodes) do
37
+ VCR.use_cassette('users/find', :record => :none) do
38
38
  tr_user = nil
39
39
  expect { tr_user = tr.users.find(TR_USERS[:without_card][:id]) }.to_not raise_error
40
40
  tr_user.id.should == TR_USERS[:without_card][:id]
41
- tr_user.short_name.should == 'John'
41
+ tr_user.short_name.should == 'User with no'
42
42
  tr_user.should be_instance_of(Taskrabbit::User)
43
43
  end
44
44
  end
@@ -57,7 +57,7 @@ describe Taskrabbit::User do
57
57
  end
58
58
 
59
59
  it "should fetch tasks with users/#{TR_USERS[:with_card][:id]}/tasks" do
60
- VCR.use_cassette('users/tasks/all', :record => :new_episodes) do
60
+ VCR.use_cassette('users/tasks/all', :record => :none) do
61
61
  tr_tasks = nil
62
62
  expect { tr_tasks = tr.users.find(TR_USERS[:with_card][:id]).tasks.all }.to_not raise_error
63
63
  tr_tasks.should be_a(Taskrabbit::Collection)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskrabbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-18 00:00:00.000000000 Z
12
+ date: 2012-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: api_smith
@@ -82,6 +82,7 @@ executables: []
82
82
  extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
+ - .env.example
85
86
  - .gitignore
86
87
  - .rspec
87
88
  - .rvmrc
@@ -100,6 +101,7 @@ files:
100
101
  - lib/taskrabbit/config.rb
101
102
  - lib/taskrabbit/error.rb
102
103
  - lib/taskrabbit/location.rb
104
+ - lib/taskrabbit/offer.rb
103
105
  - lib/taskrabbit/proxy.rb
104
106
  - lib/taskrabbit/smash.rb
105
107
  - lib/taskrabbit/task.rb
@@ -121,6 +123,7 @@ files:
121
123
  - spec/support/cassettes/tasks/create/using_account.yml
122
124
  - spec/support/cassettes/tasks/create/with_invalid_params.yml
123
125
  - spec/support/cassettes/tasks/create/with_location.yml
126
+ - spec/support/cassettes/tasks/create/with_times.yml
124
127
  - spec/support/cassettes/tasks/create/without_credit_card.yml
125
128
  - spec/support/cassettes/tasks/create/without_user.yml
126
129
  - spec/support/cassettes/tasks/delete.yml
@@ -128,6 +131,7 @@ files:
128
131
  - spec/support/cassettes/tasks/properties.yml
129
132
  - spec/support/cassettes/tasks/save.yml
130
133
  - spec/support/cassettes/tasks/update.yml
134
+ - spec/support/cassettes/tasks/with_offers_properties.yml
131
135
  - spec/support/cassettes/tasks/without_client.yml
132
136
  - spec/support/cassettes/users/find.yml
133
137
  - spec/support/cassettes/users/properties.yml
@@ -138,6 +142,7 @@ files:
138
142
  - spec/taskrabbit/collection_spec.rb
139
143
  - spec/taskrabbit/error_spec.rb
140
144
  - spec/taskrabbit/location_spec.rb
145
+ - spec/taskrabbit/offer_spec.rb
141
146
  - spec/taskrabbit/proxy_spec.rb
142
147
  - spec/taskrabbit/smash_spec.rb
143
148
  - spec/taskrabbit/task_spec.rb
@@ -158,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
163
  version: '0'
159
164
  segments:
160
165
  - 0
161
- hash: -1275229321438796564
166
+ hash: -2615664640514100221
162
167
  required_rubygems_version: !ruby/object:Gem::Requirement
163
168
  none: false
164
169
  requirements:
@@ -187,6 +192,7 @@ test_files:
187
192
  - spec/support/cassettes/tasks/create/using_account.yml
188
193
  - spec/support/cassettes/tasks/create/with_invalid_params.yml
189
194
  - spec/support/cassettes/tasks/create/with_location.yml
195
+ - spec/support/cassettes/tasks/create/with_times.yml
190
196
  - spec/support/cassettes/tasks/create/without_credit_card.yml
191
197
  - spec/support/cassettes/tasks/create/without_user.yml
192
198
  - spec/support/cassettes/tasks/delete.yml
@@ -194,6 +200,7 @@ test_files:
194
200
  - spec/support/cassettes/tasks/properties.yml
195
201
  - spec/support/cassettes/tasks/save.yml
196
202
  - spec/support/cassettes/tasks/update.yml
203
+ - spec/support/cassettes/tasks/with_offers_properties.yml
197
204
  - spec/support/cassettes/tasks/without_client.yml
198
205
  - spec/support/cassettes/users/find.yml
199
206
  - spec/support/cassettes/users/properties.yml
@@ -204,6 +211,7 @@ test_files:
204
211
  - spec/taskrabbit/collection_spec.rb
205
212
  - spec/taskrabbit/error_spec.rb
206
213
  - spec/taskrabbit/location_spec.rb
214
+ - spec/taskrabbit/offer_spec.rb
207
215
  - spec/taskrabbit/proxy_spec.rb
208
216
  - spec/taskrabbit/smash_spec.rb
209
217
  - spec/taskrabbit/task_spec.rb