wordjelly-auth 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/auth/application.js +1 -1
  3. data/app/controllers/auth/application_controller.rb +6 -0
  4. data/app/controllers/auth/concerns/devise_concern.rb +1 -1
  5. data/app/controllers/auth/concerns/work/communication_controller_concern.rb +82 -0
  6. data/app/controllers/auth/concerns/work/instruction_controller_concern.rb +6 -1
  7. data/app/controllers/auth/endpoints_controller.rb +41 -24
  8. data/app/controllers/auth/images_controller.rb +0 -4
  9. data/app/controllers/auth/profiles_controller.rb +2 -13
  10. data/app/controllers/auth/work/communications_controller.rb +18 -0
  11. data/app/controllers/auth/work/work_controller.rb +43 -0
  12. data/app/jobs/notification_job.rb +17 -0
  13. data/app/mailers/auth/send_mail.rb +15 -0
  14. data/app/models/auth/concerns/chief_model_concern.rb +4 -0
  15. data/app/models/auth/concerns/shopping/product_concern.rb +5 -3
  16. data/app/models/auth/concerns/user_concern.rb +2 -6
  17. data/app/models/auth/endpoint.rb +26 -3
  18. data/app/models/auth/image.rb +5 -0
  19. data/app/models/auth/work/communication.rb +109 -0
  20. data/app/models/auth/work/cycle.rb +8 -14
  21. data/app/models/auth/work/instruction.rb +1 -0
  22. data/app/models/auth/work/minute.rb +75 -52
  23. data/app/views/auth/images/_form.html.erb +1 -1
  24. data/app/views/auth/images/_image_concern.html.erb +3 -3
  25. data/app/views/auth/send_mail/send.html.erb +1 -0
  26. data/app/views/auth/shopping/products/show/_summary.html.erb +12 -0
  27. data/app/views/auth/work/communications/_form.html.erb +57 -0
  28. data/app/views/auth/work/instructions/_form.html.erb +7 -1
  29. data/app/views/auth/work/instructions/_image.html.erb +5 -0
  30. data/app/views/auth/work/instructions/new.html.erb +1 -0
  31. data/app/views/auth/work/instructions/show.html.erb +1 -0
  32. data/app/views/layouts/send_mail.html.erb +5 -0
  33. data/lib/auth/engine.rb +34 -4
  34. data/lib/auth/rails/routes.rb +11 -11
  35. data/lib/auth/version.rb +1 -1
  36. data/spec/dummy/app/assets/javascripts/application.js +0 -2
  37. data/spec/dummy/app/assets/javascripts/images.js +9 -19
  38. data/spec/dummy/app/assets/time_hashes.json +1 -1
  39. data/spec/dummy/app/views/layouts/application.html.erb +0 -1
  40. data/spec/dummy/app/views/new/notification.text.erb +1 -1
  41. data/spec/dummy/app/views/worms/new.html.erb +3 -0
  42. data/spec/dummy/config/cloudinary.yml +6 -6
  43. data/spec/dummy/config/initializers/preinitializer.rb +1 -4
  44. data/spec/models/auth/work/minute_spec.rb +43 -34
  45. data/spec/requests/user/amazon_sns_request_spec.rb +34 -2
  46. data/spec/support/work_support.rb +133 -0
  47. metadata +13 -2
@@ -8,7 +8,6 @@
8
8
  <%= stylesheet_link_tag "https://fonts.googleapis.com/icon?family=Material+Icons", media: "all" %>
9
9
  <%= javascript_include_tag "application" %>
10
10
  <%= csrf_meta_tags %>
11
-
12
11
  <%= cloudinary_js_config %>
13
12
  <%= javascript_include_tag "https://widget.cloudinary.com/global/all.js" %>
14
13
 
@@ -1 +1 @@
1
- notification.text.erb
1
+ hi this is a text partial.
@@ -3,3 +3,6 @@
3
3
  <%= render 'form' %>
4
4
 
5
5
  <%= link_to 'Back', worms_path %>
6
+
7
+ <% @model = @worm %>
8
+ <%= render :partial => "auth/images/image_concern.html.erb" %>
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  development:
3
3
  cloud_name: doohavoda
4
- api_key: '779116626984783'
5
- api_secret: cOGDGWqkPT9rQ-VtBxBb5ej1j50
4
+ api_key: <%= ENV["CLOUDINARY_API_KEY"] %>
5
+ api_secret: <%= ENV["CLOUDINARY_API_SECRET"] %>
6
6
  enhance_image_tag: true
7
7
  static_image_support: false
8
8
  production:
9
9
  cloud_name: doohavoda
10
- api_key: '779116626984783'
11
- api_secret: cOGDGWqkPT9rQ-VtBxBb5ej1j50
10
+ api_key: <%= ENV["CLOUDINARY_API_KEY"] %>
11
+ api_secret: <%= ENV["CLOUDINARY_API_SECRET"] %>
12
12
  enhance_image_tag: true
13
13
  static_image_support: true
14
14
  test:
15
15
  cloud_name: doohavoda
16
- api_key: '779116626984783'
17
- api_secret: cOGDGWqkPT9rQ-VtBxBb5ej1j50
16
+ api_key: <%= ENV["CLOUDINARY_API_KEY"] %>
17
+ api_secret: <%= ENV["CLOUDINARY_API_SECRET"] %>
18
18
  enhance_image_tag: true
19
19
  static_image_support: false
@@ -136,15 +136,12 @@ Mongoid::Elasticsearch.client_options = {hosts: ["localhost"], port: 9200, trans
136
136
  [Auth.configuration.product_class, Auth.configuration.cart_class, Auth.configuration.cart_item_class, Auth.configuration.payment_class, Auth.configuration.discount_class, Auth.configuration.user_class, Auth.configuration.assembly_class]. each do |cl|
137
137
 
138
138
  if ((cl) && (cl.constantize.respond_to? :es))
139
- puts "CREATING INDEX : #{cl} , IF IT DOESNT EXIST"
139
+
140
140
  cl.constantize.es.index.create
141
141
  end
142
142
 
143
143
  end
144
144
 
145
- puts "--------------------------------------------------------------------------------------------------------------------------------------------------------------------"
146
-
147
-
148
145
 
149
146
  ##TEST CODE TO RUN BEFORE EACH STARTUP.
150
147
 
@@ -1,5 +1,5 @@
1
1
  require 'rails_helper'
2
- RSpec.describe Auth::Shopping::Product, type: :model, :minute_model => true do
2
+ RSpec.describe Auth::Work::Minute, type: :model, :minute_model => true do
3
3
 
4
4
  context " -- wrapper -- " do
5
5
 
@@ -27,6 +27,8 @@ RSpec.describe Auth::Shopping::Product, type: :model, :minute_model => true do
27
27
  clean_all_work_related_classes
28
28
  end
29
29
 
30
+
31
+
30
32
  it " -- adds the entity types and counts to the minutes -- ", :update_minute_entities => true do
31
33
 
32
34
  ### CREATING PRODUCTS AND CYCLES
@@ -297,42 +299,49 @@ RSpec.describe Auth::Shopping::Product, type: :model, :minute_model => true do
297
299
 
298
300
  end
299
301
 
300
- it " -- finds the nearest minute to schedule the job -- " do
301
-
302
- ## so we have three products that need to be done
303
- ## product 1 -> starts with cycle a : {worker_type_a => 1, entity_type_a => 1, :capacity => }
304
- ## product 2 -> starts with cycle b : {worker_type_a => 1, enttity_type_a => 1} : this could
305
- ## product 3 -> starts with cycle c : {worker_type_b => 1}
306
-
307
- ## what if two products, need the same start cycle ?
308
- ## then they have to be fused, just bumping the capacity.
309
- ## so that will be the first step.
310
- ## a cycle runs on a certain set of samples.
311
- ## so basically we are looking for something with a minimum capacity of say 10.
312
- ## why not complicate this with redis
313
- ## wouldn't that be really fun.
314
- ## subtract total worker types found, from the maximum needed,
315
- ## this not practical by any length.
316
- ## i need to structure the cycles like that.
317
- ## worker type a, worker type b, worker type c
318
- ## project a ->
319
- ## so first of all have to build this.
320
-
321
-
322
- ## so in order to do this job, we need 2 workers of type a, and one of type b.
323
- ## the minimum's are to be found and defined first.
324
- ## so they will be the individual start cycle clauses.
325
- ## now the search is done for the bare minimum's
326
- ##
302
+
303
+ it " -- finds the nearest minute to schedule the job -- ", :find_minutes => true do
304
+
305
+
306
+ minutes_hash = setup_minutes_with_cycles
307
+
308
+ cycles = {}
309
+
310
+ cycle_one = Auth::Work::Cycle.new
311
+ cycle_one.cycle_type = "a"
312
+ cycle_one.capacity = 1
313
+ cycle_one.requirements = {
314
+ :person_trained_on_em_200 => 1
315
+ }
316
+
317
+ cycles[cycle_one.id.to_s] = cycle_one
318
+
319
+ cycle_two = Auth::Work::Cycle.new
320
+ cycle_two.cycle_type = "b"
321
+ cycle_two.capacity = 1
322
+ cycle_two.requirements = {
323
+ :person_trained_on_em_200 => 1
324
+ }
325
+
326
+ cycles[cycle_two.id.to_s] = cycle_two
327
+
328
+ ## why this is not working is because the minutes dont have anything in them.
329
+
330
+ applicable_minutes = Auth::Work::Minute.find_applicable_minutes(cycles)
331
+
332
+ applicable_minutes.each do |min|
333
+ puts min
334
+ end
327
335
 
328
336
  end
329
-
337
+
338
+ =begin
339
+ {"_id"=>BSON::ObjectId('5b2deab0421aa958e6e221d1'), "entity_types"=>{}, "time"=>2011-05-05 04:43:00 UTC, "cycles"=>[{"_id"=>BSON::ObjectId('5b2deab0421aa958e6e221cd'), "capacity"=>1, "time_since_prev_cycle"=>0, "output"=>[], "cycle_chain"=>[], "duration"=>10, "time_to_next_cycle"=>20, "cycle_type"=>"a", "requirements"=>{"person_trained_on_em_200"=>1}, "start_time"=>1304570580, "end_time"=>1304570590}, {"_id"=>BSON::ObjectId('5b2deab0421aa958e6e221ce'), "capacity"=>1, "time_since_prev_cycle"=>0, "output"=>[], "cycle_chain"=>["5b2deab0421aa958e6e221cd"], "duration"=>10, "time_to_next_cycle"=>20, "cycle_type"=>"b", "requirements"=>{"person_trained_on_em_200"=>1}, "cycle_code"=>"5b2deaaf421aa958e6e221c0", "start_time"=>1304570580, "end_time"=>1304570590}, {"_id"=>BSON::ObjectId('5b2deab0421aa958e6e221cf'), "capacity"=>1, "time_since_prev_cycle"=>0, "output"=>[], "cycle_chain"=>["5b2deab0421aa958e6e221cd", "5b2deab0421aa958e6e221ce"], "duration"=>10, "time_to_next_cycle"=>20, "cycle_type"=>"c", "requirements"=>{"person_trained_on_em_200"=>1, "em_200"=>1}, "cycle_code"=>"5b2deaaf421aa958e6e221c1", "start_time"=>1304570580, "end_time"=>1304570590}]}
340
+ =end
341
+
342
+
330
343
  end
331
344
 
332
345
  end
333
346
 
334
- ## rough plan
335
- ## 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.
336
- ## 20 -> 30 : b2b + collection boy interface + location interface + apis for the symptoms, videos, image +
337
- ## 20 -> 30 : cycle ui + symptom test
338
- ## 1 -> 7 : add all the cycles and steps into the
347
+
@@ -52,12 +52,14 @@ RSpec.describe "Registration requests", :amazon_endpoint => true,:authentication
52
52
 
53
53
  end
54
54
 
55
- it " -- adds android endpoint to user -- " do
55
+ it " -- adds android endpoint to user -- ", :user_endpoint => true do
56
56
 
57
57
  a = {:id => @u2.id.to_s, :user => {:android_token => "xyz"}, api_key: @ap_key, :current_app_id => "testappid", :resource => "users"}
58
58
 
59
59
  put credential_exists_profiles_path, a.to_json, @headers
60
60
 
61
+ #puts response.body.to_s
62
+ #puts response.code.to_s
61
63
  ## get this user
62
64
  ## assert that it has an endpoint.
63
65
  user = User.find(@u2.id.to_s)
@@ -65,9 +67,39 @@ RSpec.describe "Registration requests", :amazon_endpoint => true,:authentication
65
67
 
66
68
  end
67
69
 
68
- it " -- creates android endpoint only from json request -- " do
70
+ it " -- creates android endpoint only from json request -- ", :raw_endpoint => true do
69
71
 
72
+ a = {:endpoint => {:android_token => "abc"}, api_key: @ap_key, :current_app_id => "testappid"}
70
73
 
74
+ post endpoints_path, a.to_json, { "CONTENT_TYPE" => "application/json" , "ACCEPT" => "application/json"}
75
+
76
+
77
+
78
+ endpoint = JSON.parse(response.body)
79
+ expect(response.code).to eq("201")
80
+ expect(endpoint["android_endpoint"]).not_to be_nil
81
+
82
+ end
83
+
84
+
85
+ it " -- does not respond to the request if headers are non-json -- ", :json_only => true do
86
+
87
+ a = {:endpoint => {:android_token => "abc"}, api_key: @ap_key, :current_app_id => "testappid"}
88
+
89
+ post endpoints_path, a.to_json, {}
90
+
91
+ expect(response.code).to eq("404")
92
+
93
+ end
94
+
95
+
96
+ it " -- does not respond without valid api key --- " do
97
+
98
+ a = {:endpoint => {:android_token => "abc"}}
99
+
100
+ post endpoints_path, a.to_json, { "CONTENT_TYPE" => "application/json" , "ACCEPT" => "application/json"}
101
+
102
+ expect(response.code).to eq("401")
71
103
 
72
104
  end
73
105
 
@@ -6,6 +6,139 @@ module WorkSupport
6
6
  Auth::Work::Schedule.delete_all
7
7
  Auth::Work::Minute.delete_all
8
8
  end
9
+
10
+
11
+ ## creates three cycles
12
+ ## creates two minutes
13
+ ## adds the cycles to the minutes
14
+ ## saves the minutes
15
+ ## @return[Hash] {epoch => minute_object}
16
+ def setup_minutes_with_cycles
17
+
18
+ ### CREATING PRODUCTS AND CYCLES
19
+ product = Auth.configuration.product_class.constantize.new
20
+ product.resource_id = @admin.id.to_s
21
+ product.resource_class = @admin.class.name
22
+ product.price = 10.00
23
+ product.signed_in_resource = @admin
24
+
25
+ cycle = Auth::Work::Cycle.new
26
+ cycle.id = "first_cycle"
27
+ cycle.duration = 10
28
+ cycle.time_to_next_cycle = 20
29
+ cycle.cycle_type = "a"
30
+ cycle.requirements = {
31
+ :person_trained_on_em_200 => 1
32
+ }
33
+ product.cycles << cycle
34
+
35
+ product.save
36
+
37
+
38
+ cycle = Auth::Work::Cycle.new
39
+ cycle.id = "second_cycle"
40
+ cycle.duration = 10
41
+ cycle.time_to_next_cycle = 20
42
+ cycle.cycle_type = "b"
43
+ cycle.requirements = {
44
+ :person_trained_on_em_200 => 1
45
+ }
46
+ product.cycles << cycle
47
+
48
+ product.save
49
+
50
+
51
+ cycle = Auth::Work::Cycle.new
52
+ cycle.duration = 10
53
+ cycle.id = "third_cycle"
54
+ cycle.time_to_next_cycle = 20
55
+ cycle.cycle_type = "c"
56
+ cycle.requirements = {
57
+ :person_trained_on_em_200 => 1,
58
+ :em_200 => 1
59
+ }
60
+ product.cycles << cycle
61
+
62
+
63
+
64
+ u = User.new(attributes_for(:user_confirmed))
65
+ u.save
66
+ c = Auth::Client.new(:resource_id => @u.id, :api_key => "test", :app_ids => ["testappid"])
67
+ c.redirect_urls = ["http://www.google.com"]
68
+ c.versioned_create
69
+ u.client_authentication["testappid"] = "testestoken"
70
+ u.cycle_types = {:person_trained_on_em_200 => true}
71
+ expect(u.save).to be_truthy
72
+
73
+
74
+
75
+ ## now the next thing is the entity
76
+ e = Auth::Work::Entity.new
77
+ e.cycle_types = {:em_200 => true}
78
+ e.save
79
+
80
+ e1 = Auth::Work::Entity.new
81
+ e1.cycle_types = {:em_200 => true}
82
+ e1.save
83
+
84
+
85
+ ## now we have to create schedules
86
+ ## this one is for the user.
87
+ schedule = Auth::Work::Schedule.new
88
+ schedule.start_time = Time.new(2010,05,17)
89
+ schedule.end_time = Time.new(2012,07,9)
90
+ schedule.for_object_id = u.id.to_s
91
+ schedule.for_object_class = u.class.name.to_s
92
+ schedule.can_do_cycles = [product.cycles.first.id.to_s]
93
+ schedule.location_id = "first_location"
94
+ schedule.save
95
+
96
+
97
+ ## now one for the entity
98
+ schedule = Auth::Work::Schedule.new
99
+ schedule.start_time = Time.new(2010,05,17)
100
+ schedule.end_time = Time.new(2012,07,9)
101
+ schedule.for_object_id = e.id.to_s
102
+ schedule.for_object_class = e.class.name.to_s
103
+ schedule.can_do_cycles = [product.cycles.first.id.to_s]
104
+ schedule.location_id = "first_location"
105
+ schedule.save
106
+
107
+ schedule = Auth::Work::Schedule.new
108
+ schedule.start_time = Time.new(2010,05,17)
109
+ schedule.end_time = Time.new(2012,07,9)
110
+ schedule.for_object_id = e1.id.to_s
111
+ schedule.for_object_class = e1.class.name.to_s
112
+ schedule.can_do_cycles = [product.cycles.first.id.to_s]
113
+ schedule.location_id = "first_location"
114
+ schedule.save
115
+
116
+ ## add the location
117
+ l = Auth.configuration.location_class.constantize.new
118
+ l.id = "first_location"
119
+ l.save
120
+ #puts l.attributes.to_s
121
+ ## so for the minutes, they are going to be the first and second minute in the duration of the schedules
122
+ minutes = {}
123
+ first_minute = Auth::Work::Minute.new
124
+ first_minute.time = Time.new(2011,05,5,10,12,0)
125
+ minutes[first_minute.time.to_i] = first_minute
126
+
127
+ ## and now the second minute
128
+ second_minute = Auth::Work::Minute.new
129
+ second_minute.time = Time.new(2011,05,5,10,13,0)
130
+ minutes[second_minute.time.to_i] = second_minute
131
+
132
+
133
+ returned_minutes = Auth.configuration.product_class.constantize.schedule_cycles(minutes,"first_location")
134
+
135
+ returned_minutes.keys.each do |epoch|
136
+ expect(returned_minutes[epoch].save).to be_truthy
137
+ end
138
+
139
+ returned_minutes
140
+ end
141
+
9
142
  end
10
143
  RSpec.configure do |config|
11
144
  config.include WorkSupport, :type => :request
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.1.7
4
+ version: 1.1.8
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-20 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xpath
@@ -670,6 +670,7 @@ files:
670
670
  - app/controllers/auth/concerns/shopping/payment_controller_concern.rb
671
671
  - app/controllers/auth/concerns/shopping/product_controller_concern.rb
672
672
  - app/controllers/auth/concerns/token_concern.rb
673
+ - app/controllers/auth/concerns/work/communication_controller_concern.rb
673
674
  - app/controllers/auth/concerns/work/instruction_controller_concern.rb
674
675
  - app/controllers/auth/confirmations_controller.rb
675
676
  - app/controllers/auth/endpoints_controller.rb
@@ -690,6 +691,7 @@ files:
690
691
  - app/controllers/auth/unlocks_controller.rb
691
692
  - app/controllers/auth/webhooks_controller.rb
692
693
  - app/controllers/auth/work/bullets_controller.rb
694
+ - app/controllers/auth/work/communications_controller.rb
693
695
  - app/controllers/auth/work/instructions_controller.rb
694
696
  - app/controllers/auth/work/work_controller.rb
695
697
  - app/controllers/auth/workflow/assemblies_controller.rb
@@ -728,9 +730,11 @@ files:
728
730
  - app/helpers/auth/users/profiles_helper.rb
729
731
  - app/helpers/auth/work/bullets/bullets_helper.rb
730
732
  - app/helpers/auth/work/instructions/instructions_helper.rb
733
+ - app/jobs/notification_job.rb
731
734
  - app/jobs/otp_job.rb
732
735
  - app/mailers/application_mailer.rb
733
736
  - app/mailers/auth/notifier.rb
737
+ - app/mailers/auth/send_mail.rb
734
738
  - app/models/auth/admin_create_user.rb
735
739
  - app/models/auth/client.rb
736
740
  - app/models/auth/concerns/activity_concern.rb
@@ -783,6 +787,7 @@ files:
783
787
  - 'app/models/auth/work/VICTORY SPEECH:'
784
788
  - app/models/auth/work/actor.rb
785
789
  - app/models/auth/work/bullet.rb
790
+ - app/models/auth/work/communication.rb
786
791
  - app/models/auth/work/cycle.rb
787
792
  - app/models/auth/work/entity.rb
788
793
  - app/models/auth/work/information.rb
@@ -900,6 +905,7 @@ files:
900
905
  - app/views/auth/search/_search_results.html.erb
901
906
  - app/views/auth/search/authenticated_user_search.js.erb
902
907
  - app/views/auth/search/authenticated_user_search.json
908
+ - app/views/auth/send_mail/send.html.erb
903
909
  - app/views/auth/sessions/create.js.erb
904
910
  - app/views/auth/sessions/new.html.erb
905
911
  - app/views/auth/sessions/new.js.erb
@@ -966,9 +972,13 @@ files:
966
972
  - app/views/auth/work/bullets/_show.html.erb
967
973
  - app/views/auth/work/bullets/edit.html.erb
968
974
  - app/views/auth/work/bullets/new.html.erb
975
+ - app/views/auth/work/communications/_form.html.erb
969
976
  - app/views/auth/work/instructions/_form.html.erb
977
+ - app/views/auth/work/instructions/_image.html.erb
970
978
  - app/views/auth/work/instructions/_show.html.erb
971
979
  - app/views/auth/work/instructions/edit.html.erb
980
+ - app/views/auth/work/instructions/new.html.erb
981
+ - app/views/auth/work/instructions/show.html.erb
972
982
  - app/views/layouts/auth/_modals.html.erb
973
983
  - app/views/layouts/auth/application.html.erb
974
984
  - app/views/layouts/auth/navbar/_navbar.html.erb
@@ -976,6 +986,7 @@ files:
976
986
  - app/views/layouts/auth/navbar/_progress_spinner.html.erb
977
987
  - app/views/layouts/mailer.html.erb
978
988
  - app/views/layouts/mailer.text.erb
989
+ - app/views/layouts/send_mail.html.erb
979
990
  - config/initializers/active_model.rb
980
991
  - config/initializers/aws.rb
981
992
  - config/initializers/devise.rb