Created
June 1, 2010 06:07
-
-
Save rcreasey/420626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module PeopleHelper | |
| def subnavigation | |
| items = [] | |
| items << link_to('Person List', people_path, :class => 'list') unless params[:action].eql?('index') | |
| items << link_to('Register Person', new_user_registration_path, :class => 'new') unless params[:action].eql?('new') or params[:action].eql?('show') | |
| items << link_to('Edit Person', edit_person_path, :class => 'edit') if params[:action].eql?('show') | |
| items << link_to('Delete Person', person_path, :confirm => 'Are you sure?', :method => :delete, :class => 'delete') if params[:action].eql?('show') | |
| items = content_tag(:ul, items.collect{|n| content_tag(:li, n)}) | |
| content_tag(:div, items, :id => 'subnavigation') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe PeopleHelper do | |
| it "subnavigation should contain links to edit and delete on a show action" do | |
| assigns[:params] = {:action => 'show', :id => 1} | |
| subnavigation = helper.subnavigation | |
| subnavigation.should have_tag('ul') do | |
| with_tag('li', :text => /Edit Person/) { with_tag('a', :href => edit_person_path(:id => 1)) } | |
| with_tag('li', :text => /Delete Person/) { with_tag('a', :href => person_path(:id => 1, :method => :delete)) } | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| edit_person_url failed to generate from {:action=>"edit", :controller=>"people"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["people", :id, "edit"] - are they all satisfied? | |
| (eval):16:in `edit_person_path' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment