acts_as_ferret 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -0
- data/doc/demo/Gemfile +18 -0
- data/doc/demo/Rakefile +3 -6
- data/doc/demo/app/controllers/application_controller.rb +3 -0
- data/doc/demo/app/helpers/application_helper.rb +0 -1
- data/doc/demo/app/views/admin/backend/search.rhtml +1 -1
- data/doc/demo/app/views/contents/edit.rhtml +1 -1
- data/doc/demo/app/views/contents/new.rhtml +1 -1
- data/doc/demo/app/views/searches/search.html.erb +1 -1
- data/doc/demo/config.ru +4 -0
- data/doc/demo/config/application.rb +57 -0
- data/doc/demo/config/boot.rb +4 -107
- data/doc/demo/config/database.yml +16 -24
- data/doc/demo/config/environment.rb +4 -68
- data/doc/demo/config/environments/development.rb +22 -12
- data/doc/demo/config/environments/production.rb +43 -13
- data/doc/demo/config/environments/test.rb +32 -16
- data/doc/demo/config/initializers/backtrace_silencers.rb +7 -0
- data/doc/demo/config/initializers/inflections.rb +10 -0
- data/doc/demo/config/initializers/mime_types.rb +5 -0
- data/doc/demo/config/initializers/secret_token.rb +7 -0
- data/doc/demo/config/initializers/session_store.rb +13 -0
- data/doc/demo/config/locales/en.yml +5 -0
- data/doc/demo/config/routes.rb +4 -5
- data/doc/demo/public/404.html +23 -5
- data/doc/demo/public/422.html +26 -0
- data/doc/demo/public/500.html +23 -5
- data/doc/demo/public/images/rails.png +0 -0
- data/doc/demo/public/index.html +50 -88
- data/doc/demo/public/javascripts/application.js +2 -0
- data/doc/demo/public/javascripts/controls.js +965 -0
- data/doc/demo/public/javascripts/dragdrop.js +974 -0
- data/doc/demo/public/javascripts/effects.js +1123 -0
- data/doc/demo/public/javascripts/prototype.js +6001 -0
- data/doc/demo/public/javascripts/rails.js +191 -0
- data/doc/demo/public/robots.txt +5 -1
- data/doc/demo/script/rails +6 -0
- data/doc/demo/test/functional/admin/backend_controller_test.rb +1 -1
- data/doc/demo/test/functional/contents_controller_test.rb +1 -2
- data/doc/demo/test/functional/searches_controller_test.rb +1 -2
- data/doc/demo/test/performance/browsing_test.rb +9 -0
- data/doc/demo/test/test_helper.rb +13 -18
- data/doc/demo/test/unit/comment_test.rb +4 -4
- data/doc/demo/test/unit/content_test.rb +6 -4
- data/doc/demo/test/unit/ferret_result_test.rb +2 -3
- data/doc/demo/test/unit/multi_index_test.rb +2 -3
- data/doc/demo/test/unit/remote_index_test.rb +2 -2
- data/doc/demo/test/unit/shared_index1_test.rb +2 -3
- data/doc/demo/test/unit/shared_index2_test.rb +2 -3
- data/doc/demo/test/unit/sort_test.rb +2 -2
- data/doc/demo/test/unit/special_content_test.rb +3 -4
- data/lib/acts_as_ferret.rb +17 -3
- data/lib/acts_as_ferret/blank_slate.rb +11 -10
- data/lib/acts_as_ferret/class_methods.rb +9 -7
- data/lib/acts_as_ferret/ferret_find_methods.rb +5 -1
- data/lib/acts_as_ferret/ferret_result.rb +11 -4
- data/lib/acts_as_ferret/multi_index.rb +8 -1
- data/lib/acts_as_ferret/search_results.rb +0 -1
- data/lib/acts_as_ferret/version.rb +1 -1
- metadata +23 -44
- data/doc/demo/test/fixtures/remote_contents.yml +0 -9
- data/doc/demo/vendor/plugins/will_paginate/LICENSE +0 -18
- data/doc/demo/vendor/plugins/will_paginate/README +0 -108
- data/doc/demo/vendor/plugins/will_paginate/Rakefile +0 -23
- data/doc/demo/vendor/plugins/will_paginate/init.rb +0 -21
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +0 -45
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +0 -44
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +0 -159
- data/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +0 -95
- data/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb +0 -23
- data/doc/demo/vendor/plugins/will_paginate/test/boot.rb +0 -27
- data/doc/demo/vendor/plugins/will_paginate/test/console +0 -10
- data/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb +0 -219
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb +0 -3
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml +0 -24
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb +0 -23
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb +0 -11
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +0 -13
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb +0 -4
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml +0 -7
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml +0 -20
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb +0 -5
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql +0 -44
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb +0 -19
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml +0 -30
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb +0 -2
- data/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml +0 -35
- data/doc/demo/vendor/plugins/will_paginate/test/helper.rb +0 -42
- data/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +0 -64
- data/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +0 -10
- data/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb +0 -136
@@ -0,0 +1,191 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
Ajax.Responders.register({
|
177
|
+
onCreate: function(request) {
|
178
|
+
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
|
179
|
+
|
180
|
+
if (csrf_meta_tag) {
|
181
|
+
var header = 'X-CSRF-Token',
|
182
|
+
token = csrf_meta_tag.readAttribute('content');
|
183
|
+
|
184
|
+
if (!request.options.requestHeaders) {
|
185
|
+
request.options.requestHeaders = {};
|
186
|
+
}
|
187
|
+
request.options.requestHeaders[header] = token;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
});
|
191
|
+
})();
|
data/doc/demo/public/robots.txt
CHANGED
@@ -1 +1,5 @@
|
|
1
|
-
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
1
|
+
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
2
|
+
#
|
3
|
+
# To ban all spiders from the entire site uncomment the next two lines:
|
4
|
+
# User-Agent: *
|
5
|
+
# Disallow: /
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -4,7 +4,7 @@ require 'admin/backend_controller'
|
|
4
4
|
# Re-raise errors caught by the controller.
|
5
5
|
class Admin::BackendController; def rescue_action(e) raise e end; end
|
6
6
|
|
7
|
-
class Admin::BackendControllerTest <
|
7
|
+
class Admin::BackendControllerTest < ActionController::TestCase
|
8
8
|
def setup
|
9
9
|
@controller = Admin::BackendController.new
|
10
10
|
@request = ActionController::TestRequest.new
|
@@ -4,8 +4,7 @@ require 'contents_controller'
|
|
4
4
|
# Re-raise errors caught by the controller.
|
5
5
|
class ContentsController; def rescue_action(e) raise e end; end
|
6
6
|
|
7
|
-
class ContentsControllerTest <
|
8
|
-
fixtures :contents
|
7
|
+
class ContentsControllerTest < ActionController::TestCase
|
9
8
|
|
10
9
|
def setup
|
11
10
|
@controller = ContentsController.new
|
@@ -4,8 +4,7 @@ require 'searches_controller'
|
|
4
4
|
# Re-raise errors caught by the controller.
|
5
5
|
class SearchesController; def rescue_action(e) raise e end; end
|
6
6
|
|
7
|
-
class SearchesControllerTest <
|
8
|
-
fixtures :contents
|
7
|
+
class SearchesControllerTest < ActionController::TestCase
|
9
8
|
|
10
9
|
def setup
|
11
10
|
@controller = SearchesController.new
|
@@ -1,30 +1,25 @@
|
|
1
1
|
ENV["RAILS_ENV"] = "test"
|
2
|
-
require File.expand_path(
|
3
|
-
require 'test_help'
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
4
|
|
5
|
-
class
|
6
|
-
#
|
7
|
-
# in a transaction that's rolled back on completion. This ensures that the
|
8
|
-
# test database remains unchanged so your fixtures don't have to be reloaded
|
9
|
-
# between every test method. Fewer database queries means faster tests.
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
10
7
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
self.use_transactional_fixtures = false
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
9
|
+
# -- they do not yet inherit this setting
|
10
|
+
fixtures :all
|
11
|
+
|
12
|
+
# The only drawback to using transactional fixtures is when you actually
|
13
|
+
# need to test transactions. Since your test is bracketed by a transaction,
|
14
|
+
# any transactions started in your code will be automatically rolled back.
|
15
|
+
use_transactional_fixtures = false
|
20
16
|
|
21
17
|
# Instantiated fixtures are slow, but give you @david where otherwise you
|
22
18
|
# would need people(:david). If you don't want to migrate your existing
|
23
19
|
# test cases which use the @david style and don't mind the speed hit (each
|
24
20
|
# instantiated fixtures translates to a database query per test method),
|
25
21
|
# then set this back to true.
|
26
|
-
|
22
|
+
use_instantiated_fixtures = false
|
27
23
|
|
28
24
|
# Add more helper methods to be used by all tests here...
|
29
25
|
end
|
30
|
-
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
class CommentTest < ActiveSupport::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
7
|
Comment.rebuild_index
|
@@ -34,7 +34,7 @@ class CommentTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_class_index_dir
|
37
|
-
assert Comment.aaf_configuration[:index_dir] =~ %r{
|
37
|
+
assert Comment.aaf_configuration[:index_dir] =~ %r{^./index/test/comment}
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_aliased_field
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
3
|
require 'pp'
|
3
4
|
require 'fileutils'
|
4
5
|
|
5
|
-
|
6
|
+
|
7
|
+
class ContentTest < ActiveSupport::TestCase
|
6
8
|
include Ferret::Index
|
7
9
|
include Ferret::Search
|
8
|
-
fixtures :contents, :comments
|
9
10
|
|
10
11
|
def setup
|
11
12
|
#make sure the fixtures are in the index
|
@@ -299,7 +300,7 @@ class ContentTest < Test::Unit::TestCase
|
|
299
300
|
end
|
300
301
|
|
301
302
|
def test_class_index_dir
|
302
|
-
assert Content.aaf_configuration[:index_dir] =~ %r{
|
303
|
+
assert Content.aaf_configuration[:index_dir] =~ %r{./index/test/content_base}
|
303
304
|
end
|
304
305
|
|
305
306
|
def test_update
|
@@ -554,6 +555,7 @@ class ContentTest < Test::Unit::TestCase
|
|
554
555
|
|
555
556
|
r = Content.find_with_ferret 'title', { :limit => 10, :offset => 0 },
|
556
557
|
{ :conditions => "description != '0'", :order => 'title ASC' }
|
558
|
+
|
557
559
|
assert_equal 29, r.total_hits
|
558
560
|
assert_equal 10, r.size
|
559
561
|
assert_equal "1", r.first.description
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
require 'pp'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
class FerretResultTest <
|
6
|
-
fixtures :contents
|
5
|
+
class FerretResultTest < ActiveSupport::TestCase
|
7
6
|
|
8
7
|
def teardown
|
9
8
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
require 'pp'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
class MultiIndexTest <
|
5
|
+
class MultiIndexTest < ActiveSupport::TestCase
|
6
6
|
include Ferret::Index
|
7
7
|
include Ferret::Search
|
8
|
-
fixtures :contents, :comments
|
9
8
|
|
10
9
|
def setup
|
11
10
|
#make sure the fixtures are in the index
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
|
3
|
-
class RemoteIndexTest <
|
3
|
+
class RemoteIndexTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
5
|
ActsAsFerret::remote = 'druby://localhost:9999'
|
6
6
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
|
3
|
-
class SharedIndex1Test <
|
4
|
-
fixtures :shared_index1s, :shared_index2s
|
3
|
+
class SharedIndex1Test < ActiveSupport::TestCase
|
5
4
|
|
6
5
|
def setup
|
7
6
|
SharedIndex1.rebuild_index
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
|
3
|
-
class SharedIndex2Test <
|
4
|
-
fixtures :shared_index2s, :shared_index1s
|
3
|
+
class SharedIndex2Test < ActiveSupport::TestCase
|
5
4
|
|
6
5
|
def setup
|
7
6
|
SharedIndex1.rebuild_index
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
2
2
|
|
3
|
-
class SpecialContentTest <
|
3
|
+
class SpecialContentTest < ActiveSupport::TestCase
|
4
4
|
include Ferret::Index
|
5
5
|
include Ferret::Search
|
6
|
-
fixtures :contents, :comments
|
7
6
|
|
8
7
|
def setup
|
9
8
|
ContentBase.rebuild_index
|
@@ -11,7 +10,7 @@ class SpecialContentTest < Test::Unit::TestCase
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_class_index_dir
|
14
|
-
assert SpecialContent.aaf_configuration[:index_dir] =~ %r{
|
13
|
+
assert SpecialContent.aaf_configuration[:index_dir] =~ %r{^./index/test/content_base}
|
15
14
|
end
|
16
15
|
|
17
16
|
def test_find_with_ferret
|
data/lib/acts_as_ferret.rb
CHANGED
@@ -474,8 +474,8 @@ module ActsAsFerret
|
|
474
474
|
end
|
475
475
|
|
476
476
|
# fetch
|
477
|
-
|
478
|
-
|
477
|
+
options = find_options.merge(:conditions => conditions, :include => filtered_include_options)
|
478
|
+
tmp_result = model_class.where(options[:conditions]).includes(options[:include]).order(options[:order]).limit(options[:limit]).offset(options[:offset])
|
479
479
|
|
480
480
|
# set scores and rank
|
481
481
|
tmp_result.each do |record|
|
@@ -493,7 +493,21 @@ module ActsAsFerret
|
|
493
493
|
|
494
494
|
# combine our conditions with those given by user, if any
|
495
495
|
def self.combine_conditions(conditions, additional_conditions = [])
|
496
|
-
|
496
|
+
|
497
|
+
any_additional_conditions = false
|
498
|
+
|
499
|
+
if additional_conditions
|
500
|
+
if additional_conditions.kind_of?(Enumerable)
|
501
|
+
# We are pre-ruby 1.9.x
|
502
|
+
any_additional_conditions = additional_conditions.any?
|
503
|
+
else
|
504
|
+
# This ruby 1.9.x - String is no longer an Enumerable
|
505
|
+
# http://www.ivanenviroman.com/string-is-not-an-enumerable-in-ruby-1-9/
|
506
|
+
any_additional_conditions = ! additional_conditions.empty?
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
if any_additional_conditions
|
497
511
|
cust_opts = (Array === additional_conditions) ? additional_conditions.dup : [ additional_conditions ]
|
498
512
|
logger.debug "cust_opts: #{cust_opts.inspect}"
|
499
513
|
conditions.first << " and " << cust_opts.shift
|