oss_active_record 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/oss_active_record/search_request.rb +13 -13
- data/lib/oss_active_record/searchable.rb +29 -13
- data/lib/oss_active_record/version.rb +1 -1
- data/test/dummy/app/models/article.rb +1 -0
- data/test/dummy/app/models/document.rb +2 -1
- data/test/dummy/config/initializers/oss_active_record.rb +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130901161100_create_articles.rb +1 -0
- data/test/dummy/db/schema.rb +1 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +66 -0
- data/test/dummy/log/test.log +5190 -0
- data/test/dummy/test/fixtures/articles.yml +13 -4
- data/test/dummy/test/fixtures/documents.yml +9 -9
- data/test/dummy/test/models/article_test.rb +43 -13
- data/test/dummy/test/models/document_test.rb +12 -6
- data/test/e +0 -0
- metadata +26 -7
@@ -2,12 +2,21 @@
|
|
2
2
|
|
3
3
|
one:
|
4
4
|
id: 1
|
5
|
-
title:
|
6
|
-
content:
|
5
|
+
title: Weather report
|
6
|
+
content: Sunny weather today
|
7
|
+
category_id: 1
|
7
8
|
updated_at: 2013-07-11 17:06:19
|
8
9
|
|
9
10
|
two:
|
10
11
|
id: 2
|
11
|
-
title:
|
12
|
-
content:
|
12
|
+
title: Active record rocks
|
13
|
+
content: Using OpenSearchServer with active record is simple
|
14
|
+
category_id: 2
|
13
15
|
updated_at: 2013-07-11 17:06:19
|
16
|
+
|
17
|
+
three:
|
18
|
+
id: 3
|
19
|
+
title: Breaking news
|
20
|
+
content: A new version should be available soon
|
21
|
+
category_id: 1000
|
22
|
+
updated_at: 2013-07-11 17:06:19
|
@@ -4,22 +4,22 @@ one:
|
|
4
4
|
id: 1
|
5
5
|
folder_id: 1
|
6
6
|
room_id: 1
|
7
|
-
name:
|
7
|
+
name: my wonderful document
|
8
8
|
updated_at: 2013-07-11 17:06:19
|
9
9
|
uuid: 1
|
10
10
|
user_id: 1
|
11
11
|
file_size: 1
|
12
|
-
file_content_type:
|
12
|
+
file_content_type: application/pdf
|
13
13
|
state: MyString
|
14
14
|
|
15
15
|
two:
|
16
|
-
id:
|
17
|
-
folder_id:
|
18
|
-
room_id:
|
19
|
-
name:
|
16
|
+
id: 2
|
17
|
+
folder_id: 2
|
18
|
+
room_id: 2
|
19
|
+
name: another amazing document
|
20
20
|
updated_at: 2013-07-11 17:06:19
|
21
21
|
uuid: 1
|
22
|
-
user_id:
|
23
|
-
file_size:
|
24
|
-
file_content_type:
|
22
|
+
user_id: 2
|
23
|
+
file_size: 2
|
24
|
+
file_content_type: application/xml
|
25
25
|
state: MyString
|
@@ -1,18 +1,48 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
class ArticleTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
fixtures :articles
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Article.reindex!
|
8
|
+
end
|
9
|
+
|
10
|
+
test "Full text search" do
|
11
|
+
|
12
|
+
results = Article.search do
|
13
|
+
fulltext 'weather'
|
14
|
+
end
|
15
|
+
|
16
|
+
puts results.inspect
|
17
|
+
assert results.length == 1, 'The number of result is wrong, should be one'
|
18
|
+
assert results[0][:title] == 'Weather report', 'The returned title is wrong'
|
16
19
|
end
|
17
|
-
|
20
|
+
|
21
|
+
test "Ascending order" do
|
22
|
+
|
23
|
+
results = Article.search do
|
24
|
+
order_by :category_id, :asc
|
25
|
+
end
|
26
|
+
|
27
|
+
cat_id = nil
|
28
|
+
results.each do |article|
|
29
|
+
assert(cat_id <= article[:category_id], 'Order is wrong') unless cat_id.nil?
|
30
|
+
cat_id = article[:category_id]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
test "Descending order" do
|
35
|
+
|
36
|
+
results = Article.search do
|
37
|
+
order_by :category_id, :desc
|
38
|
+
end
|
39
|
+
|
40
|
+
cat_id = nil
|
41
|
+
results.each do |article|
|
42
|
+
assert(cat_id >= article[:category_id], 'Order is wrong') unless cat_id.nil?
|
43
|
+
cat_id = article[:category_id]
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
18
48
|
end
|
@@ -1,19 +1,25 @@
|
|
1
1
|
require_relative '../../../test_helper'
|
2
2
|
|
3
3
|
class DocumentTest < ActiveSupport::TestCase
|
4
|
+
fixtures :documents
|
5
|
+
|
6
|
+
setup do
|
7
|
+
Document.reindex!
|
8
|
+
end
|
9
|
+
|
4
10
|
test "the truth" do
|
5
11
|
assert true
|
6
12
|
end
|
7
13
|
|
8
|
-
test "Search" do
|
9
|
-
|
10
|
-
fulltext '
|
11
|
-
with
|
14
|
+
test "Search document" do
|
15
|
+
result = Document.search(:include => { :current_revision => :user }) do
|
16
|
+
fulltext 'document'
|
17
|
+
with(:room_id, 42)
|
18
|
+
without(:room_id, 43)
|
12
19
|
paginate page: 1, per_page: 10
|
13
20
|
order_by :score, :desc
|
14
21
|
order_by :id
|
15
22
|
end
|
16
|
-
|
17
|
-
assert true
|
23
|
+
assert result.length == 2, 'The number of document returned is wrong'
|
18
24
|
end
|
19
25
|
end
|
data/test/e
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oss_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ori Pekelman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 4.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: oss_rb
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.1.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.1.0
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: sqlite3
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,8 @@ dependencies:
|
|
39
53
|
- - '>='
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '0'
|
42
|
-
description:
|
56
|
+
description: oss_active_record is a library providing an all-ruby API for the OpenSearchServer
|
57
|
+
search engine.
|
43
58
|
email:
|
44
59
|
- ori@pekelman.com
|
45
60
|
- ekeller@open-search-server.com
|
@@ -101,12 +116,15 @@ files:
|
|
101
116
|
- test/dummy/test/fixtures/documents.yml
|
102
117
|
- test/dummy/test/models/article_test.rb
|
103
118
|
- test/dummy/test/models/document_test.rb
|
119
|
+
- test/e
|
104
120
|
- test/oss_active_record_test.rb
|
105
121
|
- test/searchable_test.rb
|
106
122
|
- test/test_helper.rb
|
107
|
-
homepage:
|
108
|
-
licenses:
|
109
|
-
|
123
|
+
homepage: https://github.com/jaeksoft/oss_active_record
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata:
|
127
|
+
Issues: https://github.com/jaeksoft/oss_active_record/issues
|
110
128
|
post_install_message:
|
111
129
|
rdoc_options: []
|
112
130
|
require_paths:
|
@@ -123,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
141
|
version: '0'
|
124
142
|
requirements: []
|
125
143
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.0.
|
144
|
+
rubygems_version: 2.0.7
|
127
145
|
signing_key:
|
128
146
|
specification_version: 4
|
129
147
|
summary: OpenSearchServer ActiveRecord integration
|
@@ -175,6 +193,7 @@ test_files:
|
|
175
193
|
- test/dummy/test/fixtures/documents.yml
|
176
194
|
- test/dummy/test/models/article_test.rb
|
177
195
|
- test/dummy/test/models/document_test.rb
|
196
|
+
- test/e
|
178
197
|
- test/oss_active_record_test.rb
|
179
198
|
- test/searchable_test.rb
|
180
199
|
- test/test_helper.rb
|