Sha256: 40b95cd7c948b6218545a9357e4fa4d8a3d939e31bbf90d5d843f921f94bd71a

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'
require 'camping'

Camping.goes :Prefixed


module Prefixed
  set :url_prefix, "pages"
end

module Prefixed::Helpers
  def frontpage
    R(Index)
  end

  def current_user
    User.new
  end
end

module Prefixed::Models
  class User
    def name
      'Bob'
    end
  end
end

module Prefixed::Controllers
  class Index
    def get
      URL('/').to_s
    end
  end

  class Friends
    def get
      self / "/view/1"    #=> "/pages/view/1"
    end
  end

  class Helpy
    def get
      @url_prefix
    end
  end

  class Model
    def get
      current_user.name
    end
  end

  class Users
    def get
      frontpage
    end
  end
end

class Prefixed::Test < TestCase

  def test_url_helper_use_prefix
    get '/pages/model'
    assert_body "Bob"
  end

  def test_slash_helper_use_prefix
    get '/pages/friends'
    assert_body "/pages/view/1"
  end

  def test_prefix_ivar
    get '/pages/helpy'
    assert_body "pages/"
  end

  # Test that R(Index) produces "/pages/"
  def test_r_helper_use_prefix
    get '/pages/users'
    assert_body "/pages"
  end

  def test_controller_routes_use_prefix
    get '/pages', {}, 'PATH_INFO' => '/pages'
    assert_body "http://example.org/pages/"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
camping-3.2.6 test/app_prefixed.rb
camping-3.2.5 test/app_prefixed.rb
camping-3.2.4 test/app_prefixed.rb
camping-3.2.3 test/app_prefixed.rb
camping-3.2.2 test/app_prefixed.rb
camping-3.2.1 test/app_prefixed.rb
camping-3.2.0 test/app_prefixed.rb
camping-3.1.3 test/app_prefixed.rb
camping-3.1.2 test/app_prefixed.rb
camping-3.1.0 test/app_prefixed.rb
camping-3.0.2 test/app_prefixed.rb
camping-3.0.1 test/app_prefixed.rb
camping-3.0.0 test/app_prefixed.rb