pg_rails 7.6.25 → 7.6.27
Sign up to get free protection for your applications and to get access to all the features.
- 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/app/models/user.rb +4 -0
- data/pg_engine/app/views/users/accounts/show.html.slim +0 -7
- data/pg_engine/config/routes.rb +2 -5
- data/pg_engine/spec/factories/users.rb +2 -2
- 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: 01d6c43a4f1804b0b45e92ebaeea5411deb1fa6dafd9a886d3ca6fe9f5151fb3
|
4
|
+
data.tar.gz: 0b1eaf69bc0fd4d9164329b90c45ed1e206195a411b060cb0ab41ec28e3eae62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2521275d846111b2386211c36524c21b0d13de8db05cc0e28fd713021ece959a0f9deb7887d9d0ec8cf20229509dff6c1feed6d67cc14934beeb44fd38feed9
|
7
|
+
data.tar.gz: 90fc3ad22510450edc3d19c0bc11f9dfba1de6471a42c2478541d4808abe69eb668f3506b44137dd815e4067d81f632ed91bdb457145eec6d11d508ae310239f
|
@@ -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
|
@@ -37,8 +37,8 @@
|
|
37
37
|
|
38
38
|
FactoryBot.define do
|
39
39
|
factory :user, class: 'User' do
|
40
|
-
nombre {
|
41
|
-
apellido {
|
40
|
+
nombre { '' }
|
41
|
+
apellido { '' }
|
42
42
|
email { Faker::Internet.email }
|
43
43
|
password { "password#{rand(99_999)}" }
|
44
44
|
confirmed_at { Faker::Date.backward }
|
@@ -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