From 1b82c3926db29402ab28207f3ac4e9e1c6c8c9b7 Mon Sep 17 00:00:00 2001 From: Ian White Date: Wed, 30 Apr 2008 16:43:59 +0100 Subject: [PATCH] Added some specs to bring C2 up to 100%, caught a bug introduced by changes in edge --- lib/ardes/response_for.rb | 2 +- spec/app.rb | 4 ++++ spec/controllers/inerited_controllers_spec.rb | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/ardes/response_for.rb b/lib/ardes/response_for.rb index 14ad105..4dac045 100644 --- a/lib/ardes/response_for.rb +++ b/lib/ardes/response_for.rb @@ -162,7 +162,7 @@ def erase_render_results_with_response_for # This allows actions without an explicit respond_to block to be decorated # with response_for def render_with_response_for(*args, &block) - if !instance_variable_get('@performed_respond_to') && !block_given? && args.reject(&:nil?) == [] && self.class.send(:action_responses)[action_name] + if !instance_variable_get('@performed_respond_to') && self.class.send(:action_responses)[action_name] && !block_given? && args.reject{|a| a.nil? || a.empty?}.empty? respond_to return if performed? end diff --git a/spec/app.rb b/spec/app.rb index 79eae53..fe7d617 100644 --- a/spec/app.rb +++ b/spec/app.rb @@ -11,6 +11,10 @@ def bar respond_to(:json) erase_render_results end + + def baz + # no respond_to block in here, but we can still supplu one with response_for + end end class XmlFooController < FooController diff --git a/spec/controllers/inerited_controllers_spec.rb b/spec/controllers/inerited_controllers_spec.rb index 2744ca9..88ce46d 100644 --- a/spec/controllers/inerited_controllers_spec.rb +++ b/spec/controllers/inerited_controllers_spec.rb @@ -5,6 +5,10 @@ class FooAController < FooController response_for :foo do |format| format.html { a } end + + response_for :baz do |format| + format.html { bazza } + end end class FooBController < FooAController @@ -16,12 +20,18 @@ class FooBController < FooAController describe FooAController do before do @controller.stub!(:a) + @controller.stub!(:bazza) end - it "get :foo should call :b" do + it "get :foo should call a" do @controller.should_receive(:a) get :foo end + + it "get :baz should call bazza (inside the response_for block)" do + @controller.should_receive(:bazza) + get :baz + end end describe FooBController do @@ -29,7 +39,7 @@ class FooBController < FooAController @controller.stub!(:b) end - it "get :foo should call :b" do + it "get :foo should call b" do @controller.should_receive(:b) get :foo end