)
assert_routing(
- { :path => "/user/username/set_status", :method => :get },
+ { :path => "/user/username/set_status", :method => :post },
{ :controller => "users", :action => "set_status", :display_name => "username" }
)
assert_routing(
- { :path => "/user/username/delete", :method => :get },
- { :controller => "users", :action => "delete", :display_name => "username" }
+ { :path => "/user/username", :method => :delete },
+ { :controller => "users", :action => "destroy", :display_name => "username" }
)
assert_routing(
get logout_path
assert_response :success
assert_template :logout
- assert_select "input[name=referer][value=?]", ""
+ assert_select "input[name=referer]:not([value])"
end
def test_logout_fallback_with_referer
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
- post user_forgot_password_path, :params => { :user => { :email => user.email } }
+ post user_forgot_password_path, :params => { :email => user.email }
end
end
assert_response :redirect
# that has the same address in a different case
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
- post user_forgot_password_path, :params => { :user => { :email => user.email.upcase } }
+ post user_forgot_password_path, :params => { :email => user.email.upcase }
end
end
assert_response :redirect
# for more than one user but not an exact match for either
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
- post user_forgot_password_path, :params => { :user => { :email => user.email.titlecase } }
+ post user_forgot_password_path, :params => { :email => user.email.titlecase }
end
end
assert_response :success
third_user = create(:user)
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
- post user_forgot_password_path, :params => { :user => { :email => third_user.email } }
+ post user_forgot_password_path, :params => { :email => third_user.email }
end
end
assert_response :redirect
# same (case insensitively unique) address in a different case
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
- post user_forgot_password_path, :params => { :user => { :email => third_user.email.upcase } }
+ post user_forgot_password_path, :params => { :email => third_user.email.upcase }
end
end
assert_response :redirect
post user_reset_password_path, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "different_password" } }
assert_response :success
assert_template :reset_password
- assert_select "div#errorExplanation"
+ assert_select "div.invalid-feedback"
# Test setting a new password
post user_reset_password_path, :params => { :token => token.token, :user => { :pass_crypt => "new_password", :pass_crypt_confirmation => "new_password" } }
user = create(:user)
# Try without logging in
- get set_status_user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
- assert_redirected_to :action => :login, :referer => set_status_user_path(:status => "suspended")
+ post set_status_user_path(user), :params => { :status => "suspended" }
+ assert_response :forbidden
# Now try as a normal user
session_for(user)
- get set_status_user_path(user), :params => { :status => "suspended" }
+ post set_status_user_path(user), :params => { :status => "suspended" }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
# Finally try as an administrator
session_for(create(:administrator_user))
- get set_status_user_path(user), :params => { :status => "suspended" }
+ post set_status_user_path(user), :params => { :status => "suspended" }
assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name
assert_equal "suspended", User.find(user.id).status
end
- def test_delete
+ def test_destroy
user = create(:user, :home_lat => 12.1, :home_lon => 12.1, :description => "test")
# Try without logging in
- get delete_user_path(user), :params => { :status => "suspended" }
- assert_response :redirect
- assert_redirected_to :action => :login, :referer => delete_user_path(:status => "suspended")
+ delete user_path(user), :params => { :status => "suspended" }
+ assert_response :forbidden
# Now try as a normal user
session_for(user)
- get delete_user_path(user), :params => { :status => "suspended" }
+ delete user_path(user), :params => { :status => "suspended" }
assert_response :redirect
assert_redirected_to :controller => :errors, :action => :forbidden
# Finally try as an administrator
session_for(create(:administrator_user))
- get delete_user_path(user), :params => { :status => "suspended" }
+ delete user_path(user), :params => { :status => "suspended" }
assert_response :redirect
assert_redirected_to :action => :show, :display_name => user.display_name