mno-enterprise-api 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d433295f9c87eef1d54931eb24268c0d884dd7a
4
- data.tar.gz: 4153fae7373b8991c6cd74d2e77a8666c06c5de3
3
+ metadata.gz: c2d4ffdd0869f327305258d29469731d30b31d5f
4
+ data.tar.gz: 3c5a02ab3f7fa05c6ea4a5ac80f40d2c89b46d9e
5
5
  SHA512:
6
- metadata.gz: 8063295c92c5ec525ba18177120644ec0daf04609716a697c8dc63c9540018801adb9f18f3c171f357c503d866d4a9cedd297b77b5a63873535d1ff2f2696cd2
7
- data.tar.gz: 98a9789331a4d92dffcbad5737f1a24e67413d3873093ac8ed4578902ddcab8f5753cf8e029179384c21699e8a524ac1ce30b53362cfff5021bcee0baac95db0
6
+ metadata.gz: 6ba45fee7bba517d7600815bb3f71933a3b93a31283f26cb2891a95f0cee75b118714444d8fa36c9aa45031f2ef3dbdd207143b08d80aa0f96b2518c42fee164
7
+ data.tar.gz: 32ac403e68f0a2e15d000a8b9cca4323c209b8c1d29ee07663f31ef7fea5c4309afad30196a081a490ac35e05fe2b82838642ccb72fe470d786a7a3c076653ac
@@ -1,63 +1,5 @@
1
1
  module MnoEnterprise
2
2
  class Jpi::V1::Impac::WidgetsController < Jpi::V1::BaseResourceController
3
- respond_to :json
4
-
5
- # POST /mnoe/jpi/v1/impac/dashboards/:id/widgets
6
- # -> POST /api/mnoe/v1/dashboards/:id/widgets
7
- def create
8
- if widgets
9
- if @widget = widgets.create(format_attrs(['widget_category','metadata']))
10
- MnoEnterprise::EventLogger.info('widget_create', current_user.id, 'Widget Creation', nil, @widget)
11
- @nocontent = true # no data fetch from Connec!
12
- render 'show'
13
- else
14
- render json: @widget.errors, status: :bad_request
15
- end
16
- else
17
- render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found
18
- end
19
- end
20
-
21
- # PUT /mnoe/jpi/v1/impac/widgets/:id
22
- def update
23
- if widget.update(format_attrs(['name','metadata']))
24
- @nocontent = !params['metadata']
25
- render 'show'
26
- else
27
- render json: @widget.errors, status: :bad_request
28
- end
29
- end
30
-
31
- # DELETE /mnoe/jpi/v1/impac/dashboards/1
32
- def destroy
33
- if widget.destroy
34
- MnoEnterprise::EventLogger.info('widget_delete', current_user.id, 'Widget Deletion', nil, widget)
35
- head status: :ok
36
- else
37
- render json: 'Unable to destroy widget', status: :bad_request
38
- end
39
- end
40
-
41
-
42
- #=================================================
43
- # Private methods
44
- #=================================================
45
- private
46
-
47
- def widget
48
- @widget ||= MnoEnterprise::Impac::Widget.find(params[:id])
49
- end
50
-
51
- def widgets
52
- @widgets ||= MnoEnterprise::Impac::Dashboard.find(params[:dashboard_id]).widgets
53
- end
54
-
55
- def format_attrs(whitelist)
56
- attrs = (params[:widget] || {}).select { |k,v| whitelist.include?(k.to_s) }
57
- attrs['settings'] = widget ? widget.settings || {} : {}
58
- attrs['settings'].merge!(attrs['metadata']) if attrs['metadata']
59
- attrs.except!('metadata')
60
- end
61
-
3
+ include MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::WidgetsController
62
4
  end
63
5
  end
@@ -0,0 +1,72 @@
1
+ module MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::WidgetsController
2
+ extend ActiveSupport::Concern
3
+
4
+ #==================================================================
5
+ # Included methods
6
+ #==================================================================
7
+ # 'included do' causes the included code to be evaluated in the
8
+ # context where it is included rather than being executed in the module's context
9
+ included do
10
+ respond_to :json
11
+ end
12
+
13
+ #==================================================================
14
+ # Instance methods
15
+ #==================================================================
16
+ # POST /mnoe/jpi/v1/impac/dashboards/:id/widgets
17
+ # -> POST /api/mnoe/v1/dashboards/:id/widgets
18
+ def create
19
+ if widgets
20
+ if @widget = widgets.create(format_attrs(['widget_category','metadata']))
21
+ MnoEnterprise::EventLogger.info('widget_create', current_user.id, 'Widget Creation', nil, @widget)
22
+ @nocontent = true # no data fetch from Connec!
23
+ render 'show'
24
+ else
25
+ render json: @widget.errors, status: :bad_request
26
+ end
27
+ else
28
+ render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found
29
+ end
30
+ end
31
+
32
+ # PUT /mnoe/jpi/v1/impac/widgets/:id
33
+ def update
34
+ if widget.update(format_attrs(['name','metadata']))
35
+ @nocontent = !params['metadata']
36
+ render 'show'
37
+ else
38
+ render json: @widget.errors, status: :bad_request
39
+ end
40
+ end
41
+
42
+ # DELETE /mnoe/jpi/v1/impac/dashboards/1
43
+ def destroy
44
+ if widget.destroy
45
+ MnoEnterprise::EventLogger.info('widget_delete', current_user.id, 'Widget Deletion', nil, widget)
46
+ head status: :ok
47
+ else
48
+ render json: 'Unable to destroy widget', status: :bad_request
49
+ end
50
+ end
51
+
52
+
53
+ #=================================================
54
+ # Private methods
55
+ #=================================================
56
+ private
57
+
58
+ def widget
59
+ @widget ||= MnoEnterprise::Impac::Widget.find(params[:id])
60
+ end
61
+
62
+ def widgets
63
+ @widgets ||= MnoEnterprise::Impac::Dashboard.find(params[:dashboard_id]).widgets
64
+ end
65
+
66
+ def format_attrs(whitelist)
67
+ attrs = (params[:widget] || {}).select { |k,v| whitelist.include?(k.to_s) }
68
+ attrs['settings'] = widget ? widget.settings || {} : {}
69
+ attrs['settings'].merge!(attrs['metadata']) if attrs['metadata']
70
+ attrs.except!('metadata')
71
+ end
72
+ end
@@ -29,7 +29,7 @@ module MnoEnterprise::Concerns::Controllers::OrgInvitesController
29
29
  redirect_path = mnoe_home_path
30
30
 
31
31
  if @org_invite && !@org_invite.expired? && @org_invite.accept!(current_user)
32
- redirect_path += "#/?dhbRefId=#{ @org_invite.organization.id}"
32
+ redirect_path = add_param_to_fragment(redirect_path.to_s, 'dhbRefId', @org_invite.organization.id)
33
33
  message = { notice: "You are now part of #{@org_invite.organization.name}" }
34
34
  yield(:success, @org_invite) if block_given?
35
35
  elsif @org_invite && @org_invite.expired?
@@ -128,7 +128,8 @@ module MnoEnterprise::Concerns::Mailers::SystemNotificationMailer
128
128
  protected
129
129
 
130
130
  def recipient(record, new_user = false)
131
- hash = { email: record.email }
131
+ # Org Invite for unconfirmed users will have the email in #unconfirmed_email
132
+ hash = { email: record.email || record.unconfirmed_email }
132
133
  hash[:name] = "#{record.name} #{record.surname}".strip unless new_user
133
134
  hash
134
135
  end
@@ -8,7 +8,7 @@ module MnoEnterprise
8
8
  describe OrgInvitesController, type: :controller do
9
9
  render_views
10
10
  routes { MnoEnterprise::Engine.routes }
11
-
11
+
12
12
  let(:user) { build(:user) }
13
13
  let(:invite) { build(:org_invite, user: user) }
14
14
  let(:token) { invite.token }
@@ -25,7 +25,7 @@ module MnoEnterprise
25
25
  describe "GET #show" do
26
26
  subject { get :show, id: invite.id, token: token}
27
27
 
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]])}" }
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
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
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
 
@@ -33,7 +33,7 @@ module MnoEnterprise
33
33
  it_behaves_like 'a user protected resource'
34
34
 
35
35
  it { subject; expect(response).to be_success }
36
- it { subject; expect(assigns(:redirect_to)).to eq(redirect_url) }
36
+ it { Timecop.freeze { subject; expect(assigns(:redirect_to)).to eq(redirect_url) } }
37
37
 
38
38
  Webhook::OAuthController::PROVIDERS_WITH_OPTIONS.each do |provider|
39
39
  describe "#{provider.capitalize} provider" do
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.0.2
4
+ version: 3.0.3
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: 2016-05-12 00:00:00.000000000 Z
12
+ date: 2016-07-13 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.0.2
20
+ version: 3.0.3
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.0.2
27
+ version: 3.0.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jbuilder
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -254,6 +254,7 @@ files:
254
254
  - lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb
255
255
  - lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb
256
256
  - lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb
257
+ - lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb
257
258
  - lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb
258
259
  - lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
259
260
  - lib/mno_enterprise/concerns/controllers/pages_controller.rb