# are not logged in
get new_diary_entry_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/new"
+ assert_redirected_to login_path(:referer => "/diary/new")
end
def test_new_form
# not logged in, without and with the id of the entry you want to edit
get edit_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit"
+ assert_redirected_to login_path(:referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit")
session_for(other_user)
get edit_diary_entry_path(:display_name => entry.user.display_name, :id => 9999)
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => "No entry with the id: 9999", :count => 1
+ assert_select "h1", :text => "No entry with the id: 9999", :count => 1
end
# Now pass the id, and check that you can edit it, when using the same
get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
assert_response :success
assert_template "show"
- assert_select "title", :text => /Users' diaries | /, :count => 1
+ assert_select "title", :text => /Users' Diaries | /, :count => 1
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
+ assert_select "h1", :text => /#{entry.user.display_name}'s Diary/, :count => 1
end
assert_select "div#content", :count => 1 do
- assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
+ assert_select "h2", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
assert_response :success
assert_template "show"
- assert_select "title", :text => /Users' diaries | /, :count => 1
+ assert_select "title", :text => /Users' Diaries | /, :count => 1
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => /#{entry.user.display_name}'s diary/, :count => 1
+ assert_select "h1", :text => /#{entry.user.display_name}'s Diary/, :count => 1
end
assert_select "div#content", :count => 1 do
- assert_select "div.post_heading", :text => /#{new_title}/, :count => 1
+ assert_select "h2", :text => /#{new_title}/, :count => 1
# This next line won't work if the text has been run through the htmlize function
# due to formatting that could be introduced
assert_select "p", :text => /#{new_body}/, :count => 1
post comment_diary_entry_path(:display_name => entry.user.display_name, :id => 9999)
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
- assert_select "h2", :text => "No entry with the id: 9999", :count => 1
+ assert_select "h1", :text => "No entry with the id: 9999", :count => 1
end
# Now try an invalid comment with an empty body
# Try a list of diary entries for your friends when not logged in
get friends_diary_entries_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/friends"
+ assert_redirected_to login_path(:referer => "/diary/friends")
# Try a list of diary entries for your friends when logged in
session_for(user)
# Try a list of diary entries for nearby users when not logged in
get nearby_diary_entries_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/nearby"
+ assert_redirected_to login_path(:referer => "/diary/nearby")
# Try a list of diary entries for nearby users when logged in
session_for(nearby_user)
get diary_comments_path(:display_name => user.display_name)
assert_response :success
assert_template :comments
- assert_select "table.table-striped" do
- assert_select "tr", :count => 1 # header, no comments
- end
+ assert_select "h4", :html => "No diary comments"
# Test a user with a comment
create(:diary_comment, :user => other_user)