4 class DescriptionsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/profile/description", :method => :get },
10 { :controller => "profiles/descriptions", :action => "show" }
13 { :path => "/profile/description", :method => :put },
14 { :controller => "profiles/descriptions", :action => "update" }
18 assert_redirected_to "/profile/description"
21 assert_redirected_to "/profile/description"
28 get profile_description_path
30 assert_response :success
34 def test_show_unauthorized
35 get profile_description_path
37 assert_redirected_to login_path(:referer => profile_description_path)
44 # Updating the description should work
45 put profile_description_path, :params => { :user => { :description => "new description" } }
46 assert_redirected_to user_path(user)
48 assert_response :success
50 assert_select ".alert-success", /^Profile updated./
51 assert_select "div", "new description"
53 # Updating social links should work
54 put profile_description_path, :params => { :user => { :description => user.description, :social_links_attributes => [{ :url => "https://test.com/test" }] } }
55 assert_redirected_to user_path(user)
57 assert_response :success
59 assert_select ".alert-success", /^Profile updated./
60 assert_select "a", "test.com/test"
63 def test_update_empty_social_link
67 put profile_description_path, :params => { :user => { :description => user.description, :social_links_attributes => [{ :url => "" }] } }
69 assert_response :success
71 assert_dom ".alert-danger", :text => "Couldn't update profile."