pg_rails 7.6.21.pre.1 → 7.6.21.pre.3

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: f3eab12e3524597cafecf025ff2f374fc8d4e6f263322889fa43f47d8053ce55
4
- data.tar.gz: 6f8a4178b6e30326d9d661371273fb0da7c232f413db0de7fd9d715bade85e11
3
+ metadata.gz: 5c7e8b1261e1be1d5db2d19ca5b4102f0bca77ae9f379da78249d2087e44736b
4
+ data.tar.gz: 455549bec4416393199d4b713cb653f008e4ff42a4d70f4923a1aff7b9dc1e78
5
5
  SHA512:
6
- metadata.gz: 1d8f9670e42068df07b4d3e770f412cae71d4477870986067bf95c025b9ab8879590ef688cf07090054e0d1499b8484ac6899f5a30ca9763a1d032aa4e1e9b04
7
- data.tar.gz: 78cce58eb9e2da9ac61d2cd469e85e98742e583e4bf3ffc9aea145b9e000cb4101734e9f51acb49813b70826ff6286fce475ce64feb339606deb74f5e9072bc9
6
+ metadata.gz: a94f33c4e747a6bae8d710c9a25ffea315f8d49cfadee1d111396381203d90c7716e160e45b6e5348b7389d4b0ef409c45c8d67b9df0fd8215ac111e84919b1a
7
+ data.tar.gz: f399f20faaccb9a7f9d5aa49c349faa67e1b1e7e56f850ba023f3a1b1471c1d35607dac07ee4fd1d8b39f733979add05bb0e98238b6352378cfe9fdb179a040c
@@ -2,6 +2,7 @@
2
2
  module PgAssociable
3
3
  module FormBuilderMethods
4
4
  def self.included(mod)
5
+ mod.include PgEngine::DefaultUrlOptions
5
6
  mod.include Rails.application.routes.url_helpers
6
7
  mod.include PgEngine::RouteHelper
7
8
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  class PgAssociableInput < SimpleForm::Inputs::StringInput
4
4
  include ActionView::Helpers::FormTagHelper
5
+ include PgEngine::DefaultUrlOptions
5
6
  include Rails.application.routes.url_helpers
6
7
  include PgEngine::RouteHelper
7
8
 
@@ -1,22 +1,22 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe 'Associable' do
4
- let(:user) { create :user, :developer }
4
+ let(:user) { create :user, :owner }
5
5
 
6
- let(:path) { '/a/cosas/new' }
6
+ let(:path) { '/u/t/cosas/new' }
7
7
 
8
8
  before do
9
9
  login_as user
10
10
  visit path
11
11
  end
12
12
 
13
- it do
13
+ fit do
14
14
  fill_in 'cosa_nombre', with: 'La cosa'
15
15
  select 'Los', from: 'cosa_tipo'
16
16
  find('.cosa_categoria_de_cosa input[type=text]').click
17
17
  expect(page).to have_text :all, 'Nueva categoría de cosa'
18
18
  find('.cosa_categoria_de_cosa .list-group-item').click
19
- select Account.first.to_s
19
+ # select Account.first.to_s
20
20
  fill_in 'categoria_de_cosa_nombre', with: 'la categoría'
21
21
  select 'Completar', from: 'categoria_de_cosa_tipo'
22
22
  click_on 'Agregar Categoría de cosa'
@@ -26,7 +26,7 @@ describe 'Associable' do
26
26
 
27
27
  context 'cuando crea desde el nested' do
28
28
  let!(:categ) { create :categoria_de_cosa }
29
- let(:path) { "/a/categoria_de_cosas/#{categ.hashid}/cosas/new" }
29
+ let(:path) { "/u/t/categoria_de_cosas/#{categ.hashid}/cosas/new" }
30
30
 
31
31
  it do
32
32
  input = find_by_id('cosa_categoria_de_cosa')
@@ -37,7 +37,7 @@ describe 'Associable' do
37
37
  context 'cuando edita desde el nested' do
38
38
  let!(:categ) { create :categoria_de_cosa }
39
39
  let!(:cosa) { create :cosa, categoria_de_cosa: categ }
40
- let(:path) { "/a/categoria_de_cosas/#{categ.hashid}/cosas/#{cosa.id}/edit" }
40
+ let(:path) { "/u/t/categoria_de_cosas/#{categ.hashid}/cosas/#{cosa.id}/edit" }
41
41
 
42
42
  it do
43
43
  ele = find_by_id('cosa_categoria_de_cosa_id', visible: :all)
@@ -3,6 +3,14 @@ class Current < ActiveSupport::CurrentAttributes
3
3
  # attribute :request_id, :user_agent, :ip_address
4
4
 
5
5
  # resets { Time.zone = nil }
6
+ def active_user_account
7
+ # Para los jobs
8
+ if attributes[:active_user_account].nil? && user.present? && account.present?
9
+ attributes[:active_user_account] = user.active_user_account_for(account)
10
+ end
11
+
12
+ super
13
+ end
6
14
 
7
15
  def tid
8
16
  active_user_account.to_param
@@ -132,12 +132,12 @@ class User < ApplicationRecord
132
132
 
133
133
  class Error < PgEngine::Error; end
134
134
 
135
- def default_account
136
- raise Error, 'El usuario debe tener cuenta' if accounts.empty?
135
+ # def default_account
136
+ # raise Error, 'El usuario debe tener cuenta' if accounts.empty?
137
137
 
138
- user_accounts.first.account
139
- # throw :warden, scope: :user, message: :user_not_belongs_to_account
140
- end
138
+ # user_accounts.first.account
139
+ # # throw :warden, scope: :user, message: :user_not_belongs_to_account
140
+ # end
141
141
 
142
142
  deprecate :current_account, deprecator: PgEngine.deprecator
143
143
 
@@ -39,7 +39,7 @@ class UserAccount < ApplicationRecord
39
39
  belongs_to :creado_por, optional: true, class_name: 'User'
40
40
  belongs_to :actualizado_por, optional: true, class_name: 'User'
41
41
 
42
- validates :user_id, uniqueness: { scope: :account_id }
42
+ validates_uniqueness_to_tenant :user_id
43
43
 
44
44
  after_destroy :cleanup_invitation
45
45
  def cleanup_invitation
@@ -3,4 +3,11 @@ class AddMembershipStatusToUserAccounts < ActiveRecord::Migration[7.2]
3
3
  add_column :user_accounts, :membership_status, :integer, null: false, default: 1
4
4
  add_column :user_accounts, :invitation_status, :integer, null: false, default: 1
5
5
  end
6
+
7
+ def migrate(direction)
8
+ if direction == :up
9
+ UserAccount.update_all(profiles: [0])
10
+ end
11
+ super
12
+ end
6
13
  end
@@ -13,4 +13,4 @@ rené = FactoryBot.create(:user, email: 'rene@bien.com', nombre: 'René', apelli
13
13
  confirmed_at: Time.now)
14
14
 
15
15
  racionalismo.user_accounts.create!(user: baruch, profiles: [:account__owner])
16
- racionalismo.user_accounts.create!(user: rené, profiles: [:cosas__read])
16
+ racionalismo.user_accounts.create!(user: rené, profiles: [])
@@ -70,8 +70,11 @@ FactoryBot.define do
70
70
  end
71
71
 
72
72
  trait :owner do
73
- user_accounts do
74
- [build(:user_account, account: ActsAsTenant.current_tenant, profiles: [:account__owner])]
73
+ after(:create) do |model|
74
+ model.user_accounts.create!(profiles: [:account__owner])
75
+ # ActsAsTenant.with_tenant(create(:account)) do
76
+ # model.user_accounts.create!(profiles: [:account__owner])
77
+ # end
75
78
  end
76
79
  end
77
80
  end
@@ -13,10 +13,6 @@ RSpec.describe User do
13
13
  expect(UserAccount.first.profiles).to include(:account__owner)
14
14
  end
15
15
 
16
- it do
17
- expect(user.default_account).to be_present
18
- end
19
-
20
16
  describe 'search ransacker' do
21
17
  it 'searchs' do
22
18
  results = described_class.ransack(search_cont: user.nombre).result.to_a
@@ -51,6 +51,7 @@ html
51
51
  }
52
52
 
53
53
  body
54
+ span#tid.d-none data-tid="#{Current.tid}"
54
55
  - sidebar_present = @navbar.present? && @sidebar != false
55
56
  - if sidebar_present
56
57
  = render partial: 'pg_layout/sidebar_mobile'
@@ -44,7 +44,7 @@
44
44
  i.bi.bi-person-circle.me-2 style="font-size: 1.7em"
45
45
  = Current.user
46
46
  ul.dropdown-menu
47
- li = link_to 'Perfil', edit_user_registration_path(tid: nil), class: 'dropdown-item'
47
+ li = link_to 'Mi cuenta', edit_user_registration_path(tid: nil), class: 'dropdown-item'
48
48
  li = link_to Account.model_name.human(count: 2), users_accounts_path(tid: nil), class: 'dropdown-item'
49
49
  - if Current.user.developer?
50
50
  li = link_to 'Admin', admin_users_path, class: 'dropdown-item'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.6.21.pre.1'
4
+ VERSION = '7.6.21-3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.21.pre.1
4
+ version: 7.6.21.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-02 00:00:00.000000000 Z
11
+ date: 2024-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails