Permalink
Browse files

[Fixes #104] Record examples considers a defined resource_id

  • Loading branch information...
1 parent ce58bd6 commit 6d61c5a82a2c56773094adb799866f5109fea491 @johanneswuerbach johanneswuerbach committed Mar 12, 2013
View
@@ -7,3 +7,5 @@ spec/dummy/tmp/
.idea
Gemfile.lock
.rvmrc
+
+.DS_Store
@@ -19,7 +19,7 @@ def controller_full_path(controller)
def ignore_call?(record)
return true unless record[:controller]
return true if @ignored.include?(record[:controller].name)
- return true if @ignored.include?("#{record[:controller].name}##{record[:action]}")
+ return true if @ignored.include?("#{Apipie.get_resource_name(record[:controller].name)}##{record[:action]}")
return true unless @api_controllers_paths.include?(controller_full_path(record[:controller]))
end
@@ -33,7 +33,7 @@ def handle_record(record)
end
def add_to_records(record)
- key = "#{record[:controller].controller_name}##{record[:action]}"
+ key = "#{Apipie.get_resource_name(record[:controller])}##{record[:action]}"
@records[key] << record
end
@@ -0,0 +1,11 @@
+require 'spec_helper'
+
+describe Api::V2::Nested::ResourcesController do
+ describe "resource id" do
+ subject { Apipie.get_resource_name(Api::V2::Nested::ResourcesController) }
+
+ it "should have resource_id set" do
+ subject.should eq("resource")
+ end
+ end
+end
@@ -0,0 +1,33 @@
+module Api
+ module V2
+ class Nested::ResourcesController < V2::BaseController
+ resource_description do
+ name 'Resources'
+ resource_id "resource"
+ end
+ api :GET, "/nested/resources/", "List all nested resources."
+ def index
+ end
+
+ api :GET, "/nested/resources/:id/", "Show a nested resource."
+ def show
+ end
+
+ api :POST, "/nested/resources/", "Create a nested resource."
+ param_group :arch, Api::V1::ArchitecturesController
+ def create
+ end
+
+ api :PUT, "/nested/resources/:id/", "Update a nested resource."
+ param :architecture, Hash, :required => true do
+ param :name, String
+ end
+ def update
+ end
+
+ api :DELETE, "/resources/:id/", "Delete a nested resource."
+ def destroy
+ end
+ end
+ end
+end

0 comments on commit 6d61c5a

Please sign in to comment.