Skip to content

Commit

Permalink
Merge pull request #24 from projecthydra/resource_instance_name
Browse files Browse the repository at this point in the history
Adapt the resource name to the name of the controller
  • Loading branch information
dchandekstark committed Jan 2, 2014
2 parents 2f7acbc + eae9890 commit 1b08b67
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/concerns/records_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def cancan_resource_class
HydraEditor::ControllerResource
end
def resource_instance_name
'record'
name.sub("Controller", "").underscore.split('/').last.singularize
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/records_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def set_attributes
@record.creator = "Fleece Vest"
end
end
# since this is using an an anonymous class, we have to stub
before {controller.stub(:resource_instance_name).and_return('record')}
it "should run set_attributes" do
post :create, :type=>'Audio', :audio=>{:title=>"My title"}
response.should redirect_to("/catalog/#{assigns[:record].id}")
Expand Down

0 comments on commit 1b08b67

Please sign in to comment.