1 # frozen_string_literal: true
6 class HeatmapsControllerTest < ActionDispatch::IntegrationTest
8 # test all routes which lead to this controller
11 { :path => "/profile/heatmap", :method => :get },
12 { :controller => "profiles/heatmaps", :action => "show" }
15 { :path => "/profile/heatmap", :method => :put },
16 { :controller => "profiles/heatmaps", :action => "update" }
24 get profile_heatmap_path
26 assert_response :success
30 def test_show_unauthorized
31 get profile_heatmap_path
33 assert_redirected_to login_path(:referer => profile_heatmap_path)
37 user = create(:user, :public_heatmap => true)
40 heatmap_selector = ".heatmap_frame"
42 assert_predicate user.reload, :public_heatmap?
44 assert_select heatmap_selector
46 put profile_heatmap_path, :params => { :user => { :public_heatmap => "0" } }
48 assert_redirected_to user_path(user)
50 assert_response :success
52 assert_dom ".alert-success", :text => "Heatmap updated."
54 assert_not_predicate user.reload, :public_heatmap?
55 refute_select heatmap_selector
57 put profile_heatmap_path, :params => { :user => { :public_heatmap => "1" } }
59 assert_redirected_to user_path(user)
61 assert_response :success
63 assert_dom ".alert-success", :text => "Heatmap updated."
65 assert_predicate user.reload, :public_heatmap?
66 assert_select heatmap_selector