This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Tag specs dependent on Elasticsearch

These are integration level specs, they require Elasticsearch test cluster
to be up in order to pass
  • Loading branch information...
saulius committed Jan 17, 2014
1 parent 7ac6080 commit a907d7c2136525eb61232f9255fc2a00dd632e02
@@ -15,10 +15,10 @@ class SearchReferencesBaseController < ApiController
def index
@search_references = begin
search_reference_collection.by_title
- .paginate(per_page: per_page, page: page)
+ .paginate(page, per_page)
rescue Sequel::Error
search_reference_collection.by_title
- .paginate(per_page: default_limit, page: default_page)
+ .paginate(page, per_page)
end
end
@@ -9,6 +9,7 @@ class GoodsNomenclature < Sequel::Model
plugin :oplog, primary_key: :goods_nomenclature_sid
plugin :nullable
plugin :conformance_validator
+ plugin :active_model
plugin :sti, class_determinator: ->(record) {
gono_id = record[:goods_nomenclature_item_id].to_s
@@ -144,4 +144,8 @@ def heading_id
def chapter_id
"#{referenced_id}00000000"
end
+
+ def commodity_id
+ referenced_id
+ end
end
@@ -46,5 +46,7 @@ def serializable_hash(opts = {})
end
end
end
+
+ commodity_attributes
end
end
@@ -3,6 +3,11 @@ class FuzzySearch < BaseSearch
class FuzzySearchResult
include Enumerable
+ # We craft Elasticsearch queries in streamlined way, but
+ # certain queries need additional query details to be provided.
+ # These details can be specified in QUERY_OPTIONS
+ #
+ # See #each_query for more details
QUERY_OPTIONS = {
goods_nomenclature_match: {
'tariff-sections' => { fields: ["title"] }
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Api::V1::Chapters::SearchReferencesController, "GET #index" do
+describe Api::V1::Chapters::SearchReferencesController, elasticsearch: true do
it_behaves_like 'search references controller' do
let(:search_reference_parent) { create :chapter }
let(:search_reference) { create :search_reference, chapter_id: search_reference_parent.short_code }
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Api::V1::Commodities::SearchReferencesController, "GET #index" do
+describe Api::V1::Commodities::SearchReferencesController, elasticsearch: true do
it_behaves_like 'search references controller' do
let(:search_reference_parent) { create :commodity, :declarable }
let(:search_reference) { create :search_reference, commodity_id: search_reference_parent.code }
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Api::V1::Headings::SearchReferencesController, "GET #index" do
+describe Api::V1::Headings::SearchReferencesController, elasticsearch: true do
it_behaves_like 'search references controller' do
let(:search_reference_parent) { create :heading }
let(:search_reference) { create :search_reference, heading_id: search_reference_parent.short_code }
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Api::V1::SearchController, "POST #search" do
+describe Api::V1::SearchController, "POST #search", elasticsearch: true do
describe 'exact matching' do
let(:chapter) { create :chapter }
let(:pattern) {
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Api::V1::Sections::SearchReferencesController do
+describe Api::V1::Sections::SearchReferencesController, elasticsearch: true do
it_behaves_like 'search references controller' do
let(:search_reference_parent) { create :section }
let(:search_reference) { create :search_reference, section_id: search_reference_parent.id }
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe SearchService do
+describe SearchService, elasticsearch: true do
describe 'initialization' do
let(:query) { Forgery(:basic).text }

0 comments on commit a907d7c

Please sign in to comment.