mno-enterprise-api 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +8 -0
- data/app/controllers/mno_enterprise/admin/invoices_controller.rb +18 -0
- data/app/controllers/mno_enterprise/impersonate_controller.rb +5 -1
- data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +9 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +10 -4
- data/app/controllers/mno_enterprise/jpi/v1/audit_events_controller.rb +28 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +1 -1
- data/app/controllers/mno_enterprise/webhook/events_controller.rb +7 -0
- data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +26 -25
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.csv.erb +14 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/audit_events/_audit_event.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/audit_events/index.csv.erb +12 -0
- data/app/views/mno_enterprise/jpi/v1/audit_events/index.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +3 -1
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +10 -1
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +1 -1
- data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +1 -1
- data/config/routes.rb +16 -5
- data/lib/mno_enterprise/audit_events_listener.rb +11 -6
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +6 -1
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +9 -10
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb +6 -3
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +20 -8
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +12 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb +13 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +2 -0
- data/lib/mno_enterprise/concerns/controllers/webhook/events_controller.rb +22 -0
- data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +12 -3
- data/lib/mno_enterprise/event_logger.rb +2 -2
- data/lib/mno_enterprise/intercom_events_listener.rb +25 -30
- data/spec/controllers/mno_enterprise/admin/invoices_controller_spec.rb +38 -0
- data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +6 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +9 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +3 -2
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +2 -1
- data/spec/controllers/mno_enterprise/jpi/v1/audit_events_controller_spec.rb +49 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +16 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +124 -89
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +83 -36
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +18 -3
- data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +3 -3
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +2 -2
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
- data/spec/lib/mno_enterprise/audit_events_listener_spec.rb +11 -0
- data/spec/lib/mno_enterprise/intercom_events_listener_spec.rb +74 -31
- data/spec/routing/devise/registrations_routing_spec.rb +43 -6
- data/spec/routing/mno_enterprise/admin/invoices_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb +30 -4
- data/spec/routing/mno_enterprise/jpi/v1/audit_events_controller_routing_spec.rb +11 -0
- metadata +20 -4
@@ -53,6 +53,15 @@ module MnoEnterprise
|
|
53
53
|
#===============================================
|
54
54
|
# Specs
|
55
55
|
#===============================================
|
56
|
+
shared_examples "an organization management action" do
|
57
|
+
context 'when Organization management is disabled' do
|
58
|
+
before { Settings.merge!(organization_management: {enabled: false}) }
|
59
|
+
after { Settings.reload! }
|
60
|
+
|
61
|
+
it { is_expected.to have_http_status(:forbidden) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
describe 'GET #index' do
|
57
66
|
subject { get :index }
|
58
67
|
|
@@ -97,6 +106,7 @@ module MnoEnterprise
|
|
97
106
|
subject { post :create, organization: params }
|
98
107
|
|
99
108
|
it_behaves_like "jpi v1 protected action"
|
109
|
+
it_behaves_like "an organization management action"
|
100
110
|
|
101
111
|
context 'success' do
|
102
112
|
before { subject }
|
@@ -120,6 +130,7 @@ module MnoEnterprise
|
|
120
130
|
subject { put :update, id: organization.id, organization: params }
|
121
131
|
|
122
132
|
it_behaves_like "jpi v1 authorizable action"
|
133
|
+
it_behaves_like "an organization management action"
|
123
134
|
|
124
135
|
context 'success' do
|
125
136
|
it 'updates the organization' do
|
@@ -140,6 +151,7 @@ module MnoEnterprise
|
|
140
151
|
subject { delete :destroy, id: organization.id }
|
141
152
|
|
142
153
|
it_behaves_like 'jpi v1 authorizable action'
|
154
|
+
it_behaves_like 'an organization management action'
|
143
155
|
|
144
156
|
context 'success' do
|
145
157
|
it 'deletes the organization' do
|
@@ -213,6 +225,7 @@ module MnoEnterprise
|
|
213
225
|
subject { put :update_billing, id: organization.id, credit_card: params }
|
214
226
|
|
215
227
|
it_behaves_like "jpi v1 protected action"
|
228
|
+
it_behaves_like "an organization management action"
|
216
229
|
|
217
230
|
context 'authorized' do
|
218
231
|
it 'updates the entity credit card' do
|
@@ -232,7 +245,7 @@ module MnoEnterprise
|
|
232
245
|
let(:mastercard) { '5105105105105100' }
|
233
246
|
|
234
247
|
context 'with a valid type' do
|
235
|
-
before { params
|
248
|
+
before { params[:number] = visa }
|
236
249
|
it 'updates the entity credit card' do
|
237
250
|
expect_any_instance_of(MnoEnterprise::CreditCard).to receive(:save).and_return(true)
|
238
251
|
subject
|
@@ -247,7 +260,7 @@ module MnoEnterprise
|
|
247
260
|
end
|
248
261
|
|
249
262
|
context 'with an invalid type' do
|
250
|
-
before { params
|
263
|
+
before { params[:number] = mastercard }
|
251
264
|
it 'does not the entity credit card' do
|
252
265
|
expect_any_instance_of(MnoEnterprise::CreditCard).not_to receive(:save)
|
253
266
|
subject
|
@@ -272,6 +285,7 @@ module MnoEnterprise
|
|
272
285
|
subject { put :invite_members, id: organization.id, invites: params }
|
273
286
|
|
274
287
|
it_behaves_like "jpi v1 authorizable action"
|
288
|
+
it_behaves_like "an organization management action"
|
275
289
|
|
276
290
|
context 'succcess' do
|
277
291
|
let(:relation) { instance_double('Her::Model::Relation') }
|
@@ -317,6 +331,7 @@ module MnoEnterprise
|
|
317
331
|
subject { put :update_member, id: organization.id, member: params }
|
318
332
|
|
319
333
|
it_behaves_like "jpi v1 authorizable action"
|
334
|
+
it_behaves_like "an organization management action"
|
320
335
|
|
321
336
|
context 'with user' do
|
322
337
|
let(:member) { build(:user) }
|
@@ -425,7 +440,7 @@ module MnoEnterprise
|
|
425
440
|
subject { put :remove_member, id: organization.id, member: params }
|
426
441
|
|
427
442
|
it_behaves_like "jpi v1 authorizable action"
|
428
|
-
|
443
|
+
it_behaves_like "an organization management action"
|
429
444
|
|
430
445
|
context 'with user' do
|
431
446
|
let(:params) { { email: user.email } }
|
@@ -25,9 +25,9 @@ module MnoEnterprise
|
|
25
25
|
describe "GET #show" do
|
26
26
|
subject { get :show, id: invite.id, token: token}
|
27
27
|
|
28
|
-
let(:success_fragment) { "
|
29
|
-
let(:expired_fragment) { "
|
30
|
-
let(:invalid_fragment) { "
|
28
|
+
let(:success_fragment) { "#!?dhbRefId=#{invite.organization.id}&#{URI.encode_www_form([['flash', {msg: "You are now part of #{invite.organization.name}", type: :success}.to_json]])}" }
|
29
|
+
let(:expired_fragment) { "#!?#{URI.encode_www_form([['flash', {msg: "It looks like this invite has expired. Please ask your company administrator to resend the invite.", type: :error}.to_json]])}" }
|
30
|
+
let(:invalid_fragment) { "#!?#{URI.encode_www_form([['flash', {msg: "Unfortunately, this invite does not seem to be valid.", type: :error}.to_json]])}" }
|
31
31
|
|
32
32
|
context 'when not signed in' do
|
33
33
|
it { expect(subject).not_to be_success }
|
@@ -57,7 +57,7 @@ module MnoEnterprise
|
|
57
57
|
describe "unauthorized" do
|
58
58
|
let(:authorized) { false }
|
59
59
|
|
60
|
-
let(:error_fragment) { "
|
60
|
+
let(:error_fragment) { "#!?#{URI.encode_www_form([['flash', {msg: "Unfortunately you do not have permission to purchase products for this organization", type: :error}.to_json]])}" }
|
61
61
|
|
62
62
|
it 'redirect to the dashboard with an error message' do
|
63
63
|
expect(response).to redirect_to(mnoe_home_path + error_fragment)
|
@@ -89,7 +89,7 @@ module MnoEnterprise
|
|
89
89
|
|
90
90
|
context 'with one organization available' do
|
91
91
|
let(:organizations) { [organization] }
|
92
|
-
let(:error_fragment) { "
|
92
|
+
let(:error_fragment) { "#!?#{URI.encode_www_form([['flash', {msg: "Unfortunately you do not have permission to purchase products for this organization", type: :error}.to_json]])}" }
|
93
93
|
|
94
94
|
it 'redirect to the dashboard with an error message' do
|
95
95
|
expect(response).to redirect_to(mnoe_home_path + error_fragment)
|
@@ -64,7 +64,7 @@ module MnoEnterprise
|
|
64
64
|
context 'when there is on oauth error' do
|
65
65
|
subject { get :callback, id: app_instance.uid, oauth: {error: :unauthorized} }
|
66
66
|
|
67
|
-
let(:fragment) { "
|
67
|
+
let(:fragment) { "#!?#{URI.encode_www_form([['flash', {msg: 'We could not validate your credentials, please try again', type: :error}.to_json]])}" }
|
68
68
|
|
69
69
|
it { subject; expect(response).to redirect_to(MnoEnterprise.router.dashboard_path + fragment) }
|
70
70
|
end
|
@@ -17,12 +17,23 @@ module MnoEnterprise
|
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:user) { build(:user) }
|
20
|
+
let(:organization) { build(:organization) }
|
20
21
|
|
21
22
|
describe '#info' do
|
22
23
|
subject { MnoEnterprise::AuditEventsListener.new.info('user_update_password', user.id, 'User password change', user.class.name, user.id, user.email) }
|
23
24
|
|
24
25
|
it { expect(subject.code).to eq(200) }
|
25
26
|
it { expect(subject.request.options[:body]).to eq(info_data(user)) }
|
27
|
+
|
28
|
+
context 'with an organization_id in the metadata' do
|
29
|
+
subject { MnoEnterprise::AuditEventsListener.new.info('user_update_password', user.id, 'User password change', user.class.name, user.id, {organization_id: 'foobar'}) }
|
30
|
+
it { expect(subject.request.options[:body][:data][:organization_id]).to eq('foobar') }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'with an Organization subject' do
|
34
|
+
subject { MnoEnterprise::AuditEventsListener.new.info('app_launch', user.id, 'App Launched', organization.class.name, organization.id, nil) }
|
35
|
+
it { expect(subject.request.options[:body][:data][:organization_id]).to eq(organization.id) }
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
28
39
|
end
|
@@ -4,12 +4,15 @@ module MnoEnterprise
|
|
4
4
|
RSpec.describe IntercomEventsListener do
|
5
5
|
let(:app) { build(:app) }
|
6
6
|
let(:app_instance) { build(:app_instance, app: app, organization_id: organization.id) }
|
7
|
-
let(:user) { build(:user) }
|
7
|
+
let(:user) { build(:user).tap {|u| u.extend(MnoEnterprise::Concerns::Models::IntercomUser)} }
|
8
|
+
let(:credit_card) { build(:credit_card) }
|
8
9
|
let(:organization) { build(:organization) }
|
9
10
|
before do
|
10
11
|
api_stub_for(get: "/users/#{user.id}", response: from_api(user))
|
11
12
|
api_stub_for(get: "/users/#{user.id}/organizations", response: from_api([organization]))
|
12
13
|
api_stub_for(get: "/organizations/#{organization.id}/app_instances", response: from_api([app_instance]))
|
14
|
+
api_stub_for(get: "/organizations/#{organization.id}/credit_card", response: from_api(credit_card))
|
15
|
+
api_stub_for(get: "/organizations/#{organization.id}/users", response: from_api([user]))
|
13
16
|
end
|
14
17
|
|
15
18
|
# Stub Intercom client
|
@@ -28,7 +31,13 @@ module MnoEnterprise
|
|
28
31
|
email: user.email,
|
29
32
|
created_at: user.created_at.to_i,
|
30
33
|
last_seen_ip: user.last_sign_in_ip,
|
31
|
-
custom_attributes: {
|
34
|
+
custom_attributes: {
|
35
|
+
first_name: user.name,
|
36
|
+
surname: user.surname,
|
37
|
+
confirmed_at: user.confirmed_at,
|
38
|
+
phone: user.phone,
|
39
|
+
admin_role: user.admin_role
|
40
|
+
},
|
32
41
|
update_last_request_at: true,
|
33
42
|
companies:[
|
34
43
|
{
|
@@ -38,9 +47,11 @@ module MnoEnterprise
|
|
38
47
|
custom_attributes: {
|
39
48
|
industry: organization.industry,
|
40
49
|
size: organization.size,
|
41
|
-
credit_card_details: organization.
|
50
|
+
credit_card_details: organization.has_credit_card_details?,
|
51
|
+
credit_card_expiry: organization.credit_card.expiry_date,
|
42
52
|
app_count: organization.app_instances.count,
|
43
|
-
app_list: organization.app_instances.map { |app| app.name }.to_sentence
|
53
|
+
app_list: organization.app_instances.map { |app| app.name }.to_sentence,
|
54
|
+
user_count: 1
|
44
55
|
}
|
45
56
|
}
|
46
57
|
]
|
@@ -48,36 +59,27 @@ module MnoEnterprise
|
|
48
59
|
}
|
49
60
|
|
50
61
|
describe '#info' do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
expect(events).to receive(:create).with(hash_including(email: user.email, user_id: user.id, event_name: 'user-update-password'))
|
57
|
-
subject.info('user_update_password', user.id, 'User password change', user.class.name, user.id, user.email)
|
58
|
-
end
|
62
|
+
before do
|
63
|
+
allow(MnoEnterprise::User).to receive(:find).and_return(user)
|
64
|
+
# It refreshes the user
|
65
|
+
expect(users).to receive(:create).with(expected_user_data)
|
66
|
+
end
|
59
67
|
|
60
|
-
|
61
|
-
expect(events).to receive(:create).with(hash_including(email: user.email, user_id: user.id, event_name: 'added-app-' + app.nid, metadata: {type: 'single', app_list: app.nid}))
|
62
|
-
subject.info('app_add', user.id, 'App Added', app_instance.class.name, app_instance.id, {name: app_instance.name, app_nid: app_instance.app.nid} )
|
63
|
-
end
|
68
|
+
subject { described_class.new }
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
it 'add an event when a password is changed' do
|
71
|
+
expect(events).to receive(:create).with(hash_including(email: user.email, user_id: user.id, event_name: 'user-update-password'))
|
72
|
+
subject.info('user_update_password', user.id, 'User password change', user.class.name, user.id, user.email)
|
73
|
+
end
|
69
74
|
|
75
|
+
it 'add an event when an app is added' do
|
76
|
+
expect(events).to receive(:create).with(hash_including(email: user.email, user_id: user.id, event_name: 'added-app-' + app.nid, metadata: {type: 'single', app_list: app.nid}))
|
77
|
+
subject.info('app_add', user.id, 'App Added', app_instance.class.name, app_instance.id, {name: app_instance.name, app_nid: app_instance.app.nid} )
|
70
78
|
end
|
71
|
-
context 'when the user does not exist in intercom' do
|
72
|
-
before do
|
73
|
-
allow(users).to receive(:find).and_raise(Intercom::ResourceNotFound.new('not found'))
|
74
|
-
expect(users).to receive(:create).with(expected_user_data)
|
75
|
-
end
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
80
|
+
it 'add an event when an app is launched' do
|
81
|
+
expect(events).to receive(:create).with(hash_including(email: user.email, user_id: user.id, event_name: 'launched-app-' + app.nid))
|
82
|
+
subject.info('app_launch', user.id, 'App Launched', app_instance.class.name, app_instance.id, {name: app_instance.name, app_nid: app_instance.app.nid} )
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -91,9 +93,11 @@ module MnoEnterprise
|
|
91
93
|
end
|
92
94
|
|
93
95
|
context 'when the user has an external_id' do
|
94
|
-
before { user.external_id = '
|
96
|
+
before { user.external_id = '123456' }
|
95
97
|
it 'updates the user' do
|
96
|
-
expect(users).to receive(:create)
|
98
|
+
expect(users).to receive(:create) do |options|
|
99
|
+
expect(options[:custom_attributes][:external_id]).to eq('123456')
|
100
|
+
end
|
97
101
|
subject
|
98
102
|
end
|
99
103
|
end
|
@@ -106,5 +110,44 @@ module MnoEnterprise
|
|
106
110
|
end
|
107
111
|
end
|
108
112
|
end
|
113
|
+
|
114
|
+
# TODO: a bit redundant with the full hash above
|
115
|
+
# To be refactored when extracting to a service
|
116
|
+
describe '#format_company' do
|
117
|
+
let(:organization) do
|
118
|
+
MnoEnterprise::Organization.new(attributes_for(:organization)).tap do |o|
|
119
|
+
o.credit_card = credit_card
|
120
|
+
o.app_instances = [build(:app_instance, name: 'Xero'), build(:app_instance, name: 'Shopify')]
|
121
|
+
o.users = [build(:user)]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
let(:intercom_data) { subject.format_company(organization) }
|
126
|
+
let(:custom_attributes) { intercom_data[:custom_attributes] }
|
127
|
+
|
128
|
+
it { expect(intercom_data[:company_id]).to eq(organization.id) }
|
129
|
+
it { expect(intercom_data[:created_at]).to eq(organization.created_at.to_i) }
|
130
|
+
it { expect(intercom_data[:name]).to eq(organization.name) }
|
131
|
+
|
132
|
+
it { expect(custom_attributes[:app_count]).to eq(2) }
|
133
|
+
it { expect(custom_attributes[:app_list]).to eq("Shopify and Xero") }
|
134
|
+
it { expect(custom_attributes[:user_count]).to eq(1) }
|
135
|
+
|
136
|
+
context 'with a credit card' do
|
137
|
+
it 'does not return CC data' do
|
138
|
+
expect(custom_attributes[:credit_card_details]).to be true
|
139
|
+
expect(custom_attributes[:credit_card_expiry]).to be_a Date
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'without a credit card' do
|
144
|
+
let(:credit_card) { MnoEnterprise::CreditCard.new }
|
145
|
+
|
146
|
+
it 'does not return CC data' do
|
147
|
+
expect(custom_attributes[:credit_card_details]).to be false
|
148
|
+
expect(custom_attributes[:credit_card_expiry]).to be nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
109
152
|
end
|
110
153
|
end
|
@@ -3,13 +3,50 @@ require 'rails_helper'
|
|
3
3
|
module MnoEnterprise
|
4
4
|
RSpec.describe Devise::RegistrationsController, type: :routing do
|
5
5
|
routes { MnoEnterprise::Engine.routes }
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
context 'it is enabled by default' do
|
8
|
+
before(:all) do
|
9
|
+
Settings.devise = {}
|
10
|
+
Rails.application.reload_routes!
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'routes to #new' do
|
14
|
+
expect(get('/auth/users/sign_up')).to route_to("mno_enterprise/auth/registrations#new")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'routes to #create' do
|
18
|
+
expect(post('/auth/users')).to route_to("mno_enterprise/auth/registrations#create")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when registration is enabled' do
|
23
|
+
before(:all) do
|
24
|
+
Settings.merge!(devise: {registration: {disabled: false}})
|
25
|
+
Rails.application.reload_routes!
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'routes to #new' do
|
29
|
+
expect(get('/auth/users/sign_up')).to route_to("mno_enterprise/auth/registrations#new")
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'routes to #create' do
|
33
|
+
expect(post('/auth/users')).to route_to("mno_enterprise/auth/registrations#create")
|
34
|
+
end
|
9
35
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
36
|
+
|
37
|
+
context 'when registration is disabled' do
|
38
|
+
before(:all) do
|
39
|
+
Settings.merge!(devise: {registration: {disabled: true}})
|
40
|
+
Rails.application.reload_routes!
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'does not route to #new' do
|
44
|
+
expect(get('/auth/users/sign_up')).not_to be_routable
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not route to #create' do
|
48
|
+
expect(post('/auth/users')).not_to be_routable
|
49
|
+
end
|
13
50
|
end
|
14
51
|
end
|
15
52
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
RSpec.describe Admin::InvoicesController, type: :routing do
|
5
|
+
routes { MnoEnterprise::Engine.routes }
|
6
|
+
|
7
|
+
it "routes to #show" do
|
8
|
+
expect(get("/admin/invoices/201504-NU4")).to route_to("mno_enterprise/admin/invoices#show", id: '201504-NU4')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -4,12 +4,38 @@ module MnoEnterprise
|
|
4
4
|
RSpec.describe ImpersonateController, type: :routing do
|
5
5
|
routes { MnoEnterprise::Engine.routes }
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
context "Impersonation is enabled" do
|
8
|
+
before(:all) do
|
9
|
+
Settings.merge!(admin_panel: {impersonation: {disabled: false}})
|
10
|
+
Rails.application.reload_routes!
|
11
|
+
end
|
12
|
+
|
13
|
+
it "routes to #create" do
|
14
|
+
expect(get("/impersonate/user/1")).to route_to("mno_enterprise/impersonate#create", user_id: '1')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "routes to #destroy" do
|
18
|
+
expect(get("/impersonate/revert")).to route_to("mno_enterprise/impersonate#destroy")
|
19
|
+
end
|
9
20
|
end
|
10
21
|
|
11
|
-
|
12
|
-
|
22
|
+
context "Impersonation is disabled" do
|
23
|
+
before(:all) do
|
24
|
+
Settings.merge!(admin_panel: {impersonation: {disabled: true}})
|
25
|
+
Rails.application.reload_routes!
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'loads regular routes' do
|
29
|
+
expect(get('/ping')).to route_to('mno_enterprise/status#ping')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "does not route to #create" do
|
33
|
+
expect(get("/impersonate/user/1")).not_to be_routable
|
34
|
+
end
|
35
|
+
|
36
|
+
it "does not route to #destroy" do
|
37
|
+
expect(get("/impersonate/revert")).not_to be_routable
|
38
|
+
end
|
13
39
|
end
|
14
40
|
end
|
15
41
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
RSpec.describe Jpi::V1::AuditEventsController, type: :routing do
|
5
|
+
routes { MnoEnterprise::Engine.routes }
|
6
|
+
|
7
|
+
it 'routes to #index' do
|
8
|
+
expect(get('/jpi/v1/organizations/1/audit_events')).to route_to('mno_enterprise/jpi/v1/audit_events#index', organization_id: '1')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mno-enterprise-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mno-enterprise-core
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 3.
|
20
|
+
version: 3.3.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 3.
|
27
|
+
version: 3.3.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: jbuilder
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- app/assets/javascripts/mno_enterprise/application.js
|
207
207
|
- app/assets/javascripts/mno_enterprise/config.js.coffee.erb
|
208
208
|
- app/controllers/devise/password_expired_controller.rb
|
209
|
+
- app/controllers/mno_enterprise/admin/invoices_controller.rb
|
209
210
|
- app/controllers/mno_enterprise/auth/confirmations_controller.rb
|
210
211
|
- app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb
|
211
212
|
- app/controllers/mno_enterprise/auth/passwords_controller.rb
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb
|
235
236
|
- app/controllers/mno_enterprise/jpi/v1/app_questions_controller.rb
|
236
237
|
- app/controllers/mno_enterprise/jpi/v1/app_reviews_controller.rb
|
238
|
+
- app/controllers/mno_enterprise/jpi/v1/audit_events_controller.rb
|
237
239
|
- app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb
|
238
240
|
- app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb
|
239
241
|
- app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb
|
@@ -248,6 +250,7 @@ files:
|
|
248
250
|
- app/controllers/mno_enterprise/pages_controller.rb
|
249
251
|
- app/controllers/mno_enterprise/provision_controller.rb
|
250
252
|
- app/controllers/mno_enterprise/status_controller.rb
|
253
|
+
- app/controllers/mno_enterprise/webhook/events_controller.rb
|
251
254
|
- app/controllers/mno_enterprise/webhook/o_auth_controller.rb
|
252
255
|
- app/jobs/mno_enterprise/event_logger_job.rb
|
253
256
|
- app/mailers/mno_enterprise/system_notification_mailer.rb
|
@@ -277,6 +280,7 @@ files:
|
|
277
280
|
- app/views/mno_enterprise/jpi/v1/admin/app_reviews/index.json.jbuilder
|
278
281
|
- app/views/mno_enterprise/jpi/v1/admin/app_reviews/show.json.jbuilder
|
279
282
|
- app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder
|
283
|
+
- app/views/mno_enterprise/jpi/v1/admin/audit_events/index.csv.erb
|
280
284
|
- app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder
|
281
285
|
- app/views/mno_enterprise/jpi/v1/admin/base_resource/_member.json.jbuilder
|
282
286
|
- app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder
|
@@ -318,6 +322,9 @@ files:
|
|
318
322
|
- app/views/mno_enterprise/jpi/v1/app_reviews/_resource.json.jbuilder
|
319
323
|
- app/views/mno_enterprise/jpi/v1/app_reviews/index.json.jbuilder
|
320
324
|
- app/views/mno_enterprise/jpi/v1/app_reviews/show.json.jbuilder
|
325
|
+
- app/views/mno_enterprise/jpi/v1/audit_events/_audit_event.json.jbuilder
|
326
|
+
- app/views/mno_enterprise/jpi/v1/audit_events/index.csv.erb
|
327
|
+
- app/views/mno_enterprise/jpi/v1/audit_events/index.json.jbuilder
|
321
328
|
- app/views/mno_enterprise/jpi/v1/base_resource/_app_review.json.jbuilder
|
322
329
|
- app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder
|
323
330
|
- app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder
|
@@ -390,11 +397,13 @@ files:
|
|
390
397
|
- lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
|
391
398
|
- lib/mno_enterprise/concerns/controllers/pages_controller.rb
|
392
399
|
- lib/mno_enterprise/concerns/controllers/provision_controller.rb
|
400
|
+
- lib/mno_enterprise/concerns/controllers/webhook/events_controller.rb
|
393
401
|
- lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb
|
394
402
|
- lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb
|
395
403
|
- lib/mno_enterprise/event_logger.rb
|
396
404
|
- lib/mno_enterprise/intercom_events_listener.rb
|
397
405
|
- lib/tasks/non_digested_assets.rake
|
406
|
+
- spec/controllers/mno_enterprise/admin/invoices_controller_spec.rb
|
398
407
|
- spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb
|
399
408
|
- spec/controllers/mno_enterprise/auth/omniauth_callback_controller_spec.rb
|
400
409
|
- spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb
|
@@ -417,6 +426,7 @@ files:
|
|
417
426
|
- spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb
|
418
427
|
- spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb
|
419
428
|
- spec/controllers/mno_enterprise/jpi/v1/app_reviews_controller_spec.rb
|
429
|
+
- spec/controllers/mno_enterprise/jpi/v1/audit_events_controller_spec.rb
|
420
430
|
- spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb
|
421
431
|
- spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb
|
422
432
|
- spec/controllers/mno_enterprise/jpi/v1/impac/alerts_controller_spec.rb
|
@@ -441,6 +451,7 @@ files:
|
|
441
451
|
- spec/routing/devise/passwords_routing_spec.rb
|
442
452
|
- spec/routing/devise/registrations_routing_spec.rb
|
443
453
|
- spec/routing/devise/sessions_routing_spec.rb
|
454
|
+
- spec/routing/mno_enterprise/admin/invoices_controller_routing_spec.rb
|
444
455
|
- spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb
|
445
456
|
- spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
|
446
457
|
- spec/routing/mno_enterprise/jpi/v1/admin/app_instances_controller_routing_spec.rb
|
@@ -456,6 +467,7 @@ files:
|
|
456
467
|
- spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb
|
457
468
|
- spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb
|
458
469
|
- spec/routing/mno_enterprise/jpi/v1/app_reviews_controller_routing_spec.rb
|
470
|
+
- spec/routing/mno_enterprise/jpi/v1/audit_events_controller_routing_spec.rb
|
459
471
|
- spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb
|
460
472
|
- spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb
|
461
473
|
- spec/routing/mno_enterprise/jpi/v1/impac/alerts_controller_routing_spec.rb
|
@@ -496,6 +508,7 @@ signing_key:
|
|
496
508
|
specification_version: 4
|
497
509
|
summary: Maestrano Enterprise - API
|
498
510
|
test_files:
|
511
|
+
- spec/routing/mno_enterprise/admin/invoices_controller_routing_spec.rb
|
499
512
|
- spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
|
500
513
|
- spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb
|
501
514
|
- spec/routing/mno_enterprise/provision_controller_routing_spec.rb
|
@@ -518,6 +531,7 @@ test_files:
|
|
518
531
|
- spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb
|
519
532
|
- spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb
|
520
533
|
- spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb
|
534
|
+
- spec/routing/mno_enterprise/jpi/v1/audit_events_controller_routing_spec.rb
|
521
535
|
- spec/routing/mno_enterprise/jpi/v1/impac/widgets_controller_routing_spec.rb
|
522
536
|
- spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb
|
523
537
|
- spec/routing/mno_enterprise/jpi/v1/impac/alerts_controller_routing_spec.rb
|
@@ -536,6 +550,7 @@ test_files:
|
|
536
550
|
- spec/lib/mno_enterprise/audit_events_listener_spec.rb
|
537
551
|
- spec/lib/mno_enterprise/intercom_events_listener_spec.rb
|
538
552
|
- spec/rails_helper.rb
|
553
|
+
- spec/controllers/mno_enterprise/admin/invoices_controller_spec.rb
|
539
554
|
- spec/controllers/mno_enterprise/pages_controller_spec.rb
|
540
555
|
- spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb
|
541
556
|
- spec/controllers/mno_enterprise/impersonate_controller_spec.rb
|
@@ -557,6 +572,7 @@ test_files:
|
|
557
572
|
- spec/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller_spec.rb
|
558
573
|
- spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb
|
559
574
|
- spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb
|
575
|
+
- spec/controllers/mno_enterprise/jpi/v1/audit_events_controller_spec.rb
|
560
576
|
- spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb
|
561
577
|
- spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb
|
562
578
|
- spec/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller_spec.rb
|