Permalink
Browse files

Merge branch 'thomasfedb-abstract_controller_are_anonymous'

  • Loading branch information...
2 parents 525ed7a + 910993e commit b8e0cdcdf408c1ec5e868743a1743f82b9bb46d7 @alindeman alindeman committed Jan 5, 2014
View
@@ -5,12 +5,12 @@ Bug fixes
* Use `__send__` rather than `send` to prevent naming collisions (Bradley Schaefer)
* Supports Rails 4.1. (Andy Lindeman)
+* Routes are drawn correctly for anonymous controllers with abstract
+ parents. (Billy Chan)
Enhancements
* Improve be_valid matcher for non-ActiveModel::Errors implementations (Ben Hamill)
-* Named "anonymous" controllers now expose the derivied `controller_name`
- and draw routes accordingly. (Billy Chan)
Breaking Changes for 3.0.0:
@@ -62,8 +62,11 @@ def controller(base_class = nil, &body)
metadata[:example_group][:described_class] = Class.new(base_class) do
def self.name
- superclass == ApplicationController ?
- "AnonymousController" : superclass.to_s
+ if superclass == ApplicationController || superclass.abstract?
+ "AnonymousController"
+ else
+ superclass.to_s
+ end
end
end
metadata[:example_group][:described_class].class_eval(&body)
@@ -1,6 +1,7 @@
require "spec_helper"
class ::ApplicationController
+ def self.abstract?; false; end
end
module RSpec::Rails
@@ -119,6 +120,14 @@ module RSpec::Rails
group.controller(ApplicationController) { }
expect(controller_class.name).to eq "AnonymousController"
end
+
+ it "sets name as AnonymousController the controller is abstract" do
+ abstract_controller = Class.new(::ApplicationController)
+ def abstract_controller.abstract?; true; end
+
+ group.controller(abstract_controller) { }
+ expect(controller_class.name).to eq "AnonymousController"
+ end
end
end
end

0 comments on commit b8e0cdc

Please sign in to comment.