census 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.
|
1
|
+
0.3.1
|
data/lib/census/search.rb
CHANGED
@@ -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
|
11
|
+
results = results ? results & users : users
|
12
12
|
end
|
13
|
-
results
|
13
|
+
results || []
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/test/models/search_test.rb
CHANGED
@@ -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 = @
|
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 = @
|
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
|
|
File without changes
|
@@ -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 =>
|
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
|
-
-
|
9
|
-
version: 0.3.
|
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/
|
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
|