From ea874fd4679ab31a68e3a2fcf9a6bb8064d028fa Mon Sep 17 00:00:00 2001 From: Niklaus Giger Date: Tue, 9 May 2017 14:09:05 +0200 Subject: [PATCH] Virbac: Changes needed for viral modules and KnownUser --- Gemfile | 17 ++++++++--------- Gemfile.lock | 27 ++++++++++++--------------- History.txt | 3 +++ doc/index.rbx | 14 -------------- get_db_virbac_bbmb | 9 ++++----- lib/bbmb/html/util/lookandfeel.rb | 23 +++++++++++++++++------ lib/bbmb/virbac/html/state/viral/customer.rb | 2 +- lib/bbmb/virbac/html/util/validator.rb | 4 ++-- readme.md | 8 ++++++++ spec/login_spec.rb | 25 ++++++++++++++++++------- spec/spec_helper.rb | 13 ++++++++++--- test/selenium/unit.rb | 3 +-- 12 files changed, 84 insertions(+), 64 deletions(-) delete mode 100755 doc/index.rbx diff --git a/Gemfile b/Gemfile index 17f23ff..620a3af 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,15 @@ source 'https://rubygems.org' -gem 'odba' +# gem 'sbsm', :git => 'https://github.com/ngiger/sbsm.git' +# gem 'sbsm', :path => '/home/niklaus/git/sbsm' +# gem 'bbmb', :path => '/home/niklaus/git/bbmb' +# gem 'htmlgrid', :path => '/home/niklaus/git/htmlgrid' gem 'bbmb' -gem 'spreadsheet' +gem 'spreadsheet' # for password importer group :debugger do - if RUBY_VERSION.match(/^1/) - gem 'pry-debugger' - else - gem 'pry-byebug' - gem 'pry-doc' - end + gem 'pry-byebug' + gem 'pry-doc' end group :test do @@ -21,4 +20,4 @@ group :test do gem 'rspec' gem 'watir' gem 'watir-webdriver' -end \ No newline at end of file +end diff --git a/Gemfile.lock b/Gemfile.lock index fa16ff7..53b1224 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,20 +18,20 @@ GEM ypdf-writer yus byebug (9.0.6) - childprocess (0.6.1) + childprocess (0.6.3) ffi (~> 1.0, >= 1.0.11) coderay (1.1.1) color (1.8) deprecated (2.0.1) diff-lcs (1.3) - ffi (1.9.17) + ffi (1.9.18) flexmock (2.3.5) highline (1.7.8) hpricot (0.8.6) - htmlgrid (1.1.3) + htmlgrid (1.1.4) sbsm (>= 1.2.7) - json (2.0.3) - mail (2.6.4) + json (2.1.0) + mail (2.6.5) mime-types (>= 1.16, < 4) method_source (0.8.2) mime-types (3.1) @@ -57,7 +57,6 @@ GEM rack (2.0.1) rake (12.0.0) rclconf (1.0.0) - rmail (1.1.2) rrba (1.0.0) rspec (3.5.0) rspec-core (~> 3.5.0) @@ -72,24 +71,24 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - ruby-ole (1.2.12) + ruby-ole (1.2.12.1) rubyzip (1.2.1) sbsm (1.3.0) hpricot mail rack - selenium-webdriver (3.1.0) + selenium-webdriver (3.3.0) childprocess (~> 0.5) rubyzip (~> 1.0) websocket (~> 1.0) slop (3.6.0) spreadsheet (1.1.4) ruby-ole (>= 1.0) - syck (1.2.0) + syck (1.3.0) test-unit (3.2.3) power_assert transaction-simple (1.4.0.2) - watir (6.2.0) + watir (6.2.1) selenium-webdriver (~> 3.0) watir-webdriver (0.9.9) selenium-webdriver (>= 2.46.2) @@ -100,13 +99,13 @@ GEM ydbi (>= 0.5.0) ydbi (0.5.3) deprecated (= 2.0.1) - ydim (1.0.3) + ydim (1.0.5) deprecated (= 2.0.1) hpricot + mail needle odba (>= 1.1.2) rclconf - rmail rrba syck ydbd-pg (>= 0.5.1) @@ -132,16 +131,14 @@ DEPENDENCIES bbmb flexmock minitest - odba pry-byebug pry-doc rake rspec - sbsm (= 1.3.0) spreadsheet test-unit watir watir-webdriver BUNDLED WITH - 1.13.7 + 1.14.6 diff --git a/History.txt b/History.txt index 9d3a207..b7f8e8b 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,6 @@ +=== 1.0.1 / 24.02.2017 +* Reworked to use RACK based SBSM gem + === 1.0.0 / 22.02.2011 * 1 major enhancement diff --git a/doc/index.rbx b/doc/index.rbx deleted file mode 100755 index e5aba4e..0000000 --- a/doc/index.rbx +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby -# index.rbx -- bbmb.ch -- hwyss@ywesee.com - -require 'sbsm/request' - -::DRb.start_service('druby://localhost:0') - -begin - SBSM::Request.new(ENV["DRB_SERVER"]).process -rescue Exception => e - $stderr << "Client Error: " << e.message << "\n" - $stderr << e.class << "\n" - $stderr << e.backtrace.join("\n") << "\n" -end diff --git a/get_db_virbac_bbmb b/get_db_virbac_bbmb index 7422b94..f2312fd 100644 --- a/get_db_virbac_bbmb +++ b/get_db_virbac_bbmb @@ -1,11 +1,10 @@ #!/bin/bash -v DB_NAME=virbac_bbmb - -yyyy=`date -d '1 days ago' +"%Y"` -mm=`date -d '1 days ago' +"%m"` -dd=`date -d '1 days ago' +"%d"` -DB_DUMP=/var/backup/fast/db_dumps/$DB_NAME.$yyyy$mm$dd.sql.gz +DAYS_AGO=1 +yyyy=`date -d "$DAYS_AGO days ago" +"%Y"` +mm=`date -d "$DAYS_AGO days ago" +"%m"` +dd=`date -d "$DAYS_AGO days ago" +"%d"` DB_DUMP=/var/backup/fast/db_dumps/$DB_NAME.$yyyy$mm$dd.sql.gz m=(dummy January February March April May June July August September October November December) diff --git a/lib/bbmb/html/util/lookandfeel.rb b/lib/bbmb/html/util/lookandfeel.rb index 78ed34f..871e46e 100644 --- a/lib/bbmb/html/util/lookandfeel.rb +++ b/lib/bbmb/html/util/lookandfeel.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby # Html::Util::Lookandfeel -- bbmb.ch -- 15.09.2006 -- hwyss@ywesee.com +require 'bbmb/html/util/session' require 'sbsm/lookandfeel' module BBMB @@ -71,7 +72,7 @@ grundsätzlich am nächsten Arbeitstag beim Kunden ein. Impfstoff-Bestellungen am späten Donnerstagnachmittag oder am Freitag werden wie folgt ausgeliefert: EOS :default_values => "Voreinstellungen", @@ -213,7 +214,7 @@ Beste Grüsse. Virbac Schweiz AG :th_price_levels => 'Staffelpreise', :th_price_public => "Publikumspreis", :th_price_quota => 'Abschlusspreis', - :th_quantity => 'Menge', + :th_quantity => 'Menge', :th_order_total => "Endpreis", :th_organisation => "Kunde", :th_plz => "PLZ", @@ -294,12 +295,12 @@ exclusivement avec notre accord :delivery_conditions_text => <<-EOS, Avec l’inscription je prends note des conditions générales -Les commandes qui nous parviennent jusqu’à 14.00 heures seront +Les commandes qui nous parviennent jusqu’à 14.00 heures seront en principe chez le client le jour suivant. -Les commandes de vaccins qui nous parviennent le jeudi, en fin +Les commandes de vaccins qui nous parviennent le jeudi, en fin d’après-midi, ou le vendredi seront expédiées comme suit: EOS :default_values => "Revenir au début", @@ -469,7 +470,17 @@ un jour ouvrable. Meilleures salutations. Virbac Suisse SA DISABLED = [ :transfer_dat, :barcode_reader ] ENABLED = [ :additional_info_first, :free_products, :request_access ] def navigation - zone_navigation + super + # was pre_rack: zone_navigation + super + begin + default_value = super + puts "navigation return zone_navigation #{zone_navigation} + default_value #{default_value}" + zone_navigation + default_value + rescue => error + prefs = @session.user.get_preference(:navigation) + puts "rescue navigation returns #{zone_navigation + (prefs ? prefs : [])}" + require 'pry';binding.pry + zone_navigation + (prefs ? prefs : []) + end end end end diff --git a/lib/bbmb/virbac/html/state/viral/customer.rb b/lib/bbmb/virbac/html/state/viral/customer.rb index 8a93765..21997b8 100644 --- a/lib/bbmb/virbac/html/state/viral/customer.rb +++ b/lib/bbmb/virbac/html/state/viral/customer.rb @@ -13,7 +13,7 @@ module BBMB module Html module State module Viral -module Customer +module Customer def calculator products = BBMB.persistence.all(Model::Product).select { |product| product.price diff --git a/lib/bbmb/virbac/html/util/validator.rb b/lib/bbmb/virbac/html/util/validator.rb index 25431e7..af6ea19 100644 --- a/lib/bbmb/virbac/html/util/validator.rb +++ b/lib/bbmb/virbac/html/util/validator.rb @@ -3,10 +3,10 @@ require 'bbmb/html/util/validator' -module BBMB +module VIRBAC module Html module Util -class Validator +class Validator < BBMB::Html::Util::Validator BOOLEAN.push(:show_vat) EVENTS.push(:calculate, :calculator, :catalogue, :promotions, :quotas) NUMERIC.push(:factor) diff --git a/readme.md b/readme.md index 4644dd3..88074f5 100644 --- a/readme.md +++ b/readme.md @@ -23,6 +23,14 @@ ## Testing +niklaus@oddb-ci2 /v/w/virbac.bbmb.ch> bin/admin +ch.bbmb> BBMB.config.auth_domain +-> ch.bbmb.vetoquinol +ch.bbmb> exit +-> Goodbye +niklaus@oddb-ci2 /v/w/virbac.bbmb.ch> bin/admin config=/var/www/virbac.bbmb.ch/etc/config.yml +ch.bbmb.virbac> BBMB.config.auth_domain +-> ch.bbmb.virbac ## DEVELOPERS: diff --git a/spec/login_spec.rb b/spec/login_spec.rb index fd14ca4..3efbb2b 100644 --- a/spec/login_spec.rb +++ b/spec/login_spec.rb @@ -65,15 +65,15 @@ describe "virbac.bbmb" do end it "fail unknown user" do # @auth.should_receive(:login).and_return { raise Yus::UnknownEntityError } - @browser.text_field(:name, 'email').when_present.set('unknown@bbmb.ch') - @browser.text_field(:name, 'pass').when_present.set('secret') + @browser.text_field(:name, 'email').wait_until(&:present?).set('unknown@bbmb.ch') + @browser.text_field(:name, 'pass').wait_until(&:present?).set('secret') @browser.form(:name, 'login').submit expect(@browser.title).to eq 'BBMB' expect(@browser.label(:text, 'E-Mail Adresse').attribute_value('class')).to eq 'error' end it "fail wrong password" do - @browser.text_field(:name, 'email').when_present.set(AdminUser) - @browser.text_field(:name, 'pass').when_present.set('secret') + @browser.text_field(:name, 'email').wait_until(&:present?).set(AdminUser) + @browser.text_field(:name, 'pass').wait_until(&:present?).set('secret') @browser.form(:name, 'login').submit expect(@browser.title).to eq 'BBMB' expect(@browser.label(:text, 'Passwort').attribute_value('class')).to eq 'error' @@ -97,6 +97,17 @@ describe "virbac.bbmb" do end end end + +describe 'mocked virbac' do + it "should logout after a timeout" do + require 'server_mock' + drb_url = "druby://localhost:10081" + my_stub = BBMB::Stub.http_server(drb_url, log_level=0) + @browser = Watir::Browser.new :chrome + @browser.goto('http://localhost:4444') + binding.pry + end +end if false class TestLogin < Test::Unit::TestCase include Selenium::TestCase @@ -199,8 +210,8 @@ Bestellungen, die bei uns bis 14.00 Uhr eingehen, treffen grundsätzlich am nächsten Arbeitstag beim Kunden ein. Impfstoff-Bestellungen am späten Donnerstagnachmittag oder am Freitag -werden wie folgt ausgeliefert: Am darauffolgenden Montag (wenn keine Dringlichkeit vermerkt ist) - Auf Wunsch am Freitag per Mondexpress, dieser wird am Samstagmorgen bis +werden wie folgt ausgeliefert: Am darauffolgenden Montag (wenn keine Dringlichkeit vermerkt ist) + Auf Wunsch am Freitag per Mondexpress, dieser wird am Samstagmorgen bis 9 Uhr ausgeliefert (Kosten gehen zu Lasten des Kunden) EOS click "//div[@class='login-foot']" @@ -212,4 +223,4 @@ werden wie folgt ausgeliefert: Am darauffolgenden Montag (wenn keine Dringlichke assert_equal false, is_visible("//div[@id='delivery-conditions']") end end -end \ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2cb8131..768d145 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -29,7 +29,7 @@ VirbacUrl = 'http://virbac.bbmb.ngiger.ch/' Flavor = 'sbsm' ImageDest = File.join(Dir.pwd, 'images') Browser2test = [ :chrome ] -require 'watir-webdriver' +require 'watir' DownloadDir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'downloads')) GlobAllDownloads = File.join(DownloadDir, '*') LeeresResult = /hat ein leeres Resultat/ @@ -68,8 +68,8 @@ def login(user = ViewerUser, password=ViewerPassword, remember_me=false) setup_browser @browser.goto VirbacUrl sleep 0.5 - @browser.text_field(:name, 'email').when_present.set(user) - @browser.text_field(:name, 'pass').when_present.set(password) + @browser.text_field(:name, 'email').wait_until(&:present?).set(user) + @browser.text_field(:name, 'pass').wait_until(&:present?).set(password) @browser.button(:name,"login").click sleep 1 unless @browser.link(:name,"logout").exists? if p @@ -133,3 +133,10 @@ def createScreenshot(browser, added=nil) browser.screenshot.save (name) puts "createScreenshot: #{name} done" if $VERBOSE end + +def show_threads + Thread.list.each do |thread| + STDERR.puts "Thread-#{thread.object_id.to_s(36)}" + STDERR.puts thread.backtrace.join("\n \\_ ") + end +end diff --git a/test/selenium/unit.rb b/test/selenium/unit.rb index 18dc001..8533239 100755 --- a/test/selenium/unit.rb +++ b/test/selenium/unit.rb @@ -39,8 +39,7 @@ end BBMB.config.http_server = 'http://localhost' -$selenium = BBMB::Selenium::SeleniumWrapper.new("localhost", 4444, - "*chrome", BBMB.config.http_server + ":10080", 10000) +$selenium = BBMB::Selenium::SeleniumWrapper.new("localhost", 4444, "*chrome", BBMB.config.http_server + ":10080", 10000) start = Time.now begin -- 2.10.2