mno-enterprise-api 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +1 -1
- data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +5 -1
- data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +1 -15
- data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +45 -18
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +0 -11
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d433295f9c87eef1d54931eb24268c0d884dd7a
|
4
|
+
data.tar.gz: 4153fae7373b8991c6cd74d2e77a8666c06c5de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8063295c92c5ec525ba18177120644ec0daf04609716a697c8dc63c9540018801adb9f18f3c171f357c503d866d4a9cedd297b77b5a63873535d1ff2f2696cd2
|
7
|
+
data.tar.gz: 98a9789331a4d92dffcbad5737f1a24e67413d3873093ac8ed4578902ddcab8f5753cf8e029179384c21699e8a524ac1ce30b53362cfff5021bcee0baac95db0
|
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
.form-group
|
23
23
|
%p= t('.my_version_is')
|
24
|
-
= select_tag :version, options_for_select([["Account Right
|
24
|
+
= select_tag :version, options_for_select([["Account Right Live","account_right"],["Essentials","essentials"]], "essentials")
|
25
25
|
|
26
26
|
%hr
|
27
27
|
|
@@ -23,7 +23,6 @@ module MnoEnterprise::Concerns::Controllers::OrgInvitesController
|
|
23
23
|
# Instance methods
|
24
24
|
#==================================================================
|
25
25
|
# GET /org_invites/1?token=HJuiofjpa45A73255a74F534FDfds
|
26
|
-
# TODO: improve integration with new frontends
|
27
26
|
def show
|
28
27
|
@current_user = current_user
|
29
28
|
@org_invite = MnoEnterprise::OrgInvite.active.where(id: params[:id], token: params[:token]).first
|
@@ -39,6 +38,11 @@ module MnoEnterprise::Concerns::Controllers::OrgInvitesController
|
|
39
38
|
message = { alert: "Unfortunately, this invite does not seem to be valid." }
|
40
39
|
end
|
41
40
|
|
41
|
+
# Add flash msg in url fragment for the new frontend
|
42
|
+
type, msg = message.first
|
43
|
+
type = (type == :alert ? :error : :success)
|
44
|
+
redirect_path = add_param_to_fragment(redirect_path.to_s, 'flash', [{msg: msg, type: type}.to_json])
|
45
|
+
|
42
46
|
redirect_to redirect_path, message
|
43
47
|
end
|
44
48
|
end
|
@@ -30,7 +30,7 @@ module MnoEnterprise::Concerns::Controllers::Webhook::OAuthController
|
|
30
30
|
# Return a hash of extra parameters that were passed along with
|
31
31
|
# the request
|
32
32
|
def extra_params
|
33
|
-
params.
|
33
|
+
params.except(:controller,:action,:id, :perform)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Current user web token
|
@@ -38,20 +38,6 @@ module MnoEnterprise::Concerns::Controllers::Webhook::OAuthController
|
|
38
38
|
MnoEnterprise.jwt(user_id: current_user.uid)
|
39
39
|
end
|
40
40
|
|
41
|
-
# Append params to the fragment part of an existing url String
|
42
|
-
# add_param("/#/platform/accounts", 'foo', 'bar')
|
43
|
-
# => "/#/platform/accounts?foo=bar"
|
44
|
-
# add_param("/#/platform/dashboard/he/43?en=690", 'foo', 'bar')
|
45
|
-
# => "/#/platform/dashboard/he/43?en=690&foo=bar"
|
46
|
-
def add_param_to_fragment(url, param_name, param_value)
|
47
|
-
uri = URI(url)
|
48
|
-
fragment = URI(uri.fragment || "")
|
49
|
-
params = URI.decode_www_form(fragment.query || "") << [param_name, param_value]
|
50
|
-
fragment.query = URI.encode_www_form(params)
|
51
|
-
uri.fragment = fragment.to_s
|
52
|
-
uri.to_s
|
53
|
-
end
|
54
|
-
|
55
41
|
def error_message(error_key)
|
56
42
|
case error_key.to_sym
|
57
43
|
when :bad_relinking
|
@@ -1,29 +1,56 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
+
def mnoe_home_path
|
4
|
+
controller.send(:mnoe_home_path)
|
5
|
+
end
|
6
|
+
|
3
7
|
module MnoEnterprise
|
4
8
|
describe OrgInvitesController, type: :controller do
|
5
9
|
render_views
|
6
10
|
routes { MnoEnterprise::Engine.routes }
|
7
11
|
|
8
12
|
let(:user) { build(:user) }
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
let(:invite) { build(:org_invite, user: user) }
|
14
|
+
let(:token) { invite.token }
|
15
|
+
|
16
|
+
before do
|
17
|
+
api_stub_for(get: "/users/#{user.id}", response: from_api(user))
|
18
|
+
|
19
|
+
# Invite stubs
|
20
|
+
api_stub_for(get: "/org_invites?filter[id]=#{invite.id}&filter[status]=pending&filter[token]=#{token}", response: from_api([invite]))
|
21
|
+
api_stub_for(get: "/org_invites?filter[id]=#{invite.id}&filter[status]=pending&filter[token]", response: from_api([]))
|
22
|
+
api_stub_for(put: "/org_invites/#{invite.id}", response: from_api(invite.tap { |x| x.status = 'accepted' }))
|
23
|
+
end
|
24
|
+
|
12
25
|
describe "GET #show" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
subject { get :show, id: invite.id, token: token}
|
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]])}" }
|
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
|
+
|
32
|
+
context 'when not signed in' do
|
33
|
+
it { expect(subject).not_to be_success }
|
34
|
+
it { expect(subject).to redirect_to(new_user_session_path) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when signed in' do
|
38
|
+
before { sign_in user }
|
39
|
+
before { subject }
|
40
|
+
|
41
|
+
it { expect(response).to redirect_to(mnoe_home_path + success_fragment) }
|
42
|
+
it { expect(assigns(:org_invite)).to eq(invite) }
|
43
|
+
|
44
|
+
context 'with expired invited' do
|
45
|
+
let(:invite) { build(:org_invite, :expired, user: user) }
|
46
|
+
it { expect(response).to redirect_to(mnoe_home_path + expired_fragment) }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'without token' do
|
50
|
+
let(:token) { nil }
|
51
|
+
it { expect(response).to redirect_to(mnoe_home_path + invalid_fragment) }
|
52
|
+
end
|
53
|
+
end
|
25
54
|
end
|
26
|
-
|
27
55
|
end
|
28
|
-
|
29
|
-
end
|
56
|
+
end
|
@@ -89,16 +89,5 @@ module MnoEnterprise
|
|
89
89
|
|
90
90
|
it { subject; expect(response).to redirect_to(redirect_url) }
|
91
91
|
end
|
92
|
-
|
93
|
-
describe '#add_param_to_fragment' do
|
94
|
-
let(:controller) { described_class.new }
|
95
|
-
|
96
|
-
it { expect(subject.send(:add_param_to_fragment, '/#/platform/accounts', 'foo', 'bar')).to eq('/#/platform/accounts?foo=bar') }
|
97
|
-
it { expect(subject.send(:add_param_to_fragment, '/', 'foo', 'bar')).to eq('/#?foo=bar') }
|
98
|
-
it { expect(subject.send(:add_param_to_fragment, '/#/platform/dashboard/he/43?en=690', 'foo', 'bar')).to eq('/#/platform/dashboard/he/43?en=690&foo=bar') }
|
99
|
-
it { expect(subject.send(:add_param_to_fragment, '/#/platform/dashboard/he/43?en=690', 'foo', [{msg: 'yolo'}])).to eq('/#/platform/dashboard/he/43?en=690&foo=%7B%3Amsg%3D%3E%22yolo%22%7D') }
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
92
|
end
|
104
93
|
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.0.
|
4
|
+
version: 3.0.2
|
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-
|
12
|
+
date: 2016-05-12 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.
|
20
|
+
version: 3.0.2
|
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.
|
27
|
+
version: 3.0.2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: jbuilder
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -318,7 +318,7 @@ files:
|
|
318
318
|
- spec/spec_helper.rb
|
319
319
|
homepage: https://maestrano.com
|
320
320
|
licenses:
|
321
|
-
-
|
321
|
+
- Apache-2.0
|
322
322
|
metadata: {}
|
323
323
|
post_install_message:
|
324
324
|
rdoc_options: []
|