1 # frozen_string_literal: true
 
   6   class LinksControllerTest < ActionDispatch::IntegrationTest
 
   8     # test all routes which lead to this controller
 
  11         { :path => "/profile/links", :method => :get },
 
  12         { :controller => "profiles/links", :action => "show" }
 
  15         { :path => "/profile/links", :method => :put },
 
  16         { :controller => "profiles/links", :action => "update" }
 
  24       get profile_links_path
 
  26       assert_response :success
 
  30     def test_show_unauthorized
 
  31       get profile_links_path
 
  33       assert_redirected_to login_path(:referer => profile_links_path)
 
  40       put profile_links_path, :params => { :user => { :social_links_attributes => [{ :url => "https://test.com/test" }] } }
 
  42       assert_redirected_to user_path(user)
 
  44       assert_response :success
 
  46       assert_dom ".alert-success", :text => "Profile links updated."
 
  47       assert_dom "a[href*='test.com/test'] span", "test.com/test"
 
  50     def test_update_empty_social_link
 
  54       put profile_links_path, :params => { :user => { :social_links_attributes => [{ :url => "" }] } }
 
  56       assert_response :success
 
  58       assert_dom ".alert-danger", :text => "Couldn't update profile links."