Module: Workarea::Factories::Search
- Defined in:
- lib/workarea/testing/factories/search.rb
Instance Method Summary collapse
- #create_admin_search(options = {}) ⇒ Object
- #create_category_browse_search(options = {}) ⇒ Object
- #create_product_browse_search_options(options = {}) ⇒ Object
- #create_product_search(options = {}) ⇒ Object
- #create_search_customization(overrides = {}) ⇒ Object
- #create_search_settings(overrides = {}) ⇒ Object
- #elasticsearch_response ⇒ Object
- #update_search_settings(overrides = {}) ⇒ Object
Instance Method Details
#create_admin_search(options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/workarea/testing/factories/search.rb', line 35 def create_admin_search( = {}) result = Workarea::Search::AdminSearch.new .reverse_merge!(factory_defaults(:admin_search)) [:results] = PagedArray.from( [:results], [:page], [:per_page], [:total] ) allow(result).to () result end |
#create_category_browse_search(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/workarea/testing/factories/search.rb', line 25 def create_category_browse_search( = {}) result = Workarea::Search::CategoryBrowse.new allow(result).to ( () ) result end |
#create_product_browse_search_options(options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/workarea/testing/factories/search.rb', line 56 def ( = {}) .reverse_merge!(factory_defaults(:product_browse_search_options)) [:results] = [:products].map do |product| { catalog_id: product.id, model: product, option: nil } end .except(:products) end |
#create_product_search(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/workarea/testing/factories/search.rb', line 15 def create_product_search( = {}) result = Workarea::Search::ProductSearch.new allow(result).to ( () ) result end |
#create_search_customization(overrides = {}) ⇒ Object
10 11 12 13 |
# 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 = {}) ⇒ Object
6 7 8 |
# File 'lib/workarea/testing/factories/search.rb', line 6 def create_search_settings(overrides = {}) Workarea::Search::Settings.create!(overrides) end |
#elasticsearch_response ⇒ Object
51 52 53 54 |
# 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 = {}) ⇒ Object
66 67 68 69 |
# 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 |