16636: Merge branch 'master' into 16636-more-metrics
[arvados.git] / services / api / test / functional / application_controller_test.rb
index d382c1c6a6bff71703c31fd87b7e30ec41b5925d..2cfa054448c29fcbbe3beb0b80edc37af514eb2e 100644 (file)
@@ -25,13 +25,15 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_operator(token_time, :>=, @start_stamp, "error token too old")
     assert_operator(token_time, :<=, now_timestamp, "error token too new")
     json_response['errors'].each do |err|
-      assert_match(/req-[a-z0-9]{20}/, err)
+      assert_match(/req-[a-z0-9]{20}/, err, "X-Request-Id value missing on error message")
     end
   end
 
   def check_404(errmsg="Path not found")
     assert_response 404
-    assert_includes(json_response['errors'].first, errmsg)
+    json_response['errors'].each do |err|
+      assert(err.include?(errmsg), "error message '#{err}' expected to include '#{errmsg}'")
+    end
     check_error_token
   end
 
@@ -98,7 +100,7 @@ class ApplicationControllerTest < ActionController::TestCase
         @controller = Arvados::V1::GroupsController.new
         authorize_with :active
         post :create, params: {
-          group: {},
+          group: {group_class: "project"},
           ensure_unique_name: boolparam
         }
         assert_response :success
@@ -111,7 +113,8 @@ class ApplicationControllerTest < ActionController::TestCase
         post :create, params: {
           group: {
             name: groups(:aproject).name,
-            owner_uuid: groups(:aproject).owner_uuid
+            owner_uuid: groups(:aproject).owner_uuid,
+            group_class: "project"
           },
           ensure_unique_name: boolparam
         }
@@ -119,4 +122,16 @@ class ApplicationControllerTest < ActionController::TestCase
       end
     end
   end
+
+  test "exceptions with backtraces get logged at exception_backtrace key" do
+    Group.stubs(:new).raises(Exception, 'Whoops')
+    Rails.logger.expects(:info).with(any_parameters) do |param|
+      param.include?('Whoops') and param.include?('"exception_backtrace":')
+    end
+    @controller = Arvados::V1::GroupsController.new
+    authorize_with :active
+    post :create, params: {
+      group: {},
+    }
+  end
 end