mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-04 23:24:49 -04:00
Removing non-elasticsearch options
This commit is contained in:
19
.travis.yml
19
.travis.yml
@@ -16,9 +16,8 @@ addons:
|
|||||||
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
|
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- GROWSTUFF_ELASTICSEARCH=true RSPEC_TAG=elasticsearch COVERAGE=true ELASTIC_SEARCH_VERSION="6.2.3"
|
- COVERAGE=true
|
||||||
- GROWSTUFF_ELASTICSEARCH=false RSPEC_TAG=~elasticsearch COVERAGE=false
|
- STATIC_CHECKS=true
|
||||||
- STATIC_CHECKS=true PERCY=true
|
|
||||||
global:
|
global:
|
||||||
- secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4="
|
- secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4="
|
||||||
- GROWSTUFF_EMAIL="noreply@test.growstuff.org"
|
- GROWSTUFF_EMAIL="noreply@test.growstuff.org"
|
||||||
@@ -30,29 +29,21 @@ before_install:
|
|||||||
- sudo apt install dpkg
|
- sudo apt install dpkg
|
||||||
- sudo apt install google-chrome-stable
|
- sudo apt install google-chrome-stable
|
||||||
- ./script/install_linters.sh
|
- ./script/install_linters.sh
|
||||||
- ./script/install_elasticsearch.sh
|
- ELASTIC_SEARCH_VERSION="6.2.3" ./script/install_elasticsearch.sh
|
||||||
script:
|
script:
|
||||||
- set -e
|
|
||||||
- >
|
- >
|
||||||
if [ "${STATIC_CHECKS}" = "true" ]; then
|
if [ "${STATIC_CHECKS}" = "true" ]; then
|
||||||
./script/check_static.rb
|
./script/check_static.rb
|
||||||
else
|
else
|
||||||
set +e;
|
RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex assets:precompile;
|
||||||
RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex;
|
npx percy exec -- bundle exec rspec spec
|
||||||
bundle exec rake assets:precompile;
|
|
||||||
bundle exec rspec -fd --tag $RSPEC_TAG spec/;
|
|
||||||
fi;
|
fi;
|
||||||
- set +e
|
|
||||||
after_script:
|
after_script:
|
||||||
- >
|
- >
|
||||||
if [ "${COVERAGE}" = "true" ]; then
|
if [ "${COVERAGE}" = "true" ]; then
|
||||||
gem install codeclimate-test-reporter
|
gem install codeclimate-test-reporter
|
||||||
codeclimate-test-reporter
|
codeclimate-test-reporter
|
||||||
fi
|
fi
|
||||||
- >
|
|
||||||
if [ "${PERCY}" = "true" ]; then
|
|
||||||
./scripts/percy.sh
|
|
||||||
fi
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- bundle exec script/heroku_maintenance.rb on
|
- bundle exec script/heroku_maintenance.rb on
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class AlternateName < ApplicationRecord
|
|||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :crop, presence: true
|
validates :crop, presence: true
|
||||||
|
|
||||||
after_commit :reindex if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
after_commit :reindex
|
||||||
|
|
||||||
delegate :reindex, to: :crop
|
delegate :reindex, to: :crop
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module CropSearch
|
|||||||
included do
|
included do
|
||||||
####################################
|
####################################
|
||||||
# Elastic search configuration
|
# Elastic search configuration
|
||||||
searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false
|
||||||
|
|
||||||
# Special scope to control if it's in the search index
|
# Special scope to control if it's in the search index
|
||||||
scope :search_import, -> { includes(:scientific_names, :photos) }
|
scope :search_import, -> { includes(:scientific_names, :photos) }
|
||||||
@@ -27,7 +27,7 @@ module CropSearch
|
|||||||
photo: default_photo&.thumbnail_url,
|
photo: default_photo&.thumbnail_url,
|
||||||
scientific_name: default_scientific_name&.name,
|
scientific_name: default_scientific_name&.name,
|
||||||
description: description,
|
description: description,
|
||||||
created_at: created_at
|
created_at: created_at.to_i
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class ScientificName < ApplicationRecord
|
|||||||
belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names
|
belongs_to :creator, class_name: 'Member', inverse_of: :created_scientific_names
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :crop, presence: true
|
validates :crop, presence: true
|
||||||
after_commit :reindex if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
after_commit :reindex
|
||||||
delegate :reindex, to: :crop
|
delegate :reindex, to: :crop
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
class CropSearchService
|
class CropSearchService
|
||||||
# Crop.search(string)
|
# Crop.search(string)
|
||||||
def self.search(query, page: 1, per_page: 12, current_member: nil)
|
def self.search(query, page: 1, per_page: 12, current_member: nil)
|
||||||
if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
|
||||||
elasticsearch(query, page: page, per_page: per_page, current_member: current_member)
|
|
||||||
else
|
|
||||||
dbsearch(query, page: page, per_page: per_page)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.elasticsearch(query, page: 1, per_page: 12, current_member: nil)
|
|
||||||
search_params = {
|
search_params = {
|
||||||
page: page,
|
page: page,
|
||||||
per_page: per_page,
|
per_page: per_page,
|
||||||
@@ -24,29 +16,6 @@ class CropSearchService
|
|||||||
Crop.search(query, search_params)
|
Crop.search(query, search_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.dbsearch(query, page: 1, per_page: 12)
|
|
||||||
# if we don't have elasticsearch, just do a basic SQL query.
|
|
||||||
# also, make sure it's an actual array not an activerecord
|
|
||||||
# collection, so it matches what we get from elasticsearch and we can
|
|
||||||
# manipulate it in the same ways (eg. deleting elements without deleting
|
|
||||||
# the whole record from the db)
|
|
||||||
matcher = "%#{query}%"
|
|
||||||
matches = Crop.approved
|
|
||||||
.left_outer_joins(:alternate_names, :scientific_names)
|
|
||||||
.where("crops.name ILIKE ? OR alternate_names.name ILIKE ? OR scientific_names.name ILIKE ?",
|
|
||||||
matcher, matcher, matcher)
|
|
||||||
|
|
||||||
matches = matches.to_a
|
|
||||||
# we want to make sure that exact matches come first, even if not
|
|
||||||
# using elasticsearch (eg. in development)
|
|
||||||
exact_match = Crop.approved.find_by(name: query)
|
|
||||||
if exact_match
|
|
||||||
matches.delete(exact_match)
|
|
||||||
matches.unshift(exact_match)
|
|
||||||
end
|
|
||||||
matches.paginate(page: page, per_page: per_page)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.random_with_photos(limit)
|
def self.random_with_photos(limit)
|
||||||
body = {
|
body = {
|
||||||
"query": {
|
"query": {
|
||||||
|
|||||||
@@ -57,13 +57,6 @@ GROWSTUFF_FACEBOOK_SECRET: ""
|
|||||||
GROWSTUFF_MAPBOX_MAP_ID: ""
|
GROWSTUFF_MAPBOX_MAP_ID: ""
|
||||||
GROWSTUFF_MAPBOX_ACCESS_TOKEN: ""
|
GROWSTUFF_MAPBOX_ACCESS_TOKEN: ""
|
||||||
|
|
||||||
# Elasticsearch is used for flexible search and it requires another component
|
|
||||||
# to be installed. To make it easy for people who don't need to test this feature
|
|
||||||
# it's been turned off for test and development environment as a default.
|
|
||||||
# If you want to test this functionality, install elasticsearch and
|
|
||||||
# set this flag to "true".
|
|
||||||
GROWSTUFF_ELASTICSEARCH: "false"
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Other environments
|
# Other environments
|
||||||
# You can override the above for staging, production, etc.
|
# You can override the above for staging, production, etc.
|
||||||
@@ -83,8 +76,6 @@ test:
|
|||||||
|
|
||||||
staging:
|
staging:
|
||||||
GROWSTUFF_SITE_NAME: Growstuff (staging)
|
GROWSTUFF_SITE_NAME: Growstuff (staging)
|
||||||
GROWSTUFF_ELASTICSEARCH: "true"
|
|
||||||
|
|
||||||
production:
|
production:
|
||||||
GROWSTUFF_SITE_NAME: Growstuff
|
GROWSTUFF_SITE_NAME: Growstuff
|
||||||
GROWSTUFF_ELASTICSEARCH: "true"
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe CropsController do
|
|||||||
describe 'fetches the crop search page' do
|
describe 'fetches the crop search page' do
|
||||||
let!(:tomato) { FactoryBot.create :tomato }
|
let!(:tomato) { FactoryBot.create :tomato }
|
||||||
let!(:maize) { FactoryBot.create :maize }
|
let!(:maize) { FactoryBot.create :maize }
|
||||||
before { Crop.reindex if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" }
|
before { Crop.reindex }
|
||||||
describe 'search form page' do
|
describe 'search form page' do
|
||||||
before { get :search }
|
before { get :search }
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
require 'custom_matchers'
|
require 'custom_matchers'
|
||||||
|
|
||||||
describe "Harvesting a crop", :js, :elasticsearch do
|
describe "Harvesting a crop", :js do
|
||||||
context 'signed in' do
|
context 'signed in' do
|
||||||
include_context 'signed in member'
|
include_context 'signed in member'
|
||||||
let!(:maize) { create :maize }
|
let!(:maize) { create :maize }
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ describe "home page" do
|
|||||||
planting.photos << photo
|
planting.photos << photo
|
||||||
seed.photos << photo
|
seed.photos << photo
|
||||||
harvest.photos << photo
|
harvest.photos << photo
|
||||||
|
Crop.reindex
|
||||||
end
|
end
|
||||||
|
|
||||||
before { visit root_path }
|
before { visit root_path }
|
||||||
@@ -54,6 +55,7 @@ describe "home page" do
|
|||||||
|
|
||||||
shared_examples "show crops" do
|
shared_examples "show crops" do
|
||||||
describe 'shows crops section' do
|
describe 'shows crops section' do
|
||||||
|
before { crop.reindex }
|
||||||
it { is_expected.to have_text 'Some of our crops' }
|
it { is_expected.to have_text 'Some of our crops' }
|
||||||
it { is_expected.to have_link href: crop_path(crop) }
|
it { is_expected.to have_link href: crop_path(crop) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ rest of the garden.
|
|||||||
maize: 'https://farm66.staticflickr.com/65535/46739264475_7cb55b2cbb_q.jpg'
|
maize: 'https://farm66.staticflickr.com/65535/46739264475_7cb55b2cbb_q.jpg'
|
||||||
}.each do |crop_type, photo_url|
|
}.each do |crop_type, photo_url|
|
||||||
crop = FactoryBot.create crop_type, creator: someone_else
|
crop = FactoryBot.create crop_type, creator: someone_else
|
||||||
|
crop.reindex
|
||||||
owner = FactoryBot.create :interesting_member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com"
|
owner = FactoryBot.create :interesting_member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com"
|
||||||
planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first
|
planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first
|
||||||
photo = FactoryBot.create(:photo, owner: owner,
|
photo = FactoryBot.create(:photo, owner: owner,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require 'custom_matchers'
|
require 'custom_matchers'
|
||||||
|
|
||||||
describe "Planting a crop", :js, :elasticsearch do
|
describe "Planting a crop", :js do
|
||||||
let!(:maize) { FactoryBot.create :maize }
|
let!(:maize) { FactoryBot.create :maize }
|
||||||
let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' }
|
let(:garden) { FactoryBot.create :garden, owner: member, name: 'Orchard' }
|
||||||
let!(:planting) do
|
let!(:planting) do
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require 'custom_matchers'
|
require 'custom_matchers'
|
||||||
describe "Display a planting", :js, :elasticsearch do
|
describe "Display a planting", :js do
|
||||||
describe 'planting perennial' do
|
describe 'planting perennial' do
|
||||||
let(:garden) { FactoryBot.create :garden, location: 'Edinburgh' }
|
let(:garden) { FactoryBot.create :garden, location: 'Edinburgh' }
|
||||||
let(:crop) { FactoryBot.create(:crop, name: 'feijoa', perennial: true) }
|
let(:crop) { FactoryBot.create(:crop, name: 'feijoa', perennial: true) }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
require 'custom_matchers'
|
require 'custom_matchers'
|
||||||
|
|
||||||
describe "Display a planting", :js, :elasticsearch do
|
describe "Display a planting", :js do
|
||||||
context 'anonymous' do
|
context 'anonymous' do
|
||||||
before { visit planting_path(planting) }
|
before { visit planting_path(planting) }
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
require 'custom_matchers'
|
require 'custom_matchers'
|
||||||
|
|
||||||
describe "Seeds", :js, :elasticsearch do
|
describe "Seeds", :js do
|
||||||
context 'signed in' do
|
context 'signed in' do
|
||||||
include_context 'signed in member'
|
include_context 'signed in member'
|
||||||
let!(:maize) { create :maize }
|
let!(:maize) { create :maize }
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ describe "signin", js: true do
|
|||||||
let(:member) { FactoryBot.create :member }
|
let(:member) { FactoryBot.create :member }
|
||||||
let(:recipient) { FactoryBot.create :member }
|
let(:recipient) { FactoryBot.create :member }
|
||||||
let(:wrangler) { FactoryBot.create :crop_wrangling_member }
|
let(:wrangler) { FactoryBot.create :crop_wrangling_member }
|
||||||
|
|
||||||
|
before do
|
||||||
|
crop = FactoryBot.create :tomato
|
||||||
|
crop.reindex
|
||||||
|
end
|
||||||
|
|
||||||
def login
|
def login
|
||||||
fill_in 'Login', with: member.login_name
|
fill_in 'Login', with: member.login_name
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe CropSearchService, type: :service do
|
RSpec.describe CropSearchService, type: :service do
|
||||||
describe 'search', :elasticsearch do
|
describe 'search' do
|
||||||
def search(term)
|
def search(term)
|
||||||
CropSearchService.search(term).map(&:name)
|
CropSearchService.search(term).map(&:name)
|
||||||
end
|
end
|
||||||
@@ -26,7 +26,7 @@ RSpec.describe CropSearchService, type: :service do
|
|||||||
|
|
||||||
# Child record
|
# Child record
|
||||||
FactoryBot.create(:crop, name: 'portobello', parent: mushroom)
|
FactoryBot.create(:crop, name: 'portobello', parent: mushroom)
|
||||||
Crop.reindex if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true'
|
Crop.reindex
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'finds exact match' do
|
describe 'finds exact match' do
|
||||||
@@ -37,47 +37,45 @@ RSpec.describe CropSearchService, type: :service do
|
|||||||
it { expect(search('mush')).to eq ['mushroom'] }
|
it { expect(search('mush')).to eq ['mushroom'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true'
|
describe 'finds mispellings matches' do
|
||||||
describe 'finds mispellings matches' do
|
it { expect(search('muhsroom')).to eq ['mushroom'] }
|
||||||
it { expect(search('muhsroom')).to eq ['mushroom'] }
|
it { expect(search('mushrom')).to eq ['mushroom'] }
|
||||||
it { expect(search('mushrom')).to eq ['mushroom'] }
|
it { expect(search('zuchini')).to eq ['zucchini'] }
|
||||||
it { expect(search('zuchini')).to eq ['zucchini'] }
|
it { expect(search('brocoli')).to eq ['broccoli'] }
|
||||||
it { expect(search('brocoli')).to eq ['broccoli'] }
|
end
|
||||||
|
|
||||||
|
describe 'biased' do
|
||||||
|
# Make some crops with planting counts
|
||||||
|
let!(:mushroom_parent) { FactoryBot.create :crop, name: 'mushroom' }
|
||||||
|
let!(:oyster) { FactoryBot.create :crop, name: 'oyster mushroom', parent: mushroom_parent }
|
||||||
|
let!(:shitake) { FactoryBot.create :crop, name: 'shitake mushroom', parent: mushroom_parent }
|
||||||
|
let!(:common) { FactoryBot.create :crop, name: 'common mushroom', parent: mushroom_parent }
|
||||||
|
let!(:brown) { FactoryBot.create :crop, name: 'brown mushroom', parent: mushroom_parent }
|
||||||
|
let!(:white) { FactoryBot.create :crop, name: 'white mushroom', parent: mushroom_parent }
|
||||||
|
|
||||||
|
describe 'biased to higher planting counts' do
|
||||||
|
subject { search('mushroom') }
|
||||||
|
before do
|
||||||
|
# Having plantings should bring these crops to the top of the search results
|
||||||
|
FactoryBot.create_list :planting, 10, crop: white
|
||||||
|
FactoryBot.create_list :planting, 4, crop: shitake
|
||||||
|
Crop.reindex
|
||||||
|
end
|
||||||
|
it { expect(subject.first).to eq 'white mushroom' }
|
||||||
|
it { expect(subject.second).to eq 'shitake mushroom' }
|
||||||
end
|
end
|
||||||
|
describe "biased to crops you've planted" do
|
||||||
describe 'biased' do
|
subject { CropSearchService.search('mushroom', current_member: owner).map(&:name) }
|
||||||
# Make some crops with planting counts
|
let(:owner) { FactoryBot.create :member }
|
||||||
let!(:mushroom_parent) { FactoryBot.create :crop, name: 'mushroom' }
|
before do
|
||||||
let!(:oyster) { FactoryBot.create :crop, name: 'oyster mushroom', parent: mushroom_parent }
|
FactoryBot.create_list :planting, 10, crop: brown
|
||||||
let!(:shitake) { FactoryBot.create :crop, name: 'shitake mushroom', parent: mushroom_parent }
|
FactoryBot.create :planting, crop: oyster, owner: owner
|
||||||
let!(:common) { FactoryBot.create :crop, name: 'common mushroom', parent: mushroom_parent }
|
FactoryBot.create :planting, crop: oyster, owner: owner
|
||||||
let!(:brown) { FactoryBot.create :crop, name: 'brown mushroom', parent: mushroom_parent }
|
FactoryBot.create :planting, crop: shitake, owner: owner
|
||||||
let!(:white) { FactoryBot.create :crop, name: 'white mushroom', parent: mushroom_parent }
|
Crop.reindex
|
||||||
|
|
||||||
describe 'biased to higher planting counts' do
|
|
||||||
subject { search('mushroom') }
|
|
||||||
before do
|
|
||||||
# Having plantings should bring these crops to the top of the search results
|
|
||||||
FactoryBot.create_list :planting, 10, crop: white
|
|
||||||
FactoryBot.create_list :planting, 4, crop: shitake
|
|
||||||
Crop.reindex
|
|
||||||
end
|
|
||||||
it { expect(subject.first).to eq 'white mushroom' }
|
|
||||||
it { expect(subject.second).to eq 'shitake mushroom' }
|
|
||||||
end
|
|
||||||
describe "biased to crops you've planted" do
|
|
||||||
subject { CropSearchService.search('mushroom', current_member: owner).map(&:name) }
|
|
||||||
let(:owner) { FactoryBot.create :member }
|
|
||||||
before do
|
|
||||||
FactoryBot.create_list :planting, 10, crop: brown
|
|
||||||
FactoryBot.create :planting, crop: oyster, owner: owner
|
|
||||||
FactoryBot.create :planting, crop: oyster, owner: owner
|
|
||||||
FactoryBot.create :planting, crop: shitake, owner: owner
|
|
||||||
Crop.reindex
|
|
||||||
end
|
|
||||||
it { expect(subject.first).to eq oyster.name }
|
|
||||||
it { expect(subject.second).to eq shitake.name }
|
|
||||||
end
|
end
|
||||||
|
it { expect(subject.first).to eq oyster.name }
|
||||||
|
it { expect(subject.second).to eq shitake.name }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -85,11 +83,9 @@ RSpec.describe CropSearchService, type: :service do
|
|||||||
it { expect(search('coffee')).to eq [] }
|
it { expect(search('coffee')).to eq [] }
|
||||||
end
|
end
|
||||||
|
|
||||||
if ENV['GROWSTUFF_ELASTICSEARCH'] == 'true'
|
describe 'finds plurals' do
|
||||||
describe 'finds plurals' do
|
it { expect(search('mushrooms')).to eq ['mushroom'] }
|
||||||
it { expect(search('mushrooms')).to eq ['mushroom'] }
|
it { expect(search('tomatoes')).to eq ['tomato'] }
|
||||||
it { expect(search('tomatoes')).to eq ['tomato'] }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'searches case insensitively' do
|
describe 'searches case insensitively' do
|
||||||
|
|||||||
@@ -35,13 +35,11 @@ RSpec.configure do |config|
|
|||||||
end
|
end
|
||||||
|
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
# reindex models
|
||||||
# reindex models
|
Crop.reindex
|
||||||
Crop.reindex
|
|
||||||
|
|
||||||
# and disable callbacks
|
# and disable callbacks
|
||||||
Searchkick.disable_callbacks
|
Searchkick.disable_callbacks
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.around(:each, search: true) do |example|
|
config.around(:each, search: true) do |example|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module FeatureHelpers
|
module FeatureHelpers
|
||||||
def fill_autocomplete(field, options = {})
|
def fill_autocomplete(field, options = {})
|
||||||
Crop.reindex if ENV["GROWSTUFF_ELASTICSEARCH"] == "true"
|
Crop.reindex
|
||||||
fill_in field, with: options[:with]
|
fill_in field, with: options[:with]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ describe 'home/index.html.haml', type: "view" do
|
|||||||
assign(:crops, [@crop])
|
assign(:crops, [@crop])
|
||||||
assign(:recent_crops, [@crop])
|
assign(:recent_crops, [@crop])
|
||||||
assign(:seeds, [FactoryBot.create(:tradable_seed)])
|
assign(:seeds, [FactoryBot.create(:tradable_seed)])
|
||||||
|
|
||||||
|
Crop.reindex
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'logged out' do
|
context 'logged out' do
|
||||||
|
|||||||
Reference in New Issue
Block a user