<< | 2010 | Masa.20101230-update-vat_rate-ydim >>
suspend
suspend
test/suite.rb
masa@masa ~/ywesee/ydim $ ruby test/suite.rb Loaded suite test/suite Started ..............................EE.................F......... Finished in 0.248527 seconds. 1) Error: test_send_invoice(YDIM::TestMail): NoMethodError: undefined method `smtp_port' for <FlexMock:Config>:FlexMock /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/ydim/lib/ydim/mail.rb:41:in `send_invoice' /home/masa/ywesee/ydim/test/test_mail.rb:67:in `test_send_invoice' 2) Error: test_send_reminder(YDIM::TestMail): NoMethodError: undefined method `smtp_port' for <FlexMock:Config>:FlexMock /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/ydim/lib/ydim/mail.rb:80:in `send_reminder' /home/masa/ywesee/ydim/test/test_mail.rb:91:in `test_send_reminder' 3) Failure: test_send_invoice(YDIM::TestRootSession) [/usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core_class_methods.rb:64:in `check' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation_director.rb:40:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:101:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/partial_mock.rb:255:in `send_invoice' /home/masa/ywesee/ydim/lib/ydim/root_session.rb:128:in `send_invoice' /home/masa/ywesee/ydim/test/test_root_session.rb:317:in `test_send_invoice' /home/masa/ywesee/ydim/test/test_root_session.rb:32:in `call' /home/masa/ywesee/ydim/test/test_root_session.rb:32:in `assert_logged' /home/masa/ywesee/ydim/test/test_root_session.rb:316:in `test_send_invoice']: in mock 'flexmock(Module)': no matching handler found for send_invoice("cnf", <FlexMock:invoice>, {}) 59 tests, 171 assertions, 1 failures, 2 errors
Notes
Resolve one by one
Check test/test_mail.rb
1) Error: test_send_invoice(YDIM::TestMail): NoMethodError: undefined method `smtp_port' for <FlexMock:Config>:FlexMock /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/ydim/lib/ydim/mail.rb:41:in `send_invoice' /home/masa/ywesee/ydim/test/test_mail.rb:67:in `test_send_invoice'
test/test_mail#test_send_invoice
def test_send_invoice debitor = flexmock('Debitor') debitor.should_receive(:email).and_return('test@ywesee.com') debitor.should_receive(:emails_cc).and_return(['test.cc@ywesee.com']) debitor.should_receive(:salutation).and_return('Herr') debitor.should_receive(:name).and_return('Company-Name') debitor.should_receive(:contact).and_return('Contact-Name') invoice = flexmock('Invoice') invoice.should_receive(:debitor).and_return(debitor) invoice.should_receive(:unique_id).and_return(12345) invoice.should_receive(:description).and_return('Description') invoice.should_receive(:to_pdf).times(1).and_return('pdf-document') smtp = flexmock('SMTP') flexstub(Net::SMTP).should_receive(:new).and_return(smtp) smtp.should_receive(:start).and_return { |block| block.call } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'cc@ywesee.com').and_return { assert(true) } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'test@ywesee.com').and_return { assert(true) } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'test.cc@ywesee.com').and_return { assert(true) } Mail.send_invoice(setup_config, invoice) <= HERE end
Update
config.should_receive(:smtp_port).and_return('123') config.should_receive(:smtp_domain).and_return('ywesee.com') config.should_receive(:smtp_user).and_return('user') config.should_receive(:smtp_pass).and_return('pass') config.should_receive(:smtp_authtype).and_return('plain') ... # smtp.should_receive(:start).and_return { |block| block.call } smtp.should_receive(:start)
Result
masa@masa ~/ywesee/ydim $ ruby test/test_mail.rb Loaded suite test/test_mail Started ..test/test_mail.rb:90: warning: multiple values for a block parameter (5 for 1) from /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:78 E Finished in 0.004763 seconds. 1) Error: test_send_reminder(YDIM::TestMail): NoMethodError: undefined method `call' for #<Array:0x7f27f24ffd28> test/test_mail.rb:90:in `test_send_reminder' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:78:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:78:in `return_value' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation.rb:59:in `verify_call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation_director.rb:42:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:101:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /usr/lib64/ruby/1.8/net/smtp.rb:315:in `start' /home/masa/ywesee/ydim/lib/ydim/mail.rb:80:in `send_reminder' test/test_mail.rb:97:in `test_send_reminder' 3 tests, 1 assertions, 0 failures, 1 errors
Check next
test/test_mail.rb#test_send_reminder
def test_send_reminder debitor = flexmock('Debitor') debitor.should_receive(:email).and_return('test@ywesee.com') debitor.should_receive(:emails_cc).and_return(['test.cc@ywesee.com']) debitor.should_receive(:salutation).and_return('Herr') debitor.should_receive(:name).and_return('Company-Name') debitor.should_receive(:contact).and_return('Contact-Name') invoice = flexmock('Invoice') invoice.should_receive(:debitor).and_return(debitor) invoice.should_receive(:unique_id).and_return(12345) invoice.should_receive(:description).and_return('Description') invoice.should_receive(:reminder_subject).and_return('Reminder') invoice.should_receive(:reminder_body).and_return('Reminder Body') smtp = flexmock('SMTP') flexstub(Net::SMTP).should_receive(:new).and_return(smtp) smtp.should_receive(:start).and_return { |block| block.call } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'cc@ywesee.com').and_return { assert(true) } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'test@ywesee.com').and_return { assert(true) } smtp.should_receive(:sendmail).with(String, 'smtp@ywesee.com', 'test.cc@ywesee.com').and_return { assert(true) } Mail.send_reminder(setup_config, invoice) <= HERE end
Update
test/test_mail.rb#test_send_reminder
#smtp.should_receive(:start).and_return { |block| block.call } smtp.should_receive(:start)
Result
masa@masa ~/ywesee/ydim $ ruby test/test_mail.rb Loaded suite test/test_mail Started ... Finished in 0.004769 seconds. 3 tests, 1 assertions, 0 failures, 0 errors
Check test/test_root_session.rb
Error
masa@masa ~/ywesee/ydim $ ruby test/test_root_session.rb Loaded suite test/test_root_session Started .................F.. Finished in 0.021553 seconds. 1) Failure: test_send_invoice(YDIM::TestRootSession) [/usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core_class_methods.rb:64:in `check' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/expectation_director.rb:40:in `call' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:101:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/partial_mock.rb:255:in `send_invoice' /home/masa/ywesee/ydim/lib/ydim/root_session.rb:128:in `send_invoice' test/test_root_session.rb:317:in `test_send_invoice' test/test_root_session.rb:32:in `call' test/test_root_session.rb:32:in `assert_logged' test/test_root_session.rb:316:in `test_send_invoice']: in mock 'flexmock(Module)': no matching handler found for send_invoice("cnf", <FlexMock:invoice>, {}) 20 tests, 62 assertions, 1 failures, 0 errors
test/test_root_session.rb#test_send_invoice
def test_send_invoice inv = flexmock('invoice') flexstub(Invoice).should_receive(:find_by_unique_id)\ .with('17').and_return(inv) @serv.should_receive(:config).and_return('cnf') flexstub(Mail).should_receive(:send_invoice).with('cnf', inv) assert_logged(:info, :debug) { <= HERE @session.send_invoice(17) } end
Update
test/test_root_session.rb#test_send_invoice
# flexstub(Mail).should_receive(:send_invoice).with('cnf', inv) flexstub(Mail).should_receive(:send_invoice).with('cnf', inv, {})
Result
masa@masa ~/ywesee/ydim $ ruby test/test_root_session.rb Loaded suite test/test_root_session Started .................... Finished in 0.02068 seconds. 20 tests, 62 assertions, 0 failures, 0 errors
Check test/suite.rb
masa@masa ~/ywesee/ydim $ ruby test/suite.rb Loaded suite test/suite Started ........................................................... Finished in 0.176264 seconds. 59 tests, 171 assertions, 0 failures, 0 errors
Commit
New View classes
class InvoiceTotalComposite_2010 < InvoiceTotalComposite COMPONENTS = { [0,0] => :total_netto, [0,1] => :vat_2010, [0,2] => :total_brutto, } end class InvoiceComposite_2010 < InvoiceComposite COMPONENTS = { [0,0] => InvoiceInnerComposite, [0,1] => :items, [0,2] => InvoiceTotalComposite_2010, [0,3] => :submit, [1,3] => :pdf, [2,3] => :send_invoice, } end class Invoice_2010 < Invoice CONTENT = InvoiceComposite_2010 end
New State class
lib/ydim/html/state/invoice.rb
class Invoice_2010 < Invoice VIEW = Html::View::Invoice_2010 end
Notes
The other modifications
sum :vat_2010 ... class Invoice_2010 < Invoice end
lib/ydim/html/util/lookandfeel.rb
:vat_2010 => 'MwSt. (7.6%)',
alias :vat_2010 :vat
Note
lib/ydim/html/state/global.rb#invoice
def invoice inv = nil if(id = @session.user_input(:unique_id)) # Invoice.new(@session, @session.invoice(id.to_i)) inv = Invoice.new(@session, @session.invoice(id.to_i)) rate = YDIM::Server.config.vat_rate if(item = inv.model.items[0] and (item.vat_rate - rate).abs > 0.1) inv = Invoice_2010.new(@session, @session.invoice(id.to_i)) end end return inv end
Notes
Check test-cases of ydim-html
masa@masa ~/ywesee/ydim-html $ ruby test/suite.rb /home/masa/ywesee/ydim-html/lib/ydim/html.rb:3: warning: already initialized constant VERSION ./test/selenium.rb:172:in `do_command': SeleniumCommandError from /usr/lib64/ruby/1.8/timeout.rb:62:in `timeout' from /usr/lib64/ruby/1.8/timeout.rb:93:in `timeout' from ./test/selenium.rb:158:in `do_command' from ./test/selenium.rb:179:in `get_string' from ./test/selenium.rb:148:in `start' from ./test/selenium/unit.rb:48 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./test/selenium/test_invoices.rb:7 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from test/suite.rb:12 from /usr/lib64/ruby/1.8/find.rb:39:in `find' from /usr/lib64/ruby/1.8/find.rb:38:in `catch' from /usr/lib64/ruby/1.8/find.rb:38:in `find' from test/suite.rb:10
Note
Experiment
def pdf_invoice(sort_args={}) config = PdfInvoice.config.dup config.formats['quantity'] = "%1.#{@precision}f" config.formats['total'] = "#{@currency} %1.2f" if(item = @items[0]) if((item.vat_rate - YDIM::Server.config.vat_rate).abs > 0.1) config.texts['tax'] = "MwSt 7.6%" end end
Result
Commit
Update on ydim server
~/git/ydim $ git checkout -f
Note
I found a kind of bug. It is not a big bug, though.
Problem
An invoice in 'Bezahlte Rechnungen'
Note