Skip to content

Commit 03b49be

Browse files
Merge pull request #276 from dmitry-sinina/1.6_cp
CDR database seed fix make smallint validators accept 32767 (#272)
2 parents afcd323 + e9fd9c1 commit 03b49be

File tree

14 files changed

+137
-55
lines changed

14 files changed

+137
-55
lines changed

app/models/account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Account < Yeti::ActiveRecord
6363
validates_presence_of :name, :contractor, :timezone
6464
validates_numericality_of :max_balance, greater_than_or_equal_to: ->(account) { account.min_balance }
6565

66-
validates_numericality_of :termination_capacity, :origination_capacity, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
66+
validates_numericality_of :termination_capacity, :origination_capacity, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
6767

6868
validates_uniqueness_of :external_id, allow_blank: true
6969

app/models/customers_auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module CONST
113113
validates_numericality_of :dst_number_min_length, greater_than_or_equal_to: 0, less_than_or_equal_to: 100, allow_nil: false, only_integer: true
114114
validates_numericality_of :dst_number_max_length, greater_than_or_equal_to: 0, less_than_or_equal_to: 100, allow_nil: false, only_integer: true
115115

116-
validates_numericality_of :capacity, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
116+
validates_numericality_of :capacity, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
117117

118118
validate :ip_is_valid
119119
validate :gateway_supports_incoming_auth

app/models/dialpeer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Dialpeer < Yeti::ActiveRecord
6666
validates_numericality_of :short_calls_limit, greater_than_or_equal_to: 0.00, less_than_or_equal_to: 1.00
6767

6868
validates_numericality_of :force_hit_rate, greater_than_or_equal_to: 0.00, less_than_or_equal_to: 1.00, allow_blank: true
69-
validates_numericality_of :capacity, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
69+
validates_numericality_of :capacity, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
7070

7171
validates_presence_of :dst_number_min_length, :dst_number_max_length
7272
validates_numericality_of :dst_number_min_length, greater_than_or_equal_to: 0, less_than_or_equal_to: 100, allow_nil: false, only_integer: true

app/models/equipment/registration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Equipment::Registration < Yeti::ActiveRecord
3535
#validates_format_of :contact, :with => /\Asip:(.*)\z/
3636
validates :contact, :format => URI::regexp(%w(sip))
3737

38-
validates_numericality_of :retry_delay, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: false, only_integer: true
39-
validates_numericality_of :max_attempts, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
38+
validates_numericality_of :retry_delay, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: false, only_integer: true
39+
validates_numericality_of :max_attempts, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
4040

4141

4242
has_paper_trail class_name: 'AuditLogItem'

app/models/gateway.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ class Gateway < Yeti::ActiveRecord
153153
validates_numericality_of :asr_limit, greater_than_or_equal_to: 0.00, less_than_or_equal_to: 1.00
154154
validates_numericality_of :short_calls_limit, greater_than_or_equal_to: 0.00, less_than_or_equal_to: 1.00
155155

156-
validates_numericality_of :max_30x_redirects, :max_transfers, greater_than_or_equal_to: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
156+
validates_numericality_of :max_30x_redirects, :max_transfers, greater_than_or_equal_to: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
157157

158-
validates_numericality_of :origination_capacity, :termination_capacity, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
158+
validates_numericality_of :origination_capacity, :termination_capacity, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
159159
validates_numericality_of :port, greater_than_or_equal_to: Yeti::ActiveRecord::L4_PORT_MIN, less_than_or_equal_to: Yeti::ActiveRecord::L4_PORT_MAX, allow_nil: true, only_integer: true
160160

161-
validates_numericality_of :fake_180_timer, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
161+
validates_numericality_of :fake_180_timer, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
162162
validates_presence_of :transport_protocol, :term_proxy_transport_protocol, :orig_proxy_transport_protocol
163163
validates_presence_of :incoming_auth_username, :incoming_auth_password,
164164
if: Proc.new { |gw|

app/models/lnp/database.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
# csv_file :string
1515
#
1616

17-
class Lnp::Database< Yeti::ActiveRecord
17+
class Lnp::Database < Yeti::ActiveRecord
1818
self.table_name = 'class4.lnp_databases'
1919

2020
belongs_to :driver, class_name: Lnp::DatabaseDriver, foreign_key: :driver_id
2121
validates_presence_of :driver, :name, :host
2222
validates_uniqueness_of :name
2323

24-
validates_numericality_of :timeout, greater_than: 0, less_than: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
24+
validates_numericality_of :timeout, greater_than: 0, less_than_or_equal_to: PG_MAX_SMALLINT, allow_nil: true, only_integer: true
2525

2626

2727
def display_name

db/seeds/cdr/pgq.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
select pgq.create_queue('cdr_billing');
22
select pgq.register_consumer('cdr_billing','cdr_billing');
3+
select pgq.create_queue('cdr_streaming');

db/seeds/cdr/sys.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ INSERT INTO cdr_tables VALUES (5, 'cdr.cdr_201411', true, true, '2014-11-01', '2
3939
INSERT INTO cdr_tables VALUES (6, 'cdr.cdr_201710', true, true, '2017-10-01', '2017-11-01', true);
4040
INSERT INTO cdr_tables VALUES (7, 'cdr.cdr_201709', true, true, '2017-09-01', '2017-10-01', true);
4141
INSERT INTO cdr_tables VALUES (8, 'cdr.cdr_201708', true, true, '2017-08-01', '2017-09-01', true);
42-
42+
INSERT INTO cdr_tables VALUES (9, 'cdr.cdr_201712', true, true, '2017-12-01', '2018-01-01', true);
43+
INSERT INTO cdr_tables VALUES (10, 'cdr.cdr_201801', true, true, '2018-01-01', '2018-02-01', true);
44+
INSERT INTO cdr_tables VALUES (11, 'cdr.cdr_201802', true, true, '2018-02-01', '2018-03-01', true);
45+
INSERT INTO cdr_tables VALUES (12, 'cdr.cdr_201803', true, true, '2018-03-01', '2018-04-01', true);
46+
INSERT INTO cdr_tables VALUES (13, 'cdr.cdr_201804', true, true, '2018-04-01', '2018-05-01', true);
4347

4448
--
4549
-- TOC entry 2514 (class 0 OID 0)
4650
-- Dependencies: 295
4751
-- Name: cdr_tables_id_seq; Type: SEQUENCE SET; Schema: sys; Owner: yeti
4852
--
4953

50-
SELECT pg_catalog.setval('cdr_tables_id_seq', 8, true);
54+
SELECT pg_catalog.setval('cdr_tables_id_seq', 13, true);
5155

5256

5357
--

spec/models/account_spec.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@
3232

3333
describe Account, type: :model do
3434

35-
let!(:account) {}
36-
37-
subject do
38-
account.destroy!
35+
it do
36+
should validate_numericality_of(:origination_capacity).is_less_than_or_equal_to(Yeti::ActiveRecord::PG_MAX_SMALLINT)
37+
should validate_numericality_of(:termination_capacity).is_less_than_or_equal_to(Yeti::ActiveRecord::PG_MAX_SMALLINT)
3938
end
40-
39+
4140
context '#destroy' do
41+
let!(:account) { create(:account) }
42+
43+
subject do
44+
account.destroy!
45+
end
4246

4347
context 'wihtout linked ApiAccess records' do
4448
let!(:api_access) { create(:api_access) }
45-
let(:account) { create(:account) }
49+
4650

4751
it 'removes Account successfully' do
4852
expect { subject }.to change { described_class.count }.by(-1)
@@ -73,17 +77,17 @@
7377
end
7478

7579
context 'when Account has Payments' do
76-
let(:account) { create(:account) }
77-
78-
before do
79-
$p1 = create(:payment, account: account)
80-
$p2 = create(:payment) # for another account
80+
let!(:p1) do
81+
create(:payment, account: account)
82+
end
83+
let!(:p2) do
84+
create(:payment) # for another account
8185
end
8286

8387
it 'removes all related Payments' do
8488
expect { subject }.to change {
8589
Payment.pluck(:id)
86-
}.from([$p1.id, $p2.id]).to([$p2.id])
90+
}.from([p1.id, p2.id]).to([p2.id])
8791
end
8892
end
8993

spec/models/customers_auth_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868

6969
context '#validations' do
7070

71+
it do
72+
should validate_numericality_of(:capacity).is_less_than_or_equal_to(Yeti::ActiveRecord::PG_MAX_SMALLINT)
73+
end
74+
75+
7176
context 'validate Routing Tag' do
7277
include_examples :test_model_with_tag_action
7378
end

0 commit comments

Comments
 (0)