rs.ge 0.0.17 → 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rs.rb +5 -71
- data/lib/rs/models/waybill_unit.rb +21 -0
- data/lib/rs/requests/base_request.rb +20 -0
- data/lib/rs/requests/waybill_unit_request.rb +44 -0
- data/lib/rs/version.rb +1 -2
- data/rs.gemspec +3 -5
- data/spec/requests/waybill_units_spec.rb +24 -0
- data/spec/spec_helper.rb +3 -85
- metadata +14 -42
- data/lib/rs/car.rb +0 -6
- data/lib/rs/dict.rb +0 -259
- data/lib/rs/invoice.rb +0 -18
- data/lib/rs/print.rb +0 -331
- data/lib/rs/sys.rb +0 -128
- data/lib/rs/waybill.rb +0 -483
- data/problems.md +0 -1
- data/spec/rs/car_spec.rb +0 -25
- data/spec/rs/dict_spec.rb +0 -181
- data/spec/rs/open_user.rb +0 -12
- data/spec/rs/pdf_spec.rb +0 -21
- data/spec/rs/sys_spec.rb +0 -77
- data/spec/rs/waybill_delete_spec.rb +0 -63
- data/spec/rs/waybill_invoice_spec.rb +0 -19
- data/spec/rs/waybill_spec.rb +0 -205
- data/spec/rs/waybill_validation_spec.rb +0 -149
@@ -1,149 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'rs'
|
4
|
-
|
5
|
-
def validable_test(cntxt, validable, field, has_errors)
|
6
|
-
describe cntxt do
|
7
|
-
before(:all) do
|
8
|
-
yield(validable) if block_given?
|
9
|
-
validable.validate
|
10
|
-
end
|
11
|
-
subject { validable.validation_errors[field] }
|
12
|
-
if has_errors
|
13
|
-
it("Errors for #{field} not nil") { should_not be_nil }
|
14
|
-
it("Errors for #{field} not empty") { should_not be_empty }
|
15
|
-
else
|
16
|
-
it("Errors for #{field} are nil") { should be_nil }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'waybill validation' do
|
22
|
-
before(:all) do
|
23
|
-
@waybill = RS::Waybill.new
|
24
|
-
@waybill.validate
|
25
|
-
end
|
26
|
-
subject { @waybill }
|
27
|
-
it { should_not be_valid }
|
28
|
-
specify do
|
29
|
-
# buyer TIN
|
30
|
-
validable_test('buyer tin errors', @waybill, :buyer_tin, true)
|
31
|
-
validable_test('fix buyer tin errors incorrectly', @waybill, :buyer_tin, true) do |waybill|
|
32
|
-
waybill.buyer_tin = '123'
|
33
|
-
waybill.check_buyer_tin = true
|
34
|
-
end
|
35
|
-
validable_test('fix buyer tin errors correctly', @waybill, :buyer_tin, false) do |waybill|
|
36
|
-
waybill.buyer_tin = '123456789'
|
37
|
-
waybill.check_buyer_tin = true
|
38
|
-
end
|
39
|
-
# buyer name
|
40
|
-
validable_test('buyer name error', @waybill, :buyer_name, true) do |waybill|
|
41
|
-
waybill.check_buyer_tin = false
|
42
|
-
end
|
43
|
-
validable_test('fix buyer name error', @waybill, :buyer_name, false) do |waybill|
|
44
|
-
waybill.buyer_name = 'dimitri'
|
45
|
-
end
|
46
|
-
# car number
|
47
|
-
validable_test('car number error', @waybill, :car_number, true) do |waybill|
|
48
|
-
waybill.transport_type_id = RS::TransportType::VEHICLE
|
49
|
-
end
|
50
|
-
validable_test('fix car number error', @waybill, :car_number, false) do |waybill|
|
51
|
-
waybill.car_number = 'WDW842'
|
52
|
-
end
|
53
|
-
# driver name
|
54
|
-
validable_test('driver name error', @waybill, :driver_name, true) do |waybill|
|
55
|
-
waybill.transport_type_id = RS::TransportType::VEHICLE
|
56
|
-
end
|
57
|
-
validable_test('fix driver name error', @waybill, :driver_name, false) do |waybill|
|
58
|
-
waybill.driver_name = 'Dimitri Kurashvili'
|
59
|
-
end
|
60
|
-
# driver TIN
|
61
|
-
validable_test('driver tin error', @waybill, :driver_tin, true)
|
62
|
-
validable_test('driver tin error fix', @waybill, :driver_tin, false) do |waybill|
|
63
|
-
waybill.driver_tin = '123456789'
|
64
|
-
end
|
65
|
-
validable_test('driver tin error again: when checking TIN', @waybill, :driver_tin, true) do |waybill|
|
66
|
-
waybill.check_driver_tin = true
|
67
|
-
end
|
68
|
-
# transport name for RS::TransportType::OTHERS
|
69
|
-
validable_test('transport name missing', @waybill, :transport_type_name, true) do |waybill|
|
70
|
-
waybill.transport_type_id = RS::TransportType::OTHERS
|
71
|
-
end
|
72
|
-
validable_test('transport name missing: fix', @waybill, :transport_type_name, false) do |waybill|
|
73
|
-
waybill.transport_type_name = 'horse'
|
74
|
-
end
|
75
|
-
# start/end address
|
76
|
-
validable_test('start address is missing', @waybill, :start_address, true)
|
77
|
-
validable_test('end address is missing', @waybill, :end_address, true)
|
78
|
-
validable_test('fixing start address', @waybill, :start_address, false) do |waybill|
|
79
|
-
waybill.start_address = 'Tbilisi'
|
80
|
-
end
|
81
|
-
validable_test('fixing end address', @waybill, :end_address, false) do |waybill|
|
82
|
-
waybill.end_address = 'Sokhumi'
|
83
|
-
end
|
84
|
-
validable_test('waybill_type == WITHOUT_TRANSPORTATION', @waybill, :type, true) do |waybill|
|
85
|
-
waybill.type = RS::WaybillType::WITHOUT_TRANSPORTATION
|
86
|
-
end
|
87
|
-
# items
|
88
|
-
validable_test('items are missing', @waybill, :items, true)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'waybill item validation' do
|
93
|
-
before(:all) do
|
94
|
-
@item = RS::WaybillItem.new
|
95
|
-
@item.validate
|
96
|
-
end
|
97
|
-
subject { @item }
|
98
|
-
it { should_not be_valid }
|
99
|
-
specify do
|
100
|
-
validable_test('prod_name is missing', @item, :prod_name, true)
|
101
|
-
validable_test('bar_code is missing', @item, :bar_code, true)
|
102
|
-
validable_test('unit is missing', @item, :unit_id, true)
|
103
|
-
validable_test('unit name missing is ok', @item, :unit_name, false)
|
104
|
-
validable_test('quantity is missing', @item, :quantity, true)
|
105
|
-
validable_test('price is missing', @item, :price, true)
|
106
|
-
validable_test('prod_name added', @item, :prod_name, false) do |item|
|
107
|
-
item.prod_name = 'პამიდორი'
|
108
|
-
end
|
109
|
-
validable_test('bar_code added', @item, :bar_code, false) do |item|
|
110
|
-
item.bar_code = '123'
|
111
|
-
end
|
112
|
-
validable_test('unit_id added', @item, :unit_id, false) do |item|
|
113
|
-
item.unit_id = RS::WaybillUnit::OTHERS
|
114
|
-
end
|
115
|
-
validable_test('unit name not defined: it is a problem now', @item, :unit_name, true)
|
116
|
-
validable_test('unit name added', @item, :unit_name, false) do |item|
|
117
|
-
item.unit_name = 'kg'
|
118
|
-
end
|
119
|
-
validable_test('quant < 0', @item, :quantity, true) do |item|
|
120
|
-
item.quantity = -1
|
121
|
-
end
|
122
|
-
validable_test('quant > 0', @item, :quantity, false) do |item|
|
123
|
-
item.quantity = 1
|
124
|
-
end
|
125
|
-
validable_test('price < 0', @item, :price, true) do |item|
|
126
|
-
item.price = -10
|
127
|
-
end
|
128
|
-
validable_test('price > 0', @item, :price, false) do |item|
|
129
|
-
item.price = 10
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe 'validation with remote' do
|
135
|
-
before(:all) do
|
136
|
-
@waybill = waybill_skeleton(:driver_tin => '02001000490', :driver_name => 'Dimitri Kurashvili', :check_driver_tin => true, :buyer_tin => '02001000490', :buyer_name => 'Dimitri Kurashvili')
|
137
|
-
@waybill.validate(RS.su_params.merge(:remote => true))
|
138
|
-
#puts @waybill.validation_errors[:driver_name]
|
139
|
-
#puts @waybill.validation_errors[:driver_tin]
|
140
|
-
#puts @waybill.validation_errors[:buyer_name]
|
141
|
-
#puts @waybill.validation_errors[:buyer_tin]
|
142
|
-
end
|
143
|
-
subject { @waybill.validation_errors }
|
144
|
-
it { should_not be_empty }
|
145
|
-
it("should have illegal driver_name") { subject[:driver_name].should_not be_nil }
|
146
|
-
it("driver_tin is OK") { subject[:driver_tin].should be_nil }
|
147
|
-
it("should have illegal buyer name") { subject[:buyer_name].should_not be_nil }
|
148
|
-
it("buyer_tin is OK") { subject[:buyer_tin].should be_nil }
|
149
|
-
end
|