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_redirected_to user_path(user)
26 assert_response :success
28 assert_select ".alert-success", /^Profile updated./
29 assert_select "div", "new description"
31 # Changing to an uploaded image should work
32 image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
33 put profile_path, :params => { :avatar_action => "new", :user => { :avatar => image, :description => user.description } }
34 assert_redirected_to user_path(user)
36 assert_response :success
38 assert_select ".alert-success", /^Profile updated./
40 assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
42 # Changing to a gravatar image should work
43 put profile_path, :params => { :avatar_action => "gravatar", :user => { :description => user.description } }
44 assert_redirected_to user_path(user)
46 assert_response :success
48 assert_select ".alert-success", /^Profile updated./
50 assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
52 # Removing the image should work
53 put profile_path, :params => { :avatar_action => "delete", :user => { :description => user.description } }
54 assert_redirected_to user_path(user)
56 assert_response :success
58 assert_select ".alert-success", /^Profile updated./
60 assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
61 assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false