lucid_works 0.7.10 → 0.7.15
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/config/locales/en.yml +45 -7
- data/lib/lucid_works/activity/history.rb +2 -6
- data/lib/lucid_works/base.rb +2 -1
- data/lib/lucid_works/collection.rb +1 -1
- data/lib/lucid_works/crawler.rb +1 -1
- data/lib/lucid_works/datasource.rb +0 -1
- data/lib/lucid_works/datasource_type.rb +23 -2
- data/lib/lucid_works/field.rb +62 -20
- data/lib/lucid_works/gem_version.rb +1 -1
- data/spec/lib/lucid_works/field_spec.rb +112 -72
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/config/locales/en.yml
CHANGED
@@ -42,7 +42,7 @@ en:
|
|
42
42
|
index_time_stopwords: Exclude stop words from index
|
43
43
|
query_parser: Query parser
|
44
44
|
query_time_stopwords: Include stop words in searches
|
45
|
-
query_time_synonyms: Use
|
45
|
+
query_time_synonyms: Use synonyms
|
46
46
|
search_server_list: Search server list
|
47
47
|
show_similar: Show "find similar" links
|
48
48
|
spellcheck: Spell-check
|
@@ -54,6 +54,9 @@ en:
|
|
54
54
|
unsupervised_feedback_emphasis: Unsupervised feedback emphasis
|
55
55
|
update_server_list: Update server list
|
56
56
|
datasource:
|
57
|
+
subtype:
|
58
|
+
web:
|
59
|
+
url: Custom legend for url
|
57
60
|
aliases: Site Aliases Mappings
|
58
61
|
auth: Authentication credentials
|
59
62
|
authorization: Authorization
|
@@ -83,7 +86,6 @@ en:
|
|
83
86
|
log_extra_detail: Log extra detail
|
84
87
|
max_bytes: Skip files larger than (bytes)
|
85
88
|
my_site_base_url: MySite URL
|
86
|
-
no_duplicates: Suppress duplicates
|
87
89
|
password: Password
|
88
90
|
proxy_host: Proxy host
|
89
91
|
proxy_password: Proxy password
|
@@ -121,7 +123,7 @@ en:
|
|
121
123
|
include_in_results: Include in results
|
122
124
|
index_for_autocomplete: Index for autocomplete
|
123
125
|
index_for_spellcheck: Index for spell checking
|
124
|
-
|
126
|
+
indexing_options: Index term frequencies and positions
|
125
127
|
indexed: Indexed
|
126
128
|
multi_valued: Multi-valued
|
127
129
|
name: Name
|
@@ -194,7 +196,7 @@ en:
|
|
194
196
|
field:
|
195
197
|
one: Field
|
196
198
|
other: Fields
|
197
|
-
|
199
|
+
indexing_options:
|
198
200
|
document_only: none
|
199
201
|
document_termfreq: term frequencies
|
200
202
|
document_termfreq_termpos: term frequencies and positions
|
@@ -212,14 +214,50 @@ en:
|
|
212
214
|
collection:
|
213
215
|
name: ! 'Collection names may use the characters: A-Z, a-z, 0-9, dash and
|
214
216
|
underscore'
|
217
|
+
|
215
218
|
datasource:
|
216
219
|
crawl_depth: Leave blank or set to -1 to crawl with no depth limit.
|
217
220
|
exclude_paths: A list of regular expressions, one per line, e.g. .*\.pdf will
|
218
221
|
ignore filenames ending in .pdf.
|
219
|
-
include_paths: A list of regular expressions, one per line
|
220
|
-
will match everything within the site only.
|
222
|
+
include_paths: A list of regular expressions, one per line.
|
221
223
|
max_bytes: Default = 10 MiB. Set to -1 to indicate no file size limit.
|
222
|
-
|
224
|
+
|
225
|
+
# Custom datasource hints
|
226
|
+
external:
|
227
|
+
file:
|
228
|
+
datasource:
|
229
|
+
path: Full pathname to folder
|
230
|
+
ftp:
|
231
|
+
hdfs:
|
232
|
+
datasource:
|
233
|
+
url: "Please include protocol: hdfs://<hostname>"
|
234
|
+
jdbc:
|
235
|
+
datasource:
|
236
|
+
delta_sql_query: "$ in this query will be replaced by the last successful import time."
|
237
|
+
driver: "Database drivers may be uploaded on the Indexing -> JDBC Drivers page.
|
238
|
+
Drivers are collection specific.
|
239
|
+
JDBC4 drivers will appear in the selector automatically.
|
240
|
+
To use a JDBC3 driver, select \"Other\" and enter the Java class name of the driver."
|
241
|
+
url: "e.g. jdbc:mysql://hostname/database_name"
|
242
|
+
kfs:
|
243
|
+
lucidworkslogs:
|
244
|
+
s3:
|
245
|
+
datasource:
|
246
|
+
url: "Please include protocol: s3://<hostname>/path/to/filesystem"
|
247
|
+
s3n:
|
248
|
+
datasource:
|
249
|
+
url: "Please include protocol: s3n://<hostname>/path/to/filesystem"
|
250
|
+
sharepoint:
|
251
|
+
smb:
|
252
|
+
datasource:
|
253
|
+
url: "Format: smb://<hostname or ip address>/<path to folder>/"
|
254
|
+
solrxml:
|
255
|
+
web:
|
256
|
+
datasource:
|
257
|
+
include_paths: A list of regular expressions, one per line, e.g. http://example\.com/.*
|
258
|
+
will match everything within the site only.
|
259
|
+
url: e.g. http://cnn.com. Please include protocol (http/https).
|
260
|
+
|
223
261
|
field:
|
224
262
|
copy_fields: A list of fields separated by spaces.
|
225
263
|
synonym:
|
@@ -4,12 +4,8 @@ module LucidWorks
|
|
4
4
|
belongs_to :activity
|
5
5
|
self.collection_name = 'history' # i.e. not the plural 'histories'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def activity_started
|
12
|
-
Time.iso8601 activityStarted
|
7
|
+
schema do
|
8
|
+
attributes :activity_started, :activity_finished, :type => :iso8601
|
13
9
|
end
|
14
10
|
|
15
11
|
def duration
|
data/lib/lucid_works/base.rb
CHANGED
@@ -27,6 +27,7 @@ module LucidWorks
|
|
27
27
|
# wandering through that code.
|
28
28
|
|
29
29
|
include ActiveModel::Validations
|
30
|
+
include ActiveModel::Validations::Callbacks
|
30
31
|
include ActiveModel::Conversion
|
31
32
|
extend ActiveModel::Naming
|
32
33
|
extend ActiveModel::Translation
|
@@ -294,8 +295,8 @@ module LucidWorks
|
|
294
295
|
end
|
295
296
|
|
296
297
|
def save
|
298
|
+
return false unless valid?
|
297
299
|
_run_save_callbacks do
|
298
|
-
return false unless valid?
|
299
300
|
ActiveSupport::Notifications.instrument("lucid_works.request") do |payload|
|
300
301
|
method, uri = persisted? ? [:put, member_url] : [:post, collection_url]
|
301
302
|
data = encode
|
@@ -20,7 +20,7 @@ module LucidWorks
|
|
20
20
|
"filterer.class" => "com.lucid.security.WindowsACLQueryFilterer",
|
21
21
|
"provider.class" => "com.lucid.security.ad.ADACLTagProvider",
|
22
22
|
}
|
23
|
-
MAGIC_ACL_ONLY_FILTER_SETTING = {'
|
23
|
+
MAGIC_ACL_ONLY_FILTER_SETTING = {'should_clause' => '*:* -data_source_type:smb'}
|
24
24
|
|
25
25
|
validates_presence_of :name
|
26
26
|
|
data/lib/lucid_works/crawler.rb
CHANGED
@@ -59,7 +59,6 @@ module LucidWorks
|
|
59
59
|
attribute :log_extra_detail, :boolean
|
60
60
|
attribute :fail_unsupported_file_types, :boolean
|
61
61
|
attribute :warn_unknown_mime_types, :boolean
|
62
|
-
attribute :no_duplicates, :boolean
|
63
62
|
# sharepoint
|
64
63
|
attribute :sharepoint_url
|
65
64
|
attribute :connector_type
|
@@ -2,9 +2,16 @@ module LucidWorks
|
|
2
2
|
|
3
3
|
class DatasourceType
|
4
4
|
|
5
|
-
|
5
|
+
DONT_INITIALIZE_PROPERTIES = [
|
6
|
+
"collection", # not something we can provide a default for
|
7
|
+
"name", # not something we can provide a default for
|
8
|
+
"---" # Separator UI hint
|
9
|
+
]
|
6
10
|
|
7
|
-
|
11
|
+
attr_reader :crawler, :category, :type, :props
|
12
|
+
|
13
|
+
def initialize(crawler, attributes = {})
|
14
|
+
@crawler = crawler
|
8
15
|
@category = attributes['category']
|
9
16
|
@type = attributes['type']
|
10
17
|
@props = attributes['props']
|
@@ -19,5 +26,19 @@ module LucidWorks
|
|
19
26
|
def property(name)
|
20
27
|
properties.detect { |p| p.name == name }
|
21
28
|
end
|
29
|
+
|
30
|
+
def default_attributes
|
31
|
+
attrs = {}.with_indifferent_access
|
32
|
+
properties.inject(attrs) do |hash, property|
|
33
|
+
unless DONT_INITIALIZE_PROPERTIES.include?(property.name) || property.read_only?
|
34
|
+
hash[property.name] = property.default_value
|
35
|
+
end
|
36
|
+
hash
|
37
|
+
end
|
38
|
+
attrs.merge!(
|
39
|
+
:crawler => @crawler.name,
|
40
|
+
:type => @type
|
41
|
+
)
|
42
|
+
end
|
22
43
|
end
|
23
44
|
end
|
data/lib/lucid_works/field.rb
CHANGED
@@ -9,6 +9,12 @@ module LucidWorks
|
|
9
9
|
'document_termfreq_termpos'
|
10
10
|
]
|
11
11
|
|
12
|
+
BOOST_VALUES = [
|
13
|
+
'none',
|
14
|
+
'moderate',
|
15
|
+
'high'
|
16
|
+
]
|
17
|
+
|
12
18
|
schema do
|
13
19
|
attribute :name, :string, :primary_key => true, :omit_during_update => true
|
14
20
|
attribute :editable, :boolean, :omit_during_update => true
|
@@ -24,16 +30,9 @@ module LucidWorks
|
|
24
30
|
attribute :default_boost, :integer
|
25
31
|
attributes :field_type, :short_field_boost, :term_vectors, :default_value, :type => :string
|
26
32
|
attribute :copy_fields, :list
|
27
|
-
|
28
|
-
attribute :index_term_freq_and_pos, :custom, :values => INDEXING_OPTIONS
|
33
|
+
attribute :indexing_options, :custom, :values => INDEXING_OPTIONS
|
29
34
|
end
|
30
35
|
|
31
|
-
BOOST_VALUES = [
|
32
|
-
'none',
|
33
|
-
'moderate',
|
34
|
-
'high'
|
35
|
-
]
|
36
|
-
|
37
36
|
validates_presence_of :name
|
38
37
|
validates_each :name, :unless => :persisted?, :allow_blank => true do |model, attr, value|
|
39
38
|
model.errors.add(attr, 'must be unique') if model.collection.fields.any? {|f| f.name == value }
|
@@ -53,11 +52,34 @@ module LucidWorks
|
|
53
52
|
validates_each :use_in_find_similar do |model, attr, value|
|
54
53
|
model.errors.add(attr, 'a field must be indexed for it to be used for find-similar') if value == true && !model.indexed?
|
55
54
|
end
|
55
|
+
validates_each :indexing_options do |model, attr, value|
|
56
|
+
if model.persisted?
|
57
|
+
if value
|
58
|
+
if model.indexed?
|
59
|
+
model.errors.add(attr, "must be one of #{INDEXING_OPTIONS.join(', ')}") unless INDEXING_OPTIONS.include?(value.to_s)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
# If the model is already persisted, but the user has not manually set indexing_options,
|
63
|
+
# just go with the omit_tf/omit_positions we have now.
|
64
|
+
end
|
65
|
+
else # new model
|
66
|
+
if model.indexed?
|
67
|
+
# If this is a new model, and the user set 'indexed' they MUST also set indexing_options
|
68
|
+
model.errors.add(attr, "must be one of #{INDEXING_OPTIONS.join(', ')}") unless INDEXING_OPTIONS.include?(value.to_s)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
before_save :convert_indexing_options_to_term_freq_and_pos
|
74
|
+
|
75
|
+
def initialize(options)
|
76
|
+
super(options.reverse_merge(:omit_tf => false, :short_field_boost => 'high'))
|
77
|
+
end
|
56
78
|
|
57
79
|
def dynamically_generated?
|
58
80
|
!dynamic_base.blank?
|
59
81
|
end
|
60
|
-
|
82
|
+
|
61
83
|
def t_field_type
|
62
84
|
self.class.t_field_type(self.field_type)
|
63
85
|
end
|
@@ -65,20 +87,39 @@ module LucidWorks
|
|
65
87
|
def self.t_field_type(type)
|
66
88
|
I18n.translate(type, :scope => 'activemodel.models.lucid_works.collection.field.field_type')
|
67
89
|
end
|
68
|
-
|
69
|
-
|
70
|
-
|
90
|
+
|
91
|
+
# Indexing_options is a fake attribute that wraps the omit_tf and omit_positions combinations.
|
92
|
+
# Translations are:
|
93
|
+
#
|
94
|
+
# INDEXED? indexing_options omit_tf omit_positions
|
95
|
+
#
|
96
|
+
# false - true true
|
97
|
+
# true :document_only true true
|
98
|
+
# true :document_termfreq false true
|
99
|
+
# true :documents_termfreq_termpos false false
|
100
|
+
#
|
101
|
+
def indexing_options
|
102
|
+
@attributes[:indexing_options] ||=
|
103
|
+
if !indexed? || omit_tf?
|
104
|
+
:document_only
|
105
|
+
else
|
106
|
+
omit_positions? ? :document_termfreq : :document_termfreq_termpos
|
107
|
+
end
|
71
108
|
end
|
72
109
|
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
110
|
+
# We have to remember the caller's choice of indexing_options, as we can't determine the correct
|
111
|
+
# omit_tf/omit_positions settins until we also know whether 'indexed' is set or not.
|
112
|
+
# So we keep it as an attribute for now, and remove it in a before_save.
|
113
|
+
def indexing_options=(new_value)
|
114
|
+
@attributes[:indexing_options] = new_value
|
77
115
|
end
|
78
116
|
|
79
|
-
|
80
|
-
|
81
|
-
|
117
|
+
# Convert indexing_options to the correct values for omit_tf and omit_positions.
|
118
|
+
# Delete indexing_options from attributes so it is not saved.
|
119
|
+
def convert_indexing_options_to_term_freq_and_pos
|
120
|
+
i_opt = @attributes.delete(:indexing_options)
|
121
|
+
if indexed? && i_opt
|
122
|
+
case i_opt.to_sym
|
82
123
|
when :document_only
|
83
124
|
self.omit_tf = true
|
84
125
|
self.omit_positions = true
|
@@ -89,12 +130,13 @@ module LucidWorks
|
|
89
130
|
self.omit_tf = false
|
90
131
|
self.omit_positions = false
|
91
132
|
else
|
92
|
-
raise "Unknown indexing option: '#{
|
133
|
+
raise "Unknown indexing option: '#{i_opt}'. Allowed values are: #{INDEXING_OPTIONS.join(', ')}"
|
93
134
|
end
|
94
135
|
else # !indexed?
|
95
136
|
self.omit_tf = true
|
96
137
|
self.omit_positions = true
|
97
138
|
end
|
139
|
+
true
|
98
140
|
end
|
99
141
|
|
100
142
|
def update_attributes(attrs)
|
@@ -4,7 +4,7 @@ describe LucidWorks::Field do
|
|
4
4
|
before :all do
|
5
5
|
@server = connect_to_live_server
|
6
6
|
@server.reset_collections!
|
7
|
-
@collection = @server.
|
7
|
+
@collection = @server.collection('collection1')
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should use the ORM" do
|
@@ -80,7 +80,7 @@ describe LucidWorks::Field do
|
|
80
80
|
field.should_not be_valid
|
81
81
|
field.errors[:short_field_boost].should == ['cannot be set to "none" for a non-indexed field']
|
82
82
|
end
|
83
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :short_field_boost => true).should be_valid
|
83
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :short_field_boost => true, :indexing_options => :document_only).should be_valid
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -90,7 +90,7 @@ describe LucidWorks::Field do
|
|
90
90
|
field.should_not be_valid
|
91
91
|
field.errors[:include_in_results].should == ["a field must be stored to be included in results"]
|
92
92
|
end
|
93
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :include_in_results => true).should be_valid
|
93
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :include_in_results => true, :indexing_options => :document_only).should be_valid
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -110,7 +110,7 @@ describe LucidWorks::Field do
|
|
110
110
|
field.should_not be_valid
|
111
111
|
field.errors[:facet].should == ["a field must be indexed to be facetable"]
|
112
112
|
end
|
113
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :facet => true).should be_valid
|
113
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :facet => true, :indexing_options => :document_only).should be_valid
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -120,7 +120,7 @@ describe LucidWorks::Field do
|
|
120
120
|
field.should_not be_valid
|
121
121
|
field.errors[:use_in_find_similar].should == ["a field must be indexed for it to be used for find-similar"]
|
122
122
|
end
|
123
|
-
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :use_in_find_similar => true).should be_valid
|
123
|
+
LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :use_in_find_similar => true, :indexing_options => :document_only).should be_valid
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -133,101 +133,141 @@ describe LucidWorks::Field do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
describe "
|
136
|
+
describe "indexing options" do
|
137
|
+
INDEXING_OPTIONS_TRUTH_TABLE = [
|
138
|
+
{ :indexed => true, :indexing_options => :document_termfreq_termpos, :omit_tf => false, :omit_positions => false },
|
139
|
+
{ :indexed => true, :indexing_options => :document_termfreq, :omit_tf => false, :omit_positions => true },
|
140
|
+
{ :indexed => true, :indexing_options => :document_only, :omit_tf => true, :omit_positions => true },
|
141
|
+
{ :indexed => false, :indexing_options => :document_termfreq_termpos, :omit_tf => true, :omit_positions => true },
|
142
|
+
{ :indexed => false, :indexing_options => :document_termfreq_termpos, :omit_tf => true, :omit_positions => true },
|
143
|
+
{ :indexed => false, :indexing_options => :document_termfreq_termpos, :omit_tf => true, :omit_positions => true },
|
144
|
+
]
|
137
145
|
|
138
|
-
context "when
|
139
|
-
|
140
|
-
|
141
|
-
|
146
|
+
context "when neither the setter nor getter have been accessed" do
|
147
|
+
context "for an object with indexed = false" do
|
148
|
+
before do
|
149
|
+
@field = LucidWorks::Field.find('url', :parent => @collection)
|
150
|
+
@field.indexed.should be_false
|
151
|
+
end
|
142
152
|
|
143
|
-
|
144
|
-
|
145
|
-
{ :omit_tf => false, :omit_positions => true },
|
146
|
-
{ :omit_tf => true, :omit_positions => false },
|
147
|
-
{ :omit_tf => true, :omit_positions => true }
|
148
|
-
].each do |settings|
|
149
|
-
it "should reuturn :document if omit_tf=#{settings[:omit_tf]} and omit_positions=#{settings[:omit_positions]}" do
|
150
|
-
settings.each { |k,v| @field.send("#{k}=", v) }
|
151
|
-
@field.index_term_freq_and_pos.should == :document_only
|
153
|
+
it "should ignore indexing_options and validate okay" do
|
154
|
+
@field.should be_valid
|
152
155
|
end
|
153
|
-
end
|
154
|
-
end
|
155
156
|
|
156
|
-
|
157
|
-
|
158
|
-
|
157
|
+
it "should save omit_tf and omit_positions as true" do
|
158
|
+
RestClient.stub(:send) do |method, url, payload, options|
|
159
|
+
method.should == :put
|
160
|
+
hash = JSON.parse(payload)
|
161
|
+
hash['omit_positions'].should be_true
|
162
|
+
hash['omit_tf'].should be_true
|
163
|
+
end
|
164
|
+
|
165
|
+
@field.save
|
166
|
+
end
|
159
167
|
end
|
160
168
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
@field.omit_tf = data[:omit_tf]
|
169
|
-
@field.omit_positions = data[:omit_positions]
|
170
|
-
@field.index_term_freq_and_pos.should == data[:expected_result]
|
169
|
+
context "for an object with indexed = true" do
|
170
|
+
before do
|
171
|
+
@field = LucidWorks::Field.find('body', :parent => @collection)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should validate correctly" do
|
175
|
+
@field.should be_valid
|
171
176
|
end
|
172
177
|
end
|
173
178
|
end
|
174
|
-
end
|
175
179
|
|
176
|
-
|
180
|
+
describe "getter" do
|
181
|
+
context "when indexed is false" do
|
182
|
+
before do
|
183
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false)
|
184
|
+
end
|
177
185
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
186
|
+
describe "it should always return :document_termfreq_termpos" do
|
187
|
+
INDEXING_OPTIONS_TRUTH_TABLE.select{ |x| x[:indexed] == 'false'}.each do |settings|
|
188
|
+
it "should return :document_termfreq_termpos if omit_tf=#{settings[:omit_tf]} and omit_positions=#{settings[:omit_positions]}" do
|
189
|
+
settings.each { |k,v| @field.send("#{k}=", v) }
|
190
|
+
@field.indexing_options.should == :document_termfreq_termpos
|
191
|
+
end
|
192
|
+
end
|
183
193
|
|
184
|
-
|
185
|
-
before do
|
186
|
-
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true)
|
194
|
+
end
|
187
195
|
end
|
188
196
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
@field.omit_tf = !data[:omit_tf]
|
193
|
-
@field.omit_positions = !data[:omit_positions]
|
194
|
-
|
195
|
-
@field.index_term_freq_and_pos = data[:index_term_freq_and_pos]
|
196
|
-
|
197
|
-
@field.omit_positions.should == data[:omit_positions]
|
198
|
-
@field.omit_tf.should == data[:omit_tf]
|
197
|
+
context "when indexed is true" do
|
198
|
+
before do
|
199
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true)
|
199
200
|
end
|
200
|
-
end
|
201
201
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
@field.
|
206
|
-
|
202
|
+
INDEXING_OPTIONS_TRUTH_TABLE.select { |x| x[:indexed] == true }.each do |data|
|
203
|
+
it "should return #{data[:indexing_options]} if omit_tf=#{data[:omit_tf]} and omit_positions=#{data[:omit_positions]}" do
|
204
|
+
@field.omit_tf = data[:omit_tf]
|
205
|
+
@field.omit_positions = data[:omit_positions]
|
206
|
+
@field.indexing_options.should == data[:indexing_options]
|
207
|
+
end
|
207
208
|
end
|
208
209
|
end
|
210
|
+
|
209
211
|
end
|
210
212
|
|
211
|
-
|
213
|
+
describe "setter" do
|
212
214
|
before do
|
213
|
-
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field'
|
215
|
+
@field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field')
|
214
216
|
end
|
215
217
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
INDEXING_OPTIONS_TRUTH_TABLE.each do |data|
|
219
|
+
|
220
|
+
context "when indexed is set to #{data[:indexed]} BEFORE indexing options is set to #{data[:indexing_options]}" do
|
221
|
+
before do
|
222
|
+
@field.indexed = data[:indexed]
|
223
|
+
@field.indexing_options = data[:indexing_options]
|
224
|
+
end
|
221
225
|
|
222
|
-
|
226
|
+
it "should set omit_tf=#{data[:omit_tf]} and omit_positions=#{data[:omit_positions]} before save" do
|
227
|
+
RestClient.stub(:send) do |method, url, payload, options|
|
228
|
+
method.should == :post
|
229
|
+
hash = JSON.parse(payload)
|
230
|
+
hash['omit_tf'].should == data[:omit_tf]
|
231
|
+
hash['omit_positions'].should == data[:omit_positions]
|
232
|
+
end
|
233
|
+
@field.save
|
234
|
+
end
|
223
235
|
|
224
|
-
|
225
|
-
|
236
|
+
it "should not pass indexing_options on to the rest api" do
|
237
|
+
RestClient.stub(:send) do |method, url, payload, options|
|
238
|
+
method.should == :post
|
239
|
+
hash = JSON.parse(payload)
|
240
|
+
hash.keys.should_not include('indexing_options')
|
241
|
+
end
|
242
|
+
@field.save
|
243
|
+
end
|
226
244
|
end
|
227
|
-
end
|
228
245
|
|
229
|
-
|
246
|
+
context "when indexed is set to #{data[:indexed]} AFTER indexing options is set to #{data[:indexing_options]}" do
|
247
|
+
before do
|
248
|
+
@field.indexing_options = data[:indexing_options]
|
249
|
+
@field.indexed = data[:indexed]
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should set omit_tf=#{data[:omit_tf]} and omit_positions=#{data[:omit_positions]} before save" do
|
253
|
+
RestClient.stub(:send) do |method, url, payload, options|
|
254
|
+
method.should == :post
|
255
|
+
hash = JSON.parse(payload)
|
256
|
+
hash['omit_tf'].should == data[:omit_tf]
|
257
|
+
hash['omit_positions'].should == data[:omit_positions]
|
258
|
+
end
|
259
|
+
@field.save
|
260
|
+
end
|
230
261
|
|
262
|
+
it "should not pass indexing_options on to the rest api" do
|
263
|
+
RestClient.stub(:send) do |method, url, payload, options|
|
264
|
+
method.should == :post
|
265
|
+
hash = JSON.parse(payload)
|
266
|
+
hash.keys.should_not include('indexing_options')
|
267
|
+
end
|
268
|
+
@field.save
|
269
|
+
end
|
270
|
+
end
|
231
271
|
end
|
232
272
|
end
|
233
273
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lucid_works
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.15
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sam Pierson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-12 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|