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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18003c61fd4e38fc6e7a70402aa0eaba4f335390e50061b1569bbea56c604a83
4
- data.tar.gz: f2732b2e071e3672cc8e4b6d16e2e577f7b6bf3590a8a6c3d76ef45215bdb67f
3
+ metadata.gz: 01d6c43a4f1804b0b45e92ebaeea5411deb1fa6dafd9a886d3ca6fe9f5151fb3
4
+ data.tar.gz: 0b1eaf69bc0fd4d9164329b90c45ed1e206195a411b060cb0ab41ec28e3eae62
5
5
  SHA512:
6
- metadata.gz: 9953c023fe35b70091a3ddc70b4a49f8cc7975476388835f1a0c7b286132afa68c4f5eaf35b6b1e80345fb2ff20251c35b9e238293b43cb217e445e226080598
7
- data.tar.gz: 39911c247bdd17a3828a378478d03bb4027326b9c9b72d9ad5c0db1dc1b0e4d491dc6b2e37d899a02043a3446818feb304969c4a828b91dc3f7bf9a0adcf89c6
6
+ metadata.gz: d2521275d846111b2386211c36524c21b0d13de8db05cc0e28fd713021ece959a0f9deb7887d9d0ec8cf20229509dff6c1feed6d67cc14934beeb44fd38feed9
7
+ data.tar.gz: 90fc3ad22510450edc3d19c0bc11f9dfba1de6471a42c2478541d4808abe69eb668f3506b44137dd815e4067d81f632ed91bdb457145eec6d11d508ae310239f
@@ -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
@@ -123,6 +123,10 @@ class User < ApplicationRecord
123
123
  end
124
124
 
125
125
  def to_s
126
+ nombre_completo_o_email
127
+ end
128
+
129
+ def nombre_completo_o_email
126
130
  nombre_completo.strip.presence || email
127
131
  end
128
132
 
@@ -9,13 +9,6 @@
9
9
  .fs-1
10
10
  = @account
11
11
 
12
- / h6
13
- |> Administrado por:
14
- = @account.owner.nombre_completo
15
- |< (
16
- = @account.owner.email
17
- | )
18
-
19
12
  - if @user_account.membership_status.ms_disabled?
20
13
  p.text-danger Deshabilitado
21
14
 
@@ -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
@@ -37,8 +37,8 @@
37
37
 
38
38
  FactoryBot.define do
39
39
  factory :user, class: 'User' do
40
- nombre { Faker::Name.first_name }
41
- apellido { Faker::Name.last_name }
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'
@@ -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.27'
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.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso