pg_rails 7.6.25 → 7.6.26

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
  SHA256:
3
- metadata.gz: 18003c61fd4e38fc6e7a70402aa0eaba4f335390e50061b1569bbea56c604a83
4
- data.tar.gz: f2732b2e071e3672cc8e4b6d16e2e577f7b6bf3590a8a6c3d76ef45215bdb67f
3
+ metadata.gz: 4b2c5672f192482e718fb6f12e66e7cfcd376e916c7663f13931aa526d931f42
4
+ data.tar.gz: cb427f6f6dd542648c697f53b3ddc688f8506919a809bfff3e32c6119612b1a4
5
5
  SHA512:
6
- metadata.gz: 9953c023fe35b70091a3ddc70b4a49f8cc7975476388835f1a0c7b286132afa68c4f5eaf35b6b1e80345fb2ff20251c35b9e238293b43cb217e445e226080598
7
- data.tar.gz: 39911c247bdd17a3828a378478d03bb4027326b9c9b72d9ad5c0db1dc1b0e4d491dc6b2e37d899a02043a3446818feb304969c4a828b91dc3f7bf9a0adcf89c6
6
+ metadata.gz: e98643fa17d81bcdfa0993cd66dbf532d36a6e1935a0144f88e67f2b54dad6e0ec81795fb9a5be9c35c42f6737e1ff8a51ed77f871104f691e711d8a16a8ffb5
7
+ data.tar.gz: df1e9eae5424d3ea481be959d24f33b09a5433ce0660f2bdc55ddda5595926ae753c7489c6ac90cc0956219b0909b0d6dd82cb784b2538d00f80820eb654d7cf
@@ -15,7 +15,7 @@ module PgEngine
15
15
  if usuario.confirmed_at.present?
16
16
  sign_in(:user, usuario)
17
17
  # redirect_to after_sign_in_path_for(usuario)
18
- redirect_to users_root_path
18
+ redirect_to user_root_path
19
19
  else
20
20
  go_back('No está confirmado')
21
21
  end
@@ -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? ? users_root_path : root_path)
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
@@ -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#index', as: :user_root
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 to: 'users/accounts#index'
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'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  module PgRails
4
- VERSION = '7.6.25'
5
+ VERSION = '7.6.26'
5
6
  end
7
+ # :nocov:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.25
4
+ version: 7.6.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso