Skip to content

Commit

Permalink
Make sure that singleton spec has no key [#5 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Sep 29, 2009
1 parent 218d7c1 commit 0376d10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ardes/resources_controller/specification.rb
Expand Up @@ -93,6 +93,11 @@ def initialize(spec_name, options = {}, &block)
def singleton?
true
end

# no key for singleton resources
def key
false
end

# finds the resource from the enclosing resource. Raise CantFindSingleton if there is no enclosing resource
def find_resource(controller)
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/request_path_introspection_spec.rb
Expand Up @@ -97,5 +97,18 @@ class User < ActiveRecord::Base; end
end
end
end

describe "#segment_for_key" do
describe "when controller has map {:user, :singelton => true}" do
before do
@klass.resources_controller_for :forums, :class => RequestPathIntrospectionSpec::Forum
@klass.map_enclosing_resource :user, :singleton => true, :class => RequestPathIntrospectionSpec::User
end

it "('user_id') should return 'users'" do
@controller.send(:segment_for_key, 'user_id').should == 'users'
end
end
end
end
end

0 comments on commit 0376d10

Please sign in to comment.