census 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,12 +5,12 @@ module Census
5
5
  end
6
6
 
7
7
  def perform
8
- results = []
8
+ results = nil
9
9
  @options.each_pair do |question, value|
10
10
  users = question.find_answers_matching(value).map(&:user)
11
- results = results.empty? ? users : results & users
11
+ results = results ? results & users : users
12
12
  end
13
- results
13
+ results || []
14
14
  end
15
15
  end
16
16
  end
@@ -19,20 +19,23 @@ class SearchTest < ActiveSupport::TestCase
19
19
  @non_matching_user = Factory(:user)
20
20
  Factory(:answer, :user => @non_matching_user, :question => @question1, :data => 'Blond')
21
21
  Factory(:answer, :user => @non_matching_user, :question => @question2, :data => '200')
22
-
23
- @search = Census::Search.new(@question1 => 'Brown', @question2 => 145..165)
24
22
  end
25
23
 
26
24
  should "find the matching user" do
27
- results = @search.perform
25
+ results = Census::Search.new(@question1 => 'Brown', @question2 => 145..165).perform
28
26
  assert results.include?(@matching_user)
29
27
  end
30
28
 
31
29
  should "not find the other users" do
32
- results = @search.perform
30
+ results = Census::Search.new(@question1 => 'Brown', @question2 => 145..165).perform
33
31
  assert !results.include?(@non_matching_user)
34
32
  assert !results.include?(@partial_match_user)
35
33
  end
34
+
35
+ should "not find any users" do
36
+ results = Census::Search.new(@question1 => 'Blue', @question2 => 145..165).perform
37
+ assert results.empty?
38
+ end
36
39
 
37
40
  end
38
41
 
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # It's strongly recommended to check this file into your version control system.
11
11
 
12
- ActiveRecord::Schema.define(:version => 20100408132452) do
12
+ ActiveRecord::Schema.define(:version => 20100408172932) do
13
13
 
14
14
  create_table "answers", :force => true do |t|
15
15
  t.integer "question_id"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark Kendall
@@ -169,7 +169,7 @@ test_files:
169
169
  - test/rails_root/config/initializers/new_rails_defaults.rb
170
170
  - test/rails_root/config/initializers/session_store.rb
171
171
  - test/rails_root/config/routes.rb
172
- - test/rails_root/db/migrate/20100408132452_create_census_tables.rb
172
+ - test/rails_root/db/migrate/20100408172932_create_census_tables.rb
173
173
  - test/rails_root/db/schema.rb
174
174
  - test/rails_root/test/factories/census.rb
175
175
  - test/rails_root/test/performance/browsing_test.rb