Skip to content

Commit

Permalink
NoMethodError: undefined method '<' for false:FalseClass (#133)
Browse files Browse the repository at this point in the history
Bump version to 0.2.7
  • Loading branch information
richhollis committed Jan 15, 2016
1 parent bdb4765 commit 517c4a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.7

- Fix issue "NoMethodError: undefined method `<' for false:FalseClass" (#133) - thanks to @heaven

## 0.2.6

- swagger_controller DSL can accept a resource_path which will be used over a generated path #126 @sb8244
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger/docs/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def process_path(path, root, config, settings)
klass = Config.log_exception { "#{path.to_s.camelize}Controller".constantize } rescue nil
return {action: :skipped, path: path, reason: :klass_not_present} if !klass
return {action: :skipped, path: path, reason: :not_swagger_resource} if !klass.methods.include?(:swagger_config) or !klass.swagger_config[:controller]
return {action: :skipped, path: path, reason: :not_kind_of_parent_controller} if config[:parent_controller] && !klass < config[:parent_controller]
return {action: :skipped, path: path, reason: :not_kind_of_parent_controller} if config[:parent_controller] && !(klass < config[:parent_controller])
apis, models, defined_nicknames = [], {}, []
routes.select{|i| i.defaults[:controller] == path}.each do |route|
unless nickname_defined?(defined_nicknames, path, route) # only add once for each route once e.g. PATCH, PUT
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger/docs/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Swagger
module Docs
VERSION = "0.2.6"
VERSION = "0.2.7"
end
end
15 changes: 14 additions & 1 deletion spec/lib/swagger/docs/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
require "fixtures/controllers/application_controller"
require "fixtures/controllers/ignored_controller"

class FooParentController; end

before(:each) do
FileUtils.rm_rf(tmp_dir)
stub_const('ActionController::Base', ApplicationController)
Expand Down Expand Up @@ -34,7 +36,9 @@

let(:default_config) {
{
:controller_base_path => "api/v1", :api_file_path => "#{tmp_dir}", :base_path => "http://api.no.where/",
:controller_base_path => "api/v1",
:api_file_path => "#{tmp_dir}",
:base_path => "http://api.no.where/",
:attributes => {
:info => {
"title" => "Swagger Sample App",
Expand Down Expand Up @@ -134,6 +138,15 @@
expect(file_resource).to_not exist
end
end
describe "#generate" do
it "respects parent_controller config option" do
new_config = default_config
new_config[:parent_controller] = ApplicationController
api_config = Swagger::Docs::Config.register_apis(DEFAULT_VER => new_config)
results = generate(api_config)
expect(results[DEFAULT_VER][:processed].count).to eq(controllers.count)
end
end
describe "#write_docs" do
context "no apis registered" do
before(:each) do
Expand Down

0 comments on commit 517c4a8

Please sign in to comment.