thinking-sphinx 1.3.14 → 1.3.15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.14
1
+ 1.3.15
@@ -6,6 +6,7 @@ module ThinkingSphinx
6
6
  stack = [@reflection.options[:through]].compact
7
7
 
8
8
  attribute = nil
9
+ @reflection.klass.define_indexes
9
10
  (@reflection.klass.sphinx_indexes || []).each do |index|
10
11
  attribute = index.attributes.detect { |attrib|
11
12
  attrib.columns.length == 1 &&
@@ -120,9 +120,15 @@ module ThinkingSphinx
120
120
  end
121
121
 
122
122
  def self.environment
123
- Thread.current[:thinking_sphinx_environment] ||= (
124
- defined?(Merb) ? Merb.environment : ENV['RAILS_ENV']
125
- ) || "development"
123
+ Thread.current[:thinking_sphinx_environment] ||= begin
124
+ if defined?(Merb)
125
+ Merb.environment
126
+ elsif defined?(RAILS_ENV)
127
+ RAILS_ENV
128
+ else
129
+ ENV['RAILS_ENV'] || 'development'
130
+ end
131
+ end
126
132
  end
127
133
 
128
134
  def environment
@@ -80,6 +80,12 @@ module ThinkingSphinx
80
80
  @array
81
81
  end
82
82
 
83
+ def freeze
84
+ populate
85
+ @array.freeze
86
+ self
87
+ end
88
+
83
89
  # Indication of whether the request has been made to Sphinx for the search
84
90
  # query.
85
91
  #
@@ -21,7 +21,13 @@ describe 'ThinkingSphinx::ActiveRecord::HasManyAssociation' do
21
21
  end
22
22
 
23
23
  @person.friendships.search "test"
24
- end
24
+ end
25
+
26
+ it "should define indexes for the reflection class" do
27
+ Friendship.should_receive(:define_indexes)
28
+
29
+ @person.friendships.search 'test'
30
+ end
25
31
  end
26
32
 
27
33
  describe "search method for has_many :through" do
@@ -17,7 +17,15 @@ describe ThinkingSphinx::Configuration do
17
17
  Merb.stub!(:environment => "merb_production")
18
18
  ThinkingSphinx::Configuration.environment.should == "merb_production"
19
19
 
20
- Object.send(:remove_const, :Merb)
20
+ Object.send :remove_const, :Merb
21
+ end
22
+
23
+ it "should use RAILS_ENV if set" do
24
+ RAILS_ENV = 'global_rails'
25
+
26
+ ThinkingSphinx::Configuration.environment.should == 'global_rails'
27
+
28
+ Object.send :remove_const, :RAILS_ENV
21
29
  end
22
30
 
23
31
  it "should use the Rails environment value if set" do
@@ -1172,6 +1172,26 @@ describe ThinkingSphinx::Search do
1172
1172
  }.should_not be_nil
1173
1173
  end
1174
1174
  end
1175
+
1176
+ describe '#freeze' do
1177
+ before :each do
1178
+ @search = ThinkingSphinx::Search.new
1179
+ end
1180
+
1181
+ it "should populate the result set" do
1182
+ @search.freeze
1183
+ @search.should be_populated
1184
+ end
1185
+
1186
+ it "should freeze the underlying array" do
1187
+ @search.freeze
1188
+ @search.to_a.should be_frozen
1189
+ end
1190
+
1191
+ it "should return the Search object" do
1192
+ @search.freeze.should be_a(ThinkingSphinx::Search)
1193
+ end
1194
+ end
1175
1195
  end
1176
1196
 
1177
1197
  describe ThinkingSphinx::Search, "playing nice with Search model" do
@@ -28,7 +28,7 @@ Jeweler::Tasks.new do |gem|
28
28
  ]
29
29
 
30
30
  gem.add_dependency 'activerecord', '>= 1.15.6'
31
- gem.add_dependency 'riddle', '>= 1.0.8'
31
+ gem.add_dependency 'riddle', '>= 1.0.9'
32
32
  gem.add_dependency 'after_commit', '>= 1.0.5'
33
33
 
34
34
  gem.post_install_message = <<-MESSAGE
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.14
4
+ version: 1.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 +11:00
12
+ date: 2010-01-29 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.8
33
+ version: 1.0.9
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: after_commit