bbmb 2.1.3 → 2.1.4
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/Gemfile +2 -0
- data/History.txt +11 -8
- data/Rakefile +1 -1
- data/bbmb.gemspec +3 -3
- data/lib/bbmb.rb +1 -1
- data/lib/bbmb/config.rb +6 -2
- data/lib/bbmb/html/state/change_password.rb +3 -3
- data/lib/bbmb/html/state/current_order.rb +1 -1
- data/lib/bbmb/html/state/customer.rb +6 -6
- data/lib/bbmb/html/state/customers.rb +2 -2
- data/lib/bbmb/html/state/global.rb +4 -2
- data/lib/bbmb/html/state/init.rb +1 -0
- data/lib/bbmb/html/state/login.rb +5 -1
- data/lib/bbmb/html/state/viral/admin.rb +2 -1
- data/lib/bbmb/html/state/viral/customer.rb +4 -3
- data/lib/bbmb/html/util/known_user.rb +42 -10
- data/lib/bbmb/html/util/session.rb +32 -7
- data/lib/bbmb/html/util/validator.rb +5 -5
- data/lib/bbmb/html/view/customers.rb +7 -22
- data/lib/bbmb/html/view/head.rb +1 -1
- data/lib/bbmb/html/view/navigation.rb +1 -0
- data/lib/bbmb/model/customer.rb +19 -6
- data/lib/bbmb/model/order.rb +8 -5
- data/lib/bbmb/model/product.rb +14 -45
- data/lib/bbmb/persistence/odba.rb +4 -4
- data/lib/bbmb/util/invoicer.rb +1 -0
- data/lib/bbmb/util/mail.rb +1 -2
- data/lib/bbmb/util/polling_manager.rb +11 -6
- data/lib/bbmb/util/server.rb +122 -68
- data/lib/bbmb/util/transfer_dat.rb +1 -1
- data/lib/bbmb/util/updater.rb +3 -3
- data/lib/bbmb/version.rb +1 -1
- data/test/html/state/test_customers.rb +1 -2
- data/test/model/test_customer.rb +1 -1
- data/test/model/test_order.rb +2 -2
- data/test/model/test_product.rb +11 -27
- data/test/model/test_promotion.rb +3 -3
- data/test/test_bbmb.rb +0 -1
- data/test/util/test_invoicer.rb +8 -8
- data/test/util/test_polling_manager.rb +12 -17
- data/test/util/test_server.rb +2 -6
- data/test/util/test_transfer_dat.rb +0 -3
- metadata +5 -20
data/lib/bbmb/util/updater.rb
CHANGED
@@ -8,17 +8,17 @@ module BBMB
|
|
8
8
|
module Util
|
9
9
|
module Updater
|
10
10
|
def Updater.run
|
11
|
-
PollingManager.new.poll_sources
|
11
|
+
PollingManager.new.poll_sources do |filename, io|
|
12
12
|
importer, *args = BBMB.config.importers[filename]
|
13
13
|
if(importer)
|
14
14
|
import(importer, args, io)
|
15
15
|
end
|
16
|
-
|
16
|
+
end
|
17
17
|
end
|
18
18
|
def Updater.import(importer, args, io)
|
19
19
|
klass = Util.const_get(importer)
|
20
20
|
count = klass.new(*args).import(io)
|
21
|
-
|
21
|
+
SBSM.info('updater') { sprintf("%s imported %i entities", importer.class, (count && count.defined?(:to_i)) ? count.to_i : 0) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/bbmb/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
|
1
2
|
require 'test_helper'
|
2
3
|
|
3
4
|
require 'htmlgrid/list'
|
@@ -15,8 +16,6 @@ module BBMB
|
|
15
16
|
def setup
|
16
17
|
super
|
17
18
|
BBMB.config = flexmock('config')
|
18
|
-
BBMB.logger = flexmock('logger')
|
19
|
-
BBMB.logger.should_receive(:debug)
|
20
19
|
BBMB.persistence = flexmock('persistence', :all => [])
|
21
20
|
app = flexmock('app')
|
22
21
|
user = flexmock('user', :pagestep => 1)
|
data/test/model/test_customer.rb
CHANGED
@@ -43,7 +43,7 @@ class TestCustomer < Minitest::Test
|
|
43
43
|
def test_email_writer__both_nil
|
44
44
|
BBMB.server = flexmock('server')
|
45
45
|
@customer.email = nil
|
46
|
-
|
46
|
+
assert_nil(@customer.email)
|
47
47
|
end
|
48
48
|
def test_protect
|
49
49
|
assert_equal false, @customer.protects?(:email)
|
data/test/model/test_order.rb
CHANGED
@@ -77,9 +77,9 @@ class TestOrder < Minitest::Test
|
|
77
77
|
assert_equal([], @order.positions)
|
78
78
|
end
|
79
79
|
def test_commit
|
80
|
-
|
80
|
+
assert_nil(@order.commit_time)
|
81
81
|
assert_raises(RuntimeError) { @order.commit!('commit_id', Time.now) }
|
82
|
-
|
82
|
+
assert_nil(@order.commit_time)
|
83
83
|
position = flexmock('position')
|
84
84
|
@order.positions.push(position)
|
85
85
|
position.should_receive(:article_number).and_return('12345')
|
data/test/model/test_product.rb
CHANGED
@@ -21,7 +21,7 @@ class TestProduct < Minitest::Test
|
|
21
21
|
assert_nil(@product.send(key))
|
22
22
|
@product.send("#{key}=", "2")
|
23
23
|
int = @product.send(key)
|
24
|
-
assert_instance_of(
|
24
|
+
assert_instance_of(Integer, int)
|
25
25
|
assert_equal(2, int)
|
26
26
|
@product.send("#{key}=", nil)
|
27
27
|
assert_nil(@product.send(key))
|
@@ -60,9 +60,9 @@ class TestProduct < Minitest::Test
|
|
60
60
|
refute_equal(@product, other)
|
61
61
|
end
|
62
62
|
def test_price
|
63
|
-
|
63
|
+
assert_nil(@product.price)
|
64
64
|
assert_equal(0, @product.price_effective)
|
65
|
-
|
65
|
+
assert_nil(@product.price(1))
|
66
66
|
assert_equal(0, @product.price_effective(1))
|
67
67
|
@product.l1_price = 11.50
|
68
68
|
assert_equal(11.50, @product.price)
|
@@ -87,29 +87,13 @@ class TestProduct < Minitest::Test
|
|
87
87
|
@product.l6_price = 16.50
|
88
88
|
assert_equal(16.50, @product.price(6))
|
89
89
|
end
|
90
|
-
|
91
|
-
def test_to_info
|
90
|
+
def test_info
|
92
91
|
info = @product.to_info
|
93
92
|
assert_instance_of(ProductInfo, info)
|
94
93
|
assert_equal('article_number', info.article_number)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
def test_to_product
|
99
|
-
product = @product.to_info.to_product
|
100
|
-
assert_instance_of(Product, product)
|
101
|
-
assert_equal('article_number', product.article_number)
|
102
|
-
assert_equal(product, product.to_product)
|
103
|
-
%w{
|
104
|
-
backorder_date catalogue1 catalogue2 catalogue3
|
105
|
-
description ean13 expiry_date partner_index pcode status
|
106
|
-
}.map do |attr|
|
107
|
-
assert_equal(@product.send(attr), product.send(attr))
|
108
|
-
end
|
109
|
-
assert_equal(@product.promotion, product.promotion)
|
110
|
-
assert_equal(@product.sale, product.sale)
|
94
|
+
info1 = info.to_info
|
95
|
+
assert_equal(info, info1)
|
111
96
|
end
|
112
|
-
|
113
97
|
def test_price_levels__no_promo
|
114
98
|
@product.l1_qty = 1
|
115
99
|
@product.l1_price = 10
|
@@ -186,7 +170,7 @@ class TestProduct < Minitest::Test
|
|
186
170
|
assert_equal(5, @product.price_qty(12))
|
187
171
|
end
|
188
172
|
def test_freebies__no_promo
|
189
|
-
|
173
|
+
assert_nil(@product.freebies(1))
|
190
174
|
end
|
191
175
|
def test_freebies__with_old_promo
|
192
176
|
@product.promotion = promo = Promotion.new
|
@@ -198,8 +182,8 @@ class TestProduct < Minitest::Test
|
|
198
182
|
promo.l2_qty = 12
|
199
183
|
promo.l2_price = 7
|
200
184
|
promo.l2_free = 3
|
201
|
-
|
202
|
-
|
185
|
+
assert_nil(@product.freebies(5))
|
186
|
+
assert_nil(@product.freebies(6))
|
203
187
|
end
|
204
188
|
def test_freebies__with_current_promo
|
205
189
|
@product.promotion = promo = Promotion.new
|
@@ -211,7 +195,7 @@ class TestProduct < Minitest::Test
|
|
211
195
|
promo.l2_qty = 12
|
212
196
|
promo.l2_price = 7
|
213
197
|
promo.l2_free = 3
|
214
|
-
|
198
|
+
assert_nil(@product.freebies(5))
|
215
199
|
assert_equal(1, @product.freebies(6))
|
216
200
|
assert_equal(1, @product.freebies(11))
|
217
201
|
assert_equal(3, @product.freebies(12))
|
@@ -250,7 +234,7 @@ class TestProduct < Minitest::Test
|
|
250
234
|
assert_equal(10, @product.qty_level(2))
|
251
235
|
promo.l1_price = 2
|
252
236
|
assert_equal(5, @product.qty_level(1))
|
253
|
-
|
237
|
+
assert_nil(@product.qty_level(2))
|
254
238
|
end
|
255
239
|
end
|
256
240
|
end
|
@@ -26,13 +26,13 @@ class TestPromotion < Minitest::Test
|
|
26
26
|
assert_equal(false, @promo.current?)
|
27
27
|
end
|
28
28
|
def test_price_qty
|
29
|
-
|
29
|
+
assert_nil(@promo.price_qty(1))
|
30
30
|
@promo.l1_qty = 6
|
31
31
|
@promo.l1_price = 10
|
32
|
-
|
32
|
+
assert_nil(@promo.price_qty(5))
|
33
33
|
assert_equal(10, @promo.price_qty(6))
|
34
34
|
@promo.l1_discount = 10
|
35
|
-
|
35
|
+
assert_nil(@promo.price_qty(5))
|
36
36
|
assert_equal(10, @promo.price_qty(6))
|
37
37
|
end
|
38
38
|
end
|
data/test/test_bbmb.rb
CHANGED
data/test/util/test_invoicer.rb
CHANGED
@@ -21,6 +21,9 @@ class TestInvoicer < Minitest::Test
|
|
21
21
|
File.open(keypath, 'w') { |fh| fh.puts(key) }
|
22
22
|
YDIM::Client::CONFIG.private_key = keypath
|
23
23
|
BBMB.config = flexmock($default_config.clone, 'config')
|
24
|
+
@session = flexmock('session')
|
25
|
+
@ydim_server = flexmock('ydim')
|
26
|
+
@ydim_server.should_receive(:login).and_return(@session)
|
24
27
|
@drb_server = false
|
25
28
|
@ydim_url = 'druby://localhost:10082'
|
26
29
|
@ydim_config = flexmock(YDIM::Client::CONFIG, 'ydim_config')
|
@@ -28,6 +31,7 @@ class TestInvoicer < Minitest::Test
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def teardown
|
34
|
+
# require 'pry'; binding.pry
|
31
35
|
@drb_server.stop_service if @drb_server
|
32
36
|
BBMB.config = $default_config.clone
|
33
37
|
super
|
@@ -70,8 +74,8 @@ class TestInvoicer < Minitest::Test
|
|
70
74
|
@ydim_server.should_receive(:logout).with(session)
|
71
75
|
range = Time.local(2006,9)..Time.local(2006,10)
|
72
76
|
@drb_server = DRb.start_service(@ydim_url, @ydim_server)
|
77
|
+
sleep 0.1
|
73
78
|
result = Invoicer.create_invoice(range, Util::Money.new(24), [order1, order2], today)
|
74
|
-
skip 'has error when with SEED=14031 bundle exec rake --verbose test'
|
75
79
|
assert_equal(invoice, result)
|
76
80
|
assert_equal("01.09.2006 - 30.09.2006", invoice.description)
|
77
81
|
assert_equal(today, invoice.date)
|
@@ -91,7 +95,6 @@ class TestInvoicer < Minitest::Test
|
|
91
95
|
Invoicer.send_invoice(123)
|
92
96
|
end
|
93
97
|
def test_run
|
94
|
-
skip 'has error when with SEED=14031 bundle exec rake --verbose test'
|
95
98
|
order1 = flexmock('order1')
|
96
99
|
order1.should_receive(:total).and_return(Util::Money.new(11.00))
|
97
100
|
order1.should_receive(:commit_time).and_return(Time.local(2006,8,31,23,59,59))
|
@@ -108,7 +111,7 @@ class TestInvoicer < Minitest::Test
|
|
108
111
|
BBMB.persistence.should_receive(:all).and_return([])
|
109
112
|
BBMB.config.should_receive(:ydim_config)
|
110
113
|
BBMB.config.should_receive(:ydim_id).and_return(7)
|
111
|
-
BBMB.config.should_receive(:error_recipients).and_return(
|
114
|
+
BBMB.config.should_receive(:error_recipients).and_return(::TestRecipient)
|
112
115
|
BBMB.config.should_receive(:invoice_percentage).and_return(1)
|
113
116
|
BBMB.config.should_receive(:invoice_format).and_return("%s - %s")
|
114
117
|
BBMB.config.should_receive(:invoice_item_format).and_return("%.2f -> %i")
|
@@ -116,9 +119,6 @@ class TestInvoicer < Minitest::Test
|
|
116
119
|
BBMB.config.should_receive(:invoice_newyear).and_return('1.1.')
|
117
120
|
BBMB.config.should_receive(:invoice_monthly_baseline)
|
118
121
|
BBMB.config.should_receive(:invoice_monthly_baseamount)
|
119
|
-
session = flexmock('session')
|
120
|
-
@ydim_server = flexmock('ydim')
|
121
|
-
@ydim_server.should_receive(:login).and_return(session)
|
122
122
|
today = Date.new(2006,10)
|
123
123
|
data = {
|
124
124
|
:price => 0.21,
|
@@ -127,10 +127,10 @@ class TestInvoicer < Minitest::Test
|
|
127
127
|
:time => Time.local(2006,10),
|
128
128
|
:unit => "1.0%",
|
129
129
|
}
|
130
|
-
session.should_receive(:add_items)
|
130
|
+
@session.should_receive(:add_items)
|
131
131
|
@ydim_server.should_receive(:logout)
|
132
132
|
range = Time.local(2006,9)...Time.local(2006,10)
|
133
|
-
session.should_receive(:send_invoice).with(39)
|
133
|
+
@session.should_receive(:send_invoice).with(39)
|
134
134
|
@drb_server = DRb.start_service(@ydim_url, @ydim_server)
|
135
135
|
Invoicer.run(range, today)
|
136
136
|
@drb_server.stop_service
|
@@ -223,6 +223,8 @@ module BBMB
|
|
223
223
|
assert(blk_called, "poll_message never called its block")
|
224
224
|
end
|
225
225
|
def test_poll
|
226
|
+
skip "Must fix test_poll using the mail gem"
|
227
|
+
|
226
228
|
src = <<-EOS
|
227
229
|
Content-Type: multipart/mixed; boundary="=-1158308026-727155-3822-1761-1-="
|
228
230
|
MIME-Version: 1.0
|
@@ -237,29 +239,22 @@ Content-Disposition: attachment; filename="ywsarti.csv"
|
|
237
239
|
attached data
|
238
240
|
--=-1158308026-727155-3822-1761-1-=--
|
239
241
|
EOS
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
mail.should_receive(:multipart?).and_return(true)
|
244
|
-
mail.should_receive(:parts).and_return([])
|
245
|
-
flexstub(::Mail).should_receive(:delivery_method).and_return(
|
246
|
-
::Mail::TestMailer.new({}))
|
247
|
-
flexstub(::Mail::TestMailer).should_receive(:deliveries)
|
248
|
-
.and_return([mail])
|
249
|
-
flexstub(Net::POP3).should_receive(:start).with(
|
250
|
-
'mail.ywesee.com',
|
251
|
-
110,
|
252
|
-
'data@bbmb.ch',
|
253
|
-
'test', Proc
|
254
|
-
).and_return { |host, port, user, pass, block|
|
242
|
+
flexstub(Net::POP3).should_receive(:start).with('mail.ywesee.com', 110,
|
243
|
+
'data@bbmb.ch',
|
244
|
+
'test', Proc).and_return { |host, port, user, pass, block|
|
255
245
|
pop = flexmock('pop')
|
256
246
|
pop.should_receive(:each_mail).and_return { |block2|
|
247
|
+
mail = flexmock('mail')
|
248
|
+
mail.should_receive(:pop).and_return(src)
|
249
|
+
mail.should_receive(:delete)
|
257
250
|
block2.call(mail)
|
258
251
|
}
|
259
252
|
block.call(pop)
|
260
253
|
}
|
261
|
-
|
262
|
-
|
254
|
+
@mission.poll { |name, data|
|
255
|
+
assert_equal('ywsarti.csv', name)
|
256
|
+
assert_equal('attached data', data)
|
257
|
+
}
|
263
258
|
end
|
264
259
|
def test_poll__error
|
265
260
|
skip "Must fix test_poll__error using the mail gem"
|
data/test/util/test_server.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
$: << File.expand_path('..', File.dirname(__FILE__))
|
4
4
|
|
5
|
-
require 'test_helper'
|
6
5
|
require 'bbmb/util/server'
|
6
|
+
require 'test_helper'
|
7
7
|
|
8
8
|
module BBMB
|
9
9
|
module Util
|
@@ -13,7 +13,7 @@ class TestServer < Minitest::Test
|
|
13
13
|
def setup
|
14
14
|
super
|
15
15
|
BBMB.config = $default_config.clone
|
16
|
-
@server =
|
16
|
+
@server = BBMB::Util::RackInterface.new
|
17
17
|
Model::Customer.instances.clear
|
18
18
|
Model::Product.instances.clear
|
19
19
|
end
|
@@ -133,8 +133,6 @@ class TestServer < Minitest::Test
|
|
133
133
|
@server.rename_user('test@bbmb.ch', 'test@bbmb.ch')
|
134
134
|
end
|
135
135
|
def test_run_invoicer
|
136
|
-
BBMB.logger = flexmock('logger')
|
137
|
-
BBMB.logger.should_ignore_missing
|
138
136
|
error_mock = flexmock(RuntimeError.new, 'error')
|
139
137
|
flexstub(Mail).should_receive(:notify_error).at_least.once.and_return { |error|
|
140
138
|
assert_instance_of(RuntimeError, error_mock)
|
@@ -159,8 +157,6 @@ class TestServer < Minitest::Test
|
|
159
157
|
def test_run_updater
|
160
158
|
BBMB.config = flexmock('config')
|
161
159
|
BBMB.config.should_receive(:update_hour).and_return(0)
|
162
|
-
BBMB.logger = flexmock('logger')
|
163
|
-
BBMB.logger.should_ignore_missing
|
164
160
|
flexstub(Mail).should_receive(:notify_error).times(1).and_return { |error|
|
165
161
|
assert_instance_of(RuntimeError, error)
|
166
162
|
}
|
@@ -12,12 +12,9 @@ class TestTransferDat < Minitest::Test
|
|
12
12
|
include FlexMock::TestCase
|
13
13
|
def setup
|
14
14
|
super
|
15
|
-
BBMB.logger = flexmock('logger')
|
16
|
-
BBMB.logger.should_receive(:error)
|
17
15
|
end
|
18
16
|
def teardown
|
19
17
|
super
|
20
|
-
BBMB.logger = nil
|
21
18
|
end
|
22
19
|
def test_parse_line
|
23
20
|
src = "030201899 0624427Mycolog creme tube 15 g 000176803710902940"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbmb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: odba
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sbsm
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: htmlgrid
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,7 +318,7 @@ dependencies:
|
|
332
318
|
- - ">="
|
333
319
|
- !ruby/object:Gem::Version
|
334
320
|
version: '0'
|
335
|
-
description:
|
321
|
+
description: A Ruby gem for browser based orders of approved medical drugs in Switzerland
|
336
322
|
email: mhatakeyama@ywesee.com, zdavatz@ywesee.com, ngiger@ywesee.com
|
337
323
|
executables:
|
338
324
|
- bbmb_admin
|
@@ -463,10 +449,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
463
449
|
version: '0'
|
464
450
|
requirements: []
|
465
451
|
rubyforge_project:
|
466
|
-
rubygems_version: 2.
|
452
|
+
rubygems_version: 2.6.8
|
467
453
|
signing_key:
|
468
454
|
specification_version: 4
|
469
|
-
summary:
|
455
|
+
summary: browser based orders of medical drugs
|
470
456
|
test_files:
|
471
457
|
- test/data/ydim.yml
|
472
458
|
- test/html/state/test_customers.rb
|
@@ -485,4 +471,3 @@ test_files:
|
|
485
471
|
- test/util/test_server.rb
|
486
472
|
- test/util/test_target_dir.rb
|
487
473
|
- test/util/test_transfer_dat.rb
|
488
|
-
has_rdoc:
|