4 class StatusesControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/user/username/status", :method => :put },
10 { :controller => "users/statuses", :action => "update", :user_display_name => "username" }
17 # Try without logging in
18 put user_status_path(user, :event => "confirm")
19 assert_response :forbidden
21 # Now try as a normal user
23 put user_status_path(user, :event => "confirm")
24 assert_redirected_to :controller => "/errors", :action => :forbidden
26 # Finally try as an administrator
27 session_for(create(:administrator_user))
28 put user_status_path(user, :event => "confirm")
29 assert_redirected_to user_path(user)
30 assert_equal "confirmed", User.find(user.id).status
34 user = create(:user, :home_lat => 12.1, :home_lon => 12.1, :description => "test")
36 # Try without logging in
37 put user_status_path(user, :event => "soft_destroy")
38 assert_response :forbidden
40 # Now try as a normal user
42 put user_status_path(user, :event => "soft_destroy")
43 assert_redirected_to :controller => "/errors", :action => :forbidden
45 # Finally try as an administrator
46 session_for(create(:administrator_user))
47 put user_status_path(user, :event => "soft_destroy")
48 assert_redirected_to user_path(user)
50 # Check that the user was deleted properly
52 assert_equal "user_#{user.id}", user.display_name
53 assert_equal "", user.description
54 assert_nil user.home_lat
55 assert_nil user.home_lon
56 assert_not user.avatar.attached?
57 assert_not user.email_valid
58 assert_nil user.new_email
59 assert_nil user.auth_provider
60 assert_nil user.auth_uid
61 assert_equal "deleted", user.status