module Workarea::Factories::Search

Public Instance Methods

create_product_browse_search_options(options = {}) click to toggle source
# File lib/workarea/testing/factories/search.rb, line 56
def create_product_browse_search_options(options = {})
  options.reverse_merge!(factory_defaults(:product_browse_search_options))

  options[:results] = options[:products].map do |product|
    { catalog_id: product.id, model: product, option: nil }
  end

  options.except(:products)
end
create_search_customization(overrides = {}) click to toggle source
# File lib/workarea/testing/factories/search.rb, line 10
def create_search_customization(overrides = {})
  attributes = factory_defaults(:search_customization).merge(overrides)
  Workarea::Search::Customization.create!(attributes)
end
create_search_settings(overrides = {}) click to toggle source
# File lib/workarea/testing/factories/search.rb, line 6
def create_search_settings(overrides = {})
  Workarea::Search::Settings.create!(overrides)
end
elasticsearch_response() click to toggle source
# File lib/workarea/testing/factories/search.rb, line 51
def elasticsearch_response
  file = "#{File.dirname(__FILE__)}/../elasticsearch_response.json"
  JSON.parse(IO.read(file))
end
update_search_settings(overrides = {}) click to toggle source
# File lib/workarea/testing/factories/search.rb, line 66
def update_search_settings(overrides = {})
  attributes = factory_defaults(:search_settings).merge(overrides)
  Workarea::Search::Settings.current.update_attributes!(attributes)
end