From ee3bec9676d1959fe3b97df27da1e69baffd7e8a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Mar 2020 06:04:48 -0700 Subject: [PATCH] Test first [skip ci] --- README.md | 2 +- test/relation_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09a65d3..cb6339c 100644 --- a/README.md +++ b/README.md @@ -670,7 +670,7 @@ First, add a route and controller action. class MoviesController < ApplicationController def autocomplete movies = Movie.search(params[:query]).fields("title^5", "director") - .match(:word_start).limit(10).load(false).misspellings(below: 5) + .match(:word_start).load(false).misspellings(below: 5).first(10) render json: movies.map(&:title) end diff --git a/test/relation_test.rb b/test/relation_test.rb index 6b64b5f..c61a1e7 100644 --- a/test/relation_test.rb +++ b/test/relation_test.rb @@ -52,6 +52,14 @@ class RelationTest < Minitest::Test assert Product.search.pluck end + def test_first + store_names ["Blue", "Red"] + assert_kind_of Product, Product.first + assert_kind_of Product, Product.search.first if defined?(ActiveRecord) + assert_equal 1, Product.first(1).size + assert_equal 1, Product.search.first(1).size if defined?(ActiveRecord) + end + def test_take store_names ["Blue", "Red"] assert_kind_of Product, Product.take -- libgit2 0.21.0