Skip to content

Commit

Permalink
[Fixes #104] Record examples considers a defined resource_id
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Mar 12, 2013
1 parent ce58bd6 commit 6d61c5a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,5 @@ spec/dummy/tmp/
.idea
Gemfile.lock
.rvmrc

.DS_Store
4 changes: 2 additions & 2 deletions lib/apipie/extractor/collector.rb
Expand Up @@ -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

Expand All @@ -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

Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/api/v2/nested/resources_controller_spec.rb
@@ -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
33 changes: 33 additions & 0 deletions spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
@@ -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.