+ test "search jobs by uuid with 'not in' query" do
+ exclude_uuids = [jobs(:running).uuid,
+ jobs(:running_cancelled).uuid]
+ authorize_with :active
+ get :index, {
+ filters: [['uuid', 'not in', exclude_uuids]]
+ }
+ assert_response :success
+ found = assigns(:objects).collect(&:uuid)
+ assert_not_empty found, "'not in' query returned nothing"
+ assert_empty(found & exclude_uuids,
+ "'not in' query returned uuids I asked not to get")
+ end
+
+ ['=', '!='].each do |operator|
+ [['uuid', 'zzzzz-8i9sb-pshmckwoma9plh7'],
+ ['output', nil]].each do |attr, operand|
+ test "search jobs with #{attr} #{operator} #{operand.inspect} query" do
+ authorize_with :active
+ get :index, {
+ filters: [[attr, operator, operand]]
+ }
+ assert_response :success
+ values = assigns(:objects).collect { |x| x.send(attr) }
+ assert_not_empty values, "query should return non-empty result"
+ if operator == '='
+ assert_empty values - [operand], "query results do not satisfy query"
+ else
+ assert_empty values & [operand], "query results do not satisfy query"
+ end
+ end
+ end
+ end
+
+ test "search jobs by started_at with < query" do
+ authorize_with :active
+ get :index, {
+ filters: [['started_at', '<', Time.now.to_s]]
+ }
+ assert_response :success
+ found = assigns(:objects).collect(&:uuid)
+ assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+ end
+
+ test "search jobs by started_at with > query" do
+ authorize_with :active
+ get :index, {
+ filters: [['started_at', '>', Time.now.to_s]]
+ }
+ assert_response :success
+ assert_equal 0, assigns(:objects).count
+ end
+
+ test "search jobs by started_at with >= query on metric date" do
+ authorize_with :active
+ get :index, {
+ filters: [['started_at', '>=', '2014-01-01']]
+ }
+ assert_response :success
+ found = assigns(:objects).collect(&:uuid)
+ assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+ end
+
+ test "search jobs by started_at with >= query on metric date and time" do
+ authorize_with :active
+ get :index, {
+ filters: [['started_at', '>=', '2014-01-01 01:23:45']]
+ }
+ assert_response :success
+ found = assigns(:objects).collect(&:uuid)
+ assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+ end
+
+ test "search jobs with 'any' operator" do
+ authorize_with :active
+ get :index, {
+ where: { any: ['contains', 'pshmckw'] }
+ }
+ assert_response :success
+ found = assigns(:objects).collect(&:uuid)
+ assert_equal 0, found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+ assert_equal 1, found.count
+ end
+