wordjelly-auth 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,10 @@ RSpec.describe Auth::Shopping::Product, type: :model, :product_model => true do
27
27
  clean_all_work_related_classes
28
28
  end
29
29
 
30
- it " -- adds cycles to appropriate minutes in the schedules -- " do
30
+ ## how will it find the affected cycles ?
31
+ ##
32
+
33
+ it " -- adds cycles to appropriate minutes in the schedules, adds rolling minutes, and cycle chains -- " do
31
34
 
32
35
  ### CREATING PRODUCTS AND CYCLES
33
36
  product = Auth.configuration.product_class.constantize.new
@@ -35,18 +38,43 @@ RSpec.describe Auth::Shopping::Product, type: :model, :product_model => true do
35
38
  product.resource_class = @admin.class.name
36
39
  product.price = 10.00
37
40
  product.signed_in_resource = @admin
41
+
38
42
  cycle = Auth::Work::Cycle.new
43
+ cycle.id = "first_cycle"
39
44
  cycle.duration = 10
40
45
  cycle.time_to_next_cycle = 20
41
46
  cycle.requirements = {
42
- :person_trained_on_em_200 => 1,
43
- :em_200 => 1
47
+ :person_trained_on_em_200 => 1
44
48
  }
45
49
  product.cycles << cycle
50
+
46
51
  product.save
47
52
 
48
53
 
49
- ## now the next thing is to make one such user and one such entity.
54
+ cycle = Auth::Work::Cycle.new
55
+ cycle.id = "second_cycle"
56
+ cycle.duration = 10
57
+ cycle.time_to_next_cycle = 20
58
+ cycle.requirements = {
59
+ :person_trained_on_em_200 => 1
60
+ }
61
+ product.cycles << cycle
62
+
63
+ product.save
64
+
65
+
66
+ cycle = Auth::Work::Cycle.new
67
+ cycle.duration = 10
68
+ cycle.id = "third_cycle"
69
+ cycle.time_to_next_cycle = 20
70
+ cycle.requirements = {
71
+ :person_trained_on_em_200 => 1,
72
+ :em_200 => 1
73
+ }
74
+ product.cycles << cycle
75
+
76
+
77
+
50
78
  u = User.new(attributes_for(:user_confirmed))
51
79
  u.save
52
80
  c = Auth::Client.new(:resource_id => @u.id, :api_key => "test", :app_ids => ["testappid"])
@@ -56,8 +84,7 @@ RSpec.describe Auth::Shopping::Product, type: :model, :product_model => true do
56
84
  u.cycle_types = {:person_trained_on_em_200 => true}
57
85
  expect(u.save).to be_truthy
58
86
 
59
- #puts "---------------- ID OF THE SAVED USER -: #{u.id.to_s}"
60
-
87
+
61
88
 
62
89
  ## now the next thing is the entity
63
90
  e = Auth::Work::Entity.new
@@ -93,27 +120,47 @@ RSpec.describe Auth::Shopping::Product, type: :model, :product_model => true do
93
120
  l.save
94
121
  #puts l.attributes.to_s
95
122
  ## so for the minutes, they are going to be the first and second minute in the duration of the schedules
96
-
97
123
  minutes = {}
98
124
  first_minute = Auth::Work::Minute.new
99
- first_minute.time = Time.new(2011,05,5)
125
+ first_minute.time = Time.new(2011,05,5,10,12,0)
100
126
  minutes[first_minute.time.to_i] = first_minute
101
127
 
102
128
  ## and now the second minute
103
129
  second_minute = Auth::Work::Minute.new
104
- second_minute.time = Time.new(2011,05,6)
130
+ second_minute.time = Time.new(2011,05,5,10,13,0)
105
131
  minutes[second_minute.time.to_i] = second_minute
106
132
 
107
- ## now that we have done that, we can pass in all this and see what happens.
108
133
  returned_minutes = Auth.configuration.product_class.constantize.schedule_cycles(minutes,"first_location")
134
+
135
+ ## if there are 3 cycles that are applicable to each minute, then the first minute should have 6 cycles and the second should have 3 cycles
136
+ ## as far as the chain is concerned.
137
+ ## if we consider the first minute.
138
+
109
139
  expect(returned_minutes.size).to eq(2)
110
- returned_minutes.keys.each do |time|
111
- expect(returned_minutes[time].cycles).not_to be_empty
112
- end
140
+
141
+ ## expect the first minute to have 6 cycles
142
+ ## expect the second minute to have 3 cycles
113
143
 
144
+ ## how to find the expected ids ?
145
+ ##
114
146
 
115
- end
147
+ expect(returned_minutes.values.first.cycles.size).to eq(6)
148
+ expect(returned_minutes.values.last.cycles.size).to eq(3)
116
149
 
150
+ returned_minutes.keys.each do |time|
151
+
152
+ returned_minutes[time].cycles.each do |cycle|
153
+
154
+ if cycle.id == "first_cycle"
155
+ expect(cycle.cycle_chain).to be_empty
156
+ elsif cycle.id == "second_cycle"
157
+ expect(cycle.cycle_chain).to eq(["first_cycle"])
158
+ elsif cycle.id == "third_cycle"
159
+ expect(cycle.cycle_chain).to eq(["first_cycle","second_cycle"])
160
+ end
161
+ end
162
+ end
163
+ end
117
164
 
118
165
  end
119
166
 
@@ -43,6 +43,7 @@ RSpec.describe Auth::Work::Cycle, type: :model, :cycle_model => true do
43
43
  product.signed_in_resource = @admin
44
44
  cycle = Auth::Work::Cycle.new
45
45
  cycle.duration = 10
46
+ cycle.start_time = Time.now.to_i
46
47
  cycle.time_to_next_cycle = 20
47
48
  product.cycles << cycle
48
49
  expect(product.save).to be_truthy
@@ -3,8 +3,44 @@ RSpec.describe Auth::Shopping::Product, type: :model, :minute_model => true do
3
3
 
4
4
  context " -- wrapper -- " do
5
5
 
6
-
6
+ it " -- finds the affected cycles -- " do
7
+
8
+ start_minute = Time.new(2012,05,05,10,10,0).to_i
9
+ 5.times do |n|
10
+ minute = Auth::Work::Minute.new
11
+ minute.time = start_minute
12
+ 2.times do |c|
13
+ cycle = Auth::Work::Cycle.new
14
+ cycle.start_time = minute.time.to_i
15
+ cycle.duration = 10
16
+ cycle.end_time = cycle.start_time + cycle.duration
17
+ cycle.requirements = {
18
+ :person_trained_on_em_200 => 1,
19
+ :em_200 => 1
20
+ }
21
+ cycle.workers_available = ["first_worker","second_worker"]
22
+ cycle.entities_available = ["first_entity","second_entity"]
23
+ minute.cycles << cycle
24
+ end
25
+ minute.save
26
+ start_minute = start_minute + 60.seconds
27
+ end
28
+
29
+ ## now we have 5 minutes, each with 2 cycles.
30
+ ## now lets search for the affected cycles.
31
+ ## we will give a minute range that encomapsses the last three minutes.
32
+ affected_cycles = Auth::Work::Minute.get_affected_minutes(Time.new(2012,05,05,10,13,0).to_i,Time.new(2012,05,05,10,16,0).to_i,["first_worker"],["second_entity"])
33
+ affected_cycles.each do |af_cycle|
34
+ puts af_cycle.to_s
35
+ end
36
+ end
7
37
 
8
38
  end
9
39
 
10
- end
40
+ end
41
+
42
+ ## rough plan
43
+ ## 10 -> 20 : finish the cycles, and then decide what kind of ui it should have, test object + integration with shopping cart + notifications + video / image integration with cycle + bar code.
44
+ ## 20 -> 30 : b2b + collection boy interface + location interface + apis for the symptoms, videos, image +
45
+ ## 20 -> 30 : cycle ui + symptom test
46
+ ## 1 -> 7 : add all the cycles and steps into the
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordjelly-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bhargav
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2018-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xpath
@@ -778,6 +778,7 @@ files:
778
778
  - app/models/auth/transaction/event_test.rb
779
779
  - app/models/auth/transaction/status.rb
780
780
  - app/models/auth/user.rb
781
+ - 'app/models/auth/work/VICTORY SPEECH:'
781
782
  - app/models/auth/work/cycle.rb
782
783
  - app/models/auth/work/entity.rb
783
784
  - app/models/auth/work/input.rb
@@ -1117,6 +1118,8 @@ files:
1117
1118
  - spec/dummy/lib/admin/parameter_sanitizer.rb
1118
1119
  - spec/dummy/lib/assets/files/test_names.json
1119
1120
  - spec/dummy/lib/user/parameter_sanitizer.rb
1121
+ - spec/dummy/log/development.log
1122
+ - spec/dummy/log/test.log
1120
1123
  - spec/dummy/public/404.html
1121
1124
  - spec/dummy/public/422.html
1122
1125
  - spec/dummy/public/500.html
@@ -1586,6 +1589,8 @@ test_files:
1586
1589
  - spec/dummy/public/favicon.ico
1587
1590
  - spec/dummy/README.rdoc
1588
1591
  - spec/dummy/sidekiq.yml
1592
+ - spec/dummy/log/test.log
1593
+ - spec/dummy/log/development.log
1589
1594
  - spec/dummy/sidekiq_prep.sh
1590
1595
  - spec/dummy/config/environments/test.rb
1591
1596
  - spec/dummy/config/environments/production.rb