Skip to content

Commit

Permalink
Added some specs to bring C2 up to 100%, caught a bug introduced by c…
Browse files Browse the repository at this point in the history
…hanges in edge
  • Loading branch information
ianwhite committed Apr 30, 2008
1 parent 8ab63ae commit 1b82c39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ardes/response_for.rb
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/app.rb
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions spec/controllers/inerited_controllers_spec.rb
Expand Up @@ -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
Expand All @@ -16,20 +20,26 @@ 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
before do
@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
Expand Down

0 comments on commit 1b82c39

Please sign in to comment.