3775: Merge branch 'master' into 3775-fetch-git-repo
[arvados.git] / apps / workbench / test / functional / projects_controller_test.rb
index e8a696bb12e5ab4c071fef4c5af394290d849e55..d76430cfdf523f246e4a60d03abf3f85e2b9a85c 100644 (file)
@@ -1,13 +1,20 @@
 require 'test_helper'
 
 class ProjectsControllerTest < ActionController::TestCase
-  test "inactive user is asked to sign user agreements on front page" do
+  test "invited user is asked to sign user agreements on front page" do
     get :index, {}, session_for(:inactive)
-    assert_response :success
-    assert_not_empty assigns(:required_user_agreements),
-    "Inactive user did not have required_user_agreements"
-    assert_template 'user_agreements/index',
-    "Inactive user was not presented with a user agreement at the front page"
+    assert_response :redirect
+    assert_match(/^#{Regexp.escape(user_agreements_url)}\b/,
+                 @response.redirect_url,
+                 "Inactive user was not redirected to user_agreements page")
+  end
+
+  test "uninvited user is asked to wait for activation" do
+    get :index, {}, session_for(:inactive_uninvited)
+    assert_response :redirect
+    assert_match(/^#{Regexp.escape(inactive_users_url)}\b/,
+                 @response.redirect_url,
+                 "Uninvited user was not redirected to inactive user page")
   end
 
   [[:active, true],
@@ -93,8 +100,15 @@ class ProjectsControllerTest < ActionController::TestCase
                  "Did not get exactly one row")
   end
 
-  test 'projects#show tab infinite scroll partial does not group object types' do
+  ['', ' asc', ' desc'].each do |direction|
+    test "projects#show tab partial orders correctly by #{direction}" do
+      _test_tab_content_order direction
+    end
+  end
+
+  def _test_tab_content_order direction
     get_contents_rows(limit: 100,
+                      order: "created_at#{direction}",
                       filters: [['uuid','is_a',['arvados#job',
                                                 'arvados#pipelineInstance']]])
     assert_response :success
@@ -103,16 +117,24 @@ class ProjectsControllerTest < ActionController::TestCase
     last_kind = nil
     found_kind = {}
     json_response['content'].scan /<tr[^>]+>/ do |tr_tag|
-      assert_equal(1,
-                   (tr_tag.scan(/\ data-object-created-at=\"(.*?)\"/).each do |t,|
-                      if last_timestamp
-                        assert_operator(last_timestamp, :>=, t,
-                                        "Rows are not sorted by timestamp desc")
-                      end
-                      last_timestamp = t
-                    end).count,
+      found_timestamps = 0
+      tr_tag.scan(/\ data-object-created-at=\"(.*?)\"/).each do |t,|
+        if last_timestamp
+          correct_operator = / desc$/ =~ direction ? :>= : :<=
+          assert_operator(last_timestamp, correct_operator, t,
+                          "Rows are not sorted by created_at#{direction}")
+        end
+        last_timestamp = t
+        found_timestamps += 1
+      end
+      assert_equal(1, found_timestamps,
                    "Content row did not have exactly one timestamp")
 
+      # Confirm that the test for timestamp ordering couldn't have
+      # passed merely because the test fixtures have convenient
+      # timestamps (e.g., there is only one pipeline and one job in
+      # the project being tested, or there are no pipelines at all in
+      # the project being tested):
       tr_tag.scan /\ data-kind=\"(.*?)\"/ do |kind|
         if last_kind and last_kind != kind and found_kind[kind]
           # We saw this kind before, then a different kind, then