gestion 1.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +48 -0
- data/.project +14 -0
- data/Binaries/adduser_to_buzz +15 -0
- data/Binaries/backup +7 -0
- data/Binaries/check_gestion +8 -0
- data/Binaries/gestion.gnumail +22 -0
- data/Binaries/gestion.logrotate +34 -0
- data/Binaries/gestion.service +12 -0
- data/Binaries/gestion_update.rb +183 -0
- data/Binaries/gestion_update.service +10 -0
- data/Binaries/get_compta +11 -0
- data/Binaries/kill_gestion +16 -0
- data/Binaries/ldap/add_indexes +51 -0
- data/Binaries/ldap/backup +2 -0
- data/Binaries/ldap/install_ldap +92 -0
- data/Binaries/ldap/restore +7 -0
- data/Binaries/lib_backup +5 -0
- data/Binaries/log_scan_errors +8 -0
- data/Binaries/loop_gestion +64 -0
- data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
- data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
- data/Binaries/reboot +5 -0
- data/Binaries/restore +3 -0
- data/Binaries/restore_do +22 -0
- data/Binaries/sort_events +31 -0
- data/Binaries/start_gestion +18 -0
- data/Binaries/swipe_gestion +18 -0
- data/Binaries/update_africompta +21 -0
- data/Binaries/update_users +3 -0
- data/Diplomas.src/accredited.odg +0 -0
- data/Diplomas.src/diploma.odg +0 -0
- data/Diplomas.src/label.odg +0 -0
- data/Diplomas.src/presence_sheet.ods +0 -0
- data/Diplomas.src/presence_sheet_small.ods +0 -0
- data/Diplomas.src/student_card.odg +0 -0
- data/Doc/130514-it-ideas.odt +0 -0
- data/Doc/Compta-cash.mm +179 -0
- data/Doc/General.odt +0 -0
- data/Entities/AccessGroups.rb +117 -0
- data/Entities/Activity.rb +178 -0
- data/Entities/ChatMsg.rb +142 -0
- data/Entities/Classroom.rb +11 -0
- data/Entities/Client.rb +19 -0
- data/Entities/Computer.rb +21 -0
- data/Entities/ConfigBase.rb +280 -0
- data/Entities/Course.rb +1588 -0
- data/Entities/CourseType.rb +171 -0
- data/Entities/DFiles.rb +466 -0
- data/Entities/FilesManage.rb +226 -0
- data/Entities/Grade.rb +186 -0
- data/Entities/Internet.rb +300 -0
- data/Entities/Netdev.rb +10 -0
- data/Entities/Person.rb +1175 -0
- data/Entities/Plug.rb +98 -0
- data/Entities/Quiz.rb +33 -0
- data/Entities/Recharges.rb +37 -0
- data/Entities/Report.rb +136 -0
- data/Entities/Room.rb +12 -0
- data/Entities/SMS.rb +30 -0
- data/Entities/ScheduleType.rb +33 -0
- data/Entities/Share.rb +120 -0
- data/Entities/Task.rb +51 -0
- data/Entities/Ticket.rb +72 -0
- data/Entities/Usage.rb +143 -0
- data/Entities/Worker.rb +29 -0
- data/Files/apache-profeda.conf +36 -0
- data/Files/label.erb +121 -0
- data/Files/label_notfound.erb +64 -0
- data/Files/label_notpassed.erb +84 -0
- data/Files/mobileinfo.erb +115 -0
- data/Files/smb.conf +333 -0
- data/Files/timetable.html +36 -0
- data/Files/timetable.js +239 -0
- data/Gemfile +12 -0
- data/Gemfile.dev +12 -0
- data/Gemfile.dev.lock +127 -0
- data/Gemfile.lock +127 -0
- data/Gemfile.prod +8 -0
- data/Gestion +35 -0
- data/Gestion.rb +220 -0
- data/INSTALL +40 -0
- data/Images/connection.xcf +0 -0
- data/Images/connection_no.png +0 -0
- data/Images/connection_wait.png +0 -0
- data/Images/connection_yes.png +0 -0
- data/Paths/Exas.rb +13 -0
- data/Paths/Files.rb +19 -0
- data/Paths/GetDiplomas.rb +20 -0
- data/Paths/Info.rb +114 -0
- data/Paths/Label.rb +187 -0
- data/Paths/MobileInfo.rb +19 -0
- data/Paths/internetCash.rb +34 -0
- data/Paths/internetWifi.rb +54 -0
- data/README.md +60 -0
- data/Rakefile +13 -0
- data/TODO +1391 -0
- data/Test/.gitignore +3 -0
- data/Test/Diplomas/base_gestion.odt +0 -0
- data/Test/Diplomas/base_report.odt +0 -0
- data/Test/Diplomas/carte_etudiant.odg +0 -0
- data/Test/Diplomas/exam_language.odt +0 -0
- data/Test/Diplomas/label.odg +0 -0
- data/Test/Diplomas/presence_sheet.ods +0 -0
- data/Test/Diplomas/presence_sheet_small.ods +0 -0
- data/Test/Diplomas/student_card.odg +0 -0
- data/Test/Manual/testMerge +18 -0
- data/Test/config_test.yaml +26 -0
- data/Test/db.testGestion +0 -0
- data/Test/dfiles/descs/avg-rescue.desc +10 -0
- data/Test/dfiles/descs/avg.desc +8 -0
- data/Test/dfiles/descs/driver.desc +8 -0
- data/Test/dfiles/descs/linuxmint.desc +7 -0
- data/Test/dfiles/files/avg-160203.exe +1 -0
- data/Test/dfiles/files/avg.iso +1 -0
- data/Test/dfiles/files/driver.exe +1 -0
- data/Test/dfiles/index_post.html +3 -0
- data/Test/dfiles/index_pre.html +8 -0
- data/Test/dfiles/priorities +5 -0
- data/Test/ge_activity.rb +124 -0
- data/Test/ge_chat.rb +106 -0
- data/Test/ge_compta.rb +67 -0
- data/Test/ge_configbase.rb +54 -0
- data/Test/ge_course.rb +1114 -0
- data/Test/ge_dfiles.rb +121 -0
- data/Test/ge_filesmanage.rb +180 -0
- data/Test/ge_info.rb +27 -0
- data/Test/ge_internet.rb +246 -0
- data/Test/ge_login.rb +55 -0
- data/Test/ge_person.rb +373 -0
- data/Test/ge_qvinfo.rb +28 -0
- data/Test/ge_report.rb +97 -0
- data/Test/ge_share.rb +27 -0
- data/Test/ge_sms.rb +34 -0
- data/Test/ge_tasks.rb +19 -0
- data/Test/ge_usage.rb +168 -0
- data/Test/ge_view.rb +46 -0
- data/Test/multiconf-captive +29 -0
- data/Test/test.conf +7 -0
- data/Test/test.rb +49 -0
- data/Test/test_bytes.png +0 -0
- data/VERSION +140 -0
- data/Views/Admin/Backup.rb +91 -0
- data/Views/Admin/Configuration.rb +44 -0
- data/Views/Admin/Credit.rb +32 -0
- data/Views/Admin/FilesManage.rb +219 -0
- data/Views/Admin/Function.rb +39 -0
- data/Views/Admin/Power.rb +49 -0
- data/Views/Admin/Printer.rb +37 -0
- data/Views/Admin/Server.rb +252 -0
- data/Views/Admin/Tabs.rb +5 -0
- data/Views/Admin/Update.rb +73 -0
- data/Views/Admin/UpdateSystem.rb +26 -0
- data/Views/Cashbox/Activity.rb +191 -0
- data/Views/Cashbox/Course.rb +141 -0
- data/Views/Cashbox/Credit.rb +79 -0
- data/Views/Cashbox/Report.rb +115 -0
- data/Views/Cashbox/Service.rb +105 -0
- data/Views/Cashbox/Tabs.rb +10 -0
- data/Views/Compta/Accounts.rb +36 -0
- data/Views/Compta/Course.rb +96 -0
- data/Views/Compta/Show.rb +6 -0
- data/Views/Compta/Transfer.rb +66 -0
- data/Views/Course/Diploma.rb +203 -0
- data/Views/Course/Grade.rb +401 -0
- data/Views/Course/Modify.rb +447 -0
- data/Views/Course/Print.rb +94 -0
- data/Views/Course/Responsible.rb +44 -0
- data/Views/Course/Stats.rb +76 -0
- data/Views/Course/Students.rb +92 -0
- data/Views/Course/Tabs.rb +220 -0
- data/Views/Internet/Access.rb +134 -0
- data/Views/Internet/ClassEdit.rb +24 -0
- data/Views/Internet/ClassUsers.rb +81 -0
- data/Views/Internet/Config.rb +32 -0
- data/Views/Internet/Mobile.rb +213 -0
- data/Views/Internet/Recharges.rb +49 -0
- data/Views/Internet/Tabs.rb +6 -0
- data/Views/Inventory/Computer.rb +24 -0
- data/Views/Inventory/Room.rb +18 -0
- data/Views/Inventory/Tabs.rb +9 -0
- data/Views/Inventory/TicketClosed.rb +7 -0
- data/Views/Inventory/TicketOpen.rb +23 -0
- data/Views/Library/Person.rb +36 -0
- data/Views/Library/Tabs.rb +7 -0
- data/Views/Network/Block.rb +87 -0
- data/Views/Network/Netdevs.rb +21 -0
- data/Views/Network/Restriction.rb +37 -0
- data/Views/Network/Share.rb +167 -0
- data/Views/Network/Tables.rb +28 -0
- data/Views/Network/Tabs.rb +6 -0
- data/Views/Person/Admin.rb +99 -0
- data/Views/Person/Center.rb +48 -0
- data/Views/Person/Course.rb +72 -0
- data/Views/Person/Modify.rb +153 -0
- data/Views/Person/Tabs.rb +162 -0
- data/Views/Report/ComptaExecutive.rb +221 -0
- data/Views/Report/ComptaFlat.rb +79 -0
- data/Views/Report/ReportCourse.rb +47 -0
- data/Views/Report/Tabs.rb +8 -0
- data/Views/Report/Usage.rb +52 -0
- data/Views/Report/UsageCases.rb +59 -0
- data/Views/Self/Cash.rb +67 -0
- data/Views/Self/Chat.rb +55 -0
- data/Views/Self/Concours.rb +109 -0
- data/Views/Self/Email.rb +34 -0
- data/Views/Self/Internet.rb +255 -0
- data/Views/Self/Results.rb +17 -0
- data/Views/Self/Services.rb +85 -0
- data/Views/Self/Show.rb +47 -0
- data/Views/Self/Tabs.rb +5 -0
- data/Views/Special/DFileEdit.rb +13 -0
- data/Views/Special/PlugEdit.rb +56 -0
- data/Views/Special/Tabs.rb +6 -0
- data/Views/Special/Vnc.rb +39 -0
- data/Views/Task/Client.rb +21 -0
- data/Views/Task/Edit.rb +33 -0
- data/Views/Task/List.rb +55 -0
- data/Views/Task/Tabs.rb +9 -0
- data/Views/Task/Worker.rb +30 -0
- data/Views/Template/Activity.rb +33 -0
- data/Views/Template/CourseType.rb +63 -0
- data/Views/Template/ScheduleType.rb +29 -0
- data/Views/Template/Tabs.rb +5 -0
- data/Views/Welcome.rb +121 -0
- data/config.yaml.default +36 -0
- data/po/Gestion-ar.po +2356 -0
- data/po/Gestion-en.mo +0 -0
- data/po/Gestion-en.po +4363 -0
- data/po/Gestion-fr.mo +0 -0
- data/po/Gestion-fr.po +4345 -0
- data/po/traduction-ar.rtf +76 -0
- metadata +381 -0
data/Test/ge_person.rb
ADDED
@@ -0,0 +1,373 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class Array
|
4
|
+
def undate
|
5
|
+
self.each { |l| l.undate }
|
6
|
+
self
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Hash
|
11
|
+
def undate
|
12
|
+
self.delete(:date_stamp)
|
13
|
+
self
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TC_Person < Test::Unit::TestCase
|
18
|
+
def send_to_sqlite_users(m)
|
19
|
+
Entities.Movements.send(m.to_sym)
|
20
|
+
Entities.Accounts.send(m.to_sym)
|
21
|
+
Entities.Users.send(m.to_sym)
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup
|
25
|
+
permissions_init
|
26
|
+
|
27
|
+
dputs(1) { 'Setting up' }
|
28
|
+
Entities.delete_all_data
|
29
|
+
dputs(2) { 'Resetting SQLite' }
|
30
|
+
SQLite.dbs_close_all
|
31
|
+
FileUtils.cp('db.testGestion', 'data/compta.db')
|
32
|
+
SQLite.dbs_open_load_migrate
|
33
|
+
|
34
|
+
ConfigBases.init_load
|
35
|
+
|
36
|
+
@admin = Entities.Persons.create(:login_name => 'admin', :password => 'super123',
|
37
|
+
:permissions => ['admin'], :account_name_due => 'Linus')
|
38
|
+
@josue = Entities.Persons.create(:login_name => 'josue', :password => 'super',
|
39
|
+
:permissions => %w( default director secretary ),
|
40
|
+
:account_due => Accounts.create_path('Root::Lending::Josué'))
|
41
|
+
@surf = Entities.Persons.create(:login_name => 'surf', :password => 'super',
|
42
|
+
:permissions => ['default'])
|
43
|
+
@student = Entities.Persons.create(:login_name => 'student', :password => 'super',
|
44
|
+
:permissions => ['student'])
|
45
|
+
@student2 = Entities.Persons.create(:login_name => 'student2', :password => 'super',
|
46
|
+
:permissions => ['student'])
|
47
|
+
@secretary = Entities.Persons.create(:login_name => 'secr',
|
48
|
+
:permissions => ['secretary'])
|
49
|
+
@teacher = Entities.Persons.create(:login_name => 'teacher',
|
50
|
+
:permissions => ['teacher'])
|
51
|
+
@center = Persons.create(:login_name => 'foo', :permissions => ['center'])
|
52
|
+
@accountant = Persons.create(:login_name => 'accountant',
|
53
|
+
:permissions => ['accountant'])
|
54
|
+
|
55
|
+
@long = Persons.create(first_name: 'foo', family_name: 'bar')
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def teardown
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_responsibles
|
63
|
+
resps = Persons.responsibles
|
64
|
+
assert_equal [[8, 'Foo'], [2, 'Josue'], [6, 'Secr'], [7, 'Teacher']], resps
|
65
|
+
@surf.permissions = @surf.permissions + ['teacher']
|
66
|
+
assert_equal [[8, 'Foo'], [2, 'Josue'], [6, 'Secr'], [3, 'Surf'], [7, 'Teacher']],
|
67
|
+
Persons.responsibles
|
68
|
+
assert Persons.resps != []
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_addcash
|
72
|
+
ConfigBase.store(functions: %w(accounting accounting_courses))
|
73
|
+
assert_equal @josue, Entities.Persons.match_by_login_name('josue')
|
74
|
+
assert_equal @surf, Entities.Persons.match_by_login_name('surf')
|
75
|
+
assert_equal @admin, Entities.Persons.match_by_login_name('admin')
|
76
|
+
Sessions.create(@surf)
|
77
|
+
session = Sessions.create(@josue)
|
78
|
+
|
79
|
+
surf_credit = @surf.internet_credit.to_i
|
80
|
+
josue_due = @josue.account_total_due.to_i
|
81
|
+
dputs(1) { "surf_credit: #{surf_credit} - josue_due: #{josue_due}" }
|
82
|
+
# Josue puts 500 on "surf"s account
|
83
|
+
View.CashboxCredit.rpc_button(session, 'add_credit',
|
84
|
+
{'login_name' => 'surf', 'credit_add' => 500})
|
85
|
+
assert_equal 500, @surf.internet_credit.to_i - surf_credit, 'Credit'
|
86
|
+
assert_equal -500, @josue.account_total_due.to_i - josue_due, 'account_total_due'
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_accents
|
90
|
+
@bizarre1 = Entities.Persons.create({:first_name => 'éaënne', :family_name => 'ässer'})
|
91
|
+
@bizarre2 = Entities.Persons.create({:first_name => '@hello', :family_name => 'wœrld#'})
|
92
|
+
assert_equal 'aeaenne', @bizarre1.login_name
|
93
|
+
assert_equal 'w_hello', @bizarre2.login_name
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_creation
|
97
|
+
@name1 = Entities.Persons.create({:first_name => 'one two three'})
|
98
|
+
assert_equal 'One', @name1.first_name
|
99
|
+
assert_equal 'Two Three', @name1.family_name
|
100
|
+
|
101
|
+
@name2 = Entities.Persons.create({:first_name => 'one two three four'})
|
102
|
+
assert_equal 'One Two', @name2.first_name
|
103
|
+
assert_equal 'Three Four', @name2.family_name
|
104
|
+
assert_equal 'tone2', @name2.login_name
|
105
|
+
end
|
106
|
+
|
107
|
+
def tesst_print
|
108
|
+
@admin.print
|
109
|
+
end
|
110
|
+
|
111
|
+
def tesst_print_accent
|
112
|
+
@accents = Entities.Persons.create({:first_name => 'éaënne', :family_name => 'ässer'})
|
113
|
+
@accents.print
|
114
|
+
end
|
115
|
+
|
116
|
+
# Problem with test_permissions
|
117
|
+
def test_account_due
|
118
|
+
ConfigBase.store(functions: %w(accounting accounting_courses))
|
119
|
+
@secretary = Entities.Persons.create(:login_name => 'secretary',
|
120
|
+
:permissions => ['secretary'])
|
121
|
+
|
122
|
+
assert_equal 'Root::Lending::Secretary',
|
123
|
+
@secretary.account_due.get_path, @secretary.inspect
|
124
|
+
|
125
|
+
assert_equal nil, @surf.account_due
|
126
|
+
|
127
|
+
@surf.permissions = %w( default secretary )
|
128
|
+
assert_equal 'Root::Lending::Surf', @surf.account_due.get_path
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_account_cash
|
132
|
+
ConfigBase.store(functions: %w(accounting accounting_courses))
|
133
|
+
@accountant = Persons.create(:login_name => 'acc', :password => 'super',
|
134
|
+
:permissions => ['accountant'])
|
135
|
+
@accountant2 = Persons.create(:login_name => 'acc2', :password => 'super',
|
136
|
+
:permissions => ['accountant'])
|
137
|
+
|
138
|
+
assert_not_nil @accountant.account_cash
|
139
|
+
assert_equal 'Root::Cash::Acc', @accountant.account_cash.get_path
|
140
|
+
assert_equal 0, @accountant.total_cash.to_f
|
141
|
+
assert_equal 0, @accountant2.total_cash.to_f
|
142
|
+
|
143
|
+
internet_credit = @josue.account_total_due
|
144
|
+
@josue.add_internet_credit(@surf, 1000)
|
145
|
+
assert_equal -1000, @josue.account_total_due - internet_credit
|
146
|
+
|
147
|
+
assert @accountant.get_cash(@josue, 1000)
|
148
|
+
assert_equal 0, @josue.account_total_due - internet_credit
|
149
|
+
assert_equal 0, @accountant2.total_cash.to_f
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_account_cash_update
|
153
|
+
ConfigBase.store(functions: %w(accounting accounting_courses))
|
154
|
+
|
155
|
+
assert_equal nil, @surf.account_cash
|
156
|
+
|
157
|
+
@surf.permissions = %w( default accountant )
|
158
|
+
assert_not_nil @surf.account_cash
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_listp_account_due
|
162
|
+
ConfigBase.store(functions: %w(accounting accounting_courses))
|
163
|
+
|
164
|
+
list = Persons.listp_account_due
|
165
|
+
assert_equal [[6, ' 0 - Secr'], [2, ' 0 - Josue']], list
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_has_all_rights
|
169
|
+
assert_equal %w(CashboxCredit FlagAddCenter FlagAddInternet FlagResponsible
|
170
|
+
Internet PersonModify PersonShow View Welcome),
|
171
|
+
Permission.views(@josue.permissions)
|
172
|
+
assert_equal %w(CashboxCredit FlagAddInternet FlagResponsible Internet
|
173
|
+
PersonModify PersonShow View Welcome),
|
174
|
+
Permission.views(@secretary.permissions)
|
175
|
+
assert_equal %w(View Welcome), Permission.views(@surf.permissions)
|
176
|
+
assert_equal %w(FlagResponsible Internet PersonShow View Welcome),
|
177
|
+
Permission.views(@teacher.permissions)
|
178
|
+
assert_equal true, @admin.has_all_rights_of(@josue)
|
179
|
+
assert_equal false, @josue.has_all_rights_of(@admin)
|
180
|
+
assert_equal true, @admin.has_all_rights_of(@secretary)
|
181
|
+
assert_equal false, @secretary.has_all_rights_of(@admin)
|
182
|
+
assert_equal true, @josue.has_all_rights_of(@secretary)
|
183
|
+
assert_equal false, @secretary.has_all_rights_of(@josue)
|
184
|
+
assert_equal true, @secretary.has_all_rights_of(@surf)
|
185
|
+
assert_equal false, @teacher.has_all_rights_of(@secretary)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_permission_sort
|
189
|
+
assert_equal %w(accountant admin center default director internet secretary student teacher),
|
190
|
+
View.PersonAdmin.layout_find('permissions').to_a[3][:list_values].sort
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_has_permission
|
194
|
+
assert @secretary.has_permission? :secretary
|
195
|
+
assert @secretary.has_permission? 'secretary'
|
196
|
+
assert @secretary.has_permission? :PersonModify
|
197
|
+
assert @secretary.has_permission? 'PersonModify'
|
198
|
+
assert @secretary.has_permission? :Internet
|
199
|
+
assert @secretary.has_permission? 'Internet'
|
200
|
+
assert !@secretary.has_permission?(:FlagAccounting)
|
201
|
+
assert !@secretary.has_permission?('FlagAccounting')
|
202
|
+
assert !@secretary.has_permission?(:admin)
|
203
|
+
assert !@secretary.has_permission?('admin')
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_delete
|
207
|
+
@maint = Courses.create(:name => 'maint_1201')
|
208
|
+
@grade = Grades.save_data(:course => @maint,
|
209
|
+
:student => @surf, :means => [12])
|
210
|
+
|
211
|
+
assert_equal 1, Grades.matches_by_student(@surf).length, Grades.data.inspect
|
212
|
+
|
213
|
+
@surf.delete
|
214
|
+
|
215
|
+
assert_equal 0, Grades.matches_by_student(@surf).length
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_delete_needed
|
219
|
+
@maint = Courses.create(:name => 'maint_1201', :teacher => @admin)
|
220
|
+
|
221
|
+
begin
|
222
|
+
@admin.delete
|
223
|
+
rescue IsNecessary => who
|
224
|
+
assert_equal 'maint_1201', who.for_course.name
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# def test_multilogin
|
229
|
+
# assert_equal nil, Views.Welcome.rpc_show( nil )
|
230
|
+
# end
|
231
|
+
|
232
|
+
def test_cash_msg
|
233
|
+
data = {'copies_laser' => '0', 'heures_groupe_grand' => '', 'CDs' => nil,
|
234
|
+
'autres_text' => '', 'autres_cfa' => ''}
|
235
|
+
assert_equal '{}', SelfServices.cash_msg(data)
|
236
|
+
|
237
|
+
data['copies_laser'] = 100
|
238
|
+
assert_equal "{\"copies_laser\"=>\"100\"}", SelfServices.cash_msg(data)
|
239
|
+
|
240
|
+
data['copies_laser'] = 0
|
241
|
+
data['autres_text'] = 'électricité'
|
242
|
+
data['autres_cfa'] = 1000
|
243
|
+
assert_equal "{\"autres_cfa\"=>\"1000\"}", SelfServices.cash_msg(data)
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_report_pdf
|
247
|
+
ConfigBase.add_function(:accounting_courses)
|
248
|
+
assert @secretary.account_due
|
249
|
+
|
250
|
+
ctype = CourseTypes.create(:name => 'base',
|
251
|
+
:account_base => Accounts.create_path('Root::Income::Courses'))
|
252
|
+
course = Courses.create_ctype(ctype, '1404')
|
253
|
+
assert course.entries
|
254
|
+
|
255
|
+
date = Date.new(2014, 4, 10)
|
256
|
+
Movements.create('test', date - 1, 10, course.entries, @secretary.account_due)
|
257
|
+
Movements.create('test', date, 20.1, course.entries, @secretary.account_due)
|
258
|
+
Movements.create('test', date - 2, 30, course.entries, @secretary.account_due)
|
259
|
+
|
260
|
+
file = @secretary.report_pdf(3)
|
261
|
+
|
262
|
+
assert file
|
263
|
+
ConfigBase.del_function(:accounting_courses)
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_get_all_due
|
267
|
+
ConfigBase.add_function(:accounting_courses)
|
268
|
+
service = ConfigBase.account_services
|
269
|
+
|
270
|
+
assert_equal 0, @secretary.account_due.total.to_f
|
271
|
+
assert_equal 0, @secretary.account_due_paid.total.to_f
|
272
|
+
assert_equal 0, service.total.to_f
|
273
|
+
assert_equal 0, @accountant.account_cash.total.to_f
|
274
|
+
|
275
|
+
@secretary.pay_service(10000, 'test1')
|
276
|
+
@secretary.pay_service(1000, 'test2')
|
277
|
+
assert_equal 11.0, @secretary.account_due.total.to_f
|
278
|
+
assert_equal 0, @secretary.account_due_paid.total.to_f
|
279
|
+
assert_equal 11.0, service.total.to_f
|
280
|
+
|
281
|
+
@accountant.get_all_due(@secretary)
|
282
|
+
assert_equal 11.0, @accountant.account_cash.total.to_f
|
283
|
+
assert_equal 0, @secretary.account_due.total.to_f
|
284
|
+
assert_equal 0, @secretary.account_due_paid.total.to_f
|
285
|
+
assert_equal 11.0, service.total.to_f
|
286
|
+
|
287
|
+
ConfigBase.del_function(:accounting_courses)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_create_person
|
291
|
+
person = Persons.create_person('Foo bar')
|
292
|
+
assert_equal 'bfoo2', person.login_name
|
293
|
+
|
294
|
+
person = Persons.create_person('Foo bar', @secretary)
|
295
|
+
assert_equal 'bfoo3', person.login_name
|
296
|
+
|
297
|
+
person = Persons.create_person('Foo bar', @secretary, 'foobar')
|
298
|
+
assert_equal 'foobar', person.login_name
|
299
|
+
|
300
|
+
person = Persons.create_person('Foo bar', @center)
|
301
|
+
assert_equal 'foo_bfoo', person.login_name
|
302
|
+
|
303
|
+
person = Persons.create_person('Foo bar', @center, 'foobar')
|
304
|
+
assert_equal 'foo_foobar', person.login_name
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_responsibles_raw
|
309
|
+
resps = Persons.responsibles_raw
|
310
|
+
assert_equal %w(josue secr teacher foo),
|
311
|
+
resps.collect { |p| p.login_name }
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_migrate_5
|
315
|
+
Entities.delete_all_data
|
316
|
+
|
317
|
+
lending = Accounts.create('Linus', 'Too lazy', Accounts.match_by_name('Lending'))
|
318
|
+
paid = Accounts.create('Paid', '', lending)
|
319
|
+
cash = Accounts.create('Linus', 'Too lazy', Accounts.match_by_name('Cash'))
|
320
|
+
ConfigBases.init_load
|
321
|
+
|
322
|
+
FileUtils.mkdir_p 'data2'
|
323
|
+
IO.write 'data2/Persons.csv',
|
324
|
+
'{"person_id":2,"login_name":"linus","permissions":["teacher"],'+
|
325
|
+
'"first_name":"Linus","family_name":"","internet_credit":0,'+
|
326
|
+
'"password_plain":"6978","password":"6978","gender":["male"],'+
|
327
|
+
'"account_name_due":"Linus","account_name_cash":"Linus"}' +
|
328
|
+
"\n"
|
329
|
+
IO.write 'data2/MigrationVersions.csv',
|
330
|
+
'{"migrationversion_id":1,"class_name":"Person","version":4}' +
|
331
|
+
"\n"
|
332
|
+
Entities.load_all
|
333
|
+
|
334
|
+
linus = Persons.match_by_login_name :linus
|
335
|
+
assert_equal lending.to_s, linus.account_due.to_s
|
336
|
+
assert_equal paid.to_s, linus.account_due_paid.to_s
|
337
|
+
assert_equal cash.to_s, linus.account_cash.to_s
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_double_responsibles
|
341
|
+
assert_equal %w(josue secr teacher foo),
|
342
|
+
Persons.responsibles_raw.collect { |p| p.login_name }
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_delete_responsible
|
346
|
+
@teacher.delete
|
347
|
+
assert_equal %w(josue secr foo),
|
348
|
+
Persons.responsibles_raw.collect { |p| p.login_name }
|
349
|
+
assert_equal %w(Foo Josue Secr),
|
350
|
+
Persons.responsibles.collect { |i, n| n }
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_search_in
|
354
|
+
lvl = 3
|
355
|
+
assert_equal [], Persons.search_in('foobar')
|
356
|
+
assert_equal 2, Persons.search_in('student').length
|
357
|
+
assert_equal 0, Persons.search_in('test_search').length
|
358
|
+
assert_equal 0, Persons.search_in('test').length
|
359
|
+
assert_equal 0, Persons.search_in('search').length
|
360
|
+
assert_equal 1, Persons.search_in('foo bar').length
|
361
|
+
|
362
|
+
(1..400).each { |i|
|
363
|
+
Persons.create(login_name: "test_search_#{i}", first_name: 'test',
|
364
|
+
family_name: 'search')
|
365
|
+
}
|
366
|
+
|
367
|
+
Timing.measure('search 1', lvl) { assert_equal 20, Persons.search_in('test_search').length }
|
368
|
+
Timing.measure('search 2', lvl) { assert_equal 20, Persons.search_in('test').length }
|
369
|
+
Timing.measure('search 3', lvl) { assert_equal 20, Persons.search_in('search').length }
|
370
|
+
|
371
|
+
Timing.measure('search all', lvl) { assert_equal 400, Persons.search_in('test_search', max: 400).length }
|
372
|
+
end
|
373
|
+
end
|
data/Test/ge_qvinfo.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
Permission.add( 'default', '.*' )
|
4
|
+
Permission.add( 'student', '.*' )
|
5
|
+
Permission.add( 'teacher', '.*' )
|
6
|
+
|
7
|
+
class TC_QVInfo < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
Entities.delete_all_data()
|
10
|
+
@admin = Entities.Persons.create( :login_name => "admin", :password => "super123",
|
11
|
+
:permissions => [ "default", "teacher" ], :first_name => "Admin", :family_name => "The" )
|
12
|
+
@secretaire = Entities.Persons.create( :login_name => "josue", :password => "super",
|
13
|
+
:permissions => [ "default", "teacher" ], :first_name => "Le", :family_name => "Secretaire" )
|
14
|
+
@surf = Entities.Persons.create( :login_name => "surf", :password => "super",
|
15
|
+
:permissions => [ "default" ], :first_name => "Internet", :family_name => "Surfer" )
|
16
|
+
@net = Entities.Courses.create( :name => "net_1001", :start => "01.02.03", :end => "04.05.03" )
|
17
|
+
@base = Entities.Courses.create( :name => "base_1004" )
|
18
|
+
@base.students = %w( admin2 surf )
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_course
|
22
|
+
# Is the student allowed to log-in during the duration of the course?
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_internet
|
26
|
+
# Can the person connect to the internet if he has cash?
|
27
|
+
end
|
28
|
+
end
|
data/Test/ge_report.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TC_Report < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Entities.delete_all_data()
|
7
|
+
|
8
|
+
SQLite.dbs_close_all
|
9
|
+
FileUtils.cp('db.testGestion', 'data/compta.db')
|
10
|
+
SQLite.dbs_open_load_migrate
|
11
|
+
|
12
|
+
ConfigBases.init_load
|
13
|
+
|
14
|
+
ConfigBase.add_function(:accounting_courses)
|
15
|
+
|
16
|
+
@secretary =
|
17
|
+
Entities.Persons.create(:login_name => 'secretary', :password => 'super',
|
18
|
+
:permissions => ['default', 'teacher', 'secretary'],
|
19
|
+
:first_name => 'The', :family_name => 'secretary')
|
20
|
+
|
21
|
+
@students = %w( Mahamat Younouss ).collect { |p|
|
22
|
+
Persons.create(:login_name => p, :permissions => %w( student ))
|
23
|
+
}
|
24
|
+
|
25
|
+
@maint_t =
|
26
|
+
CourseTypes.create(:name => 'maint', :duration => 72,
|
27
|
+
:desciption => 'maintenance', :contents => 'lots of work',
|
28
|
+
:file_diploma => ['base_gestion.odt'], :output => 'certificate',
|
29
|
+
:diploma_type => ['simple'],
|
30
|
+
:account_base => Accounts.create_path('Root::Income::Courses'))
|
31
|
+
|
32
|
+
@maint = Courses.create_ctype(@maint_t, '1404')
|
33
|
+
@maint.students = @students
|
34
|
+
|
35
|
+
@root = Accounts.find_by_path('Root')
|
36
|
+
|
37
|
+
@report_simple =
|
38
|
+
Reports.create(:name => 'basic',
|
39
|
+
:accounts => [
|
40
|
+
ReportAccounts.create(:root => @root, :level => 2,
|
41
|
+
:account => Accounts.find_by_path('Root::Income')),
|
42
|
+
])
|
43
|
+
@report_double =
|
44
|
+
Reports.create(:name => 'double',
|
45
|
+
:accounts => [
|
46
|
+
ReportAccounts.create(:root => @root, :level => 1,
|
47
|
+
:account => Accounts.find_by_path('Root::Income')),
|
48
|
+
ReportAccounts.create(:root => @root, :level => 0,
|
49
|
+
:account => Accounts.find_by_path('Root::Lending'))
|
50
|
+
])
|
51
|
+
|
52
|
+
[[0, 10000], [0, 5000], [1, 5000]].each { |s, c|
|
53
|
+
@maint.payment(@secretary, @students[s], c)
|
54
|
+
}
|
55
|
+
|
56
|
+
#Accounts.dump( true )
|
57
|
+
end
|
58
|
+
|
59
|
+
def teardown
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_report_list
|
63
|
+
assert_equal [[['Root::Income::Courses::maint_1404',
|
64
|
+
[20.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20.0]]]],
|
65
|
+
@report_simple.print_list_monthly
|
66
|
+
assert_equal [[['Root::Income::Courses', [20.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20.0]]],
|
67
|
+
[['Root::Lending', [20.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20.0]]],
|
68
|
+
[['Total', [40.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40.0]],
|
69
|
+
['Running',
|
70
|
+
[40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0]]]],
|
71
|
+
@report_double.print_list_monthly
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_report_deep
|
75
|
+
courses = Accounts.find_by_path('Root::Income::Courses')
|
76
|
+
it = Accounts.create('it', nil, courses)
|
77
|
+
it_101 = Accounts.create('it-101', nil, it)
|
78
|
+
Movements.create('inscription', Date.today, 10, @root, it_101)
|
79
|
+
assert_equal [[['Root::Income::Courses', [30.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30.0]]],
|
80
|
+
[['Root::Lending', [20.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20.0]]],
|
81
|
+
[['Total', [50.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50.0]],
|
82
|
+
['Running',
|
83
|
+
[50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0]]]],
|
84
|
+
@report_double.print_list_monthly
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_heading
|
88
|
+
assert_equal %w(Period 2014/09 2014/10 2014/11 2014/12 2015/01 2015/02
|
89
|
+
2015/03 2015/04 2015/05 2015/06 2015/07 2015/08 Sum),
|
90
|
+
@report_simple.print_heading_monthly(Date.new(2014, 9)).flatten
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_report_pdf
|
94
|
+
@report_simple.print_pdf_monthly
|
95
|
+
@report_double.print_pdf_monthly
|
96
|
+
end
|
97
|
+
end
|
data/Test/ge_share.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TC_share < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Entities.delete_all_data()
|
6
|
+
|
7
|
+
Entities.Persons.create( :first_name => 'admin', :password => 'super123',
|
8
|
+
:permissions => ['admin'], :groups => [] )
|
9
|
+
Entities.Persons.create( :first_name => 'surf', :password => 'super',
|
10
|
+
:password_plain => '1234', :permissions => ['internet'], :groups => ['share'] )
|
11
|
+
@share_public = Shares.create( :name => 'public', :path => './share_test', :public => ['No'],
|
12
|
+
:acl => {'surf' => 'rw'} )
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_htaccess
|
19
|
+
FileUtils.rm_rf('./share_test')
|
20
|
+
@share_public.add_htaccess
|
21
|
+
assert ! File.exists?('./share_test')
|
22
|
+
FileUtils.mkdir('./share_test')
|
23
|
+
@share_public.add_htaccess
|
24
|
+
assert File.exists? './share_test/.htaccess'
|
25
|
+
assert File.exists? './share_test/.htpasswd'
|
26
|
+
end
|
27
|
+
end
|
data/Test/ge_sms.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TC_sms < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
end
|
6
|
+
|
7
|
+
def teardown
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_last
|
11
|
+
assert_equal [], SMSs.last( 0 )
|
12
|
+
assert_equal [], SMSs.last( 2 )
|
13
|
+
|
14
|
+
SMSs.create( { id: 1000,
|
15
|
+
phone: '12345678',
|
16
|
+
msg: 'This is a first SMS',
|
17
|
+
date: '2014-06-05 16:16:16'} )
|
18
|
+
|
19
|
+
assert_equal 1, SMSs.last( 2 ).length
|
20
|
+
|
21
|
+
SMSs.create( { id: 1001,
|
22
|
+
phone: '12345678',
|
23
|
+
msg: 'This is a first SMS',
|
24
|
+
date: '2014-06-05 16:16:17'} )
|
25
|
+
|
26
|
+
SMSs.create( { id: 1002,
|
27
|
+
phone: '12345678',
|
28
|
+
msg: 'This is a first SMS',
|
29
|
+
date: '2014-06-05 16:16:18'} )
|
30
|
+
|
31
|
+
assert_equal 2, SMSs.last( 2 ).length
|
32
|
+
assert_equal( [1001, 1002], SMSs.last(2).collect{|s| s.index})
|
33
|
+
end
|
34
|
+
end
|
data/Test/ge_tasks.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class TC_Tasks < Test::Unit::TestCase
|
2
|
+
def setup
|
3
|
+
Entities.delete_all_data()
|
4
|
+
@pers_admin = Entities.Persons.create( :first_name => "admin", :password => "super123",
|
5
|
+
:permissions => [ "default" ] )
|
6
|
+
@client_one = Entities.Clients.create( :name => "one" )
|
7
|
+
@worker_foo = Entities.Workers.create( :person_id => @pers_admin.person_id,
|
8
|
+
:login_name => @pers_admin.login_name )
|
9
|
+
@task_one = Entities.Tasks.create( :client => @client_one.name,
|
10
|
+
:person => @pers_admin.login_name, :date => "11.03.2011", :time => "11:00" )
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_addlogin
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|