Skip to content

Commit

Permalink
Fix base_url issue as non flavored
Browse files Browse the repository at this point in the history
* Omit flavor from base_url
* Add simple unit test for custom lookandfeel
  • Loading branch information
Yasuhiro Asaka committed Jul 13, 2016
1 parent 4bbd258 commit 8f8f54d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/bbmb/html/util/lookandfeel.rb
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions 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

0 comments on commit 8f8f54d

Please sign in to comment.