mno-enterprise-api 3.1.4 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +7 -1
  3. data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +3 -27
  4. data/app/controllers/mno_enterprise/auth/sessions_controller.rb +1 -3
  5. data/app/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller.rb +26 -0
  6. data/app/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller.rb +28 -0
  7. data/app/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller.rb +16 -0
  8. data/app/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller.rb +30 -0
  9. data/app/controllers/mno_enterprise/jpi/v1/admin/invites_controller.rb +1 -1
  10. data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +55 -37
  11. data/app/controllers/mno_enterprise/jpi/v1/app_answers_controller.rb +22 -0
  12. data/app/controllers/mno_enterprise/jpi/v1/app_comments_controller.rb +22 -0
  13. data/app/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller.rb +14 -0
  14. data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +1 -20
  15. data/app/controllers/mno_enterprise/jpi/v1/app_questions_controller.rb +25 -0
  16. data/app/controllers/mno_enterprise/jpi/v1/app_reviews_controller.rb +94 -0
  17. data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +12 -0
  18. data/app/controllers/mno_enterprise/jpi/v1/impac/alerts_controller.rb +5 -0
  19. data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +1 -76
  20. data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +1 -18
  21. data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +1 -83
  22. data/app/jobs/mno_enterprise/event_logger_job.rb +10 -0
  23. data/app/views/mno_enterprise/auth/confirmations/new.html.haml +6 -6
  24. data/app/views/mno_enterprise/auth/passwords/new.html.haml +8 -8
  25. data/app/views/mno_enterprise/auth/registrations/new.html.haml +1 -0
  26. data/app/views/mno_enterprise/auth/sessions/new.html.haml +1 -0
  27. data/app/views/mno_enterprise/auth/shared/_links.html.haml +0 -5
  28. data/app/views/mno_enterprise/auth/shared/_omniauth.html.haml +10 -0
  29. data/app/views/mno_enterprise/jpi/v1/admin/app_answers/show.json.jbuilder +15 -0
  30. data/app/views/mno_enterprise/jpi/v1/admin/app_comments/show.json.jbuilder +15 -0
  31. data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/_app_review.json.jbuilder +13 -0
  32. data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/index.json.jbuilder +1 -0
  33. data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/show.json.jbuilder +3 -0
  34. data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +1 -0
  35. data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -1
  36. data/app/views/mno_enterprise/jpi/v1/app_answers/_resource.json.jbuilder +4 -0
  37. data/app/views/mno_enterprise/jpi/v1/app_answers/index.json.jbuilder +5 -0
  38. data/app/views/mno_enterprise/jpi/v1/app_answers/show.json.jbuilder +3 -0
  39. data/app/views/mno_enterprise/jpi/v1/app_comments/_resource.json.jbuilder +3 -0
  40. data/app/views/mno_enterprise/jpi/v1/app_comments/index.json.jbuilder +5 -0
  41. data/app/views/mno_enterprise/jpi/v1/app_comments/show.json.jbuilder +3 -0
  42. data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_comment.json.jbuilder +10 -0
  43. data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_resource.json.jbuilder +7 -0
  44. data/app/views/mno_enterprise/jpi/v1/app_feedbacks/index.json.jbuilder +5 -0
  45. data/app/views/mno_enterprise/jpi/v1/app_feedbacks/show.json.jbuilder +4 -0
  46. data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +9 -0
  47. data/app/views/mno_enterprise/jpi/v1/app_questions/_answer.json.jbuilder +3 -0
  48. data/app/views/mno_enterprise/jpi/v1/app_questions/_resource.json.jbuilder +8 -0
  49. data/app/views/mno_enterprise/jpi/v1/app_questions/index.json.jbuilder +5 -0
  50. data/app/views/mno_enterprise/jpi/v1/app_questions/show.json.jbuilder +3 -0
  51. data/app/views/mno_enterprise/jpi/v1/app_reviews/_resource.json.jbuilder +13 -0
  52. data/app/views/mno_enterprise/jpi/v1/app_reviews/index.json.jbuilder +5 -0
  53. data/app/views/mno_enterprise/jpi/v1/app_reviews/show.json.jbuilder +4 -0
  54. data/app/views/mno_enterprise/jpi/v1/base_resource/_app_review.json.jbuilder +17 -0
  55. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +9 -1
  56. data/app/views/mno_enterprise/jpi/v1/impac/alerts/_alert.json.jbuilder +7 -0
  57. data/app/views/mno_enterprise/jpi/v1/impac/alerts/index.json.jbuilder +1 -0
  58. data/app/views/mno_enterprise/jpi/v1/impac/alerts/show.json.jbuilder +1 -0
  59. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +8 -3
  60. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +4 -1
  61. data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +1 -1
  62. data/app/views/mno_enterprise/jpi/v1/impac/widgets/index.json.jbuilder +3 -0
  63. data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +4 -0
  64. data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +1 -2
  65. data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +1 -1
  66. data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +1 -1
  67. data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +3 -2
  68. data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +2 -2
  69. data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +2 -2
  70. data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +11 -5
  71. data/app/views/mno_enterprise/pages/terms.html.haml +219 -0
  72. data/app/views/mno_enterprise/provision/_select_organization.html.haml +6 -2
  73. data/config/initializers/devise.rb +31 -9
  74. data/config/initializers/devise_log.rb +4 -4
  75. data/config/routes.rb +41 -6
  76. data/lib/mno_enterprise/api.rb +1 -0
  77. data/lib/mno_enterprise/audit_events_listener.rb +28 -0
  78. data/lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb +45 -0
  79. data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +14 -4
  80. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/alerts_controller.rb +76 -0
  81. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +49 -23
  82. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +167 -0
  83. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb +33 -17
  84. data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +32 -0
  85. data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +68 -28
  86. data/lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb +92 -0
  87. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +17 -3
  88. data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +17 -2
  89. data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +27 -3
  90. data/lib/mno_enterprise/event_logger.rb +34 -16
  91. data/lib/mno_enterprise/intercom_events_listener.rb +96 -0
  92. data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +28 -0
  93. data/spec/controllers/mno_enterprise/auth/omniauth_callback_controller_spec.rb +34 -0
  94. data/spec/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller_spec.rb +45 -0
  95. data/spec/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller_spec.rb +45 -0
  96. data/spec/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller_spec.rb +31 -0
  97. data/spec/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller_spec.rb +103 -0
  98. data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +4 -15
  99. data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +12 -3
  100. data/spec/controllers/mno_enterprise/jpi/v1/admin/invites_controller_spec.rb +4 -0
  101. data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +15 -0
  102. data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +17 -1
  103. data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +5 -0
  104. data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +30 -16
  105. data/spec/controllers/mno_enterprise/jpi/v1/app_answers_controller_spec.rb +74 -0
  106. data/spec/controllers/mno_enterprise/jpi/v1/app_comments_controller_spec.rb +74 -0
  107. data/spec/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller_spec.rb +84 -0
  108. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +36 -22
  109. data/spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb +80 -0
  110. data/spec/controllers/mno_enterprise/jpi/v1/app_reviews_controller_spec.rb +107 -0
  111. data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +16 -1
  112. data/spec/controllers/mno_enterprise/jpi/v1/impac/alerts_controller_spec.rb +82 -0
  113. data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +147 -10
  114. data/spec/controllers/mno_enterprise/jpi/v1/impac/widgets_controller_spec.rb +39 -0
  115. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +19 -26
  116. data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +248 -303
  117. data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +4 -1
  118. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +21 -0
  119. data/spec/controllers/mno_enterprise/provision_controller_spec.rb +65 -22
  120. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
  121. data/spec/jobs/mno_enterprise/event_logger_job_spec.rb +11 -0
  122. data/spec/lib/mno_enterprise/audit_events_listener_spec.rb +28 -0
  123. data/spec/lib/mno_enterprise/intercom_events_listener_spec.rb +110 -0
  124. data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +81 -46
  125. data/spec/routing/mno_enterprise/jpi/v1/admin/app_instances_controller_routing_spec.rb +11 -0
  126. data/spec/routing/mno_enterprise/jpi/v1/admin/app_reviews_controller_routing_spec.rb +19 -0
  127. data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +9 -2
  128. data/spec/routing/mno_enterprise/jpi/v1/app_reviews_controller_routing_spec.rb +15 -0
  129. data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +5 -0
  130. data/spec/routing/mno_enterprise/jpi/v1/impac/alerts_controller_routing_spec.rb +24 -0
  131. data/spec/routing/mno_enterprise/jpi/v1/impac/dashboards_controller_routing_spec.rb +28 -0
  132. data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +17 -11
  133. data/spec/routing/mno_enterprise/jpi/v1/impac/widgets_controller_routing_spec.rb +24 -0
  134. data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +2 -2
  135. data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +4 -0
  136. metadata +178 -9
  137. data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +0 -25
  138. data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +0 -93
  139. data/spec/lib/mno_enterprise/event_logger_spec.rb +0 -28
@@ -1,25 +0,0 @@
1
- module MnoEnterprise
2
- class Jpi::V1::IndustryBundleController < ApplicationController
3
-
4
- # GET /mnoe/jpi/v1/industry_bundles/app_descriptions/pr.json
5
- # def app_descriptions
6
- # @bundle = IndustryBundle.find_by_name(params[:bundle_name])
7
- # if @bundle
8
- # app_descriptions_array = @bundle.apps.map do |app|
9
- # [app.name, { 'pictures' => app.pictures.map { |picture| {'thumb' => picture.thumb.to_s, 'url' => picture.url.to_s } } }.merge(
10
- # @bundle.app_descriptions[app.name]) ]
11
- # end
12
- # @app_descriptions = Hash[*(app_descriptions_array.flatten)]
13
- # @bundle_description = { appNames: @bundle.apps.map { |app| app.name }, appDescriptions: @app_descriptions }
14
- # respond_to do |format|
15
- # format.json { render json: @bundle_description, status: :ok }
16
- # end
17
- # else
18
- # respond_to do |format|
19
- # format.json { render json: "That bundle does not exist", status: :bad_request }
20
- # end
21
- # end
22
- # end
23
-
24
- end
25
- end
@@ -1,93 +0,0 @@
1
- module MnoEnterprise
2
- class Jpi::V1::ShoppingCartController < ApplicationController
3
- # before_filter :authenticate_user!, except: [:apps]
4
- # before_filter :inject_cart_and_authorize, only: [:show,:upsert_item,:remove_item,:checkout]
5
- #
6
- # # When a user signs in from the shopping
7
- # # cart, the CSRF token seems to change therefore
8
- # # preventing any POST request later on
9
- # # TODO: We should be able to grab the new CSRF token on
10
- # # login and inject it in angular
11
- # skip_before_filter :verify_authenticity_token
12
- #
13
- # # GET /mnoe/jpi/v1/shopping_cart/apps
14
- # # params:
15
- # # - ensure_apps: [{ app: {id: 16 } }] (as string) -- ensure that some apps are present in the list
16
- # def apps
17
- # @apps = App.active.to_a
18
- #
19
- # if params[:ensure_apps].present?
20
- # begin
21
- # id_list = JSON.parse(params[:ensure_apps]).map { |h| (h['app']||{})['id'] }.compact
22
- # @apps += App.where(id: id_list).to_a
23
- # @apps.uniq!
24
- # rescue
25
- # end
26
- # end
27
- #
28
- # @apps.sort! { |a,b| a.name <=> b.name }
29
- #
30
- # render json: @apps.map { |a| Shopping::Cart.hash_for_app(a) }
31
- # end
32
- #
33
- # # GET /mnoe/jpi/v1/shopping_cart/organizations
34
- # def organizations
35
- # @orgs = Organization.accessible_by(Ability.new(current_user)).sort_by { |o| o.name }
36
- # end
37
- #
38
- # # GET /mnoe/jpi/v1/shopping_cart/1
39
- # def show
40
- # end
41
- #
42
- # # POST /mnoe/jpi/v1/shopping_cart
43
- # # TODO: add test for bundle parameter on create
44
- # def create
45
- # organization = Organization.find(params[:shopping_cart][:organization_id])
46
- # bundle = params[:shopping_cart][:bundle]
47
- # authorize! :purchase, organization
48
- #
49
- # @cart = Shopping::Cart.create(requestor: current_user, beneficiary: organization, bundle: bundle)
50
- #
51
- # render 'show'
52
- # end
53
- #
54
- # # PUT /mnoe/jpi/v1/shopping_cart/1/upsert_item
55
- # def upsert_item
56
- # @item = @cart.add_item!(params[:item])
57
- # render 'show_item'
58
- # end
59
- #
60
- # # PUT /mnoe/jpi/v1/shopping_cart/1/remove_item
61
- # def remove_item
62
- # @item = @cart.remove_item!(params[:item])
63
- # render 'show_item'
64
- # end
65
- #
66
- # # PUT /mnoe/jpi/v1/shopping_cart/1/checkout
67
- # def checkout
68
- # if @cart.checkout!(params[:credit_card])
69
- # render 'show'
70
- # else
71
- # render json: @cart.errors, status: :bad_request
72
- # end
73
- #
74
- # end
75
- #
76
- # #============================================
77
- # # Private Methods
78
- # #============================================
79
- # private
80
- # # Inject @cart and authorize access
81
- # # TODO: use CanCan for authorization
82
- # def inject_cart_and_authorize
83
- # @cart = Shopping::Cart.find(params[:id])
84
- #
85
- # unless @cart.requestor == current_user
86
- # render json: { errors: 'unauthorized' }, status: :unauthorized
87
- # return false
88
- # end
89
- #
90
- # return true
91
- # end
92
- end
93
- end
@@ -1,28 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module MnoEnterprise
4
- RSpec.describe EventLogger do
5
-
6
- def info_data(user)
7
- {
8
- data: {
9
- key: 'user_update_password',
10
- user_id: user.id,
11
- description: 'User password change',
12
- metadata: user.email,
13
- subject_type: user.class.name,
14
- subject_id: user.id
15
- }
16
- }
17
- end
18
-
19
- let(:user) { build(:user) }
20
-
21
- describe "#info" do
22
- subject { MnoEnterprise::EventLogger.info('user_update_password', user.id, "User password change", user.email, user) }
23
-
24
- it { expect(subject.code).to eq(200) }
25
- it { expect(subject.request.options[:body]).to eq(info_data(user)) }
26
- end
27
- end
28
- end