# 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)
+ get edit_diary_entry_path(entry.user, entry)
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)
+ get edit_diary_entry_path(entry.user, entry)
assert_redirected_to :action => :show, :display_name => entry.user.display_name, :id => entry.id
session_for(entry.user)
# Verify that you get a not found error, when you pass a bogus id
- get edit_diary_entry_path(:display_name => entry.user.display_name, :id => 9999)
+ get edit_diary_entry_path(entry.user, :id => 9999)
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
assert_select "h1", :text => "No entry with the id: 9999", :count => 1
# Now pass the id, and check that you can edit it, when using the same
# user as the person who created the entry
- get edit_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ get edit_diary_entry_path(entry.user, entry)
assert_response :success
assert_select "title", :text => /Edit Diary Entry/, :count => 1
assert_select "div.content-heading", :count => 1 do
new_latitude = "1.1"
new_longitude = "2.2"
new_language_code = "en"
- 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 })
+ put diary_entry_path(entry.user, entry, :commit => "save",
+ :diary_entry => { :title => new_title, :body => new_body, :latitude => new_latitude,
+ :longitude => new_longitude, :language_code => new_language_code })
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
- get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ get diary_entry_path(entry.user, entry)
assert_response :success
assert_template "show"
assert_select "title", :text => /Users' Diaries | /, :count => 1
# and when not logged in as the user who wrote the entry
session_for(create(:user))
- get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ get diary_entry_path(entry.user, entry)
assert_response :success
assert_template "show"
assert_select "title", :text => /Users' Diaries | /, :count => 1
user = create(:user)
diary_entry = create(:diary_entry, :language_code => "en", :user => user)
session_for(user)
- get edit_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ get edit_diary_entry_path(user, diary_entry)
assert_response :success
assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry"
end
create(:diary_entry_subscription, :diary_entry => entry, :user => user)
# Make sure that you are denied when you are not logged in
- post comment_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ post comment_diary_entry_path(entry.user, entry)
assert_response :forbidden
session_for(other_user)
# Verify that you get a not found error, when you pass a bogus id
- post comment_diary_entry_path(:display_name => entry.user.display_name, :id => 9999)
+ post comment_diary_entry_path(entry.user, :id => 9999)
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
assert_select "h1", :text => "No entry with the id: 9999", :count => 1
assert_no_difference "DiaryComment.count" do
assert_no_difference "entry.subscribers.count" do
perform_enqueued_jobs do
- post comment_diary_entry_path(:display_name => entry.user.display_name, :id => entry, :diary_comment => { :body => "" })
+ post comment_diary_entry_path(entry.user, entry, :diary_comment => { :body => "" })
end
end
end
assert_difference "DiaryComment.count", 1 do
assert_difference "entry.subscribers.count", 1 do
perform_enqueued_jobs do
- post comment_diary_entry_path(:display_name => entry.user.display_name, :id => entry, :diary_comment => { :body => "New comment" })
+ post comment_diary_entry_path(entry.user, entry, :diary_comment => { :body => "New comment" })
end
end
end
assert_equal "New comment", comment.body
# Now show the diary entry, and check the new comment is present
- get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ get diary_entry_path(entry.user, entry)
assert_response :success
assert_select ".diary-comment", :count => 1 do
assert_select "#comment#{comment.id}", :count => 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "DiaryComment.count", 1 do
perform_enqueued_jobs do
- post comment_diary_entry_path(:display_name => entry.user.display_name, :id => entry, :diary_comment => { :body => spammy_text })
+ post comment_diary_entry_path(entry.user, entry, :diary_comment => { :body => spammy_text })
end
end
end
assert_redirected_to :controller => :users, :action => :suspended
# Now show the diary entry, and check the new comment is not present
- get diary_entry_path(:display_name => entry.user.display_name, :id => entry)
+ get diary_entry_path(entry.user, entry)
assert_response :success
assert_select ".diary-comment", :count => 0
end
# Try a normal entry that should work
diary_entry = create(:diary_entry, :user => user)
- get diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ get diary_entry_path(user, diary_entry)
assert_response :success
assert_template :show
# Try a deleted entry
diary_entry_deleted = create(:diary_entry, :user => user, :visible => false)
- get diary_entry_path(:display_name => user.display_name, :id => diary_entry_deleted)
+ get diary_entry_path(user, diary_entry_deleted)
assert_response :not_found
# Try an entry by a suspended user
diary_entry_suspended_user = create(:diary_entry, :user => suspended_user)
- get diary_entry_path(:display_name => suspended_user.display_name, :id => diary_entry_suspended_user)
+ get diary_entry_path(suspended_user, diary_entry_suspended_user)
assert_response :not_found
# Try an entry by a deleted user
diary_entry_deleted_user = create(:diary_entry, :user => deleted_user)
- get diary_entry_path(:display_name => deleted_user.display_name, :id => diary_entry_deleted_user)
+ get diary_entry_path(deleted_user, diary_entry_deleted_user)
assert_response :not_found
# Now try as a moderator
session_for(create(:moderator_user))
- get diary_entry_path(:display_name => user.display_name, :id => diary_entry_deleted)
+ get diary_entry_path(user, diary_entry_deleted)
assert_response :success
assert_template :show
# Finally try as an administrator
session_for(create(:administrator_user))
- get diary_entry_path(:display_name => user.display_name, :id => diary_entry_deleted)
+ get diary_entry_path(user, diary_entry_deleted)
assert_response :success
assert_template :show
end
deleted_user_comment = create(:diary_comment, :diary_entry => diary_entry, :user => create(:user, :deleted))
hidden_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false)
- get diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ get diary_entry_path(user, diary_entry)
assert_response :success
assert_template :show
assert_select "div.comments" do
diary_entry = create(:diary_entry, :user => user)
# Try without logging in
- post hide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ post hide_diary_entry_path(user, diary_entry)
assert_response :forbidden
assert DiaryEntry.find(diary_entry.id).visible
# Now try as a normal user
session_for(user)
- post hide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ post hide_diary_entry_path(user, diary_entry)
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)
+ post hide_diary_entry_path(user, diary_entry)
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)
+ post hide_diary_entry_path(user, diary_entry)
assert_redirected_to :action => :index, :display_name => user.display_name
assert_not DiaryEntry.find(diary_entry.id).visible
end
# Try without logging in
diary_entry = create(:diary_entry, :user => user, :visible => false)
- post unhide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ post unhide_diary_entry_path(user, diary_entry)
assert_response :forbidden
assert_not DiaryEntry.find(diary_entry.id).visible
# Now try as a normal user
session_for(user)
- post unhide_diary_entry_path(:display_name => user.display_name, :id => diary_entry)
+ post unhide_diary_entry_path(user, diary_entry)
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)
+ post unhide_diary_entry_path(user, diary_entry)
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)
+ post unhide_diary_entry_path(user, diary_entry)
assert_redirected_to :action => :index, :display_name => user.display_name
assert DiaryEntry.find(diary_entry.id).visible
end
diary_comment = create(:diary_comment, :diary_entry => diary_entry)
# Try without logging in
- post hide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
+ post hide_diary_comment_path(user, diary_entry, diary_comment)
assert_response :forbidden
assert DiaryComment.find(diary_comment.id).visible
# 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)
+ post hide_diary_comment_path(user, diary_entry, diary_comment)
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)
+ post hide_diary_comment_path(user, diary_entry, diary_comment)
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)
+ post hide_diary_comment_path(user, diary_entry, diary_comment)
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert_not DiaryComment.find(diary_comment.id).visible
end
diary_comment = create(:diary_comment, :diary_entry => diary_entry, :visible => false)
# Try without logging in
- post unhide_diary_comment_path(:display_name => user.display_name, :id => diary_entry, :comment => diary_comment)
+ post unhide_diary_comment_path(user, diary_entry, diary_comment)
assert_response :forbidden
assert_not DiaryComment.find(diary_comment.id).visible
# 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)
+ post unhide_diary_comment_path(user, diary_entry, diary_comment)
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)
+ post unhide_diary_comment_path(user, diary_entry, diary_comment)
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)
+ post unhide_diary_comment_path(user, diary_entry, diary_comment)
assert_redirected_to :action => :show, :display_name => user.display_name, :id => diary_entry.id
assert DiaryComment.find(diary_comment.id).visible
end
user = create(:user)
other_user = create(:user)
diary_entry = create(:diary_entry, :user => user)
- path = diary_entry_subscribe_path(:id => diary_entry, :display_name => user.display_name)
+ path = diary_entry_subscribe_path(user, diary_entry)
get path
assert_redirected_to login_path(:referer => path)
get path
assert_response :success
assert_dom ".content-body" do
- assert_dom "a[href='#{diary_entry_path(:id => diary_entry, :display_name => user.display_name)}']", :text => diary_entry.title
+ assert_dom "a[href='#{diary_entry_path(user, diary_entry)}']", :text => diary_entry.title
assert_dom "a[href='#{user_path(user)}']", :text => user.display_name
end
end
session_for(other_user)
assert_difference "diary_entry.subscribers.count", 1 do
- post diary_entry_subscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_subscribe_path(user, diary_entry)
end
assert_response :redirect
end
# not signed in
assert_no_difference "diary_entry.subscribers.count" do
- post diary_entry_subscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_subscribe_path(user, diary_entry)
end
assert_response :forbidden
session_for(other_user)
# bad diary id
- post diary_entry_subscribe_path(:id => 999111, :display_name => "username")
+ post diary_entry_subscribe_path("username", 999111)
assert_response :not_found
# trying to subscribe when already subscribed
- post diary_entry_subscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_subscribe_path(user, diary_entry)
assert_no_difference "diary_entry.subscribers.count" do
- post diary_entry_subscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_subscribe_path(user, diary_entry)
end
end
user = create(:user)
other_user = create(:user)
diary_entry = create(:diary_entry, :user => user)
- path = diary_entry_unsubscribe_path(:id => diary_entry, :display_name => user.display_name)
+ path = diary_entry_unsubscribe_path(user, diary_entry)
get path
assert_redirected_to login_path(:referer => path)
get path
assert_response :success
assert_dom ".content-body" do
- assert_dom "a[href='#{diary_entry_path(:id => diary_entry, :display_name => user.display_name)}']", :text => diary_entry.title
+ assert_dom "a[href='#{diary_entry_path(user, diary_entry)}']", :text => diary_entry.title
assert_dom "a[href='#{user_path(user)}']", :text => user.display_name
end
end
session_for(other_user)
assert_difference "diary_entry.subscribers.count", -1 do
- post diary_entry_unsubscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_unsubscribe_path(user, diary_entry)
end
assert_response :redirect
end
# not signed in
assert_no_difference "diary_entry.subscribers.count" do
- post diary_entry_unsubscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_unsubscribe_path(user, diary_entry)
end
assert_response :forbidden
session_for(other_user)
# bad diary id
- post diary_entry_unsubscribe_path(:id => 999111, :display_name => "username")
+ post diary_entry_unsubscribe_path("username", 999111)
assert_response :not_found
# trying to unsubscribe when not subscribed
assert_no_difference "diary_entry.subscribers.count" do
- post diary_entry_unsubscribe_path(:id => diary_entry, :display_name => diary_entry.user.display_name)
+ post diary_entry_unsubscribe_path(user, diary_entry)
end
end
# When not logged in a GET should ask us to login
get make_friend_path(friend)
- assert_redirected_to login_path(:referer => make_friend_path(:display_name => friend.display_name))
+ assert_redirected_to login_path(:referer => make_friend_path(friend))
# When not logged in a POST should error
post make_friend_path(friend)
def test_make_friend_unknown_user
# Should error when a bogus user is specified
session_for(create(:user))
- get make_friend_path(:display_name => "No Such User")
+ get make_friend_path("No Such User")
assert_response :not_found
assert_template :no_such_user
end
# When not logged in a GET should ask us to login
get remove_friend_path(friend)
- assert_redirected_to login_path(:referer => remove_friend_path(:display_name => friend.display_name))
+ assert_redirected_to login_path(:referer => remove_friend_path(friend))
# When not logged in a POST should error
post remove_friend_path, :params => { :display_name => friend.display_name }
def test_remove_friend_unknown_user
# Should error when a bogus user is specified
session_for(create(:user))
- get remove_friend_path(:display_name => "No Such User")
+ get remove_friend_path("No Such User")
assert_response :not_found
assert_template :no_such_user
end
def test_new_no_login
# Check that the new message page requires us to login
user = create(:user)
- get new_message_path(:display_name => user.display_name)
- assert_redirected_to login_path(:referer => new_message_path(:display_name => user.display_name))
+ get new_message_path(user)
+ assert_redirected_to login_path(:referer => new_message_path(user))
end
##
session_for(user)
# Check that the new message page loads
- get new_message_path(:display_name => recipient_user.display_name)
+ get new_message_path(recipient_user)
assert_response :success
assert_template "new"
assert_select "title", "Send message | OpenStreetMap"
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
perform_enqueued_jobs do
- get new_message_path(:display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" })
+ get new_message_path(recipient_user, :message => { :title => "Test Message", :body => "Test message body" })
end
end
end
assert_equal "markdown", m.body_format
# Asking to send a message with a bogus user name should fail
- get new_message_path(:display_name => "non_existent_user")
+ get new_message_path("non_existent_user")
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
create(:note_comment, :note => note, :author => second_user)
end
- get user_notes_path(:display_name => first_user.display_name)
+ get user_notes_path(first_user)
assert_response :success
assert_select "table.note_list tbody tr", :count => 1
- get user_notes_path(:display_name => second_user.display_name)
+ get user_notes_path(second_user)
assert_response :success
assert_select "table.note_list tbody tr", :count => 1
- get user_notes_path(:display_name => "non-existent")
+ get user_notes_path("non-existent")
assert_response :not_found
session_for(moderator_user)
- get user_notes_path(:display_name => first_user.display_name)
+ get user_notes_path(first_user)
assert_response :success
assert_select "table.note_list tbody tr", :count => 1
- get user_notes_path(:display_name => second_user.display_name)
+ get user_notes_path(second_user)
assert_response :success
assert_select "table.note_list tbody tr", :count => 2
- get user_notes_path(:display_name => "non-existent")
+ get user_notes_path("non-existent")
assert_response :not_found
end
create(:note_comment, :note => note, :author => user)
end
- get user_notes_path(:display_name => user.display_name)
+ get user_notes_path(user)
assert_response :success
assert_select "table.note_list tbody tr", :count => 10
- get user_notes_path(:display_name => user.display_name, :page => 2)
+ get user_notes_path(user, :page => 2)
assert_response :success
assert_select "table.note_list tbody tr", :count => 10
end
def test_empty_page
user = create(:user)
- get user_notes_path(:display_name => user.display_name)
+ get user_notes_path(user)
assert_response :success
assert_select "h4", :html => "No notes"
end
create_list(:client_application, 2, :user => user)
create_list(:access_token, 2, :user => user)
- get oauth_clients_path(:display_name => user.display_name)
- assert_redirected_to login_path(:referer => oauth_clients_path(:display_name => user.display_name))
+ get oauth_clients_path(user)
+ assert_redirected_to login_path(:referer => oauth_clients_path(user))
session_for(user)
- get oauth_clients_path(:display_name => user.display_name)
+ get oauth_clients_path(user)
assert_response :success
assert_template "index"
assert_select "li.client_application", 2
def test_new
user = create(:user)
- get new_oauth_client_path(:display_name => user.display_name)
- assert_redirected_to login_path(:referer => new_oauth_client_path(:display_name => user.display_name))
+ get new_oauth_client_path(user)
+ assert_redirected_to login_path(:referer => new_oauth_client_path(user))
session_for(user)
- get new_oauth_client_path(:display_name => user.display_name)
+ get new_oauth_client_path(user)
assert_response :success
assert_template "new"
assert_select "form", 1 do
user = create(:user)
with_settings(:oauth_10_registration => false) do
- get new_oauth_client_path(:display_name => user.display_name)
- assert_redirected_to login_path(:referer => new_oauth_client_path(:display_name => user.display_name))
+ get new_oauth_client_path(user)
+ assert_redirected_to login_path(:referer => new_oauth_client_path(user))
session_for(user)
- get new_oauth_client_path(:display_name => user.display_name)
- assert_redirected_to oauth_clients_path(:display_name => user.display_name)
+ get new_oauth_client_path(user)
+ assert_redirected_to oauth_clients_path(user)
end
end
user = create(:user)
assert_difference "ClientApplication.count", 0 do
- post oauth_clients_path(:display_name => user.display_name)
+ post oauth_clients_path(user)
end
assert_response :forbidden
session_for(user)
assert_difference "ClientApplication.count", 0 do
- post oauth_clients_path(:display_name => user.display_name,
- :client_application => { :name => "Test Application" })
+ post oauth_clients_path(user, :client_application => { :name => "Test Application" })
end
assert_response :success
assert_template "new"
assert_difference "ClientApplication.count", 1 do
- post oauth_clients_path(:display_name => user.display_name,
- :client_application => { :name => "Test Application",
- :url => "http://test.example.com/" })
+ post oauth_clients_path(user, :client_application => { :name => "Test Application",
+ :url => "http://test.example.com/" })
end
assert_redirected_to oauth_client_path(:id => ClientApplication.find_by(:name => "Test Application").id)
end
client = create(:client_application, :user => user)
other_client = create(:client_application)
- get oauth_client_path(:display_name => user.display_name, :id => client)
- assert_redirected_to login_path(:referer => oauth_client_path(:display_name => user.display_name, :id => client.id))
+ get oauth_client_path(user, client)
+ assert_redirected_to login_path(:referer => oauth_client_path(user, client.id))
session_for(user)
- get oauth_client_path(:display_name => user.display_name, :id => other_client)
+ get oauth_client_path(user, other_client)
assert_response :not_found
assert_template "not_found"
- get oauth_client_path(:display_name => user.display_name, :id => client)
+ get oauth_client_path(user, client)
assert_response :success
assert_template "show"
end
client = create(:client_application, :user => user)
other_client = create(:client_application)
- get edit_oauth_client_path(:display_name => user.display_name, :id => client)
- assert_redirected_to login_path(:referer => edit_oauth_client_path(:display_name => user.display_name, :id => client.id))
+ get edit_oauth_client_path(user, client)
+ assert_redirected_to login_path(:referer => edit_oauth_client_path(user, client.id))
session_for(user)
- get edit_oauth_client_path(:display_name => user.display_name, :id => other_client)
+ get edit_oauth_client_path(user, other_client)
assert_response :not_found
assert_template "not_found"
- get edit_oauth_client_path(:display_name => user.display_name, :id => client)
+ get edit_oauth_client_path(user, client)
assert_response :success
assert_template "edit"
assert_select "form", 1 do
client = create(:client_application, :user => user)
other_client = create(:client_application)
- put oauth_client_path(:display_name => user.display_name, :id => client)
+ put oauth_client_path(user, client)
assert_response :forbidden
session_for(user)
- put oauth_client_path(:display_name => user.display_name, :id => other_client)
+ put oauth_client_path(user, other_client)
assert_response :not_found
assert_template "not_found"
- put oauth_client_path(:display_name => user.display_name, :id => client,
- :client_application => { :name => "New Name", :url => nil })
+ put oauth_client_path(user, client, :client_application => { :name => "New Name", :url => nil })
assert_response :success
assert_template "edit"
- put oauth_client_path(:display_name => user.display_name, :id => client,
- :client_application => { :name => "New Name", :url => "http://new.example.com/url" })
+ put oauth_client_path(user, client, :client_application => { :name => "New Name", :url => "http://new.example.com/url" })
assert_redirected_to oauth_client_path(:id => client.id)
end
other_client = create(:client_application)
assert_difference "ClientApplication.count", 0 do
- delete oauth_client_path(:display_name => user.display_name, :id => client)
+ delete oauth_client_path(user, client)
end
assert_response :forbidden
session_for(user)
assert_difference "ClientApplication.count", 0 do
- delete oauth_client_path(:display_name => user.display_name, :id => other_client)
+ delete oauth_client_path(user, other_client)
end
assert_response :not_found
assert_template "not_found"
assert_difference "ClientApplication.count", -1 do
- delete oauth_client_path(:display_name => user.display_name, :id => client)
+ delete oauth_client_path(user, client)
end
- assert_redirected_to oauth_clients_path(:display_name => user.display_name)
+ assert_redirected_to oauth_clients_path(user)
end
end
public_trace_file = create(:trace, :visibility => "public")
# First with no auth, which should work since the trace is public
- get show_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get show_trace_path(public_trace_file.user, public_trace_file)
check_trace_show public_trace_file
# Now with some other user, which should work since the trace is public
session_for(create(:user))
- get show_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get show_trace_path(public_trace_file.user, public_trace_file)
check_trace_show public_trace_file
# And finally we should be able to do it with the owner of the trace
session_for(public_trace_file.user)
- get show_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get show_trace_path(public_trace_file.user, public_trace_file)
check_trace_show public_trace_file
end
anon_trace_file = create(:trace, :visibility => "private")
# First with no auth
- get show_trace_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get show_trace_path(anon_trace_file.user, anon_trace_file)
assert_redirected_to :action => :index
# Now with some other user, which should not work since the trace is anon
session_for(create(:user))
- get show_trace_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get show_trace_path(anon_trace_file.user, anon_trace_file)
assert_redirected_to :action => :index
# And finally we should be able to do it with the owner of the trace
session_for(anon_trace_file.user)
- get show_trace_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get show_trace_path(anon_trace_file.user, anon_trace_file)
check_trace_show anon_trace_file
end
deleted_trace_file = create(:trace, :deleted)
# First with a trace that has never existed
- get show_trace_path(:display_name => create(:user).display_name, :id => 0)
+ get show_trace_path(create(:user), 0)
assert_redirected_to :action => :index
# Now with a trace that has been deleted
session_for(deleted_trace_file.user)
- get show_trace_path(:display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file)
+ get show_trace_path(deleted_trace_file.user, deleted_trace_file)
assert_redirected_to :action => :index
end
public_trace_file = create(:trace, :visibility => "public", :fixture => "a")
# First with no auth, which should work since the trace is public
- get trace_picture_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_picture_path(public_trace_file.user, public_trace_file)
check_trace_picture public_trace_file
# Now with some other user, which should work since the trace is public
session_for(create(:user))
- get trace_picture_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_picture_path(public_trace_file.user, public_trace_file)
check_trace_picture public_trace_file
# And finally we should be able to do it with the owner of the trace
session_for(public_trace_file.user)
- get trace_picture_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_picture_path(public_trace_file.user, public_trace_file)
check_trace_picture public_trace_file
end
anon_trace_file = create(:trace, :visibility => "private", :fixture => "b")
# First with no auth
- get trace_picture_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_picture_path(anon_trace_file.user, anon_trace_file)
assert_response :forbidden
# Now with some other user, which shouldn't work since the trace is anon
session_for(create(:user))
- get trace_picture_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_picture_path(anon_trace_file.user, anon_trace_file)
assert_response :forbidden
# And finally we should be able to do it with the owner of the trace
session_for(anon_trace_file.user)
- get trace_picture_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_picture_path(anon_trace_file.user, anon_trace_file)
check_trace_picture anon_trace_file
end
deleted_trace_file = create(:trace, :deleted)
# First with a trace that has never existed
- get trace_picture_path(:display_name => create(:user).display_name, :id => 0)
+ get trace_picture_path(create(:user), 0)
assert_response :not_found
# Now with a trace that has been deleted
session_for(deleted_trace_file.user)
- get trace_picture_path(:display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file)
+ get trace_picture_path(deleted_trace_file.user, deleted_trace_file)
assert_response :not_found
end
public_trace_file = create(:trace, :visibility => "public", :fixture => "a")
# First with no auth, which should work since the trace is public
- get trace_icon_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_icon_path(public_trace_file.user, public_trace_file)
check_trace_icon public_trace_file
# Now with some other user, which should work since the trace is public
session_for(create(:user))
- get trace_icon_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_icon_path(public_trace_file.user, public_trace_file)
check_trace_icon public_trace_file
# And finally we should be able to do it with the owner of the trace
session_for(public_trace_file.user)
- get trace_icon_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
+ get trace_icon_path(public_trace_file.user, public_trace_file)
check_trace_icon public_trace_file
end
anon_trace_file = create(:trace, :visibility => "private", :fixture => "b")
# First with no auth
- get trace_icon_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_icon_path(anon_trace_file.user, anon_trace_file)
assert_response :forbidden
# Now with some other user, which shouldn't work since the trace is anon
session_for(create(:user))
- get trace_icon_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_icon_path(anon_trace_file.user, anon_trace_file)
assert_response :forbidden
# And finally we should be able to do it with the owner of the trace
session_for(anon_trace_file.user)
- get trace_icon_path(:display_name => anon_trace_file.user.display_name, :id => anon_trace_file)
+ get trace_icon_path(anon_trace_file.user, anon_trace_file)
check_trace_icon anon_trace_file
end
deleted_trace_file = create(:trace, :deleted)
# First with a trace that has never existed
- get trace_icon_path(:display_name => create(:user).display_name, :id => 0)
+ get trace_icon_path(create(:user), 0)
assert_response :not_found
# Now with a trace that has been deleted
session_for(deleted_trace_file.user)
- get trace_icon_path(:display_name => deleted_trace_file.user.display_name, :id => deleted_trace_file)
+ get trace_icon_path(deleted_trace_file.user, deleted_trace_file)
assert_response :not_found
end
target_user = create(:user)
# Check that the block creation page requires us to login
- get new_user_block_path(:display_name => target_user.display_name)
- assert_redirected_to login_path(:referer => new_user_block_path(:display_name => target_user.display_name))
+ get new_user_block_path(target_user)
+ assert_redirected_to login_path(:referer => new_user_block_path(target_user))
# Login as a normal user
session_for(create(:user))
# Check that normal users can't load the block creation page
- get new_user_block_path(:display_name => target_user.display_name)
+ get new_user_block_path(target_user)
assert_redirected_to :controller => "errors", :action => "forbidden"
# Login as a moderator
session_for(create(:moderator_user))
# Check that the block creation page loads for moderators
- get new_user_block_path(:display_name => target_user.display_name)
+ get new_user_block_path(target_user)
assert_response :success
assert_select "form#new_user_block", :count => 1 do
assert_select "textarea#user_block_reason", :count => 1
post user_blocks_path(:display_name => target_user.display_name,
:user_block_period => "99")
end
- assert_redirected_to new_user_block_path(:display_name => target_user.display_name)
+ assert_redirected_to new_user_block_path(target_user)
assert_equal "The blocking period must be one of the values selectable in the drop-down list.", flash[:error]
# Check that creating a block works
create(:user_block, :user => blocked_user)
# Asking for the revoke all blocks page with a bogus user name should fail
- get user_blocks_on_path(:display_name => "non_existent_user")
+ get user_blocks_on_path("non_existent_user")
assert_response :not_found
# Check that the revoke all blocks page requires us to login
expired_block = create(:user_block, :expired, :user => unblocked_user)
# Asking for a list of blocks with a bogus user name should fail
- get user_blocks_on_path(:display_name => "non_existent_user")
+ get user_blocks_on_path("non_existent_user")
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks for a user that has never been blocked
- get user_blocks_on_path(:display_name => normal_user.display_name)
+ get user_blocks_on_path(normal_user)
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not been blocked yet."
# Check the list of blocks for a user that is currently blocked
- get user_blocks_on_path(:display_name => blocked_user.display_name)
+ get user_blocks_on_path(blocked_user)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", 3
end
# Check the list of blocks for a user that has previously been blocked
- get user_blocks_on_path(:display_name => unblocked_user.display_name)
+ get user_blocks_on_path(unblocked_user)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", 2
user = create(:user)
create_list(:user_block, 50, :user => user)
- get user_blocks_on_path(:display_name => user.display_name)
+ get user_blocks_on_path(user)
assert_response :success
assert_select "table#block_list tbody", :count => 1 do
assert_select "tr", :count => 20
end
- get user_blocks_on_path(:display_name => user.display_name, :page => 2)
+ get user_blocks_on_path(user, :page => 2)
assert_response :success
assert_select "table#block_list tbody", :count => 1 do
assert_select "tr", :count => 20
revoked_block = create(:user_block, :revoked, :creator => second_moderator_user)
# Asking for a list of blocks with a bogus user name should fail
- get user_blocks_by_path(:display_name => "non_existent_user")
+ get user_blocks_by_path("non_existent_user")
assert_response :not_found
assert_template "users/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
# Check the list of blocks given by one moderator
- get user_blocks_by_path(:display_name => moderator_user.display_name)
+ get user_blocks_by_path(moderator_user)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", 2
end
# Check the list of blocks given by a different moderator
- get user_blocks_by_path(:display_name => second_moderator_user.display_name)
+ get user_blocks_by_path(second_moderator_user)
assert_response :success
assert_select "table#block_list", :count => 1 do
assert_select "tr", 3
end
# Check the list of blocks (not) given by a normal user
- get user_blocks_by_path(:display_name => normal_user.display_name)
+ get user_blocks_by_path(normal_user)
assert_response :success
assert_select "table#block_list", false
assert_select "p", "#{normal_user.display_name} has not made any blocks yet."
user = create(:moderator_user)
create_list(:user_block, 50, :creator => user)
- get user_blocks_by_path(:display_name => user.display_name)
+ get user_blocks_by_path(user)
assert_response :success
assert_select "table#block_list tbody", :count => 1 do
assert_select "tr", :count => 20
end
- get user_blocks_by_path(:display_name => user.display_name, :page => 2)
+ get user_blocks_by_path(user, :page => 2)
assert_response :success
assert_select "table#block_list tbody", :count => 1 do
assert_select "tr", :count => 20
super_user = create(:super_user)
# Granting should fail when not logged in
- post grant_role_path(:display_name => target_user.display_name, :role => "moderator")
+ post grant_role_path(target_user, "moderator")
assert_response :forbidden
# Login as an unprivileged user
session_for(normal_user)
# Granting should still fail
- post grant_role_path(:display_name => target_user.display_name, :role => "moderator")
+ post grant_role_path(target_user, "moderator")
assert_redirected_to :controller => :errors, :action => :forbidden
# Login as an administrator
UserRole::ALL_ROLES.each do |role|
# Granting a role to a non-existent user should fail
assert_difference "UserRole.count", 0 do
- post grant_role_path(:display_name => "non_existent_user", :role => role)
+ post grant_role_path("non_existent_user", role)
end
assert_response :not_found
assert_template "users/no_such_user"
# Granting a role to a user that already has it should fail
assert_no_difference "UserRole.count" do
- post grant_role_path(:display_name => super_user.display_name, :role => role)
+ post grant_role_path(super_user, role)
end
assert_redirected_to user_path(super_user)
assert_equal "The user already has role #{role}.", flash[:error]
# Granting a role to a user that doesn't have it should work...
assert_difference "UserRole.count", 1 do
- post grant_role_path(:display_name => target_user.display_name, :role => role)
+ post grant_role_path(target_user, role)
end
assert_redirected_to user_path(target_user)
# ...but trying a second time should fail
assert_no_difference "UserRole.count" do
- post grant_role_path(:display_name => target_user.display_name, :role => role)
+ post grant_role_path(target_user, role)
end
assert_redirected_to user_path(target_user)
assert_equal "The user already has role #{role}.", flash[:error]
# Granting a non-existent role should fail
assert_difference "UserRole.count", 0 do
- post grant_role_path(:display_name => target_user.display_name, :role => "no_such_role")
+ post grant_role_path(target_user, "no_such_role")
end
assert_redirected_to user_path(target_user)
assert_equal "The string `no_such_role' is not a valid role.", flash[:error]
super_user = create(:super_user)
# Revoking should fail when not logged in
- post revoke_role_path(:display_name => target_user.display_name, :role => "moderator")
+ post revoke_role_path(target_user, "moderator")
assert_response :forbidden
# Login as an unprivileged user
session_for(normal_user)
# Revoking should still fail
- post revoke_role_path(:display_name => target_user.display_name, :role => "moderator")
+ post revoke_role_path(target_user, "moderator")
assert_redirected_to :controller => :errors, :action => :forbidden
# Login as an administrator
UserRole::ALL_ROLES.each do |role|
# Removing a role from a non-existent user should fail
assert_difference "UserRole.count", 0 do
- post revoke_role_path(:display_name => "non_existent_user", :role => role)
+ post revoke_role_path("non_existent_user", role)
end
assert_response :not_found
assert_template "users/no_such_user"
# Removing a role from a user that doesn't have it should fail
assert_no_difference "UserRole.count" do
- post revoke_role_path(:display_name => target_user.display_name, :role => role)
+ post revoke_role_path(target_user, role)
end
assert_redirected_to user_path(target_user)
assert_equal "The user does not have role #{role}.", flash[:error]
# Removing a role from a user that has it should work...
assert_difference "UserRole.count", -1 do
- post revoke_role_path(:display_name => super_user.display_name, :role => role)
+ post revoke_role_path(super_user, role)
end
assert_redirected_to user_path(super_user)
# ...but trying a second time should fail
assert_no_difference "UserRole.count" do
- post revoke_role_path(:display_name => super_user.display_name, :role => role)
+ post revoke_role_path(super_user, role)
end
assert_redirected_to user_path(super_user)
assert_equal "The user does not have role #{role}.", flash[:error]
# Revoking a non-existent role should fail
assert_difference "UserRole.count", 0 do
- post revoke_role_path(:display_name => target_user.display_name, :role => "no_such_role")
+ post revoke_role_path(target_user, "no_such_role")
end
assert_redirected_to user_path(target_user)
assert_equal "The string `no_such_role' is not a valid role.", flash[:error]
# Revoking administrator role from current user should fail
- post revoke_role_path(:display_name => administrator_user.display_name, :role => "administrator")
+ post revoke_role_path(administrator_user, "administrator")
assert_redirected_to user_path(administrator_user)
assert_equal "Cannot revoke administrator role from current user.", flash[:error]
end
# information for the user
def test_show
# Test a non-existent user
- get user_path(:display_name => "unknown")
+ get user_path("unknown")
assert_response :not_found
# Test a normal user