Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0716d55b54
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 35 lines (28 sloc) 0.949 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
class CustomUrlModel < RemoteModule::RemoteModel
  collection_url "collection"
  member_url "collection/:id"

  custom_urls :a_url => "custom", :format_url => "custom/:var",
    :method_url => "custom/:a_method"

  def id
    8
  end

  def a_method
    10
  end
end

describe "URLs" do
  it "should make visible urls at class and instance level" do
    CustomUrlModel.a_url.should == "custom"
    CustomUrlModel.collection_url.should == "collection"
    CustomUrlModel.member_url.should == "collection/:id"

    # NOTE that Class.member_url(params) won't work (it's the setter).
    CustomUrlModel.member_url.format(:id => 9).should == "collection/9"

    c = CustomUrlModel.new
    c.collection_url.should == "collection"
    c.member_url.should == "collection/8"
    c.a_url.should == "custom"

    CustomUrlModel.format_url.should == "custom/:var"
    c.format_url(:var => 3).should == "custom/3"
    c.method_url.should == "custom/10"
  end
end
Something went wrong with that request. Please try again.