supernova 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -1,5 +1,4 @@
1
1
  require "supernova/solr_criteria"
2
- require "supernova/solr_indexer"
3
2
 
4
3
  module Supernova::Solr
5
4
  class << self
@@ -18,4 +17,6 @@ module Supernova::Solr
18
17
  base.extend(Supernova::ClassMethods)
19
18
  base.criteria_class = Supernova::SolrCriteria
20
19
  end
21
- end
20
+ end
21
+
22
+ require "supernova/solr_indexer"
@@ -4,6 +4,8 @@ class Supernova::SolrIndexer
4
4
  attr_accessor :options, :db, :ids
5
5
  attr_writer :index_file_path
6
6
 
7
+ include Supernova::Solr
8
+
7
9
  class << self
8
10
  def field_definitions
9
11
  @field_definitions ||= {}
@@ -24,13 +26,16 @@ class Supernova::SolrIndexer
24
26
  end
25
27
 
26
28
  def method_missing(*args)
27
- criteria = Supernova::SolrCriteria.new(self.clazz).attribute_mapping(self.field_definitions)
28
- if criteria.respond_to?(args.first)
29
- criteria.send(*args)
29
+ if search_scope.respond_to?(args.first)
30
+ search_scope.send(*args)
30
31
  else
31
32
  super
32
33
  end
33
34
  end
35
+
36
+ def search_scope
37
+ Supernova::SolrCriteria.new(self.clazz).attribute_mapping(self.field_definitions)
38
+ end
34
39
  end
35
40
 
36
41
  FIELD_SUFFIX_MAPPING = {
@@ -23,7 +23,7 @@ describe "ThinkingSphinx" do
23
23
  @offer1 = Offer.create!(:id => 1, :user_id => 1, :enabled => false, :text => "Hans Meyer", :popularity => 10, :lat => root.lat, :lng => root.lng)
24
24
  @offer2 = Offer.create!(:id => 2, :user_id => 2, :enabled => true, :text => "Marek Mintal", :popularity => 1, :lat => endpoint.lat, :lng => endpoint.lng)
25
25
  ts.controller.index
26
- sleep 0.2
26
+ sleep 0.3
27
27
  end
28
28
 
29
29
  it "finds the correct objects" do
@@ -417,6 +417,24 @@ describe Supernova::SolrIndexer do
417
417
  end
418
418
  end
419
419
 
420
+ describe "#named_search_scope" do
421
+ it "returns the correct scope" do
422
+ indexer_clazz.named_search_scope :published do
423
+ where(:public => true)
424
+ end
425
+ indexer_clazz.published.search_options[:attribute_mapping].should == {
426
+ :artist_id=>{:type=>:integer}, :title=>{:type=>:text}, :created_at=>{:type=>:date}, :description=>{:type=>:text}
427
+ }
428
+ end
429
+
430
+ it "works with attribute mappings" do
431
+ indexer_clazz.named_search_scope :with_title do
432
+ where(:title.ne => nil)
433
+ end
434
+ indexer_clazz.with_title.to_params[:fq].should include("title_t:[* TO *]")
435
+ end
436
+ end
437
+
420
438
  describe "#solr_field_for_field_name_and_mapping" do
421
439
  let(:mapping) do
422
440
  {
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{supernova}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tobias Schwab"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supernova
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Schwab