spec/lockdown/frameworks/rails_spec.rb in lockdown-1.3.0 vs spec/lockdown/frameworks/rails_spec.rb in lockdown-1.3.1
- old
+ new
@@ -21,32 +21,60 @@
end
end
describe "#mixin" do
it "should perform class_eval on controller view and system to inject itself" do
- module ActionController; class Base; end end
- module ActionView; class Base; end end
- Lockdown.stub!(:controller_parent).and_return(ActionController::Base)
- Lockdown.stub!(:view_helper).and_return(ActionView::Base)
+ @view_helper = Mikey
+ @view_helper.should_receive(:include).
+ with( Lockdown::Frameworks::Rails::View )
- ActionView::Base.should_receive(:class_eval)
+ Lockdown.should_receive(:view_helper) do
+ @view_helper
+ end
- ActionController::Base.should_receive(:helper_method)
- ActionController::Base.should_receive(:before_filter)
- ActionController::Base.should_receive(:filter_parameter_logging)
- ActionController::Base.should_receive(:rescue_from)
+ @system = Mikey
+ @system.should_receive(:extend).
+ with( Lockdown::Frameworks::Rails::System )
- ActionController::Base.should_receive(:class_eval)
- ActionController::Base.should_receive(:hide_action)
+ Lockdown.should_receive(:system) do
+ @system
+ end
- Lockdown::System.should_receive(:class_eval)
+ @rails.should_receive(:mixin_controller)
-
@rails.mixin
end
end
+
+ describe "#mixin_controller" do
+
+ it "should inject itself" do
+ klass = Mikey
+
+ klass.should_receive(:include).
+ with(Lockdown::Session)
+
+ klass.should_receive(:include).
+ with(Lockdown::Frameworks::Rails::Controller::Lock)
+
+ klass.should_receive(:helper_method).with(:authorized?)
+
+ klass.should_receive(:hide_action).with(:set_current_user, :configure_lockdown, :check_request_authorization, :check_model_authorization)
+
+ klass.should_receive(:before_filter).and_return do |c|
+ #not working yet. very frustrating trying to test this
+ end
+
+ klass.should_receive(:filter_parameter_logging)
+
+ klass.should_receive(:rescue_from)
+
+ @rails.mixin_controller(klass)
+ end
+ end
+
end
RAILS_ROOT = "/shibby/dibby/do"
module ActionController; class Base; end end