mno-enterprise-api 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +7 -1
- data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +3 -27
- data/app/controllers/mno_enterprise/auth/sessions_controller.rb +1 -3
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller.rb +26 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller.rb +28 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller.rb +16 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller.rb +30 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/invites_controller.rb +1 -1
- data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +55 -37
- data/app/controllers/mno_enterprise/jpi/v1/app_answers_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_comments_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller.rb +14 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +1 -20
- data/app/controllers/mno_enterprise/jpi/v1/app_questions_controller.rb +25 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_reviews_controller.rb +94 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +12 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/alerts_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +1 -76
- data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +1 -18
- data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +1 -83
- data/app/jobs/mno_enterprise/event_logger_job.rb +10 -0
- data/app/views/mno_enterprise/auth/confirmations/new.html.haml +6 -6
- data/app/views/mno_enterprise/auth/passwords/new.html.haml +8 -8
- data/app/views/mno_enterprise/auth/registrations/new.html.haml +1 -0
- data/app/views/mno_enterprise/auth/sessions/new.html.haml +1 -0
- data/app/views/mno_enterprise/auth/shared/_links.html.haml +0 -5
- data/app/views/mno_enterprise/auth/shared/_omniauth.html.haml +10 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_answers/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_comments/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/_app_review.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/app_answers/_resource.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/app_answers/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_answers/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/_resource.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_comment.json.jbuilder +10 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_resource.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/show.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/_answer.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/_resource.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/_resource.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/show.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/base_resource/_app_review.json.jbuilder +17 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +9 -1
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/_alert.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +8 -3
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +4 -1
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/index.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +1 -2
- data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +3 -2
- data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +2 -2
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +2 -2
- data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +11 -5
- data/app/views/mno_enterprise/pages/terms.html.haml +219 -0
- data/app/views/mno_enterprise/provision/_select_organization.html.haml +6 -2
- data/config/initializers/devise.rb +31 -9
- data/config/initializers/devise_log.rb +4 -4
- data/config/routes.rb +41 -6
- data/lib/mno_enterprise/api.rb +1 -0
- data/lib/mno_enterprise/audit_events_listener.rb +28 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb +45 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +14 -4
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/alerts_controller.rb +76 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +49 -23
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +167 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb +33 -17
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +32 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +68 -28
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb +92 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +17 -3
- data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +17 -2
- data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +27 -3
- data/lib/mno_enterprise/event_logger.rb +34 -16
- data/lib/mno_enterprise/intercom_events_listener.rb +96 -0
- data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +28 -0
- data/spec/controllers/mno_enterprise/auth/omniauth_callback_controller_spec.rb +34 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller_spec.rb +45 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller_spec.rb +45 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller_spec.rb +31 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller_spec.rb +103 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +4 -15
- data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +12 -3
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invites_controller_spec.rb +4 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +15 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +17 -1
- data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +5 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +30 -16
- data/spec/controllers/mno_enterprise/jpi/v1/app_answers_controller_spec.rb +74 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_comments_controller_spec.rb +74 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller_spec.rb +84 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +36 -22
- data/spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb +80 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_reviews_controller_spec.rb +107 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +16 -1
- data/spec/controllers/mno_enterprise/jpi/v1/impac/alerts_controller_spec.rb +82 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +147 -10
- data/spec/controllers/mno_enterprise/jpi/v1/impac/widgets_controller_spec.rb +39 -0
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +19 -26
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +248 -303
- data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +4 -1
- data/spec/controllers/mno_enterprise/pages_controller_spec.rb +21 -0
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +65 -22
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
- data/spec/jobs/mno_enterprise/event_logger_job_spec.rb +11 -0
- data/spec/lib/mno_enterprise/audit_events_listener_spec.rb +28 -0
- data/spec/lib/mno_enterprise/intercom_events_listener_spec.rb +110 -0
- data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +81 -46
- data/spec/routing/mno_enterprise/jpi/v1/admin/app_instances_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/app_reviews_controller_routing_spec.rb +19 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +9 -2
- data/spec/routing/mno_enterprise/jpi/v1/app_reviews_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +5 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/alerts_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/dashboards_controller_routing_spec.rb +28 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +17 -11
- data/spec/routing/mno_enterprise/jpi/v1/impac/widgets_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +2 -2
- data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +4 -0
- metadata +178 -9
- data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +0 -25
- data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +0 -93
- data/spec/lib/mno_enterprise/event_logger_spec.rb +0 -28
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
describe Jpi::V1::Admin::AppAnswersController, 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
|
+
|
11
|
+
#===============================================
|
12
|
+
# Assignments
|
13
|
+
#===============================================
|
14
|
+
let(:user) { build(:user, :admin, :with_organizations) }
|
15
|
+
let(:organization) { user.organizations.first }
|
16
|
+
let(:question) { build(:app_question) }
|
17
|
+
|
18
|
+
before { api_stub_for(get: "/organization/#{organization.id}", response: from_api(organization)) }
|
19
|
+
before { api_stub_for(get: "/users/#{user.id}/organizations", response: from_api([organization])) }
|
20
|
+
before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
|
21
|
+
before { api_stub_for(get: "/app_questions/#{question.id}", response: from_api(question)) }
|
22
|
+
before { sign_in user }
|
23
|
+
|
24
|
+
let(:answer_1) { build(:app_answer, question_id: 'qid') }
|
25
|
+
let(:expected_hash_for_answer_1) do
|
26
|
+
attrs = %w(id description status user_id user_name organization_id organization_name app_id question_id app_name)
|
27
|
+
answer_1.attributes.slice(*attrs).merge({'type' => 'Answer', 'created_at' => answer_1.created_at.as_json, 'updated_at' => answer_1.updated_at.as_json})
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'POST #create', focus: true do
|
31
|
+
let(:params) { {description: 'A Review', foo: 'bar'} }
|
32
|
+
|
33
|
+
before do
|
34
|
+
api_stub_for(post: "/app_answers", response: from_api(answer_1))
|
35
|
+
api_stub_for(get: "/app_answers/#{answer_1.id}", response: from_api(answer_1))
|
36
|
+
end
|
37
|
+
|
38
|
+
subject { post :create, app_answer: params, question_id: question.id }
|
39
|
+
|
40
|
+
it 'renders the new review' do
|
41
|
+
expect(JSON.parse(subject.body)).to include('app_answer' => expected_hash_for_answer_1)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
describe Jpi::V1::Admin::AppCommentsController, 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
|
+
|
11
|
+
#===============================================
|
12
|
+
# Assignments
|
13
|
+
#===============================================
|
14
|
+
let(:user) { build(:user, :admin, :with_organizations) }
|
15
|
+
let(:organization) { user.organizations.first }
|
16
|
+
let(:feedback) { build(:app_feedback) }
|
17
|
+
|
18
|
+
before { api_stub_for(get: "/organization/#{organization.id}", response: from_api(organization)) }
|
19
|
+
before { api_stub_for(get: "/users/#{user.id}/organizations", response: from_api([organization])) }
|
20
|
+
before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
|
21
|
+
before { api_stub_for(get: "/app_feedbacks/#{feedback.id}", response: from_api(feedback)) }
|
22
|
+
before { sign_in user }
|
23
|
+
|
24
|
+
let(:comment_1) { build(:app_comment, feedback_id: 'fid') }
|
25
|
+
let(:expected_hash_for_comment_1) do
|
26
|
+
attrs = %w(id description status user_id user_name organization_id organization_name type app_id feedback_id app_name)
|
27
|
+
comment_1.attributes.slice(*attrs).merge({'type'=>'Comment', 'created_at' => comment_1.created_at.as_json, 'updated_at' => comment_1.updated_at.as_json})
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'POST #create', focus: true do
|
31
|
+
let(:params) { {description: 'A Review', foo: 'bar'} }
|
32
|
+
|
33
|
+
before do
|
34
|
+
api_stub_for(post: "/app_comments", response: from_api(comment_1))
|
35
|
+
api_stub_for(get: "/app_comments/#{comment_1.id}", response: from_api(comment_1))
|
36
|
+
end
|
37
|
+
|
38
|
+
subject { post :create, app_comment: params, feedback_id: feedback.id }
|
39
|
+
|
40
|
+
it 'renders the new review' do
|
41
|
+
expect(JSON.parse(subject.body)).to include('app_comment' => expected_hash_for_comment_1)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# TODO: spec AppInstance response
|
4
|
+
module MnoEnterprise
|
5
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
6
|
+
|
7
|
+
describe Jpi::V1::Admin::AppInstancesController, type: :controller do
|
8
|
+
render_views
|
9
|
+
routes { MnoEnterprise::Engine.routes }
|
10
|
+
before { request.env["HTTP_ACCEPT"] = 'application/json' }
|
11
|
+
|
12
|
+
let(:user) { build(:user, :admin, :with_organizations) }
|
13
|
+
before do
|
14
|
+
api_stub_for(get: "/users/#{user.id}", response: from_api(user))
|
15
|
+
sign_in user
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'DELETE #destroy' do
|
19
|
+
# Stub AppInstance
|
20
|
+
let(:app_instance) { build(:app_instance) }
|
21
|
+
before { api_stub_for(get: "/app_instances/#{app_instance.id}", respond_with: app_instance)}
|
22
|
+
before { api_stub_for(delete: "/app_instances/#{app_instance.id}", response: ->{ app_instance.status = 'terminated'; from_api(app_instance) }) }
|
23
|
+
|
24
|
+
subject { delete :destroy, id: app_instance.id }
|
25
|
+
|
26
|
+
it_behaves_like "a jpi v1 admin action"
|
27
|
+
|
28
|
+
it { subject; expect(app_instance.status).to eq('terminated') }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
5
|
+
|
6
|
+
describe Jpi::V1::Admin::AppReviewsController, type: :controller do
|
7
|
+
render_views
|
8
|
+
routes { MnoEnterprise::Engine.routes }
|
9
|
+
before { request.env['HTTP_ACCEPT'] = 'application/json' }
|
10
|
+
let(:user) { build(:user, :admin, :with_organizations) }
|
11
|
+
let(:app_review) { build(:app_review, user: user) }
|
12
|
+
before do
|
13
|
+
api_stub_for(get: '/app_reviews', response: from_api([app_review]))
|
14
|
+
api_stub_for(get: "/app_reviews/#{app_review.id}", response: from_api(app_review))
|
15
|
+
api_stub_for(get: "/users/#{user.id}", response: from_api(user))
|
16
|
+
sign_in user
|
17
|
+
end
|
18
|
+
|
19
|
+
def partial_hash_for_app_review(app_review)
|
20
|
+
{
|
21
|
+
'id' => app_review.id,
|
22
|
+
'rating' => app_review.rating,
|
23
|
+
'description' => app_review.description,
|
24
|
+
'status' => app_review.status,
|
25
|
+
'app_id' => app_review.app_id,
|
26
|
+
'app_name' => app_review.app_name,
|
27
|
+
'user_id' => app_review.user_id,
|
28
|
+
'user_name' => app_review.user_name,
|
29
|
+
'organization_id' => app_review.organization_id,
|
30
|
+
'organization_name' => app_review.organization_name,
|
31
|
+
'type' => app_review.type,
|
32
|
+
'created_at' => app_review.created_at,
|
33
|
+
'updated_at' => app_review.updated_at,
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def hash_for_app_review(app_review)
|
38
|
+
{
|
39
|
+
'app_review' => partial_hash_for_app_review(app_review)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def hash_for_app_reviews(app_reviews)
|
44
|
+
{
|
45
|
+
'app_reviews' => app_reviews.map { |o| partial_hash_for_app_review(o) }
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
describe '#index' do
|
51
|
+
subject { get :index }
|
52
|
+
|
53
|
+
it_behaves_like "a jpi v1 admin action"
|
54
|
+
|
55
|
+
context 'success' do
|
56
|
+
before { subject }
|
57
|
+
|
58
|
+
it 'returns a list of app_review' do
|
59
|
+
expect(response).to be_success
|
60
|
+
expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_app_reviews([app_review]).to_json))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'GET #show' do
|
66
|
+
subject { get :show, id: app_review.id }
|
67
|
+
|
68
|
+
it_behaves_like "a jpi v1 admin action"
|
69
|
+
|
70
|
+
context 'success' do
|
71
|
+
before { subject }
|
72
|
+
|
73
|
+
it 'returns a complete description of the app_review' do
|
74
|
+
expect(response).to be_success
|
75
|
+
expect(JSON.parse(response.body)).to eq(JSON.parse(hash_for_app_review(app_review).to_json))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
describe 'PUT #update' do
|
82
|
+
subject { put :update, id: app_review.id, app_review: {status: 'rejected'} }
|
83
|
+
|
84
|
+
before do
|
85
|
+
sign_in user
|
86
|
+
api_stub_for(put: "/app_reviews/#{app_review.id}", response: -> { app_review.status = 'rejected'; from_api(app_review) })
|
87
|
+
end
|
88
|
+
|
89
|
+
it_behaves_like "a jpi v1 admin action"
|
90
|
+
|
91
|
+
context 'success' do
|
92
|
+
before { subject }
|
93
|
+
|
94
|
+
it { expect(response).to be_success }
|
95
|
+
|
96
|
+
# Test that the app_review is updated by testing the api endpoint was called
|
97
|
+
it { expect(app_review.status).to eq('rejected') }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
@@ -2,7 +2,8 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module MnoEnterprise
|
4
4
|
describe Jpi::V1::Admin::AuditEventsController, type: :controller do
|
5
|
-
include MnoEnterprise::TestingSupport::
|
5
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
6
|
+
|
6
7
|
render_views
|
7
8
|
routes { MnoEnterprise::Engine.routes }
|
8
9
|
before { request.env["HTTP_ACCEPT"] = 'application/json' }
|
@@ -10,15 +11,9 @@ module MnoEnterprise
|
|
10
11
|
#===============================================
|
11
12
|
# Assignments
|
12
13
|
#===============================================
|
13
|
-
# Stub
|
14
|
-
# let!(:ability) { stub_ability }
|
15
|
-
# before { allow(ability).to receive(:can?).with(any_args).and_return(true) }
|
16
|
-
|
17
|
-
# # Stub user and user call
|
14
|
+
# Stub user and user call
|
18
15
|
let(:user) { FactoryGirl.build(:user, :admin) }
|
19
16
|
before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
|
20
|
-
# before { api_stub_for(get: '/users?filter%5Bemail%5D&limit=1', response: from_api(nil)) }
|
21
|
-
|
22
17
|
before { sign_in user }
|
23
18
|
|
24
19
|
let(:audit_event) { FactoryGirl.build(:audit_event) }
|
@@ -27,13 +22,7 @@ module MnoEnterprise
|
|
27
22
|
describe 'GET #index' do
|
28
23
|
subject { get :index }
|
29
24
|
|
30
|
-
|
31
|
-
# it_behaves_like 'jpi v1 protected action'
|
32
|
-
|
33
|
-
it 'is successful' do
|
34
|
-
subject
|
35
|
-
expect(response).to be_success
|
36
|
-
end
|
25
|
+
it_behaves_like 'a jpi v1 admin action'
|
37
26
|
|
38
27
|
context 'sucess' do
|
39
28
|
it 'assigns @audit_events' do
|
@@ -2,6 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module MnoEnterprise
|
4
4
|
describe Jpi::V1::Admin::CloudAppsController, type: :controller do
|
5
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
5
6
|
render_views
|
6
7
|
routes { MnoEnterprise::Engine.routes }
|
7
8
|
before { request.env["HTTP_ACCEPT"] = 'application/json' }
|
@@ -24,7 +25,9 @@ module MnoEnterprise
|
|
24
25
|
|
25
26
|
describe "#index" do
|
26
27
|
subject { get :index }
|
27
|
-
|
28
|
+
|
29
|
+
it_behaves_like 'a jpi v1 admin action'
|
30
|
+
|
28
31
|
it 'returns the cloud aplications' do
|
29
32
|
subject
|
30
33
|
expect(JSON.parse(response.body)).to eq({"cloud_apps"=>[{"id"=>app.id, "uid"=>app.uid, "name"=>app.name, "api_key"=>app.api_key, "tiny_description"=>app.tiny_description, "description"=>app.description, "metadata_url"=>nil, "details"=>nil, "terms_url"=>app.terms_url}]})
|
@@ -37,6 +40,8 @@ module MnoEnterprise
|
|
37
40
|
|
38
41
|
before { allow(MnoEnterprise::App).to receive(:find) { app } }
|
39
42
|
|
43
|
+
it_behaves_like 'a jpi v1 admin action'
|
44
|
+
|
40
45
|
it 'assigns the cloud app' do
|
41
46
|
subject
|
42
47
|
expect(assigns[:cloud_app]).to eq(app)
|
@@ -61,7 +66,9 @@ module MnoEnterprise
|
|
61
66
|
|
62
67
|
describe "#regenerate_api_key" do
|
63
68
|
subject { put :regenerate_api_key, id: app.id }
|
64
|
-
|
69
|
+
|
70
|
+
it_behaves_like 'a jpi v1 admin action'
|
71
|
+
|
65
72
|
it 'regenerates the API key' do
|
66
73
|
expect_any_instance_of(MnoEnterprise::App).to receive(:regenerate_api_key!)
|
67
74
|
subject
|
@@ -70,7 +77,9 @@ module MnoEnterprise
|
|
70
77
|
|
71
78
|
describe "#refresh_metadata" do
|
72
79
|
subject { put :refresh_metadata, id: app.id, metadata_url: 'http://test.com' }
|
73
|
-
|
80
|
+
|
81
|
+
it_behaves_like 'a jpi v1 admin action'
|
82
|
+
|
74
83
|
context 'with a valid response' do
|
75
84
|
it 'refreshes the metadata' do
|
76
85
|
expect(subject).to render_template(:show)
|
@@ -2,6 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module MnoEnterprise
|
4
4
|
RSpec.describe Jpi::V1::Admin::InvitesController do
|
5
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
5
6
|
routes { MnoEnterprise::Engine.routes }
|
6
7
|
before { request.env['HTTP_ACCEPT'] = 'application/json' }
|
7
8
|
|
@@ -42,6 +43,9 @@ module MnoEnterprise
|
|
42
43
|
describe 'POST #create' do
|
43
44
|
subject { post :create, user_id: invitee.id, organization_id: organization.id }
|
44
45
|
|
46
|
+
before { allow(SystemNotificationMailer).to receive(:organization_invite).with(invite).and_return(message_delivery) }
|
47
|
+
it_behaves_like 'a jpi v1 admin action'
|
48
|
+
|
45
49
|
context 'existing user' do
|
46
50
|
it 'sends the invitation email' do
|
47
51
|
expect(SystemNotificationMailer).to receive(:organization_invite).with(invite).and_return(message_delivery)
|
@@ -2,6 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module MnoEnterprise
|
4
4
|
describe Jpi::V1::Admin::InvoicesController, type: :controller do
|
5
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
5
6
|
render_views
|
6
7
|
routes { MnoEnterprise::Engine.routes }
|
7
8
|
before { request.env["HTTP_ACCEPT"] = 'application/json' }
|
@@ -56,6 +57,8 @@ module MnoEnterprise
|
|
56
57
|
describe '#index' do
|
57
58
|
subject { get :index }
|
58
59
|
|
60
|
+
it_behaves_like 'a jpi v1 admin action'
|
61
|
+
|
59
62
|
context 'success' do
|
60
63
|
before { subject }
|
61
64
|
|
@@ -69,6 +72,8 @@ module MnoEnterprise
|
|
69
72
|
describe 'GET #show' do
|
70
73
|
subject { get :show, id: invoice.id }
|
71
74
|
|
75
|
+
it_behaves_like 'a jpi v1 admin action'
|
76
|
+
|
72
77
|
context 'success' do
|
73
78
|
before { subject }
|
74
79
|
|
@@ -82,6 +87,8 @@ module MnoEnterprise
|
|
82
87
|
describe 'GET #current_billing_amount' do
|
83
88
|
subject { get :current_billing_amount }
|
84
89
|
|
90
|
+
it_behaves_like 'a jpi v1 admin action'
|
91
|
+
|
85
92
|
context 'with an old MnoHub' do
|
86
93
|
let(:tenant) { build(:old_tenant) }
|
87
94
|
|
@@ -110,6 +117,8 @@ module MnoEnterprise
|
|
110
117
|
describe 'GET #last_invoicing_amount' do
|
111
118
|
subject { get :last_invoicing_amount }
|
112
119
|
|
120
|
+
it_behaves_like 'a jpi v1 admin action'
|
121
|
+
|
113
122
|
context 'success' do
|
114
123
|
before { subject }
|
115
124
|
|
@@ -125,6 +134,8 @@ module MnoEnterprise
|
|
125
134
|
describe 'GET #outstanding_amount' do
|
126
135
|
subject { get :outstanding_amount }
|
127
136
|
|
137
|
+
it_behaves_like 'a jpi v1 admin action'
|
138
|
+
|
128
139
|
context 'success' do
|
129
140
|
before { subject }
|
130
141
|
let(:outstanding_amount) { {'outstanding_amount' => {"amount"=>"1789.86", "currency"=>"AUD"}} }
|
@@ -139,6 +150,8 @@ module MnoEnterprise
|
|
139
150
|
describe 'GET #last_portfolio_amount' do
|
140
151
|
subject { get :last_portfolio_amount }
|
141
152
|
|
153
|
+
it_behaves_like 'a jpi v1 admin action'
|
154
|
+
|
142
155
|
context 'success' do
|
143
156
|
before { subject }
|
144
157
|
|
@@ -155,6 +168,8 @@ module MnoEnterprise
|
|
155
168
|
describe 'GET #last_commission_amount' do
|
156
169
|
subject { get :last_commission_amount }
|
157
170
|
|
171
|
+
it_behaves_like 'a jpi v1 admin action'
|
172
|
+
|
158
173
|
context 'success' do
|
159
174
|
before { subject }
|
160
175
|
let(:last_commission_amount) { {'last_commission_amount' => {"amount"=>"4123.45", "currency"=>"AUD"}} }
|
@@ -3,6 +3,8 @@ require 'rails_helper'
|
|
3
3
|
module MnoEnterprise
|
4
4
|
describe Jpi::V1::Admin::OrganizationsController, type: :controller do
|
5
5
|
include MnoEnterprise::TestingSupport::OrganizationsSharedHelpers
|
6
|
+
include MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
|
7
|
+
|
6
8
|
render_views
|
7
9
|
routes { MnoEnterprise::Engine.routes }
|
8
10
|
before { request.env["HTTP_ACCEPT"] = 'application/json' }
|
@@ -43,7 +45,9 @@ module MnoEnterprise
|
|
43
45
|
let(:credit_card) { build(:credit_card, organization: organization) }
|
44
46
|
|
45
47
|
before do
|
46
|
-
|
48
|
+
organizations = [organization]
|
49
|
+
allow(organizations).to receive(:loaded?).and_return(true)
|
50
|
+
allow_any_instance_of(MnoEnterprise::User).to receive(:organizations).and_return(organizations)
|
47
51
|
api_stub_for(get: "/organizations/#{organization.id}/invoices", response: from_api([invoice]))
|
48
52
|
api_stub_for(get: "/organizations", response: from_api([organization]))
|
49
53
|
api_stub_for(get: "/organizations/#{organization.id}", response: from_api(organization))
|
@@ -75,6 +79,8 @@ module MnoEnterprise
|
|
75
79
|
describe '#index' do
|
76
80
|
subject { get :index }
|
77
81
|
|
82
|
+
it_behaves_like 'a jpi v1 admin action'
|
83
|
+
|
78
84
|
context 'success' do
|
79
85
|
before { subject }
|
80
86
|
|
@@ -89,6 +95,8 @@ module MnoEnterprise
|
|
89
95
|
describe 'GET #show' do
|
90
96
|
subject { get :show, id: organization.id }
|
91
97
|
|
98
|
+
it_behaves_like 'a jpi v1 admin action'
|
99
|
+
|
92
100
|
context 'success' do
|
93
101
|
before { subject }
|
94
102
|
|
@@ -104,6 +112,8 @@ module MnoEnterprise
|
|
104
112
|
describe 'GET #in_arrears' do
|
105
113
|
subject { get :in_arrears }
|
106
114
|
|
115
|
+
it_behaves_like 'a jpi v1 admin action'
|
116
|
+
|
107
117
|
context 'success' do
|
108
118
|
before { subject }
|
109
119
|
|
@@ -120,6 +130,8 @@ module MnoEnterprise
|
|
120
130
|
|
121
131
|
subject { post :create, organization: params }
|
122
132
|
|
133
|
+
it_behaves_like 'a jpi v1 admin action'
|
134
|
+
|
123
135
|
it 'creates the organization' do
|
124
136
|
expect(MnoEnterprise::Organization).to receive(:create).with(params.slice(:name)) { organization }
|
125
137
|
subject
|
@@ -153,6 +165,8 @@ module MnoEnterprise
|
|
153
165
|
context 'with existing user' do
|
154
166
|
before { allow(MnoEnterprise::User).to receive(:find_by) { user } }
|
155
167
|
|
168
|
+
it_behaves_like 'a jpi v1 admin action'
|
169
|
+
|
156
170
|
it 'creates an invite' do
|
157
171
|
subject
|
158
172
|
expect(@api_call).to be true
|
@@ -166,6 +180,8 @@ module MnoEnterprise
|
|
166
180
|
let(:new_user) { build(:user, params.slice(:email, :name, :surname, :phone)) }
|
167
181
|
before { allow(controller).to receive(:create_unconfirmed_user) { new_user } }
|
168
182
|
|
183
|
+
it_behaves_like 'a jpi v1 admin action'
|
184
|
+
|
169
185
|
it 'creates a user' do
|
170
186
|
expect(controller).to receive(:create_unconfirmed_user) { new_user }
|
171
187
|
subject
|