From: Anton Khorev Date: Thu, 21 Mar 2024 13:43:15 +0000 (+0300) Subject: Fix user's traces tab link X-Git-Tag: live~703^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/919fcef149174df96afa95644981c04e825da445 Fix user's traces tab link --- diff --git a/app/views/traces/index.html.erb b/app/views/traces/index.html.erb index 90abdad71..447716a18 100644 --- a/app/views/traces/index.html.erb +++ b/app/views/traces/index.html.erb @@ -43,7 +43,7 @@ <% end %> <% end %> diff --git a/test/controllers/traces_controller_test.rb b/test/controllers/traces_controller_test.rb index 9a818786d..d187f2264 100644 --- a/test/controllers/traces_controller_test.rb +++ b/test/controllers/traces_controller_test.rb @@ -172,6 +172,7 @@ class TracesControllerTest < ActionDispatch::IntegrationTest # Check the index of traces for a specific user def test_index_user user = create(:user) + checked_user_traces_path = url_for :only_path => true, :controller => "traces", :action => "index", :display_name => user.display_name second_user = create(:user) third_user = create(:user) create(:trace) @@ -187,18 +188,33 @@ class TracesControllerTest < ActionDispatch::IntegrationTest # Test the user with the traces - should see only public ones get traces_path(:display_name => user.display_name) check_trace_index [trace_b] + assert_dom ".nav-tabs" do + assert_dom "a[href='#{traces_path}']", :text => "All Traces", :count => 1 + assert_dom "a[href='#{traces_mine_path}']", :text => "My Traces", :count => 0 + assert_dom "a[href='#{checked_user_traces_path}']", :text => Regexp.new(Regexp.escape(user.display_name)), :count => 1 + end session_for(third_user) # Should still see only public ones when authenticated as another user get traces_path(:display_name => user.display_name) check_trace_index [trace_b] + assert_dom ".nav-tabs" do + assert_dom "a[href='#{traces_path}']", :text => "All Traces", :count => 1 + assert_dom "a[href='#{traces_mine_path}']", :text => "My Traces", :count => 1 + assert_dom "a[href='#{checked_user_traces_path}']", :text => Regexp.new(Regexp.escape(user.display_name)), :count => 1 + end session_for(user) # Should see all traces when authenticated as the target user get traces_path(:display_name => user.display_name) check_trace_index [trace_c, trace_b] + assert_dom ".nav-tabs" do + assert_dom "a[href='#{traces_path}']", :text => "All Traces", :count => 1 + assert_dom "a[href='#{traces_mine_path}']", :text => "My Traces", :count => 1 + assert_dom "a[href='#{checked_user_traces_path}']", :text => Regexp.new(Regexp.escape(user.display_name)), :count => 0 + end # Should only see traces with the correct tag when a tag is specified get traces_path(:display_name => user.display_name, :tag => "London")