friendlyfashion-thinking-sphinx 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/HISTORY +244 -0
  2. data/LICENCE +20 -0
  3. data/README.textile +235 -0
  4. data/features/abstract_inheritance.feature +10 -0
  5. data/features/alternate_primary_key.feature +27 -0
  6. data/features/attribute_transformation.feature +22 -0
  7. data/features/attribute_updates.feature +77 -0
  8. data/features/deleting_instances.feature +67 -0
  9. data/features/direct_attributes.feature +11 -0
  10. data/features/excerpts.feature +21 -0
  11. data/features/extensible_delta_indexing.feature +9 -0
  12. data/features/facets.feature +88 -0
  13. data/features/facets_across_model.feature +29 -0
  14. data/features/field_sorting.feature +18 -0
  15. data/features/handling_edits.feature +94 -0
  16. data/features/retry_stale_indexes.feature +24 -0
  17. data/features/searching_across_models.feature +20 -0
  18. data/features/searching_by_index.feature +40 -0
  19. data/features/searching_by_model.feature +175 -0
  20. data/features/searching_with_find_arguments.feature +56 -0
  21. data/features/sphinx_detection.feature +25 -0
  22. data/features/sphinx_scopes.feature +68 -0
  23. data/features/step_definitions/alpha_steps.rb +16 -0
  24. data/features/step_definitions/beta_steps.rb +7 -0
  25. data/features/step_definitions/common_steps.rb +201 -0
  26. data/features/step_definitions/extensible_delta_indexing_steps.rb +7 -0
  27. data/features/step_definitions/facet_steps.rb +96 -0
  28. data/features/step_definitions/find_arguments_steps.rb +36 -0
  29. data/features/step_definitions/gamma_steps.rb +15 -0
  30. data/features/step_definitions/scope_steps.rb +19 -0
  31. data/features/step_definitions/search_steps.rb +94 -0
  32. data/features/step_definitions/sphinx_steps.rb +35 -0
  33. data/features/sti_searching.feature +19 -0
  34. data/features/support/env.rb +27 -0
  35. data/features/support/lib/generic_delta_handler.rb +8 -0
  36. data/features/thinking_sphinx/database.example.yml +3 -0
  37. data/features/thinking_sphinx/db/.gitignore +1 -0
  38. data/features/thinking_sphinx/db/fixtures/alphas.rb +8 -0
  39. data/features/thinking_sphinx/db/fixtures/authors.rb +1 -0
  40. data/features/thinking_sphinx/db/fixtures/betas.rb +11 -0
  41. data/features/thinking_sphinx/db/fixtures/boxes.rb +9 -0
  42. data/features/thinking_sphinx/db/fixtures/categories.rb +1 -0
  43. data/features/thinking_sphinx/db/fixtures/cats.rb +3 -0
  44. data/features/thinking_sphinx/db/fixtures/comments.rb +24 -0
  45. data/features/thinking_sphinx/db/fixtures/developers.rb +31 -0
  46. data/features/thinking_sphinx/db/fixtures/dogs.rb +3 -0
  47. data/features/thinking_sphinx/db/fixtures/extensible_betas.rb +10 -0
  48. data/features/thinking_sphinx/db/fixtures/foxes.rb +3 -0
  49. data/features/thinking_sphinx/db/fixtures/gammas.rb +10 -0
  50. data/features/thinking_sphinx/db/fixtures/music.rb +4 -0
  51. data/features/thinking_sphinx/db/fixtures/people.rb +1001 -0
  52. data/features/thinking_sphinx/db/fixtures/post_keywords.txt +1 -0
  53. data/features/thinking_sphinx/db/fixtures/posts.rb +10 -0
  54. data/features/thinking_sphinx/db/fixtures/robots.rb +8 -0
  55. data/features/thinking_sphinx/db/fixtures/tags.rb +27 -0
  56. data/features/thinking_sphinx/db/migrations/create_alphas.rb +8 -0
  57. data/features/thinking_sphinx/db/migrations/create_animals.rb +5 -0
  58. data/features/thinking_sphinx/db/migrations/create_authors.rb +3 -0
  59. data/features/thinking_sphinx/db/migrations/create_authors_posts.rb +6 -0
  60. data/features/thinking_sphinx/db/migrations/create_betas.rb +5 -0
  61. data/features/thinking_sphinx/db/migrations/create_boxes.rb +5 -0
  62. data/features/thinking_sphinx/db/migrations/create_categories.rb +3 -0
  63. data/features/thinking_sphinx/db/migrations/create_comments.rb +10 -0
  64. data/features/thinking_sphinx/db/migrations/create_developers.rb +7 -0
  65. data/features/thinking_sphinx/db/migrations/create_extensible_betas.rb +5 -0
  66. data/features/thinking_sphinx/db/migrations/create_gammas.rb +3 -0
  67. data/features/thinking_sphinx/db/migrations/create_genres.rb +3 -0
  68. data/features/thinking_sphinx/db/migrations/create_music.rb +6 -0
  69. data/features/thinking_sphinx/db/migrations/create_people.rb +13 -0
  70. data/features/thinking_sphinx/db/migrations/create_posts.rb +6 -0
  71. data/features/thinking_sphinx/db/migrations/create_robots.rb +4 -0
  72. data/features/thinking_sphinx/db/migrations/create_taggings.rb +5 -0
  73. data/features/thinking_sphinx/db/migrations/create_tags.rb +4 -0
  74. data/features/thinking_sphinx/models/alpha.rb +23 -0
  75. data/features/thinking_sphinx/models/andrew.rb +17 -0
  76. data/features/thinking_sphinx/models/animal.rb +5 -0
  77. data/features/thinking_sphinx/models/author.rb +3 -0
  78. data/features/thinking_sphinx/models/beta.rb +13 -0
  79. data/features/thinking_sphinx/models/box.rb +8 -0
  80. data/features/thinking_sphinx/models/cat.rb +3 -0
  81. data/features/thinking_sphinx/models/category.rb +4 -0
  82. data/features/thinking_sphinx/models/comment.rb +10 -0
  83. data/features/thinking_sphinx/models/developer.rb +21 -0
  84. data/features/thinking_sphinx/models/dog.rb +3 -0
  85. data/features/thinking_sphinx/models/extensible_beta.rb +9 -0
  86. data/features/thinking_sphinx/models/fox.rb +5 -0
  87. data/features/thinking_sphinx/models/gamma.rb +5 -0
  88. data/features/thinking_sphinx/models/genre.rb +3 -0
  89. data/features/thinking_sphinx/models/medium.rb +5 -0
  90. data/features/thinking_sphinx/models/music.rb +10 -0
  91. data/features/thinking_sphinx/models/person.rb +24 -0
  92. data/features/thinking_sphinx/models/post.rb +22 -0
  93. data/features/thinking_sphinx/models/robot.rb +12 -0
  94. data/features/thinking_sphinx/models/tag.rb +3 -0
  95. data/features/thinking_sphinx/models/tagging.rb +4 -0
  96. data/lib/cucumber/thinking_sphinx/external_world.rb +12 -0
  97. data/lib/cucumber/thinking_sphinx/internal_world.rb +137 -0
  98. data/lib/cucumber/thinking_sphinx/sql_logger.rb +28 -0
  99. data/lib/thinking-sphinx.rb +1 -0
  100. data/lib/thinking_sphinx/action_controller.rb +31 -0
  101. data/lib/thinking_sphinx/active_record/attribute_updates.rb +53 -0
  102. data/lib/thinking_sphinx/active_record/collection_proxy.rb +47 -0
  103. data/lib/thinking_sphinx/active_record/collection_proxy_with_scopes.rb +27 -0
  104. data/lib/thinking_sphinx/active_record/delta.rb +67 -0
  105. data/lib/thinking_sphinx/active_record/has_many_association.rb +44 -0
  106. data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +21 -0
  107. data/lib/thinking_sphinx/active_record/log_subscriber.rb +61 -0
  108. data/lib/thinking_sphinx/active_record/scopes.rb +110 -0
  109. data/lib/thinking_sphinx/active_record.rb +386 -0
  110. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +87 -0
  111. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +62 -0
  112. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +188 -0
  113. data/lib/thinking_sphinx/association.rb +230 -0
  114. data/lib/thinking_sphinx/attribute.rb +405 -0
  115. data/lib/thinking_sphinx/auto_version.rb +40 -0
  116. data/lib/thinking_sphinx/bundled_search.rb +44 -0
  117. data/lib/thinking_sphinx/class_facet.rb +20 -0
  118. data/lib/thinking_sphinx/configuration.rb +375 -0
  119. data/lib/thinking_sphinx/context.rb +76 -0
  120. data/lib/thinking_sphinx/core/string.rb +15 -0
  121. data/lib/thinking_sphinx/deltas/default_delta.rb +62 -0
  122. data/lib/thinking_sphinx/deltas.rb +28 -0
  123. data/lib/thinking_sphinx/deploy/capistrano.rb +99 -0
  124. data/lib/thinking_sphinx/excerpter.rb +23 -0
  125. data/lib/thinking_sphinx/facet.rb +135 -0
  126. data/lib/thinking_sphinx/facet_search.rb +170 -0
  127. data/lib/thinking_sphinx/field.rb +98 -0
  128. data/lib/thinking_sphinx/index/builder.rb +315 -0
  129. data/lib/thinking_sphinx/index/faux_column.rb +118 -0
  130. data/lib/thinking_sphinx/index.rb +159 -0
  131. data/lib/thinking_sphinx/join.rb +37 -0
  132. data/lib/thinking_sphinx/property.rb +187 -0
  133. data/lib/thinking_sphinx/railtie.rb +43 -0
  134. data/lib/thinking_sphinx/search.rb +1061 -0
  135. data/lib/thinking_sphinx/search_methods.rb +439 -0
  136. data/lib/thinking_sphinx/sinatra.rb +7 -0
  137. data/lib/thinking_sphinx/source/internal_properties.rb +51 -0
  138. data/lib/thinking_sphinx/source/sql.rb +174 -0
  139. data/lib/thinking_sphinx/source.rb +194 -0
  140. data/lib/thinking_sphinx/tasks.rb +142 -0
  141. data/lib/thinking_sphinx/test.rb +55 -0
  142. data/lib/thinking_sphinx/version.rb +3 -0
  143. data/lib/thinking_sphinx.rb +297 -0
  144. data/spec/fixtures/data.sql +32 -0
  145. data/spec/fixtures/database.yml.default +3 -0
  146. data/spec/fixtures/models.rb +164 -0
  147. data/spec/fixtures/structure.sql +146 -0
  148. data/spec/spec_helper.rb +61 -0
  149. data/spec/sphinx_helper.rb +60 -0
  150. data/spec/support/rails.rb +25 -0
  151. data/spec/thinking_sphinx/active_record/delta_spec.rb +122 -0
  152. data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +173 -0
  153. data/spec/thinking_sphinx/active_record/scopes_spec.rb +176 -0
  154. data/spec/thinking_sphinx/active_record_spec.rb +573 -0
  155. data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +145 -0
  156. data/spec/thinking_sphinx/association_spec.rb +250 -0
  157. data/spec/thinking_sphinx/attribute_spec.rb +552 -0
  158. data/spec/thinking_sphinx/auto_version_spec.rb +103 -0
  159. data/spec/thinking_sphinx/configuration_spec.rb +326 -0
  160. data/spec/thinking_sphinx/context_spec.rb +126 -0
  161. data/spec/thinking_sphinx/core/array_spec.rb +9 -0
  162. data/spec/thinking_sphinx/core/string_spec.rb +9 -0
  163. data/spec/thinking_sphinx/excerpter_spec.rb +49 -0
  164. data/spec/thinking_sphinx/facet_search_spec.rb +176 -0
  165. data/spec/thinking_sphinx/facet_spec.rb +359 -0
  166. data/spec/thinking_sphinx/field_spec.rb +127 -0
  167. data/spec/thinking_sphinx/index/builder_spec.rb +532 -0
  168. data/spec/thinking_sphinx/index/faux_column_spec.rb +36 -0
  169. data/spec/thinking_sphinx/index_spec.rb +189 -0
  170. data/spec/thinking_sphinx/search_methods_spec.rb +156 -0
  171. data/spec/thinking_sphinx/search_spec.rb +1455 -0
  172. data/spec/thinking_sphinx/source_spec.rb +267 -0
  173. data/spec/thinking_sphinx/test_spec.rb +20 -0
  174. data/spec/thinking_sphinx_spec.rb +204 -0
  175. metadata +524 -0
@@ -0,0 +1,173 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ThinkingSphinx::ActiveRecord::HasManyAssociation' do
4
+ describe "search method" do
5
+ before :each do
6
+ Friendship.stub!(:search => true)
7
+
8
+ @person = Person.find(:first)
9
+ @index = Friendship.sphinx_indexes.first
10
+ end
11
+
12
+ it "should raise an error if the required attribute doesn't exist" do
13
+ @index.stub!(:attributes => [])
14
+
15
+ lambda { @person.friendships.search "test" }.should raise_error(RuntimeError)
16
+ end
17
+
18
+ it "should add a filter for the attribute into a normal search call" do
19
+ Friendship.should_receive(:search) do |query, options|
20
+ options[:with][:person_id].should == @person.id
21
+ end
22
+
23
+ @person.friendships.search "test"
24
+ end
25
+
26
+ it "should add a filter for an aliased attribute into a normal search call" do
27
+ @team = CricketTeam.new
28
+ @team.stub!(:id => 1)
29
+
30
+ Person.should_receive(:search).with do |query, options|
31
+ options[:with][:team_id].should == @team.id
32
+ end
33
+
34
+ @team.people.search "test"
35
+ end
36
+
37
+ it "should define indexes for the reflection class" do
38
+ Friendship.should_receive(:define_indexes)
39
+
40
+ @person.friendships.search 'test'
41
+ end
42
+ end
43
+
44
+ describe "facets method" do
45
+ before :each do
46
+ Friendship.stub!(:facets => true)
47
+
48
+ @person = Person.find(:first)
49
+ @index = Friendship.sphinx_indexes.first
50
+ end
51
+
52
+ it "should raise an error if the required attribute doesn't exist" do
53
+ @index.stub!(:attributes => [])
54
+
55
+ lambda { @person.friendships.facets "test" }.should raise_error(RuntimeError)
56
+ end
57
+
58
+ it "should add a filter for the attribute into a normal facets call" do
59
+ Friendship.should_receive(:facets) do |query, options|
60
+ options[:with][:person_id].should == @person.id
61
+ end
62
+
63
+ @person.friendships.facets "test"
64
+ end
65
+
66
+ it "should add a filter for an aliased attribute into a normal facets call" do
67
+ @team = CricketTeam.new
68
+ @team.stub!(:id => 1)
69
+
70
+ Person.should_receive(:facets).with do |query, options|
71
+ options[:with][:team_id].should == @team.id
72
+ end
73
+
74
+ @team.people.facets "test"
75
+ end
76
+
77
+ it "should define indexes for the reflection class" do
78
+ Friendship.should_receive(:define_indexes)
79
+
80
+ @person.friendships.facets 'test'
81
+ end
82
+ end
83
+
84
+ describe "search method for has_many :through" do
85
+ before :each do
86
+ Person.stub!(:search => true)
87
+
88
+ @person = Person.find(:first)
89
+ @index = Person.sphinx_indexes.first
90
+ end
91
+
92
+ it "should raise an error if the required attribute doesn't exist" do
93
+ @index.stub!(:attributes => [])
94
+
95
+ lambda { @person.friends.search "test" }.should raise_error(RuntimeError)
96
+ end
97
+
98
+ it "should add a filter for the attribute into a normal search call" do
99
+ Person.should_receive(:search).with do |query, options|
100
+ options[:with][:friendly_ids].should == @person.id
101
+ end
102
+
103
+ @person.friends.search "test"
104
+ end
105
+
106
+ it "should add a filter for an aliased attribute into a normal search call" do
107
+ @team = FootballTeam.new
108
+ @team.stub!(:id => 1)
109
+
110
+ Person.should_receive(:search).with do |query, options|
111
+ options[:with][:football_team_id].should == @team.id
112
+ end
113
+
114
+ @team.people.search "test"
115
+ end
116
+ end
117
+
118
+ describe "facets method for has_many :through" do
119
+ before :each do
120
+ Person.stub!(:facets => true)
121
+
122
+ @person = Person.find(:first)
123
+ @index = Person.sphinx_indexes.first
124
+ end
125
+
126
+ it "should raise an error if the required attribute doesn't exist" do
127
+ @index.stub!(:attributes => [])
128
+
129
+ lambda { @person.friends.facets "test" }.should raise_error(RuntimeError)
130
+ end
131
+
132
+ it "should add a filter for the attribute into a normal facets call" do
133
+ Person.should_receive(:facets).with do |query, options|
134
+ options[:with][:friendly_ids].should == @person.id
135
+ end
136
+
137
+ @person.friends.facets "test"
138
+ end
139
+
140
+ it "should add a filter for an aliased attribute into a normal facets call" do
141
+ @team = FootballTeam.new
142
+ @team.stub!(:id => 1)
143
+
144
+ Person.should_receive(:facets).with do |query, options|
145
+ options[:with][:football_team_id].should == @team.id
146
+ end
147
+
148
+ @team.people.facets "test"
149
+ end
150
+ end
151
+
152
+ describe 'filtering sphinx scopes' do
153
+ before :each do
154
+ Friendship.stub!(:search => Friendship)
155
+
156
+ @person = Person.find(:first)
157
+ end
158
+
159
+ it "should add a filter for the attribute in a sphinx scope call" do
160
+ Friendship.should_receive(:search).with do |options|
161
+ options[:with][:person_id].should == @person.id
162
+ Friendship
163
+ end
164
+
165
+ @person.friendships.reverse
166
+ end
167
+
168
+ it "should pass method_missing onto CollectionProxy" do
169
+ Friendship.stub!(:missing_method => true)
170
+ @person.friendships.missing_method.should == true
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,176 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThinkingSphinx::ActiveRecord::Scopes do
4
+ after :each do
5
+ Alpha.remove_sphinx_scopes
6
+ end
7
+
8
+ it "should be included into models with indexes" do
9
+ Alpha.included_modules.should include(ThinkingSphinx::ActiveRecord::Scopes)
10
+ end
11
+
12
+ it "should not be included into models without indexes" do
13
+ Gamma.included_modules.should_not include(
14
+ ThinkingSphinx::ActiveRecord::Scopes
15
+ )
16
+ end
17
+
18
+ describe '.sphinx_scope' do
19
+ before :each do
20
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
21
+ end
22
+
23
+ it "should define a method on the model" do
24
+ Alpha.should respond_to(:by_name)
25
+ end
26
+ end
27
+
28
+ describe '.sphinx_scopes' do
29
+ before :each do
30
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
31
+ end
32
+
33
+ it "should return an array of defined scope names as symbols" do
34
+ Alpha.sphinx_scopes.should == [:by_name]
35
+ end
36
+ end
37
+
38
+ describe '.default_sphinx_scope' do
39
+ before :each do
40
+ Alpha.sphinx_scope(:scope_used_as_default_scope) { {:conditions => {:name => 'name'}} }
41
+ Alpha.default_sphinx_scope :scope_used_as_default_scope
42
+ end
43
+
44
+ it "should return an array of defined scope names as symbols" do
45
+ Alpha.sphinx_scopes.should == [:scope_used_as_default_scope]
46
+ end
47
+
48
+ it "should have a default_sphinx_scope" do
49
+ Alpha.has_default_sphinx_scope?.should be_true
50
+ end
51
+ end
52
+
53
+ describe '.remove_sphinx_scopes' do
54
+ before :each do
55
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
56
+ Alpha.remove_sphinx_scopes
57
+ end
58
+
59
+ it "should remove sphinx scope methods" do
60
+ Alpha.should_not respond_to(:by_name)
61
+ end
62
+
63
+ it "should empty the list of sphinx scopes" do
64
+ Alpha.sphinx_scopes.should be_empty
65
+ end
66
+ end
67
+
68
+ describe '.example_default_scope' do
69
+ before :each do
70
+ Alpha.sphinx_scope(:foo_scope){ {:conditions => {:name => 'foo'}} }
71
+ Alpha.default_sphinx_scope :foo_scope
72
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
73
+ Alpha.sphinx_scope(:by_foo) { |foo| {:conditions => {:foo => foo}} }
74
+ end
75
+
76
+ it "should return a ThinkingSphinx::Search object" do
77
+ Alpha.search.should be_a(ThinkingSphinx::Search)
78
+ end
79
+
80
+ it "should apply the default scope options to the underlying search object" do
81
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
82
+ search.search.options[:conditions].should == {:name => 'foo'}
83
+ end
84
+
85
+ it "should apply the default scope options and scope options to the underlying search object" do
86
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
87
+ search.by_foo('foo').search.options[:conditions].should == {:foo => 'foo', :name => 'foo'}
88
+ end
89
+
90
+ it "should apply the default scope options before other scope options to the underlying search object" do
91
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
92
+ search.by_name('bar').search.options[:conditions].should == {:name => 'bar'}
93
+ end
94
+ end
95
+
96
+ describe '.example_scope' do
97
+ before :each do
98
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
99
+ Alpha.sphinx_scope(:by_foo) { |foo| {:conditions => {:foo => foo}} }
100
+ Alpha.sphinx_scope(:with_betas) { {:classes => [Beta]} }
101
+ end
102
+
103
+ it "should return a ThinkingSphinx::Search object" do
104
+ Alpha.by_name('foo').should be_a(ThinkingSphinx::Search)
105
+ end
106
+
107
+ it "should set the classes option" do
108
+ Alpha.by_name('foo').options[:classes].should == [Alpha]
109
+ end
110
+
111
+ it "should be able to be called on a ThinkingSphinx::Search object" do
112
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
113
+ lambda {
114
+ search.by_name('foo')
115
+ }.should_not raise_error
116
+ end
117
+
118
+ it "should return the search object it gets called upon" do
119
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
120
+ search.by_name('foo').object_id.should == search.object_id
121
+ end
122
+
123
+ it "should apply the scope options to the underlying search object" do
124
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
125
+ search.by_name('foo').options[:conditions].should == {:name => 'foo'}
126
+ end
127
+
128
+ it "should combine hash option scopes such as :conditions" do
129
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
130
+ search.by_name('foo').by_foo('bar').options[:conditions].
131
+ should == {:name => 'foo', :foo => 'bar'}
132
+ end
133
+
134
+ it "should combine array option scopes such as :classes" do
135
+ search = ThinkingSphinx::Search.new(:classes => [Alpha])
136
+ search.with_betas.options[:classes].should == [Alpha, Beta]
137
+ end
138
+ end
139
+
140
+ describe '.search_count_with_scope' do
141
+ before :each do
142
+ @config = ThinkingSphinx::Configuration.instance
143
+ @client = Riddle::Client.new
144
+
145
+ @config.stub!(:client => @client)
146
+ @client.stub!(:query => {:matches => [], :total_found => 43})
147
+ Alpha.sphinx_scope(:by_name) { |name| {:conditions => {:name => name}} }
148
+ Alpha.sphinx_scope(:ids_only) { {:ids_only => true} }
149
+ end
150
+
151
+ it "should return the total number of results" do
152
+ Alpha.by_name('foo').search_count.should == 43
153
+ end
154
+
155
+ it "should not make any calls to the database" do
156
+ Alpha.should_not_receive(:find)
157
+
158
+ Alpha.by_name('foo').search_count
159
+ end
160
+
161
+ it "should not leave the :ids_only option set and the results populated if it was not set before" do
162
+ stored_scope = Alpha.by_name('foo')
163
+ stored_scope.search_count
164
+ stored_scope.options[:ids_only].should be_false
165
+ stored_scope.populated?.should be_false
166
+ end
167
+
168
+ it "should leave the :ids_only option set and the results populated if it was set before" do
169
+ stored_scope = Alpha.by_name('foo').ids_only
170
+ stored_scope.search_count
171
+ stored_scope.options[:ids_only].should be_true
172
+ stored_scope.populated?.should be_true
173
+ end
174
+ end
175
+
176
+ end