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,72 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ describe Jpi::V1::DeletionRequestsController, type: :controller do
5
+ include MnoEnterprise::TestingSupport::JpiV1TestHelper
6
+ render_views
7
+ routes { MnoEnterprise::Engine.routes }
8
+ before { request.env["HTTP_ACCEPT"] = 'application/json' }
9
+
10
+ # Stub model calls
11
+ let(:deletion_request) { build(:deletion_request) }
12
+ let(:user) { build(:user, deletion_request: deletion_request) }
13
+ before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
14
+ before { sign_in user }
15
+
16
+ describe 'POST #create' do
17
+ before { api_stub_for(post: "/deletion_requests", response: from_api(deletion_request)) }
18
+
19
+ subject { post :create }
20
+ it_behaves_like "jpi v1 protected action"
21
+
22
+ context 'success' do
23
+ it 'creates the account deletion_request' do
24
+ subject
25
+ expect(assigns(:deletion_request).user).to eq(user)
26
+ end
27
+
28
+ it 'sends the instructions email' do
29
+ message_delivery = instance_double(ActionMailer::MessageDelivery)
30
+ expect(message_delivery).to receive(:deliver_now).with(no_args)
31
+
32
+ expect(SystemNotificationMailer).to receive(:deletion_request_instructions)
33
+ .with(user, deletion_request)
34
+ .and_return(message_delivery)
35
+
36
+ subject
37
+ end
38
+ end
39
+ end
40
+
41
+ describe 'PUT #resend' do
42
+ subject { put :resend, id: deletion_request.token }
43
+ it_behaves_like "jpi v1 protected action"
44
+
45
+ context 'success' do
46
+ it 'resends the deletion instructions' do
47
+ message_delivery = instance_double(ActionMailer::MessageDelivery)
48
+ expect(message_delivery).to receive(:deliver_now).with(no_args)
49
+
50
+ expect(SystemNotificationMailer).to receive(:deletion_request_instructions)
51
+ .with(user, deletion_request)
52
+ .and_return(message_delivery)
53
+
54
+ subject
55
+ end
56
+ end
57
+ end
58
+
59
+ describe 'DELETE #destroy' do
60
+ before { api_stub_for(get: "/deletion_requests/#{deletion_request.id}", response: from_api(deletion_request)) }
61
+ before { api_stub_for(delete: "/deletion_requests/#{deletion_request.id}", response: from_api({})) }
62
+
63
+ subject { delete :destroy, id: deletion_request.token }
64
+ it_behaves_like "jpi v1 protected action"
65
+
66
+ context 'success' do
67
+ it 'destroys the deletion request'
68
+ end
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,80 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ describe Jpi::V1::Impac::KpisController, type: :controller do
5
+ include MnoEnterprise::TestingSupport::JpiV1TestHelper
6
+ render_views
7
+ routes { MnoEnterprise::Engine.routes }
8
+ before { request.env["HTTP_ACCEPT"] = 'application/json' }
9
+
10
+ # Stub ability
11
+ let!(:ability) { stub_ability }
12
+ before { allow(ability).to receive(:can?).with(any_args).and_return(true) }
13
+
14
+ # Stub user and user call
15
+ let!(:user) { build(:user) }
16
+ before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
17
+ before { sign_in user }
18
+
19
+ let(:dashboard) { build(:impac_dashboard) }
20
+ before { allow_any_instance_of(MnoEnterprise::Impac::Dashboard).to receive(:owner).and_return(user) }
21
+ before { api_stub_for(get: "/dashboards/#{dashboard.id}", response: from_api(dashboard)) }
22
+
23
+ let(:kpi) { build(:impac_kpi, dashboard: dashboard) }
24
+ let(:kpi_hash) { from_api(kpi)[:data].except(:dashboard) }
25
+
26
+ before { api_stub_for(post: "/dashboards/#{dashboard.id}/kpis", response: from_api(kpi)) }
27
+ before { api_stub_for(get: "/dashboards/#{dashboard.id}/kpis", response: from_api([])) }
28
+
29
+
30
+ describe 'POST #create' do
31
+ subject { post :create, dashboard_id: dashboard.id, kpi: kpi_hash }
32
+ it_behaves_like "jpi v1 authorizable action"
33
+
34
+ it ".dashboard retrieves the correct dashboard" do
35
+ subject
36
+ expect(assigns(:dashboard)).to eq(dashboard)
37
+ end
38
+
39
+ it "creates the kpi" do
40
+ subject
41
+ expect(assigns(:kpi)).to eq(kpi)
42
+ end
43
+
44
+ it { subject; expect(response.code).to eq('200') }
45
+ it { subject; expect(JSON.parse(response.body)).to eq(kpi_hash) }
46
+ end
47
+
48
+ describe 'PUT #update' do
49
+ let(:kpi_hash) { from_api(kpi)[:data].except(:dashboard).merge(name: 'New Name') }
50
+
51
+ subject { put :update, id: kpi.id, kpi: kpi_hash }
52
+
53
+ before { api_stub_for(get: "/kpis/#{kpi.id}", response: from_api(kpi)) }
54
+ before { api_stub_for(put: "/kpis/#{kpi.id}", response: kpi_hash) }
55
+
56
+ before { kpi.save }
57
+
58
+ it_behaves_like "jpi v1 authorizable action"
59
+
60
+ it "updates the kpi" do
61
+ subject
62
+ expect(assigns(:kpi).name).to eq('New Name')
63
+ end
64
+
65
+ it { subject; expect(response.code).to eq('200') }
66
+ it { subject; expect(JSON.parse(response.body)).to eq(kpi_hash) }
67
+ end
68
+
69
+ describe 'DELETE #destroy' do
70
+ subject { delete :destroy, id: kpi.id }
71
+
72
+ before { api_stub_for(get: "/kpis/#{kpi.id}", response: from_api(kpi)) }
73
+ before { api_stub_for(delete: "/kpis/#{kpi.id}", response: {message: 'ok', code: 200}) }
74
+
75
+ it_behaves_like "jpi v1 authorizable action"
76
+
77
+ it { expect(response.code).to eq('200') }
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,115 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ describe MnoEnterprise::Jpi::V1::MarketplaceController, type: :controller do
5
+ render_views
6
+ routes { MnoEnterprise::Engine.routes }
7
+ before { request.env["HTTP_ACCEPT"] = 'application/json' }
8
+
9
+ let!(:app) { build(:app) }
10
+
11
+ def markdown(text)
12
+ return text unless text.present?
13
+ HtmlProcessor.new(text, format: :markdown).html.html_safe
14
+ end
15
+
16
+ def partial_hash_for_app(app)
17
+ {
18
+ 'id' => app.id,
19
+ 'nid' => app.nid,
20
+ 'name' => app.name,
21
+ 'stack' => app.stack,
22
+ 'logo' => app.logo.to_s,
23
+ 'key_benefits' => app.key_benefits,
24
+ 'categories' => ["CRM"],
25
+ 'tags' => ['Foo', 'Bar'],
26
+ 'is_responsive' => false && app.responsive?,
27
+ 'is_star_ready' => false && app.star_ready?,
28
+ 'is_connec_ready' => false && app.connec_ready?,
29
+ 'is_coming_soon' => app.coming_soon?,
30
+ 'single_billing' => app.single_billing?,
31
+ 'tiny_description' => app.tiny_description,
32
+ 'description' => markdown(app.sanitized_description),
33
+ 'testimonials' => app.testimonials,
34
+ 'pictures' => app.pictures,
35
+ 'pricing_plans' => app.pricing_plans
36
+ }
37
+ end
38
+
39
+ def hash_for_app(app)
40
+ {
41
+ 'app' => partial_hash_for_app(app)
42
+ }
43
+ end
44
+
45
+ def hash_for_apps(apps)
46
+ hash = {}
47
+ hash['apps'] = []
48
+ hash['categories'] = App.categories(apps)
49
+ hash['categories'].delete('Most Popular')
50
+
51
+ apps.each do |app|
52
+ hash['apps'] << partial_hash_for_app(app)
53
+ end
54
+
55
+ return hash
56
+ end
57
+
58
+ describe 'GET #index' do
59
+ subject { get :index }
60
+
61
+ context 'when marketplace_listing is set' do
62
+ before do
63
+ MnoEnterprise.marketplace_listing = [app.nid]
64
+ api_stub_for(
65
+ get: '/apps',
66
+ params: { filter: { 'nid.in' => MnoEnterprise.marketplace_listing } },
67
+ response: from_api([app])
68
+ )
69
+ end
70
+
71
+ it 'is successful' do
72
+ subject
73
+ expect(response).to be_success
74
+ end
75
+
76
+ it 'returns the right response' do
77
+ subject
78
+ expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_apps([app]).to_json))
79
+ end
80
+ end
81
+
82
+ context 'when marketplace_listing is not set' do
83
+ before do
84
+ MnoEnterprise.marketplace_listing = nil
85
+ api_stub_for(get: '/apps', response: from_api([app]))
86
+ end
87
+
88
+ it 'is successful' do
89
+ subject
90
+ expect(response).to be_success
91
+ end
92
+
93
+ it 'returns the right response' do
94
+ subject
95
+ expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_apps([app]).to_json))
96
+ end
97
+ end
98
+ end
99
+
100
+ describe 'GET #show' do
101
+ before { api_stub_for(get: "/apps/#{app.id}", response: from_api(app)) }
102
+ subject { get :show, id: app.id }
103
+
104
+ it 'is successful' do
105
+ subject
106
+ expect(response).to be_success
107
+ end
108
+
109
+ it 'returns the right response' do
110
+ subject
111
+ expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_app(app).to_json))
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,516 @@
1
+ require 'rails_helper'
2
+
3
+ module MnoEnterprise
4
+ describe Jpi::V1::OrganizationsController, type: :controller do
5
+ include MnoEnterprise::TestingSupport::JpiV1TestHelper
6
+ include MnoEnterprise::TestingSupport::OrganizationsSharedHelpers
7
+
8
+ render_views
9
+ routes { MnoEnterprise::Engine.routes }
10
+ before { request.env["HTTP_ACCEPT"] = 'application/json' }
11
+ #before { allow_any_instance_of(CreditCard).to receive(:save_to_gateway).and_return(true) }
12
+
13
+
14
+ #===============================================
15
+ # Assignments
16
+ #===============================================
17
+ # Stub controller ability
18
+ let!(:ability) { stub_ability }
19
+ before { allow(ability).to receive(:can?).with(any_args).and_return(true) }
20
+
21
+ # Stub user and user call
22
+ let(:user) { build(:user) }
23
+ before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
24
+ before { sign_in user }
25
+
26
+ # Advanced features - currently disabled
27
+ let!(:credit_card) { build(:credit_card, organization_id: organization.id) }
28
+ let!(:invoice) { build(:invoice, organization_id: organization.id) }
29
+ let!(:org_invite) { build(:org_invite, organization: organization) }
30
+
31
+ # Stub organization + associations
32
+ let(:organization) { build(:organization) }
33
+ before { allow_any_instance_of(MnoEnterprise::User).to receive(:organizations).and_return([organization]) }
34
+
35
+ before { api_stub_for(post: "/organizations", response: from_api(organization)) }
36
+ before { api_stub_for(put: "/organizations/#{organization.id}", response: from_api(organization)) }
37
+ before { api_stub_for(delete: "/organizations/#{organization.id}", response: from_api(nil)) }
38
+
39
+ before { api_stub_for(get: "/organizations/#{organization.id}/credit_card", response: from_api(credit_card)) }
40
+ before { api_stub_for(put: "/credit_cards/#{credit_card.id}", response: from_api(credit_card)) }
41
+
42
+
43
+ before { api_stub_for(get: "/organizations/#{organization.id}/invoices", response: from_api([invoice])) }
44
+ before { api_stub_for(get: "/organizations/#{organization.id}/org_invites", response: from_api([org_invite])) }
45
+ before { api_stub_for(get: "/organizations/#{organization.id}/users", response: from_api([user])) }
46
+ before { api_stub_for(post: "/organizations/#{organization.id}/users", response: from_api(user)) }
47
+
48
+ #===============================================
49
+ # Specs
50
+ #===============================================
51
+ describe 'GET #index' do
52
+ subject { get :index }
53
+
54
+ it_behaves_like "jpi v1 protected action"
55
+
56
+ context 'success' do
57
+ before { subject }
58
+
59
+ it 'returns a list of organizations' do
60
+ expect(response).to be_success
61
+ expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_organizations([organization]).to_json))
62
+ end
63
+ end
64
+ end
65
+
66
+ describe 'GET #show' do
67
+ subject { get :show, id: organization.id }
68
+
69
+ it_behaves_like "jpi v1 protected action"
70
+
71
+ context 'success' do
72
+ before { subject }
73
+
74
+ it 'returns a complete description of the organization' do
75
+ expect(response).to be_success
76
+ expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_organization(organization,user).to_json))
77
+ end
78
+
79
+ # context 'and super admin' do
80
+ # let(:role) { 'Super Admin' }
81
+ #
82
+ # it 'includes additional details' do
83
+ # expect(response).to be_success
84
+ # expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_organization(organization,user).to_json))
85
+ # end
86
+ # end
87
+ end
88
+ end
89
+
90
+ describe 'POST #create' do
91
+ let(:params) { { 'name' => organization.name } }
92
+ subject { post :create, organization: params }
93
+
94
+ it_behaves_like "jpi v1 protected action"
95
+
96
+ context 'success' do
97
+ before { subject }
98
+
99
+ it 'creates the organization' do
100
+ expect(assigns(:organization).name).to eq(organization.name)
101
+ end
102
+
103
+ it 'adds the user as Super Admin' do
104
+ expect(assigns(:organization).users).to eq([user])
105
+ end
106
+
107
+ it 'returns a partial representation of the entity' do
108
+ expect(JSON.parse(response.body)).to eq(hash_for_organization(organization,user))
109
+ end
110
+ end
111
+ end
112
+
113
+ describe 'PUT #update' do
114
+ let(:params) { { 'name' => organization.name + 'a', 'soa_enabled' => !organization.soa_enabled } }
115
+ subject { put :update, id: organization.id, organization: params }
116
+
117
+ it_behaves_like "jpi v1 authorizable action"
118
+
119
+ context 'success' do
120
+ it 'updates the organization' do
121
+ expect(organization).to receive(:save).and_return(true)
122
+ subject
123
+ expect(organization.name).to eq(params['name'])
124
+ expect(organization.soa_enabled).to eq(params['soa_enabled'])
125
+ end
126
+
127
+ it 'returns a partial representation of the entity' do
128
+ subject
129
+ expect(JSON.parse(response.body)).to eq(hash_for_reduced_organization(organization))
130
+ end
131
+ end
132
+ end
133
+
134
+ describe 'DELETE #destroy' do
135
+ subject { delete :destroy, id: organization.id }
136
+
137
+ it_behaves_like 'jpi v1 authorizable action'
138
+
139
+ context 'success' do
140
+ it 'deletes the organization' do
141
+ expect(organization).to receive(:destroy)
142
+ subject
143
+ end
144
+ end
145
+ end
146
+
147
+ # describe 'PUT #charge' do
148
+ # let(:organization) { build(:organization) }
149
+ # let(:user) { build(:user) }
150
+ # subject { put :charge, id: organization.id }
151
+ #
152
+ # context 'guest' do
153
+ # before { subject }
154
+ # it { expect(response.code).to eq("401") }
155
+ # end
156
+ #
157
+ # context 'unauthorized as guest' do
158
+ # before { sign_in user }
159
+ # before { subject }
160
+ # it { expect(response.code).to eq("401") }
161
+ # end
162
+ #
163
+ # context 'unauthorized as an admin' do
164
+ # let(:role) { 'Admin' }
165
+ # before { sign_in user }
166
+ # before { organization.add_user(user,role) }
167
+ # before { subject }
168
+ # it { expect(response.code).to eq("401") }
169
+ # end
170
+ #
171
+ # context 'when the user is authorized as a Super Admin' do
172
+ # let(:role) { 'Super Admin' }
173
+ # let(:payment) { build(:payment) }
174
+ # before { sign_in user }
175
+ # before { organization.add_user(user,role) }
176
+ # before { allow_any_instance_of(Organization).to receive(:charge).and_return(payment) }
177
+ #
178
+ # context 'with a successful payment' do
179
+ # before { subject }
180
+ # it 'returns "success" and the payment object' do
181
+ # expect(JSON.parse(response.body)['status']).to eq('success')
182
+ # expect(JSON.parse(response.body)['data'].to_json).to eq(payment.to_json)
183
+ # end
184
+ # end
185
+ #
186
+ # context 'with a failed payment' do
187
+ # before { payment.success = false; payment.save }
188
+ # before { subject }
189
+ # it 'returns "fail" and the payment object' do
190
+ # expect(JSON.parse(response.body)['status']).to eq('fail')
191
+ # expect(JSON.parse(response.body)['data'].to_json).to eq(payment.to_json)
192
+ # end
193
+ # end
194
+ #
195
+ # context 'with a fail in the charge function' do
196
+ # let(:payment) { nil }
197
+ # before { subject }
198
+ # it 'returns "error" and data is nil' do
199
+ # expect(JSON.parse(response.body)['status']).to eq('error')
200
+ # expect(JSON.parse(response.body)['data']).to eq(nil)
201
+ # end
202
+ # end
203
+ # end
204
+ # end
205
+
206
+ describe 'PUT #update_billing' do
207
+ let(:params) { attributes_for(:credit_card) }
208
+ subject { put :update_billing, id: organization.id, credit_card: params }
209
+
210
+ it_behaves_like "jpi v1 protected action"
211
+
212
+ context 'authorized' do
213
+ it 'updates the entity credit card' do
214
+ expect_any_instance_of(MnoEnterprise::CreditCard).to receive(:save).and_return(true)
215
+ subject
216
+ expect(organization.credit_card).to_not be_nil
217
+ end
218
+
219
+ it 'returns a partial representation of the entity' do
220
+ subject
221
+ expect(JSON.parse(response.body)).to eq(partial_hash_for_credit_card(organization.credit_card))
222
+ end
223
+ end
224
+ end
225
+
226
+ # describe 'PUT #invite_members' do
227
+ # let(:team) { build(:team, organization: organization) }
228
+ # let(:params) { [{email: 'newmember@maestrano.com', role: 'Power User', team_id: team.id}] }
229
+ # subject { put :invite_members, id: organization.id, invites: params }
230
+ #
231
+ # it_behaves_like "jpi v1 authorizable action"
232
+ #
233
+ # context 'success' do
234
+ # before { subject }
235
+ #
236
+ # it 'creates a new invite' do
237
+ # invite = organization.org_invites.first
238
+ # expect(invite.user_email).to eq(params.first[:email])
239
+ # expect(invite.user_role).to eq(params.first[:role])
240
+ # expect(invite.organization).to eq(organization)
241
+ # expect(invite.team).to eq(team)
242
+ # expect(invite.referrer).to eq(user)
243
+ # end
244
+ #
245
+ # it 'returns a partial representation of the entity' do
246
+ # organization.reload
247
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_members(organization))
248
+ # end
249
+ # end
250
+ # end
251
+
252
+ # describe 'PUT #update_member' do
253
+ # let(:user) { build(:user) }
254
+ # let(:organization) { build(:organization) }
255
+ # let(:params) { { email: 'somemember@maestrano.com', role: 'Admin'} }
256
+ # subject { put :update_member, id: organization.id, member: params }
257
+ #
258
+ # context 'guest' do
259
+ # before { subject }
260
+ # it { expect(response.code).to eq("401") }
261
+ # end
262
+ #
263
+ # context 'unauthorized as guest' do
264
+ # before { sign_in user }
265
+ # before { subject }
266
+ # it { expect(response.code).to eq("401") }
267
+ # end
268
+ #
269
+ # context 'unauthorized as member' do
270
+ # let(:role) { 'Power User' }
271
+ # before { sign_in user }
272
+ # before { organization.add_user(user,role) }
273
+ # before { subject }
274
+ # it { expect(response.code).to eq("401") }
275
+ # end
276
+ #
277
+ # context 'authorized with member' do
278
+ # let(:role) { 'Admin' }
279
+ # let(:member) { build(:user, email: params[:email]) }
280
+ # before { organization.add_user(user,role) }
281
+ # before { organization.add_user(member) }
282
+ # before { sign_in user }
283
+ # before { subject }
284
+ #
285
+ # it 'updates the member role' do
286
+ # member.reload
287
+ # expect(member.role(organization)).to eq(params[:role])
288
+ # end
289
+ #
290
+ # it 'returns a partial representation of the entity' do
291
+ # organization.reload
292
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_members(organization))
293
+ # end
294
+ # end
295
+ #
296
+ # context 'authorized with invite' do
297
+ # let(:role) { 'Admin' }
298
+ # let!(:member) { build(:org_invite, user_email: params[:email], organization: organization) }
299
+ # before { organization.add_user(user,role) }
300
+ # before { sign_in user }
301
+ # before { subject }
302
+ #
303
+ # it 'updates the member role' do
304
+ # member.reload
305
+ # expect(member.user_role).to eq(params[:role])
306
+ # end
307
+ #
308
+ # it 'returns a partial representation of the entity' do
309
+ # organization.reload
310
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_members(organization))
311
+ # end
312
+ # end
313
+ # end
314
+ #
315
+ # describe 'PUT #remove_member' do
316
+ # let(:user) { build(:user) }
317
+ # let(:organization) { build(:organization) }
318
+ # let(:params) { { email: 'somemember@maestrano.com', role: 'Admin'} }
319
+ # subject { put :remove_member, id: organization.id, member: params }
320
+ #
321
+ # context 'guest' do
322
+ # before { subject }
323
+ # it { expect(response.code).to eq("401") }
324
+ # end
325
+ #
326
+ # context 'unauthorized as guest' do
327
+ # before { sign_in user }
328
+ # before { subject }
329
+ # it { expect(response.code).to eq("401") }
330
+ # end
331
+ #
332
+ # context 'unauthorized as member' do
333
+ # let(:role) { 'Power User' }
334
+ # let!(:member) { build(:user, email: params[:email]) }
335
+ # before { sign_in user }
336
+ # before { organization.add_user(user,role) }
337
+ # before { subject }
338
+ # it { expect(response.code).to eq("401") }
339
+ # end
340
+ #
341
+ # context 'authorized - with member' do
342
+ # let(:role) { 'Admin' }
343
+ # let(:member) { build(:user, email: params[:email]) }
344
+ # before { organization.add_user(user,role) }
345
+ # before { organization.add_user(member) }
346
+ # before { sign_in user }
347
+ # before { subject }
348
+ #
349
+ # it 'remove the member' do
350
+ # member.reload
351
+ # expect(member.role(organization)).to be_nil
352
+ # end
353
+ #
354
+ # it 'returns a partial representation of the entity' do
355
+ # organization.reload
356
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_members(organization))
357
+ # end
358
+ # end
359
+ #
360
+ # context 'authorized - with invite' do
361
+ # let(:role) { 'Admin' }
362
+ # let!(:invite) { build(:org_invite, organization: organization, user_email: params[:email]) }
363
+ # before { organization.add_user(user,role) }
364
+ # before { sign_in user }
365
+ # before { subject }
366
+ #
367
+ # it 'remove the member' do
368
+ # invite.reload
369
+ # expect(invite).to be_expired
370
+ # end
371
+ #
372
+ # it 'returns a partial representation of the entity' do
373
+ # organization.reload
374
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_members(organization))
375
+ # end
376
+ # end
377
+ # end
378
+
379
+ # describe "PUT update_support_plan" do
380
+ # let(:user) { build(:user) }
381
+ # let(:organization) { build(:organization) }
382
+ #
383
+ # before { allow_any_instance_of(CreditCard).to receive(:save_to_gateway).and_return(true) }
384
+ # subject { put :update_support_plan, id: organization.id, support_plan:'concierge' }
385
+ #
386
+ # context 'guest' do
387
+ # before { subject }
388
+ # it { expect(response.code).to eq("401") }
389
+ # end
390
+ #
391
+ # context 'unauthorized as guest' do
392
+ # before { sign_in user }
393
+ # before { subject }
394
+ # it { expect(response.code).to eq("401") }
395
+ # end
396
+ #
397
+ # context 'unauthorized as member' do
398
+ # let(:role) { 'Admin' }
399
+ # before { sign_in user }
400
+ # before { organization.add_user(user,role) }
401
+ # before { subject }
402
+ # it { expect(response.code).to eq("401") }
403
+ # end
404
+ #
405
+ # context 'authorized' do
406
+ # let(:role) { 'Super Admin' }
407
+ # before { sign_in user }
408
+ # before { organization.add_user(user,role) }
409
+ # before { subject }
410
+ #
411
+ # it 'updates the entity support plan' do
412
+ # organization.reload
413
+ # expect(organization.current_support_plan).to eq('concierge')
414
+ # end
415
+ #
416
+ # it 'returns a partial representation of the entity' do
417
+ # organization.reload
418
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_organization(organization))
419
+ # end
420
+ # end
421
+ # end
422
+
423
+ # describe "POST training_session_req" do
424
+ # let(:user) { build(:user) }
425
+ # let(:organization) { build(:organization) }
426
+ #
427
+ # before { allow_any_instance_of(CreditCard).to receive(:save_to_gateway).and_return(true) }
428
+ # subject { post :training_session_req, id: organization.id, message: 'I would like to be trained on blabla' }
429
+ #
430
+ # context 'guest' do
431
+ # before { subject }
432
+ # it { expect(response.code).to eq("401") }
433
+ # end
434
+ #
435
+ # context 'unauthorized as guest' do
436
+ # before { sign_in user }
437
+ # before { subject }
438
+ # it { expect(response.code).to eq("401") }
439
+ # end
440
+ #
441
+ # context '#NO concierge support' do
442
+ # before { sign_in user }
443
+ # before { organization.add_user(user) }
444
+ # before { subject }
445
+ #
446
+ # it { expect(response.code).to eq("400") }
447
+ # end
448
+ #
449
+ # context 'authorized' do
450
+ # let(:now) { Time.new("2014-01-01") }
451
+ # before {
452
+ # Timecop.freeze(now) do
453
+ # organization.update_support_plan('concierge')
454
+ # end
455
+ # }
456
+ # before { sign_in user }
457
+ # before { organization.add_user(user) }
458
+ # let(:delay) { double(:delay) }
459
+ # before { PartnerMailer.stub(:delay).and_return(delay) }
460
+ #
461
+ # it "sends an email to the account manager with the customer's enquiry" do
462
+ # Timecop.freeze(now + 6.months) do
463
+ # expect(delay).to receive(:contact_partner).with({"message"=>"I would like to be trained on blabla", "first_name"=>user.name, "last_name"=>user.surname, "email"=>user.email})
464
+ # subject
465
+ # end
466
+ # end
467
+ #
468
+ # it "consume a custom training session credit" do
469
+ # delay.stub(:contact_partner).and_return(true)
470
+ # Timecop.freeze(now + 8.months) do
471
+ # subject
472
+ # expect(organization.support_plan.custom_training_credits).to eq(0)
473
+ # end
474
+ # end
475
+ #
476
+ # it 'returns a partial representation of the entity' do
477
+ # delay.stub(:contact_partner).and_return(true)
478
+ # Timecop.freeze(now + 6.months) do
479
+ # subject
480
+ # organization.reload
481
+ # expect(JSON.parse(response.body)).to eq(partial_hash_for_organization(organization))
482
+ # end
483
+ # end
484
+ # end
485
+ # end
486
+
487
+ # describe "PUT update_meta_data" do
488
+ # let(:user) { build(:user) }
489
+ # let(:organization) { build(:organization) }
490
+ # subject { put :update_meta_data, name:'field_example', value:'test', id: organization.id }
491
+ #
492
+ # context "when organization has update rights" do
493
+ # let(:role) { 'Super Admin' }
494
+ # before { sign_in user }
495
+ # before { organization.add_user(user,role) }
496
+ #
497
+ # it { expect(subject).to be_success }
498
+ #
499
+ # it "calls put_meta_data with the rights args" do
500
+ # Organization.any_instance.should_receive(:put_meta_data).with('field_example','test')
501
+ # subject
502
+ # end
503
+ # end
504
+ #
505
+ # context "when user is not logged in" do
506
+ # before { sign_in user }
507
+ # before { organization.add_user(user) }
508
+ #
509
+ # it "is not successful" do
510
+ # expect(subject).to_not be_success
511
+ # end
512
+ # end
513
+ # end
514
+
515
+ end
516
+ end