pg_rails 7.6.25 → 7.6.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/pg_engine/app/controllers/pg_engine/base_public_controller.rb +1 -1
- data/pg_engine/app/controllers/users/accounts_controller.rb +10 -0
- data/pg_engine/app/helpers/pg_engine/route_helper.rb +8 -1
- data/pg_engine/config/routes.rb +2 -5
- data/pg_engine/spec/requests/users/accounts_spec.rb +38 -0
- data/pg_rails/lib/version.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2c5672f192482e718fb6f12e66e7cfcd376e916c7663f13931aa526d931f42
|
4
|
+
data.tar.gz: cb427f6f6dd542648c697f53b3ddc688f8506919a809bfff3e32c6119612b1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98643fa17d81bcdfa0993cd66dbf532d36a6e1935a0144f88e67f2b54dad6e0ec81795fb9a5be9c35c42f6737e1ff8a51ed77f871104f691e711d8a16a8ffb5
|
7
|
+
data.tar.gz: df1e9eae5424d3ea481be959d24f33b09a5433ce0660f2bdc55ddda5595926ae753c7489c6ac90cc0956219b0909b0d6dd82cb784b2538d00f80820eb654d7cf
|
@@ -36,6 +36,16 @@ module Users
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def user_root
|
40
|
+
scope = policy_scope(Account)
|
41
|
+
if scope.count == 1
|
42
|
+
ua = Current.user.user_account_for(scope.first)
|
43
|
+
redirect_to tenant_root_path(ua.to_param)
|
44
|
+
else
|
45
|
+
redirect_to users_accounts_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
39
49
|
# La user_account puede estar disabled
|
40
50
|
def show
|
41
51
|
add_breadcrumb @account, users_account_path(@account, tid: nil)
|
@@ -72,8 +72,15 @@ module PgEngine
|
|
72
72
|
if Current.tid.present?
|
73
73
|
tenant_root_path(tid: Current.tid)
|
74
74
|
else
|
75
|
-
(Current.user.present? ?
|
75
|
+
(Current.user.present? ? user_root_path : root_path)
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
# :nocov:
|
80
|
+
deprecate :users_root_path, deprecator: PgEngine.deprecator
|
81
|
+
def users_root_path
|
82
|
+
user_root_path
|
83
|
+
end
|
84
|
+
# :nocov:
|
78
85
|
end
|
79
86
|
end
|
data/pg_engine/config/routes.rb
CHANGED
@@ -31,12 +31,10 @@ Rails.application.routes.draw do
|
|
31
31
|
put :update_invitation
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
35
|
-
root to: 'accounts#index'
|
36
34
|
end
|
37
35
|
|
38
36
|
# User root for devise's signed_in_root_path
|
39
|
-
get '/u', to: 'accounts#
|
37
|
+
get '/u', to: 'users/accounts#user_root', as: :user_root
|
40
38
|
|
41
39
|
namespace :tenant, path: 'u/t(/:tid)' do
|
42
40
|
pg_resource(:user_accounts, only: [:index, :show, :edit, :update, :destroy])
|
@@ -50,8 +48,7 @@ Rails.application.routes.draw do
|
|
50
48
|
root to: 'dashboard#dashboard'
|
51
49
|
end
|
52
50
|
|
53
|
-
# root
|
54
|
-
# FIXME: qué onda
|
51
|
+
# Si en la main app no se define una root path, se redirige al user_root
|
55
52
|
root to: redirect('/u')
|
56
53
|
|
57
54
|
namespace :admin, path: 'a' do
|
@@ -88,6 +88,44 @@ describe 'Users::AccountsController' do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
describe 'user_root' do
|
92
|
+
subject do
|
93
|
+
get '/u'
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when no accounts' do
|
97
|
+
let(:user) { create :user }
|
98
|
+
|
99
|
+
it do
|
100
|
+
subject
|
101
|
+
expect(response).to redirect_to(users_accounts_path)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when one account' do
|
106
|
+
it do
|
107
|
+
subject
|
108
|
+
ua = user.user_account_for(account)
|
109
|
+
expect(response).to redirect_to(tenant_root_path(ua.to_param))
|
110
|
+
# File.write(Rails.root.join('out.html'), response.body)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when multiple accounts' do
|
115
|
+
before do
|
116
|
+
other_account = create(:account)
|
117
|
+
ActsAsTenant.without_tenant do
|
118
|
+
create(:user_account, account: other_account, user:)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it do
|
123
|
+
subject
|
124
|
+
expect(response).to redirect_to(users_accounts_path)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
91
129
|
describe 'index' do
|
92
130
|
subject do
|
93
131
|
get '/u/espacios'
|
data/pg_rails/lib/version.rb
CHANGED