Merge branch '4836-first-tab-load-wip'
authorBrett Smith <brett@curoverse.com>
Tue, 6 Jan 2015 17:12:27 +0000 (12:12 -0500)
committerBrett Smith <brett@curoverse.com>
Tue, 6 Jan 2015 17:12:36 +0000 (12:12 -0500)
Closes #4836, #4870.

apps/workbench/app/assets/javascripts/infinite_scroll.js
apps/workbench/test/integration/projects_test.rb
apps/workbench/test/integration_helper.rb

index 7bdf574ed9964802d6dab2b011ad3d8ca8b7fd1d..d7ad41abdd1779d727a6d6aae0435cc4f816d27d 100644 (file)
@@ -225,6 +225,10 @@ $(document).
                 trigger('scroll');
         });
     }).
+    on('shown.bs.tab', 'a[data-toggle="tab"]', function(event) {
+        $(event.target.getAttribute('href') + ' [data-infinite-scroller]').
+            trigger('scroll');
+    }).
     on('click', 'th[data-sort-order]', function() {
         var direction = $(this).data('sort-order-direction');
         // reverse the current direction, or do ascending if none
index 97e1a542bafcfad5f7a7e930c48c21f9417ec149..e5aa791de7c9494023d7c3d93f9d3f8f3b662fb0 100644 (file)
@@ -744,4 +744,15 @@ class ProjectsTest < ActionDispatch::IntegrationTest
     assert match, 'Expected project name not found'
     assert_text 'No description provided'
   end
+
+  test "first tab loads data when visiting other tab directly" do
+    # As of 2014-12-19, the first tab of project#show uses infinite scrolling.
+    # Make sure that it loads data even if we visit another tab directly.
+    project = api_fixture("groups", "aproject")
+    visit(page_with_token("active_trustedclient",
+                          "/projects/#{project['uuid']}#Advanced"))
+    assert_text("API response")
+    find("#page-wrapper .nav-tabs :first-child a").click
+    assert_text("bytes Collection")
+  end
 end
index febcfcfec0eb2c87122ba00594dfffc9a3958d37..2cf6bca2ad37b9064945957933b737158d44421b 100644 (file)
@@ -32,9 +32,11 @@ class ActionDispatch::IntegrationTest
     # fixture, or passed as a raw string.
     api_token = ((@@API_AUTHS.include? token) ?
                  @@API_AUTHS[token]['api_token'] : token)
-    sep = (path.include? '?') ? '&' : '?'
+    path_parts = path.partition("#")
+    sep = (path_parts.first.include? '?') ? '&' : '?'
     q_string = URI.encode_www_form('api_token' => api_token)
-    "#{path}#{sep}#{q_string}"
+    path_parts.insert(1, "#{sep}#{q_string}")
+    path_parts.join("")
   end
 
   # Find a page element, but return false instead of raising an