Sha256: 9901d83a1c14af1eee14db4b087690e176dac4f26b5cad4adff283866e9fd6c2

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')

require 'test/unit'
require 'ostruct'

require 'glue'
require 'glue/logger'
require 'nitro'
require 'nitro/util/encode_url'

class TC_EncodeUrl < Test::Unit::TestCase # :nodoc: all
  include Nitro

  class FirstController < Controller
    def list
    end
    public :encode_url
  end

  class SecondController < Controller
    attr_reader :aqflag, :tflag

    def self.setup_template_root(path)
      @template_root << File.expand_path(File.join(Nitro::LibPath, "../test/public/#{path}"))
    end   

    def list
      @aqflag = true 
    end

    def another(oid)
      # nop
    end
  end

  class TestEncoder
    include Nitro::EncodeUrl
    public :encode_url
  end

  def setup
    @disp = Dispatcher.new '/first'  => FirstController,
                           '/second' => SecondController
    @conf = OpenStruct.new
    @conf.dispatcher = @disp
    Thread.current[:CURRENT_CONTEXT] = @conf
  end

  def test_encode
    t = TestEncoder.new
    
    assert_equal 'test', t.encode_url('test')
    assert_equal '/first/list', t.encode_url(FirstController, :list)
  
  end

  def test_controller_encode
    t = FirstController.new(@conf)
    
    assert_equal '/first/list', t.encode_url(:list)
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.41.0 test/nitro/util/tc_encode_url.rb