mno-enterprise-api 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -0
  3. data/Rakefile +12 -0
  4. data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
  5. data/app/assets/javascripts/mno_enterprise/application.js +13 -0
  6. data/app/controllers/devise/password_expired_controller.rb +55 -0
  7. data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
  8. data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
  9. data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
  10. data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
  11. data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
  12. data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
  13. data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
  14. data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
  15. data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
  16. data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
  17. data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
  18. data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
  19. data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
  20. data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
  21. data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
  22. data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
  23. data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
  24. data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
  25. data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
  26. data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
  27. data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
  28. data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
  29. data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
  30. data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
  31. data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
  32. data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
  33. data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
  34. data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
  35. data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
  36. data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
  37. data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
  38. data/app/controllers/mno_enterprise/status_controller.rb +27 -0
  39. data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
  40. data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
  41. data/app/models/mno_enterprise/health_check.rb +16 -0
  42. data/app/views/devise/password_expired/show.html.haml +32 -0
  43. data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
  44. data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
  45. data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
  46. data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
  47. data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
  48. data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
  49. data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
  50. data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
  51. data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
  52. data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
  53. data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
  54. data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
  55. data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
  56. data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
  57. data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
  58. data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
  59. data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
  60. data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
  61. data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
  62. data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
  63. data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
  64. data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
  65. data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
  66. data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
  67. data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
  68. data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
  69. data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
  70. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
  71. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
  72. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
  73. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
  74. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
  75. data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
  76. data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
  77. data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
  78. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
  79. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
  80. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
  81. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
  82. data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
  83. data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
  84. data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
  85. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
  86. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
  87. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
  88. data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
  89. data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
  90. data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
  91. data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
  92. data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
  93. data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
  94. data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
  95. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
  96. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
  97. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
  98. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
  99. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
  100. data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
  101. data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
  102. data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
  103. data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
  104. data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
  105. data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
  106. data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
  107. data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
  108. data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
  109. data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
  110. data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
  111. data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
  112. data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
  113. data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
  114. data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
  115. data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
  116. data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
  117. data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
  118. data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
  119. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
  120. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
  121. data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
  122. data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
  123. data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
  124. data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
  125. data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
  126. data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
  127. data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
  128. data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
  129. data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
  130. data/app/views/mno_enterprise/provision/new.html.haml +4 -0
  131. data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
  132. data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
  133. data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
  134. data/config/initializers/devise.rb +273 -0
  135. data/config/initializers/devise_extension.rb +9 -0
  136. data/config/initializers/devise_log.rb +12 -0
  137. data/config/initializers/health_check.rb +35 -0
  138. data/config/initializers/main_app_version.rb +6 -0
  139. data/config/routes.rb +152 -0
  140. data/lib/mno-enterprise-api.rb +1 -0
  141. data/lib/mno_enterprise/api.rb +14 -0
  142. data/lib/mno_enterprise/api/engine.rb +9 -0
  143. data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
  144. data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
  145. data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
  146. data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
  147. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
  148. data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
  149. data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
  150. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
  151. data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
  152. data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
  153. data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
  154. data/lib/mno_enterprise/event_logger.rb +32 -0
  155. data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
  156. data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
  157. data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
  158. data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
  159. data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
  160. data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
  161. data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
  162. data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
  163. data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
  164. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
  165. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
  166. data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
  167. data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
  168. data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
  169. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
  170. data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
  171. data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
  172. data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
  173. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
  174. data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
  175. data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
  176. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
  177. data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
  178. data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
  179. data/spec/rails_helper.rb +94 -0
  180. data/spec/requests/devise/authentication_spec.rb +43 -0
  181. data/spec/requests/devise/registration_spec.rb +64 -0
  182. data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
  183. data/spec/routing/devise/passwords_routing_spec.rb +24 -0
  184. data/spec/routing/devise/registrations_routing_spec.rb +16 -0
  185. data/spec/routing/devise/sessions_routing_spec.rb +20 -0
  186. data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
  187. data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
  188. data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
  189. data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
  190. data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
  191. data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
  192. data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
  193. data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
  194. data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
  195. data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
  196. data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
  197. data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
  198. data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
  199. data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
  200. data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
  201. data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
  202. data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
  203. data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
  204. data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
  205. data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
  206. data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
  207. data/spec/spec_helper.rb +88 -0
  208. metadata +402 -0
@@ -0,0 +1,94 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require 'spec_helper'
4
+ require 'her'
5
+ require 'factory_girl_rails'
6
+
7
+ require 'mno_enterprise/testing_support/user_action_shared'
8
+
9
+ # Load the Dummy application
10
+ begin
11
+ require File.expand_path("../dummy/config/environment", __FILE__)
12
+ rescue LoadError
13
+ puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
14
+ end
15
+ # require File.expand_path("../../spec/dummy/config/environment.rb", __FILE__)
16
+
17
+ require 'rspec/rails'
18
+ require 'shoulda/matchers'
19
+
20
+ # Check Dummy application migrations
21
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../spec/dummy/db/migrate", __FILE__)]
22
+ ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
23
+
24
+
25
+ # Requires supporting ruby files with custom matchers and macros, etc, in
26
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
27
+ # run as spec files by default. This means that files in spec/support that end
28
+ # in _spec.rb will both be required and run as specs, causing the specs to be
29
+ # run twice. It is recommended that you do not name files matching this glob to
30
+ # end with _spec.rb. You can configure this pattern with the --pattern
31
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
32
+ Dir[Rails.root.join("../..","spec/support/**/*.rb")].each { |f| require f }
33
+
34
+ # Require all factories
35
+ # Dir[Rails.root.join("../..", "spec/factories/**/*.rb")].each {|f| require f }
36
+ require 'mno_enterprise/testing_support/factories'
37
+
38
+ # Checks for pending migrations before tests are run.
39
+ # If you are not using ActiveRecord, you can remove this line.
40
+ ActiveRecord::Migration.maintain_test_schema!
41
+
42
+ RSpec.configure do |config|
43
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
44
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
45
+
46
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
47
+ # examples within a transaction, remove the following line or assign false
48
+ # instead of true.
49
+ # config.use_transactional_fixtures = true
50
+
51
+ # Include FactoryGirl methods to avoid typing FactoryGirl.create(...)
52
+ config.include FactoryGirl::Syntax::Methods
53
+
54
+ # Include MnoEnterpriseApiTestHelper
55
+ # Enable API stub helpers (e.g.: api_stub_for)
56
+ config.include MnoEnterpriseApiTestHelper
57
+
58
+ # Include ability test helper
59
+ config.include AbilityTestHelper, type: :controller
60
+
61
+ # Include devise tests
62
+ config.include Devise::TestHelpers, type: :controller
63
+
64
+ # Include Rails route helpers
65
+ config.include Rails.application.routes.url_helpers, type: :controller
66
+
67
+ # Reset API stubs before each step
68
+ config.before :each do
69
+ api_stub_reset
70
+ end
71
+ #Fix time rounding issues
72
+ ActiveSupport::JSON::Encoding.time_precision = 0
73
+ # RSpec Rails can automatically mix in different behaviours to your tests
74
+ # based on their file location, for example enabling you to call `get` and
75
+ # `post` in specs under `spec/controllers`.
76
+ #
77
+ # You can disable this behaviour by removing the line below, and instead
78
+ # explicitly tag your specs with their type, e.g.:
79
+ #
80
+ # RSpec.describe UsersController, :type => :controller do
81
+ # # ...
82
+ # end
83
+ #
84
+ # The different available types are documented in the features, such as in
85
+ # https://relishapp.com/rspec/rspec-rails/docs
86
+ config.infer_spec_type_from_file_location!
87
+ end
88
+
89
+ Shoulda::Matchers.configure do |config|
90
+ config.integrate do |with|
91
+ with.test_framework :rspec
92
+ with.library :rails
93
+ end
94
+ end
@@ -0,0 +1,43 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe "Remote Authentication", type: :request do
5
+
6
+ let(:user) { build(:user) }
7
+ before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
8
+ before { api_stub_for(put: "/users/#{user.id}", response: from_api(user)) }
9
+
10
+ # Stub session authentication
11
+ let(:session_resp_code) { 200 }
12
+ let(:session_resp) { from_api(user) }
13
+ before { api_stub_for(post: '/user_sessions',
14
+ code: -> { session_resp_code },
15
+ response: -> { session_resp }
16
+ ) }
17
+
18
+ describe 'login' do
19
+ subject { post '/mnoe/auth/users/sign_in', user: {email: user.email, password: 'securepassword'} }
20
+
21
+ describe 'success' do
22
+ before { subject }
23
+
24
+ it 'logs the user in' do
25
+ expect(controller).to be_user_signed_in
26
+ expect(controller.current_user.id).to eq(user.id)
27
+ expect(controller.current_user.name).to eq(user.name)
28
+ end
29
+ end
30
+
31
+ describe 'failure' do
32
+ let(:session_resp_code) { 404 }
33
+ let(:session_resp) { {errors: "does not exist"} }
34
+ before { subject }
35
+
36
+ it 'does logs the user in' do
37
+ expect(controller).to_not be_user_signed_in
38
+ expect(controller.current_user).to be_nil
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,64 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe "Remote Registration", type: :request do
5
+
6
+ let(:confirmation_token) { 'wky763pGjtzWR7dP44PD' }
7
+ let(:user) { build(:user, :unconfirmed, confirmation_token: confirmation_token) }
8
+ let(:email_uniq_resp) { [] }
9
+ let(:signup_attrs) { {name: "John", surname: "Doe", email: 'john@doecorp.com', password: 'securepassword'} }
10
+
11
+ # Stub user calls
12
+ before { api_stub_for(post: '/users', response: from_api(user)) }
13
+ before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
14
+ before { api_stub_for(put: "/users/#{user.id}", response: from_api(user)) }
15
+
16
+ # Stub user retrieval using confirmation token
17
+ before { api_stub_for(
18
+ get: '/users',
19
+ params: {filter: {confirmation_token: '**'}, limit: 1},
20
+ response: from_api([])
21
+ ) }
22
+
23
+ # Stub user email uniqueness check
24
+ before { api_stub_for(
25
+ get: '/users',
26
+ params: {filter: {email: '**'}, limit: 1},
27
+ response: -> { from_api(email_uniq_resp) }
28
+ ) }
29
+
30
+ # Stub org_invites retrieval
31
+ before { api_stub_for(get: '/org_invites', response: from_api([])) }
32
+
33
+
34
+ describe 'signup' do
35
+ subject { post '/mnoe/auth/users', user: signup_attrs }
36
+
37
+ describe 'success' do
38
+ before { subject }
39
+
40
+ it 'signs the user up' do
41
+ expect(controller).to be_user_signed_in
42
+ curr_user = controller.current_user
43
+ expect(curr_user.id).to eq(user.id)
44
+ expect(curr_user.name).to eq(user.name)
45
+ expect(curr_user.surname).to eq(user.surname)
46
+ end
47
+
48
+ it 'redirects to the confirmation lounge' do
49
+ expect(response).to redirect_to('/mnoe/auth/users/confirmation/lounge')
50
+ end
51
+ end
52
+
53
+ describe 'failure' do
54
+ let(:email_uniq_resp) { [from_api(user)] }
55
+ before { subject }
56
+
57
+ it 'does not log the user in' do
58
+ expect(controller).to_not be_user_signed_in
59
+ expect(controller.current_user).to be_nil
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Devise::ConfirmationsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #show' do
8
+ expect(get('/auth/users/confirmation?confirmation_token=bla')).to route_to("mno_enterprise/auth/confirmations#show", confirmation_token: 'bla')
9
+ end
10
+
11
+ it 'routes to #finalize' do
12
+ expect(patch('/auth/users/confirmation/finalize')).to route_to("mno_enterprise/auth/confirmations#finalize")
13
+ end
14
+
15
+ it 'routes to #lounge' do
16
+ expect(get('/auth/users/confirmation/lounge')).to route_to("mno_enterprise/auth/confirmations#lounge")
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Devise::PasswordsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #new' do
8
+ expect(get('/auth/users/password/new')).to route_to("mno_enterprise/auth/passwords#new")
9
+ end
10
+
11
+ it 'routes to #edit' do
12
+ expect(get('/auth/users/password/edit')).to route_to("mno_enterprise/auth/passwords#edit")
13
+ end
14
+
15
+ it 'routes to #update' do
16
+ expect(put('/auth/users/password')).to route_to("mno_enterprise/auth/passwords#update")
17
+ end
18
+
19
+ it 'routes to #create' do
20
+ expect(post('/auth/users/password')).to route_to("mno_enterprise/auth/passwords#create")
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Devise::RegistrationsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #new' do
8
+ expect(get('/auth/users/sign_up')).to route_to("mno_enterprise/auth/registrations#new")
9
+ end
10
+
11
+ it 'routes to #create' do
12
+ expect(post('/auth/users')).to route_to("mno_enterprise/auth/registrations#create")
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Devise::SessionsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #new' do
8
+ expect(get('/auth/users/sign_in')).to route_to("mno_enterprise/auth/sessions#new")
9
+ end
10
+
11
+ it 'routes to #create' do
12
+ expect(post('/auth/users/sign_in')).to route_to("mno_enterprise/auth/sessions#create")
13
+ end
14
+
15
+ it 'routes to #destroy' do
16
+ expect(delete('/auth/users/sign_out')).to route_to("mno_enterprise/auth/sessions#destroy")
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,20 @@
1
+ require "rails_helper"
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe DeletionRequestsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it "routes to #show" do
8
+ expect(get("/deletion_requests/1")).to route_to("mno_enterprise/deletion_requests#show", id: '1')
9
+ end
10
+
11
+ it "routes to #freeze_account" do
12
+ expect(patch("/deletion_requests/1/freeze_account")).to route_to("mno_enterprise/deletion_requests#freeze_account", id: '1')
13
+ end
14
+
15
+ it 'routes to #checkout' do
16
+ expect(patch("/deletion_requests/1/checkout")).to route_to("mno_enterprise/deletion_requests#checkout", id: '1')
17
+ end
18
+ it 'routes to #terminate_account'
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ require "rails_helper"
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe ImpersonateController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it "routes to #create" do
8
+ expect(get("/impersonate/user/1")).to route_to("mno_enterprise/impersonate#create", user_id: '1')
9
+ end
10
+
11
+ it "routes to #destroy" do
12
+ expect(delete("/impersonate/revert")).to route_to("mno_enterprise/impersonate#destroy")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Jpi::V1::Admin::AuditEventsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #index' do
8
+ expect(get('/jpi/v1/admin/audit_events')).to route_to('mno_enterprise/jpi/v1/admin/audit_events#index', format: "json")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Jpi::V1::Admin::CloudAppsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #index' do
8
+ expect(get('/jpi/v1/admin/cloud_apps')).to route_to('mno_enterprise/jpi/v1/admin/cloud_apps#index', format: 'json')
9
+ end
10
+
11
+ it 'routes to #update' do
12
+ expect(put('/jpi/v1/admin/cloud_apps/1')).to route_to('mno_enterprise/jpi/v1/admin/cloud_apps#update', id: '1', format: 'json')
13
+ end
14
+
15
+ it 'routes to #regenerate_api_key' do
16
+ expect(put('/jpi/v1/admin/cloud_apps/1/regenerate_api_key')).to route_to('mno_enterprise/jpi/v1/admin/cloud_apps#regenerate_api_key', id: '1', format: 'json')
17
+ end
18
+
19
+ it 'routes to #refresh_metadata' do
20
+ expect(put('/jpi/v1/admin/cloud_apps/1/refresh_metadata')).to route_to('mno_enterprise/jpi/v1/admin/cloud_apps#refresh_metadata', id: '1', format: 'json')
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Jpi::V1::Admin::InvoicesController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #index' do
8
+ expect(get('/jpi/v1/admin/invoices')).to route_to("mno_enterprise/jpi/v1/admin/invoices#index", format: "json")
9
+ end
10
+
11
+ it 'routes to #show' do
12
+ expect(get('/jpi/v1/admin/invoices/1')).to route_to("mno_enterprise/jpi/v1/admin/invoices#show", format: "json", id: '1')
13
+ end
14
+
15
+ it 'routes to #current_billing_amount' do
16
+ expect(get('/jpi/v1/admin/invoices/current_billing_amount')).to route_to("mno_enterprise/jpi/v1/admin/invoices#current_billing_amount", format: "json")
17
+ end
18
+
19
+ it 'routes to #last_invoicing_amount' do
20
+ expect(get('/jpi/v1/admin/invoices/last_invoicing_amount')).to route_to("mno_enterprise/jpi/v1/admin/invoices#last_invoicing_amount", format: "json")
21
+ end
22
+
23
+ it 'routes to #outstanding_amount' do
24
+ expect(get('/jpi/v1/admin/invoices/outstanding_amount')).to route_to("mno_enterprise/jpi/v1/admin/invoices#outstanding_amount", format: "json")
25
+ end
26
+
27
+ it 'routes to #last_portfolio_amount' do
28
+ expect(get('/jpi/v1/admin/invoices/last_portfolio_amount')).to route_to('mno_enterprise/jpi/v1/admin/invoices#last_portfolio_amount', format: 'json')
29
+ end
30
+
31
+ it 'routes to #last_commission_amount' do
32
+ expect(get('/jpi/v1/admin/invoices/last_commission_amount')).to route_to('mno_enterprise/jpi/v1/admin/invoices#last_commission_amount', format: 'json')
33
+ end
34
+
35
+ end
36
+ end
37
+
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Jpi::V1::Admin::OrganizationsController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #index' do
8
+ expect(get('/jpi/v1/admin/organizations')).to route_to("mno_enterprise/jpi/v1/admin/organizations#index", format: "json")
9
+ end
10
+
11
+ it 'routes to #show' do
12
+ expect(get('/jpi/v1/admin/organizations/1')).to route_to("mno_enterprise/jpi/v1/admin/organizations#show", format: "json", id: '1')
13
+ end
14
+
15
+ it 'routes to #in_arrears' do
16
+ expect(get('/jpi/v1/admin/organizations/in_arrears')).to route_to("mno_enterprise/jpi/v1/admin/organizations#in_arrears", format: "json")
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ RSpec.describe Jpi::V1::Admin::TenantInvoicesController, type: :routing do
5
+ routes { MnoEnterprise::Engine.routes }
6
+
7
+ it 'routes to #index' do
8
+ expect(get('/jpi/v1/admin/tenant_invoices')).to route_to("mno_enterprise/jpi/v1/admin/tenant_invoices#index", format: "json")
9
+ end
10
+
11
+ it 'routes to #show' do
12
+ expect(get('/jpi/v1/admin/tenant_invoices/1')).to route_to("mno_enterprise/jpi/v1/admin/tenant_invoices#show", format: "json", id: '1')
13
+ end
14
+ end
15
+ end
16
+