# Make sure that you are redirected to the login page when you
# are not logged in
get new_diary_entry_path
- assert_response :redirect
assert_redirected_to login_path(:referer => "/diary/new")
end
:diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1",
:longitude => "2.2", :language_code => "en" })
end
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
:diary_entry => { :title => "New Title", :body => "This is a new body for the diary entry", :latitude => "1.1",
:longitude => "2.2", :language_code => "de" })
end
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
post diary_entries_path(:commit => "save",
:diary_entry => { :title => spammy_title, :body => spammy_body, :language_code => "en" })
end
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
entry = DiaryEntry.order(:id).last
assert_equal user.id, entry.user_id
# Follow the redirect
get diary_entries_path(:display_name => user.display_name)
- assert_response :redirect
assert_redirected_to :controller => :users, :action => :suspended
end
# Make sure that you are redirected to the login page when you are
# 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 login_path(:referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit")
session_for(other_user)
# Verify that you get redirected to show if you are not the user
# that created the entry
get edit_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
session_for(entry.user)
put diary_entry_path(:display_name => entry.user.display_name, :id => entry, :commit => "save",
:diary_entry => { :title => new_title, :body => new_body, :latitude => new_latitude,
:longitude => new_longitude, :language_code => new_language_code })
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
# Now check that the new data is rendered, when logged in
end
end
end
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
email = ActionMailer::Base.deliveries.first
assert_equal [user.email], email.to
end
end
end
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
email = ActionMailer::Base.deliveries.first
assert_equal [user.email], email.to
# Follow the redirect
get diary_entries_path(:display_name => user.display_name)
- assert_response :redirect
assert_redirected_to :controller => :users, :action => :suspended
# Now show the diary entry, and check the new comment is not present
# Try a list of diary entries for your friends when not logged in
get friends_diary_entries_path
- assert_response :redirect
assert_redirected_to login_path(:referer => "/diary/friends")
# Try a list of diary entries for your friends when logged in
# Try a list of diary entries for nearby users when not logged in
get nearby_diary_entries_path
- assert_response :redirect
assert_redirected_to login_path(:referer => "/diary/nearby")
# Try a list of diary entries for nearby users when logged in
# Now try as a normal user
session_for(user)
post hide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert DiaryEntry.find(diary_entry.id).visible
# Now try as a moderator
session_for(create(:moderator_user))
post hide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
assert_not DiaryEntry.find(diary_entry.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
post hide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
assert_not DiaryEntry.find(diary_entry.id).visible
end
# Now try as a normal user
session_for(user)
post unhide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_not DiaryEntry.find(diary_entry.id).visible
# Now try as a moderator
session_for(create(:moderator_user))
post unhide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
assert DiaryEntry.find(diary_entry.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
post unhide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
- assert_response :redirect
assert_redirected_to :action => :index, :display_name => user.display_name
assert DiaryEntry.find(diary_entry.id).visible
end
# Now try as a normal user
session_for(user)
post hide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert DiaryComment.find(diary_comment.id).visible
# Try as a moderator
session_for(create(:moderator_user))
post hide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert_not DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
post hide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert_not DiaryComment.find(diary_comment.id).visible
end
# Now try as a normal user
session_for(user)
post unhide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
assert_not DiaryComment.find(diary_comment.id).visible
# Now try as a moderator
session_for(create(:moderator_user))
post unhide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
session_for(create(:administrator_user))
post unhide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
- assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert DiaryComment.find(diary_comment.id).visible
end
path = diary_entry_subscribe_path(:id => diary_entry, :display_name => user.display_name)
get path
- assert_response :redirect
assert_redirected_to login_path(:referer => path)
session_for(other_user)
path = diary_entry_unsubscribe_path(:id => diary_entry, :display_name => user.display_name)
get path
- assert_response :redirect
assert_redirected_to login_path(:referer => path)
session_for(other_user)