From 8f8f54deb4697150366c81d4199baccb201ab265 Mon Sep 17 00:00:00 2001 From: Yasuhiro Asaka Date: Wed, 13 Jul 2016 20:10:05 +0200 Subject: [PATCH] Fix base_url issue as non flavored * Omit flavor from base_url * Add simple unit test for custom lookandfeel --- lib/bbmb/html/util/lookandfeel.rb | 11 +++++++++++ test/html/util/test_lookandfeel.rb | 31 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/html/util/test_lookandfeel.rb diff --git a/lib/bbmb/html/util/lookandfeel.rb b/lib/bbmb/html/util/lookandfeel.rb index 24c5046..acee895 100644 --- a/lib/bbmb/html/util/lookandfeel.rb +++ b/lib/bbmb/html/util/lookandfeel.rb @@ -196,6 +196,17 @@ class Lookandfeel < SBSM::Lookandfeel def navigation zone_navigation + super end + + alias :orig_base_url :base_url + + # Provides non flavored base url + def base_url + _flavor = @flavor + @flavor = nil + url = orig_base_url + @flavor = _flavor + url + end end end end diff --git a/test/html/util/test_lookandfeel.rb b/test/html/util/test_lookandfeel.rb new file mode 100644 index 0000000..6d0c853 --- /dev/null +++ b/test/html/util/test_lookandfeel.rb @@ -0,0 +1,31 @@ +$: << File.dirname(__FILE__) +$: << File.expand_path('..', File.dirname(__FILE__)) +$: << File.expand_path('../../../lib', File.dirname(__FILE__)) + +require 'minitest/autorun' +require 'flexmock/minitest' +require 'sbsm/session' +require 'bbmb/html/util/lookandfeel' + +module BBMB + module Html + class TestApplication + def unknown_user; end + end + + module Util + class TestLookandfeel < ::Minitest::Test + def setup + @app = TestApplication.new + @session = SBSM::Session.new('test', @app) + end + + def test_base_url_does_not_include_flavor + lookandfeel = Lookandfeel.new(@session) + assert_equal('sbsm', lookandfeel.flavor) + refute_match(@session.flavor, lookandfeel.base_url) + end + end + end + end +end