bbmb 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/LICENSE.txt +339 -0
- data/Manifest.txt +91 -0
- data/README.txt +25 -0
- data/Rakefile +28 -0
- data/bin/admin +71 -0
- data/bin/bbmbd +61 -0
- data/lib/bbmb.rb +9 -0
- data/lib/bbmb/config.rb +106 -0
- data/lib/bbmb/html/state/change_password.rb +50 -0
- data/lib/bbmb/html/state/current_order.rb +81 -0
- data/lib/bbmb/html/state/customer.rb +109 -0
- data/lib/bbmb/html/state/customers.rb +52 -0
- data/lib/bbmb/html/state/favorites.rb +19 -0
- data/lib/bbmb/html/state/favorites_result.rb +21 -0
- data/lib/bbmb/html/state/global.rb +62 -0
- data/lib/bbmb/html/state/history.rb +95 -0
- data/lib/bbmb/html/state/info.rb +23 -0
- data/lib/bbmb/html/state/json.rb +16 -0
- data/lib/bbmb/html/state/login.rb +76 -0
- data/lib/bbmb/html/state/order.rb +21 -0
- data/lib/bbmb/html/state/orders.rb +19 -0
- data/lib/bbmb/html/state/result.rb +64 -0
- data/lib/bbmb/html/state/show_pass.rb +16 -0
- data/lib/bbmb/html/state/viral/admin.rb +41 -0
- data/lib/bbmb/html/state/viral/customer.rb +143 -0
- data/lib/bbmb/html/util/known_user.rb +51 -0
- data/lib/bbmb/html/util/multilingual.rb +18 -0
- data/lib/bbmb/html/util/session.rb +52 -0
- data/lib/bbmb/html/util/validator.rb +55 -0
- data/lib/bbmb/html/view/backorder.rb +24 -0
- data/lib/bbmb/html/view/change_password.rb +42 -0
- data/lib/bbmb/html/view/copyleft.rb +41 -0
- data/lib/bbmb/html/view/current_order.rb +482 -0
- data/lib/bbmb/html/view/customer.rb +152 -0
- data/lib/bbmb/html/view/customers.rb +145 -0
- data/lib/bbmb/html/view/favorites.rb +162 -0
- data/lib/bbmb/html/view/favorites_result.rb +26 -0
- data/lib/bbmb/html/view/foot.rb +21 -0
- data/lib/bbmb/html/view/head.rb +32 -0
- data/lib/bbmb/html/view/history.rb +60 -0
- data/lib/bbmb/html/view/info.rb +33 -0
- data/lib/bbmb/html/view/json.rb +20 -0
- data/lib/bbmb/html/view/list_prices.rb +51 -0
- data/lib/bbmb/html/view/login.rb +46 -0
- data/lib/bbmb/html/view/multilingual.rb +17 -0
- data/lib/bbmb/html/view/navigation.rb +30 -0
- data/lib/bbmb/html/view/order.rb +123 -0
- data/lib/bbmb/html/view/orders.rb +50 -0
- data/lib/bbmb/html/view/result.rb +107 -0
- data/lib/bbmb/html/view/search.rb +28 -0
- data/lib/bbmb/html/view/show_pass.rb +60 -0
- data/lib/bbmb/html/view/template.rb +61 -0
- data/lib/bbmb/model/customer.rb +96 -0
- data/lib/bbmb/model/order.rb +255 -0
- data/lib/bbmb/model/product.rb +99 -0
- data/lib/bbmb/model/promotion.rb +52 -0
- data/lib/bbmb/model/quota.rb +27 -0
- data/lib/bbmb/model/subject.rb +46 -0
- data/lib/bbmb/persistence/none.rb +6 -0
- data/lib/bbmb/persistence/odba.rb +42 -0
- data/lib/bbmb/persistence/odba/model/customer.rb +47 -0
- data/lib/bbmb/persistence/odba/model/order.rb +50 -0
- data/lib/bbmb/persistence/odba/model/product.rb +26 -0
- data/lib/bbmb/persistence/odba/model/quota.rb +12 -0
- data/lib/bbmb/util/invoicer.rb +126 -0
- data/lib/bbmb/util/mail.rb +140 -0
- data/lib/bbmb/util/multilingual.rb +57 -0
- data/lib/bbmb/util/numbers.rb +67 -0
- data/lib/bbmb/util/password_generator.rb +44 -0
- data/lib/bbmb/util/polling_manager.rb +135 -0
- data/lib/bbmb/util/server.rb +159 -0
- data/lib/bbmb/util/target_dir.rb +36 -0
- data/lib/bbmb/util/transfer_dat.rb +34 -0
- data/lib/bbmb/util/updater.rb +27 -0
- data/test/data/ydim.yml +2 -0
- data/test/model/test_customer.rb +75 -0
- data/test/model/test_order.rb +426 -0
- data/test/model/test_product.rb +238 -0
- data/test/model/test_promotion.rb +40 -0
- data/test/stub/persistence.rb +57 -0
- data/test/suite.rb +12 -0
- data/test/test_bbmb.rb +18 -0
- data/test/util/test_invoicer.rb +189 -0
- data/test/util/test_mail.rb +359 -0
- data/test/util/test_money.rb +71 -0
- data/test/util/test_password_generator.rb +27 -0
- data/test/util/test_polling_manager.rb +312 -0
- data/test/util/test_server.rb +189 -0
- data/test/util/test_target_dir.rb +82 -0
- data/test/util/test_transfer_dat.rb +45 -0
- metadata +190 -0
@@ -0,0 +1,359 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Util::TestMail -- bbmb.ch -- 27.09.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
|
5
|
+
$: << File.expand_path('../lib', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'bbmb/util/mail'
|
8
|
+
require 'flexmock'
|
9
|
+
require 'test/unit'
|
10
|
+
|
11
|
+
module BBMB
|
12
|
+
module Util
|
13
|
+
class TestMail < Test::Unit::TestCase
|
14
|
+
include FlexMock::TestCase
|
15
|
+
def setup_config
|
16
|
+
config = BBMB.config
|
17
|
+
config.error_recipients = ['to.test@bbmb.ch']
|
18
|
+
config.mail_order_from = 'from.test@bbmb.ch'
|
19
|
+
config.mail_order_to = 'to.test@bbmb.ch'
|
20
|
+
config.mail_order_cc = 'cc.test@bbmb.ch'
|
21
|
+
config.mail_order_subject = 'order %s'
|
22
|
+
config.mail_request_from = 'from.request.test@bbmb.ch'
|
23
|
+
config.mail_request_to = 'to.request.test@bbmb.ch'
|
24
|
+
config.mail_request_cc = 'cc.request.test@bbmb.ch'
|
25
|
+
config.mail_request_subject = 'Request %s'
|
26
|
+
config.name = 'Application/User Agent'
|
27
|
+
config.smtp_authtype = :plain
|
28
|
+
config.smtp_helo = 'helo.domain'
|
29
|
+
config.smtp_pass = 'secret'
|
30
|
+
config.smtp_port = 25
|
31
|
+
config.smtp_server = 'mail.test.com'
|
32
|
+
config.smtp_user = 'user'
|
33
|
+
config.mail_confirm_reply_to = 'replyto-test@bbmb.ch'
|
34
|
+
config.mail_confirm_from = 'from-test@bbmb.ch'
|
35
|
+
config.mail_confirm_cc = []
|
36
|
+
config.mail_confirm_subject = 'Confirmation %s'
|
37
|
+
config.mail_confirm_body = <<-EOS
|
38
|
+
Sie haben am %s folgende Artikel bestellt:
|
39
|
+
|
40
|
+
%s
|
41
|
+
------------------------------------------------------------------------
|
42
|
+
Bestelltotal exkl. Mwst. %10.2f
|
43
|
+
Bestelltotal inkl. Mwst. %10.2f
|
44
|
+
====================================
|
45
|
+
|
46
|
+
En date du %s vous avez commandé les articles suivants
|
47
|
+
|
48
|
+
%s
|
49
|
+
------------------------------------------------------------------------
|
50
|
+
Commande excl. Tva. %10.2f
|
51
|
+
Commande incl. Tva. %10.2f
|
52
|
+
====================================
|
53
|
+
|
54
|
+
In data del %s Lei ha ordinato i seguenti prodotti.
|
55
|
+
|
56
|
+
%s
|
57
|
+
------------------------------------------------------------------------
|
58
|
+
Totale dell'ordine escl. %10.2f
|
59
|
+
Totale dell'ordine incl. %10.2f
|
60
|
+
====================================
|
61
|
+
EOS
|
62
|
+
config.mail_confirm_lines = [
|
63
|
+
"%3i x %-36s à %7.2f, total %10.2f",
|
64
|
+
"%3i x %-36s à %7.2f, total %10.2f",
|
65
|
+
"%3i x %-36s a %7.2f, totale %10.2f",
|
66
|
+
]
|
67
|
+
config.inject_error_to = 'to.test@bbmb.ch'
|
68
|
+
config.confirm_error_to = 'to.test@bbmb.ch'
|
69
|
+
config
|
70
|
+
end
|
71
|
+
def test_inject_error
|
72
|
+
config = setup_config
|
73
|
+
customer = flexmock('customer')
|
74
|
+
customer.should_receive(:customer_id).and_return('12345678')
|
75
|
+
order = flexmock('order')
|
76
|
+
order.should_receive(:customer).and_return(customer)
|
77
|
+
order.should_receive(:order_id).and_return('12345678-90')
|
78
|
+
order.should_receive(:commit_time).and_return Time.local(2009, 8, 7, 11, 14, 4)
|
79
|
+
smtp = flexmock('smtp')
|
80
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
81
|
+
|srv, port, helo, user, pass, type, block|
|
82
|
+
assert_equal('mail.test.com', srv)
|
83
|
+
assert_equal(25, port)
|
84
|
+
assert_equal('helo.domain', helo)
|
85
|
+
assert_equal('user', user)
|
86
|
+
assert_equal('secret', pass)
|
87
|
+
assert_equal(:plain, type)
|
88
|
+
block.call(smtp)
|
89
|
+
}
|
90
|
+
headers = <<-EOS
|
91
|
+
Mime-Version: 1.0
|
92
|
+
User-Agent: Application/User Agent
|
93
|
+
Content-Type: text/plain; charset="utf-8"
|
94
|
+
Content-Disposition: inline
|
95
|
+
From: errors.test@bbmb.ch
|
96
|
+
To: to.test@bbmb.ch
|
97
|
+
Cc:
|
98
|
+
Subject: Order 12345678-90 with missing customer: Pharmacy Health
|
99
|
+
EOS
|
100
|
+
body = <<-EOS
|
101
|
+
The order Pharmacy Health, committed on 07.08.2009 11:14:04, assigned to the unknown customer: 12345678
|
102
|
+
EOS
|
103
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
104
|
+
assert(message.include?(headers),
|
105
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
106
|
+
assert(message.include?(body),
|
107
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
108
|
+
assert_equal('errors.test@bbmb.ch', from)
|
109
|
+
assert_equal(['to.test@bbmb.ch'], recipients)
|
110
|
+
}
|
111
|
+
Mail.notify_inject_error(order, :customer_name => 'Pharmacy Health')
|
112
|
+
end
|
113
|
+
def test_confirm_error
|
114
|
+
config = setup_config
|
115
|
+
customer = flexmock('customer')
|
116
|
+
customer.should_receive(:customer_id).and_return('12345678')
|
117
|
+
order = flexmock('order')
|
118
|
+
order.should_receive(:customer).and_return(customer)
|
119
|
+
order.should_receive(:order_id).and_return('12345678-90')
|
120
|
+
order.should_receive(:commit_time).and_return Time.local(2009, 8, 7, 11, 14, 4)
|
121
|
+
smtp = flexmock('smtp')
|
122
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
123
|
+
|srv, port, helo, user, pass, type, block|
|
124
|
+
assert_equal('mail.test.com', srv)
|
125
|
+
assert_equal(25, port)
|
126
|
+
assert_equal('helo.domain', helo)
|
127
|
+
assert_equal('user', user)
|
128
|
+
assert_equal('secret', pass)
|
129
|
+
assert_equal(:plain, type)
|
130
|
+
block.call(smtp)
|
131
|
+
}
|
132
|
+
headers = <<-EOS
|
133
|
+
Mime-Version: 1.0
|
134
|
+
User-Agent: Application/User Agent
|
135
|
+
Content-Type: text/plain; charset="utf-8"
|
136
|
+
Content-Disposition: inline
|
137
|
+
From: errors.test@bbmb.ch
|
138
|
+
To: to.test@bbmb.ch
|
139
|
+
Cc:
|
140
|
+
Subject: Customer 12345678 without email address
|
141
|
+
EOS
|
142
|
+
body = <<-EOS
|
143
|
+
Customer 12345678 does not have an email address configured
|
144
|
+
EOS
|
145
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
146
|
+
assert(message.include?(headers),
|
147
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
148
|
+
assert(message.include?(body),
|
149
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
150
|
+
assert_equal('errors.test@bbmb.ch', from)
|
151
|
+
assert_equal(['to.test@bbmb.ch'], recipients)
|
152
|
+
}
|
153
|
+
Mail.notify_confirmation_error(order)
|
154
|
+
end
|
155
|
+
def test_notify_error
|
156
|
+
config = setup_config
|
157
|
+
smtp = flexmock('smtp')
|
158
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
159
|
+
|srv, port, helo, user, pass, type, block|
|
160
|
+
assert_equal('mail.test.com', srv)
|
161
|
+
assert_equal(25, port)
|
162
|
+
assert_equal('helo.domain', helo)
|
163
|
+
assert_equal('user', user)
|
164
|
+
assert_equal('secret', pass)
|
165
|
+
assert_equal(:plain, type)
|
166
|
+
block.call(smtp)
|
167
|
+
}
|
168
|
+
headers = <<-EOS
|
169
|
+
Mime-Version: 1.0
|
170
|
+
User-Agent: Application/User Agent
|
171
|
+
Content-Type: text/plain; charset="utf-8"
|
172
|
+
Content-Disposition: inline
|
173
|
+
From: from.test@bbmb.ch
|
174
|
+
To: to.test@bbmb.ch
|
175
|
+
Subject: Application/User Agent: error-message
|
176
|
+
EOS
|
177
|
+
body = <<-EOS
|
178
|
+
RuntimeError
|
179
|
+
error-message
|
180
|
+
EOS
|
181
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
182
|
+
assert(message.include?(headers),
|
183
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
184
|
+
assert(message.include?(body),
|
185
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
186
|
+
assert_equal('from.test@bbmb.ch', from)
|
187
|
+
assert_equal(['to.test@bbmb.ch'], recipients)
|
188
|
+
}
|
189
|
+
Mail.notify_error(RuntimeError.new("error-message"))
|
190
|
+
end
|
191
|
+
def test_send_order
|
192
|
+
order = flexmock('order')
|
193
|
+
order.should_receive(:to_target_format).and_return('i2-data')
|
194
|
+
order.should_receive(:order_id).and_return('order-id')
|
195
|
+
order.should_receive(:filename).and_return('filename')
|
196
|
+
config = setup_config
|
197
|
+
smtp = flexmock('smtp')
|
198
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
199
|
+
|srv, port, helo, user, pass, type, block|
|
200
|
+
assert_equal('mail.test.com', srv)
|
201
|
+
assert_equal(25, port)
|
202
|
+
assert_equal('helo.domain', helo)
|
203
|
+
assert_equal('user', user)
|
204
|
+
assert_equal('secret', pass)
|
205
|
+
assert_equal(:plain, type)
|
206
|
+
block.call(smtp)
|
207
|
+
}
|
208
|
+
headers = <<-EOS
|
209
|
+
Mime-Version: 1.0
|
210
|
+
User-Agent: Application/User Agent
|
211
|
+
Content-Type: text/plain; charset="utf-8"
|
212
|
+
Content-Disposition: inline
|
213
|
+
From: from.test@bbmb.ch
|
214
|
+
To: to.test@bbmb.ch
|
215
|
+
Cc: cc.test@bbmb.ch
|
216
|
+
Subject: order order-id
|
217
|
+
Message-ID: <order-id@from.test.bbmb.ch>
|
218
|
+
EOS
|
219
|
+
body = <<-EOS
|
220
|
+
i2-data
|
221
|
+
EOS
|
222
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
223
|
+
assert(message.include?(headers),
|
224
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
225
|
+
assert(message.include?(body),
|
226
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
227
|
+
#assert(message.include?(attachment),
|
228
|
+
#"missing attachment:\n#{attachment}\nin message:\n#{message}")
|
229
|
+
assert_equal('from.test@bbmb.ch', from)
|
230
|
+
assert_equal(['to.test@bbmb.ch', 'cc.test@bbmb.ch'], recipients)
|
231
|
+
}
|
232
|
+
Mail.send_order(order)
|
233
|
+
end
|
234
|
+
def test_send_request
|
235
|
+
config = setup_config
|
236
|
+
smtp = flexmock('smtp')
|
237
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
238
|
+
|srv, port, helo, user, pass, type, block|
|
239
|
+
assert_equal('mail.test.com', srv)
|
240
|
+
assert_equal(25, port)
|
241
|
+
assert_equal('helo.domain', helo)
|
242
|
+
assert_equal('user', user)
|
243
|
+
assert_equal('secret', pass)
|
244
|
+
assert_equal(:plain, type)
|
245
|
+
block.call(smtp)
|
246
|
+
}
|
247
|
+
headers = <<-EOS
|
248
|
+
Mime-Version: 1.0
|
249
|
+
User-Agent: Application/User Agent
|
250
|
+
Content-Type: text/plain; charset="utf-8"
|
251
|
+
Content-Disposition: inline
|
252
|
+
From: from.request.test@bbmb.ch
|
253
|
+
To: to.request.test@bbmb.ch
|
254
|
+
Cc: cc.request.test@bbmb.ch
|
255
|
+
Subject: Request Organisation
|
256
|
+
Reply-To: sender@email.com
|
257
|
+
EOS
|
258
|
+
body = <<-EOS
|
259
|
+
request body
|
260
|
+
EOS
|
261
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
262
|
+
assert(message.include?(headers),
|
263
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
264
|
+
assert(message.include?(body),
|
265
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
266
|
+
assert_equal('from.request.test@bbmb.ch', from)
|
267
|
+
assert_equal(['to.request.test@bbmb.ch', 'cc.request.test@bbmb.ch'],
|
268
|
+
recipients)
|
269
|
+
}
|
270
|
+
Mail.send_request('sender@email.com', 'Organisation', 'request body')
|
271
|
+
end
|
272
|
+
def test_send_confirmation
|
273
|
+
pos1 = flexmock('position')
|
274
|
+
pos1.should_receive(:quantity).and_return(2)
|
275
|
+
pos1.should_receive(:description).and_return('Product1')
|
276
|
+
pos1.should_receive(:price_qty).and_return(10.0)
|
277
|
+
pos1.should_receive(:price).and_return(20.0)
|
278
|
+
pos2 = flexmock('position')
|
279
|
+
pos2.should_receive(:quantity).and_return(3)
|
280
|
+
pos2.should_receive(:description).and_return('Product2')
|
281
|
+
pos2.should_receive(:price_qty).and_return(5.0)
|
282
|
+
pos2.should_receive(:price).and_return(15.0)
|
283
|
+
customer = flexmock('customer')
|
284
|
+
customer.should_receive(:email).and_return('customer@bbmb.ch')
|
285
|
+
order = flexmock('order')
|
286
|
+
order.should_receive(:to_target_format).and_return('i2-data')
|
287
|
+
order.should_receive(:order_id).and_return('order-id')
|
288
|
+
order.should_receive(:filename).and_return('filename')
|
289
|
+
order.should_receive(:customer).and_return(customer)
|
290
|
+
order.should_receive(:commit_time).and_return(Time.local(2009,8,6,11,55))
|
291
|
+
order.should_receive(:collect).and_return do |block|
|
292
|
+
[pos1, pos2].collect(&block)
|
293
|
+
end
|
294
|
+
order.should_receive(:total).and_return 25.0
|
295
|
+
order.should_receive(:total_incl_vat).and_return 25.6
|
296
|
+
config = setup_config
|
297
|
+
smtp = flexmock('smtp')
|
298
|
+
flexstub(Net::SMTP).should_receive(:start).and_return {
|
299
|
+
|srv, port, helo, user, pass, type, block|
|
300
|
+
assert_equal('mail.test.com', srv)
|
301
|
+
assert_equal(25, port)
|
302
|
+
assert_equal('helo.domain', helo)
|
303
|
+
assert_equal('user', user)
|
304
|
+
assert_equal('secret', pass)
|
305
|
+
assert_equal(:plain, type)
|
306
|
+
block.call(smtp)
|
307
|
+
}
|
308
|
+
headers = <<-EOS
|
309
|
+
Mime-Version: 1.0
|
310
|
+
User-Agent: Application/User Agent
|
311
|
+
Content-Type: text/plain; charset="utf-8"
|
312
|
+
Content-Disposition: inline
|
313
|
+
From: from-test@bbmb.ch
|
314
|
+
To: customer@bbmb.ch
|
315
|
+
Subject: Confirmation order-id
|
316
|
+
Message-ID: <order-id@from-test.bbmb.ch>
|
317
|
+
Reply-To: replyto-test@bbmb.ch
|
318
|
+
EOS
|
319
|
+
body = <<-EOS
|
320
|
+
Sie haben am 06.08.2009 folgende Artikel bestellt:
|
321
|
+
|
322
|
+
2 x Product1 à 10.00, total 20.00
|
323
|
+
3 x Product2 à 5.00, total 15.00
|
324
|
+
------------------------------------------------------------------------
|
325
|
+
Bestelltotal exkl. Mwst. 25.00
|
326
|
+
Bestelltotal inkl. Mwst. 25.60
|
327
|
+
====================================
|
328
|
+
|
329
|
+
En date du 06.08.2009 vous avez commandé les articles suivants
|
330
|
+
|
331
|
+
2 x Product1 à 10.00, total 20.00
|
332
|
+
3 x Product2 à 5.00, total 15.00
|
333
|
+
------------------------------------------------------------------------
|
334
|
+
Commande excl. Tva. 25.00
|
335
|
+
Commande incl. Tva. 25.60
|
336
|
+
====================================
|
337
|
+
|
338
|
+
In data del 06.08.2009 Lei ha ordinato i seguenti prodotti.
|
339
|
+
|
340
|
+
2 x Product1 a 10.00, totale 20.00
|
341
|
+
3 x Product2 a 5.00, totale 15.00
|
342
|
+
------------------------------------------------------------------------
|
343
|
+
Totale dell'ordine escl. 25.00
|
344
|
+
Totale dell'ordine incl. 25.60
|
345
|
+
====================================
|
346
|
+
EOS
|
347
|
+
smtp.should_receive(:sendmail).and_return { |message, from, recipients|
|
348
|
+
assert(message.include?(headers),
|
349
|
+
"missing headers:\n#{headers}\nin message:\n#{message}")
|
350
|
+
assert(message.include?(body),
|
351
|
+
"missing body:\n#{body}\nin message:\n#{message}")
|
352
|
+
assert_equal('from-test@bbmb.ch', from)
|
353
|
+
assert_equal(['customer@bbmb.ch'], recipients)
|
354
|
+
}
|
355
|
+
Mail.send_confirmation(order)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Util::TestMoney -- bbmb.ch -- 14.09.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'bbmb/util/numbers'
|
8
|
+
|
9
|
+
module BBMB
|
10
|
+
module Util
|
11
|
+
class TestMoney < Test::Unit::TestCase
|
12
|
+
def test_initialize_integer
|
13
|
+
m = Money.new(15)
|
14
|
+
assert_equal(1500, m.credits)
|
15
|
+
assert_equal(15.0, m.to_f)
|
16
|
+
assert_equal("15.00", m.to_s)
|
17
|
+
end
|
18
|
+
def test_initialize_float
|
19
|
+
m = Money.new(15.55)
|
20
|
+
assert_equal(1555, m.credits)
|
21
|
+
assert_equal(15.55, m.to_f)
|
22
|
+
assert_equal("15.55", m.to_s)
|
23
|
+
end
|
24
|
+
def test_initialize_money
|
25
|
+
n = Money.new(15.55)
|
26
|
+
m = Money.new(n)
|
27
|
+
assert_equal(1555, m.credits)
|
28
|
+
assert_equal(15.55, m.to_f)
|
29
|
+
assert_equal("15.55", m.to_s)
|
30
|
+
end
|
31
|
+
def test_equality
|
32
|
+
m = Money.new(15.55)
|
33
|
+
n = Money.new(15.55)
|
34
|
+
o = Money.new(15.56)
|
35
|
+
assert_equal(m, m)
|
36
|
+
assert_equal(m, n)
|
37
|
+
assert_not_equal(m, o)
|
38
|
+
assert_equal(m, 15.55)
|
39
|
+
assert_not_equal(m, 15.56)
|
40
|
+
assert_equal(m, "15.55")
|
41
|
+
assert_not_equal(m, "15.56")
|
42
|
+
end
|
43
|
+
def test_add
|
44
|
+
m = Money.new(15.55)
|
45
|
+
n = Money.new(12.45)
|
46
|
+
o = m + n
|
47
|
+
assert_instance_of(Money, o)
|
48
|
+
assert_equal(28, o)
|
49
|
+
end
|
50
|
+
def test_subtract
|
51
|
+
m = Money.new(15.55)
|
52
|
+
n = Money.new(12.45)
|
53
|
+
o = m - n
|
54
|
+
assert_instance_of(Money, o)
|
55
|
+
assert_equal(3.1, o)
|
56
|
+
end
|
57
|
+
def test_multiply
|
58
|
+
m = Money.new(15.55)
|
59
|
+
n = m * 4
|
60
|
+
assert_instance_of(Money, n)
|
61
|
+
assert_equal(62.20, n)
|
62
|
+
end
|
63
|
+
def test_divide
|
64
|
+
m = Money.new(16.80)
|
65
|
+
n = m / 4
|
66
|
+
assert_instance_of(Money, n)
|
67
|
+
assert_equal(4.20, n)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Util::TestPasswordGenerator -- bbmb.ch -- 19.10.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'bbmb/util/password_generator'
|
8
|
+
require 'flexmock'
|
9
|
+
|
10
|
+
module BBMB
|
11
|
+
module Util
|
12
|
+
class TestPasswordGenerator < Test::Unit::TestCase
|
13
|
+
include FlexMock::TestCase
|
14
|
+
def test_generate
|
15
|
+
customer = flexmock('Customer')
|
16
|
+
customer.should_receive(:organisation).and_return('abab')
|
17
|
+
customer.should_receive(:firstname).and_return('abab')
|
18
|
+
customer.should_receive(:lastname).and_return('abab')
|
19
|
+
pass = PasswordGenerator.generate(customer)
|
20
|
+
assert_equal 9, pass.length
|
21
|
+
assert /\d{4}/.match(pass)
|
22
|
+
assert /[!@?*]/.match(pass)
|
23
|
+
assert /[ab]{2}/.match(pass)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|