4 class ImagesControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/profile/image", :method => :get },
10 { :controller => "profiles/images", :action => "show" }
13 { :path => "/profile/image", :method => :put },
14 { :controller => "profiles/images", :action => "update" }
22 get profile_image_path
24 assert_response :success
28 def test_show_unauthorized
29 get profile_image_path
31 assert_redirected_to login_path(:referer => profile_image_path)
38 # Changing to an uploaded image should work
39 image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
40 put profile_image_path, :params => { :avatar_action => "new", :user => { :avatar => image, :description => user.description } }
41 assert_redirected_to user_path(user)
43 assert_response :success
45 assert_dom ".alert-success", :text => "Profile updated."
46 get profile_image_path
47 assert_dom "form > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
49 # Changing to a gravatar image should work
50 put profile_image_path, :params => { :avatar_action => "gravatar", :user => { :description => user.description } }
51 assert_redirected_to user_path(user)
53 assert_response :success
55 assert_dom ".alert-success", :text => "Profile updated."
56 get profile_image_path
57 assert_dom "form > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
59 # Removing the image should work
60 put profile_image_path, :params => { :avatar_action => "delete", :user => { :description => user.description } }
61 assert_redirected_to user_path(user)
63 assert_response :success
65 assert_dom ".alert-success", :text => "Profile updated."
66 get profile_image_path
67 assert_dom "form > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
68 assert_dom "form > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false