Skip to content

Commit

Permalink
Don't load parent object for non-m_r actions.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.hamptoncatlin.com/make_resourceful/trunk@166 c18eca5a-f828-0410-9317-b2e082e89db6
  • Loading branch information
nex3 committed Nov 16, 2007
1 parent e51f653 commit 2a46b90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/resourceful/builder.rb
Expand Up @@ -53,7 +53,7 @@ def apply
kontroller.read_inheritable_attribute(:resourceful_responses).merge! @responses

kontroller.write_inheritable_attribute(:parents, @parents)
kontroller.before_filter { |c| c.send(:load_parent_object) }
kontroller.before_filter :load_parent_object, :only => @ok_actions
end

# :call-seq:
Expand Down
11 changes: 7 additions & 4 deletions spec/builder_spec.rb
Expand Up @@ -34,10 +34,8 @@
parents.should be_empty
end

it "should set load_parent_object as a before_filter" do
yielded = stub
@kontroller.expects(:before_filter).yields(yielded)
yielded.expects(:send).with(:load_parent_object)
it "should set load_parent_object as a before_filter for no actions" do
@kontroller.expects(:before_filter).with(:load_parent_object, :only => [])
@builder.apply
end
end
Expand All @@ -63,6 +61,11 @@
@builder.apply
(@kontroller.hidden_actions & @actions).should be_empty
end

it "should set load_parent_object as a before_filter for the given actions" do
@kontroller.expects(:before_filter).with(:load_parent_object, :only => [:show, :index, :new, :create])
@builder.apply
end
end

describe Resourceful::Builder, " with all actions set for a plural controller" do
Expand Down

0 comments on commit 2a46b90

Please sign in to comment.