diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e2c29..9c2dcfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/swagger/docs/generator.rb b/lib/swagger/docs/generator.rb index f49e377..1cb5bda 100644 --- a/lib/swagger/docs/generator.rb +++ b/lib/swagger/docs/generator.rb @@ -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 diff --git a/lib/swagger/docs/version.rb b/lib/swagger/docs/version.rb index 5b6841a..6fe2644 100644 --- a/lib/swagger/docs/version.rb +++ b/lib/swagger/docs/version.rb @@ -1,5 +1,5 @@ module Swagger module Docs - VERSION = "0.2.6" + VERSION = "0.2.7" end end diff --git a/spec/lib/swagger/docs/generator_spec.rb b/spec/lib/swagger/docs/generator_spec.rb index f9acaa6..aaf7ca9 100644 --- a/spec/lib/swagger/docs/generator_spec.rb +++ b/spec/lib/swagger/docs/generator_spec.rb @@ -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) @@ -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", @@ -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