3 class ProfilesControllerTest < ActionDispatch::IntegrationTest
5 # test all routes which lead to this controller
8 { :path => "/profile/edit", :method => :get },
9 { :controller => "profiles", :action => "edit" }
13 { :path => "/profile", :method => :put },
14 { :controller => "profiles", :action => "update" }
22 # Updating the description should work
23 put profile_path, :params => { :user => { :description => "new description" } }
24 assert_response :redirect
25 assert_redirected_to user_path(user)
27 assert_response :success
29 assert_select ".alert-success", /^Profile updated./
30 assert_select "div", "new description"
32 # Changing to an uploaded image should work
33 image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
34 put profile_path, :params => { :avatar_action => "new", :user => { :avatar => image, :description => user.description } }
35 assert_response :redirect
36 assert_redirected_to user_path(user)
38 assert_response :success
40 assert_select ".alert-success", /^Profile updated./
42 assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
44 # Changing to a gravatar image should work
45 put profile_path, :params => { :avatar_action => "gravatar", :user => { :description => user.description } }
46 assert_response :redirect
47 assert_redirected_to user_path(user)
49 assert_response :success
51 assert_select ".alert-success", /^Profile updated./
53 assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
55 # Removing the image should work
56 put profile_path, :params => { :avatar_action => "delete", :user => { :description => user.description } }
57 assert_response :redirect
58 assert_redirected_to user_path(user)
60 assert_response :success
62 assert_select ".alert-success", /^Profile updated./
64 assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
65 assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false