Sha256: 5d2db52dfa48f8fda03344fb20fa07d3b46198e49f8a76d6d5c73bb426348163

Contents?: true

Size: 1.77 KB

Versions: 129

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe "Saucy routing extensions" do
  include ActionDispatch::Routing::UrlFor

  let(:_routes) { ActionDispatch::Routing::RouteSet.new }

  before do
    _routes.draw do
      resources :accounts
      through :accounts do
        resources :projects
        through :projects do
          resources :discussions
        end
      end
    end

    extend(_routes.named_routes.module)
  end

  it "allows a nested member path to be accessed through just the child's name" do
    account = stub('account', :to_param => 'abc')
    project = stub('project', :account => account, :to_param => 'def')
    project_path(project).should == "/accounts/abc/projects/def"
  end

  it "allows a nested member url to be accessed through just the child's name" do
    account = stub('account', :to_param => 'abc')
    project = stub('project', :account => account, :to_param => 'def')
    project_url(project, :host => 'example.com').
      should == "http://example.com/accounts/abc/projects/def"
  end

  it "allows a nested collection path to be accessed through just the parent's name" do
    account = stub('account', :to_param => 'abc')
    projects_path(account).should == "/accounts/abc/projects"
  end

  it "allows a nested new path to be accessed through just the parent's name" do
    account = stub('account', :to_param => 'abc')
    new_project_path(account).should == "/accounts/abc/projects/new"
  end

  it "allows a doubly nested member path to be access through just the child's name" do
    account = stub('account', :to_param => 'abc')
    project = stub('project', :account => account, :to_param => 'def')
    discussion = stub('discussion', :project => project, :to_param => 'ghi')
    discussion_path(discussion).should == "/accounts/abc/projects/def/discussions/ghi"
  end
end

Version data entries

129 entries across 129 versions & 2 rubygems

Version Path
saucy-0.4.7 spec/route_extensions_spec.rb
saucy-0.4.6 spec/route_extensions_spec.rb
saucy-0.4.5 spec/route_extensions_spec.rb
saucy-0.4.4 spec/route_extensions_spec.rb
saucy-0.4.3 spec/route_extensions_spec.rb
saucy-0.4.2 spec/route_extensions_spec.rb
saucy-0.4.1 spec/route_extensions_spec.rb
saucy-0.3.4.1 spec/route_extensions_spec.rb
saucy-0.4.0 spec/route_extensions_spec.rb
saucy-0.3.4 spec/route_extensions_spec.rb
saucy-0.3.3 spec/route_extensions_spec.rb
saucy-0.3.2 spec/route_extensions_spec.rb
saucy-0.3.1 spec/route_extensions_spec.rb
saucy-0.3.0 spec/route_extensions_spec.rb
saucy-0.2.45 spec/route_extensions_spec.rb
saucy-0.2.44 spec/route_extensions_spec.rb
saucy-0.2.43 spec/route_extensions_spec.rb
saucy-0.2.42 spec/route_extensions_spec.rb
saucy-0.2.41 spec/route_extensions_spec.rb
saucy-0.2.40 spec/route_extensions_spec.rb