whois_slacking 0.0.5 → 0.0.6

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: 2c12a90fd78ffc81ec00d90aa15e50c61bb53041
4
- data.tar.gz: 95ae875b987913537d79c40de5676a8ea3df0392
3
+ metadata.gz: 1519d96d93e6f93912944e91c3c9d642d946747c
4
+ data.tar.gz: c2202e378d424d844b65ecd635bfb76e83cf5d4a
5
5
  SHA512:
6
- metadata.gz: b343af7a6be9858de23f6285a7a9d33729c7b16982580155d871493fb978d4221c52bc5ed2e0b84db0ab52ce28b4a8fe8bcd964ddacd572613af6a495a66e2d6
7
- data.tar.gz: 4d4e91bc2a20bedff2b746a9335371034f17b94ff64998932eb2b19bec54e87dc9548631d6c8625d438fa373b80959bab328776b8dc92a6c566d2432aa025cd7
6
+ metadata.gz: 95cc7e0edf3acf1d74c6982b29095d4a82ab7f42fb6191bed97474240e96df022cdcec567b1b9d1eaae8b7fc464f213119adc8db6cd72a5d375173b4bf2b4442
7
+ data.tar.gz: e924331a002d5c3579bf265a2cc80751f97fc90da8c7890cfee5c35ca00a0fbac12f1c7fe2c79df17148f55207319d504a3604b4305bcc67f496217a1eb21aa7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whois_slacking (0.0.4)
4
+ whois_slacking (0.0.5)
5
5
  dotenv (~> 2.0.2)
6
6
  moneta (~> 0.8.0)
7
7
  multi_xml (~> 0.5)
@@ -117,6 +117,7 @@ GEM
117
117
  thread_safe (0.3.5)
118
118
  time_difference (0.4.2)
119
119
  activesupport
120
+ timecop (0.8.0)
120
121
  typhoeus (0.3.3)
121
122
  mime-types
122
123
  tzinfo (1.2.2)
@@ -125,7 +126,7 @@ GEM
125
126
  unf_ext
126
127
  unf_ext (0.0.7.1)
127
128
  vcr (2.9.3)
128
- websocket-driver (0.6.0)
129
+ websocket-driver (0.6.2)
129
130
  websocket-extensions (>= 0.1.0)
130
131
  websocket-extensions (0.1.2)
131
132
 
@@ -136,5 +137,6 @@ DEPENDENCIES
136
137
  byebug
137
138
  guard-rspec (~> 4.2)
138
139
  rspec (~> 2.13)
140
+ timecop
139
141
  vcr (~> 2.4)
140
142
  whois_slacking!
@@ -168,8 +168,8 @@ module WhoIsSlacking
168
168
  # keep the created dt and start_dt
169
169
  created_dt = entity_exists[:created_dt]
170
170
  start_dt = entity_exists[:start_dt].to_datetime
171
- task_entity["created_dt"] = created_dt
172
- task_entity["start_dt"] = start_dt.to_s
171
+ task_entity[:created_dt] = created_dt
172
+ task_entity[:start_dt] = start_dt.to_s
173
173
  puts "start_dt in db will be #{start_dt}"
174
174
  store[mkey] = task_entity
175
175
 
@@ -1,3 +1,3 @@
1
1
  module WhoIsSlacking
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
  require 'moneta'
5
5
  require 'date'
6
6
  require 'byebug'
7
+ require 'timecop'
7
8
 
8
9
  describe "json client" do
9
10
 
@@ -64,6 +65,21 @@ describe "json client" do
64
65
  DateTime.now
65
66
  end
66
67
 
68
+ def direct_save(start_dt = (DateTime.now - 1), cstate = current_state, accepted_date=(DateTime.now - 1) )
69
+ accepted_at = accepted_at
70
+ created_dt = DateTime.now.to_s
71
+ updated_dt = created_dt
72
+ active = true
73
+ message = nil
74
+ task_entity = {project: project, task_id: task_id, task: task, user: user, current_state: cstate, active: active, start_dt: start_dt, created_dt: created_dt, accepted_at: accepted_at, updated_dt: updated_dt}
75
+ store = WhoIsSlacking::DataTools.whois_store
76
+ mutex = Moneta::Mutex.new(store, 'moneta')
77
+ mutex.synchronize do
78
+ mkey = WhoIsSlacking::DataTools.whois_key(project, task_id, user)
79
+ store[mkey] = task_entity
80
+ end
81
+ end
82
+
67
83
  it "should connect to pivotal" do
68
84
  WhoIsSlacking::Pivotal.connect_to_pivotal
69
85
  expect(PivotalTracker::Client.connection.timeout).to eql ENV["PIVOTAL_TIMEOUT"].to_i
@@ -122,20 +138,6 @@ describe "json client" do
122
138
  .fetch("message", nil).fetch("text", nil)) .to eql "Today *user delivered* <https://www.pivotaltracker.com/story/show/98984232|task> and it is *waiting to be accepted*"
123
139
  end
124
140
 
125
- def direct_save(start_dt = (DateTime.now - 1), cstate = current_state)
126
- accepted_at = accepted_at
127
- created_dt = DateTime.now.to_s
128
- updated_dt = created_dt
129
- active = true
130
- message = nil
131
- task_entity = {project: project, task_id: task_id, task: task, user: user, current_state: cstate, active: active, start_dt: start_dt, created_dt: created_dt, accepted_at: accepted_at, updated_dt: updated_dt}
132
- store = WhoIsSlacking::DataTools.whois_store
133
- mutex = Moneta::Mutex.new(store, 'moneta')
134
- mutex.synchronize do
135
- mkey = WhoIsSlacking::DataTools.whois_key(project, task_id, user)
136
- store[mkey] = task_entity
137
- end
138
- end
139
141
 
140
142
  it "should not post to slack when a finished task exists in pivotal *and* in the db" do
141
143
  accepted_dt = DateTime.now - 1
@@ -159,17 +161,32 @@ describe "json client" do
159
161
  .fetch("message", nil).fetch("text", nil)) .to eql "*user* has spent *1 days* working on <https://www.pivotaltracker.com/story/show/98984232|task>"
160
162
  end
161
163
 
162
- it "should post to slack 'xx has spent xx hours working on xxx' when a non completed task exists in pivotal and in the db and the days worked is less than 1" do
163
- start_dt = DateTime.now - 0.5
164
- direct_save(start_dt)
165
- expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt, url)
166
- .fetch("message", nil).fetch("text", nil)) .to eql "*user* has spent *less than a day* working on <https://www.pivotaltracker.com/story/show/98984232|task>"
167
- end
168
-
169
- it "should run through all tasks for a project, sending a message into slack for each of them" do
170
- WhoIsSlacking::Pivotal.connect_to_pivotal
171
- project_object = WhoIsSlacking::Pivotal.pivotal_project(project_name)
172
- expect(WhoIsSlacking::Start.now.count).to eql WhoIsSlacking::Pivotal.project_stories(project_object).count
173
- end
164
+ it "should update a completed task and then post to slack 'xx has spent xx days working on xxx' when a non completed task exists in pivotal and in the db" do
165
+ accepted_dt = DateTime.now - 2 # accepted two days ago
166
+ Timecop.travel(DateTime.now - 2) do # save for the first time two days ago
167
+ WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt, url)
168
+ end
169
+ Timecop.travel(DateTime.now - 1) do # save again yesterday
170
+ WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt, url)
171
+ end
172
+ Timecop.travel(DateTime.now + 1) do # save again tomorrow
173
+ # check 2 days from now
174
+ expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt, url)
175
+ .fetch("message", nil).fetch("text", nil)) .to eql "*user* has spent *3 days* working on <https://www.pivotaltracker.com/story/show/98984232|task>"
176
+ end
177
+ end
178
+
179
+ it "should post to slack 'xx has spent xx hours working on xxx' when a non completed task exists in pivotal and in the db and the days worked is less than 1" do
180
+ start_dt = DateTime.now - 0.5
181
+ direct_save(start_dt)
182
+ expect(WhoIsSlacking::DataTools.save_task(project, task_id, task, user, current_state, accepted_dt, url)
183
+ .fetch("message", nil).fetch("text", nil)) .to eql "*user* has spent *less than a day* working on <https://www.pivotaltracker.com/story/show/98984232|task>"
184
+ end
185
+
186
+ it "should run through all tasks for a project, sending a message into slack for each of them" do
187
+ WhoIsSlacking::Pivotal.connect_to_pivotal
188
+ project_object = WhoIsSlacking::Pivotal.pivotal_project(project_name)
189
+ expect(WhoIsSlacking::Start.now.count).to eql WhoIsSlacking::Pivotal.project_stories(project_object).count
190
+ end
174
191
  end
175
192
 
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency 'vcr',["~> 2.4"]
25
25
  s.add_development_dependency 'guard-rspec', ["~> 4.2"]
26
26
  s.add_development_dependency 'byebug'
27
+ s.add_development_dependency 'timecop'
27
28
  # s.add_development_dependency 'debugger'
28
29
 
29
30
  s.add_runtime_dependency "pivotal-tracker", ["~> 0.5.13"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whois_slacking
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - W Watson
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: pivotal-tracker
71
85
  requirement: !ruby/object:Gem::Requirement