mno-enterprise-api 2.0.1 → 2.0.2

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: daea0cd14c70b1ba2bbc525497d295fb550afbe5
4
- data.tar.gz: 1ac8fb3d0f97b9f4a4919ebc89fb7a68ddb5b272
3
+ metadata.gz: 06a34e4066d4912616b04c98ef5d7a1edeaba36e
4
+ data.tar.gz: 29516a4df5d0ddf21261b17e78d43d97743f65bc
5
5
  SHA512:
6
- metadata.gz: 7a726373d6fda644393ce1f0ef0302fd0211447064a781eccbeab62ec362f1b8d1d083f835ddc6de70504518b971948dba7414018dbae954734e1b3163cf3834
7
- data.tar.gz: b5ad0804e82e9cfcd8450f9dc7968321e8c2929e5074627141df053cd02980d7636d870ab42cb23033962ec9f2a8f8f3f04e2f57cd16d93be50e1e2bf7723163
6
+ metadata.gz: 67aaab3ebbdb8ec01c453b96d53f6d4eae2f0e7cddf2bd5998f461c4e904fc6f760ada7d2f257412c7944a347a55ab7b7868f536e9cbb7106a88485854461053
7
+ data.tar.gz: e9b4d84536aaf56dc637caa9997128f288ef77beab1d3cd8ec710b21eef0976d41833f0c28ac5f406706dcae813566b8d5c7563bc45f18ad844559dbc4370e86
@@ -21,9 +21,9 @@
21
21
 
22
22
  .form-group
23
23
  %p My version of MYOB is:
24
- = select_tag :version, options_for_select([["Account Right (Desktop)","account_right"],["Essentials (Cloud)","essentials"]], "essentials")
24
+ = select_tag :version, options_for_select([["Account Right Live","account_right"],["Essentials","essentials"]], "essentials")
25
25
 
26
26
  %hr
27
27
 
28
28
  .form-group
29
- %button{ class: 'btn btn-warning', type: 'submit' } Connect
29
+ %button{ class: 'btn btn-warning', type: 'submit' } Connect
@@ -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.reject { |k,v| [:controller,:action,:id, :perform].include?(k.to_sym) }
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
- #before { api_stub_for(get: "/users/#{user.id}", response: from_api(user)) }
10
- #before { api_stub_for(put: "/users/#{user.id}", response: from_api(user)) }
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
- before { sign_in user }
14
- subject { get :show }
15
-
16
- # it_behaves_like "a navigatable protected user action"
17
- #
18
- # it "assigns the right meta information" do
19
- # get :myspace
20
- # meta = {}
21
- # meta[:title] = "Dashboard"
22
- # meta[:description] = "Dashboard"
23
- # assigns(:meta).should == meta
24
- # end
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: 2.0.1
4
+ version: 2.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-04-21 00:00:00.000000000 Z
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: 2.0.1
20
+ version: 2.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: 2.0.1
27
+ version: 2.0.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jbuilder
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -324,7 +324,7 @@ files:
324
324
  - spec/spec_helper.rb
325
325
  homepage: https://maestrano.com
326
326
  licenses:
327
- - Maestrano Enterprise License V1
327
+ - Apache-2.0
328
328
  metadata: {}
329
329
  post_install_message:
330
330
  rdoc_options: []