lucid_works 0.6.20 → 0.6.21

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.
@@ -67,17 +67,20 @@ module LucidWorks
67
67
  validates_each :name, :allow_blank => true do |model, attr, value|
68
68
  model.errors.add(attr, 'must be unique') if model.collection.fields.any? {|f| f.name == value }
69
69
  end
70
+ validates_each :short_field_boost do |model, attr, value|
71
+ model.errors.add(attr, "cannot be set to \"#{value}\" for a non-indexed field") if value == 'none' && !model.indexed?
72
+ end
70
73
  validates_each :include_in_results do |model, attr, value|
71
- model.errors.add(attr, 'a field must be stored to be included in results') unless model.stored?
74
+ model.errors.add(attr, 'a field must be stored to be included in results') if value == true && !model.stored?
72
75
  end
73
76
  validates_each :highlight do |model, attr, value|
74
- model.errors.add(attr, 'a field must be stored to be highlighted') unless model.stored?
77
+ model.errors.add(attr, 'a field must be stored to be highlighted') if value == true && !model.stored?
75
78
  end
76
79
  validates_each :facet do |model, attr, value|
77
- model.errors.add(attr, 'a field must be indexed to be facetable') unless model.indexed?
80
+ model.errors.add(attr, 'a field must be indexed to be facetable') if value == true && !model.indexed?
78
81
  end
79
82
  validates_each :use_in_find_similar do |model, attr, value|
80
- model.errors.add(attr, 'a field must be indexed for it to be used for find-similar') unless model.indexed?
83
+ model.errors.add(attr, 'a field must be indexed for it to be used for find-similar') if value == true && !model.indexed?
81
84
  end
82
85
 
83
86
  def t_field_type
@@ -1,3 +1,3 @@
1
1
  module LucidWorks
2
- VERSION = "0.6.20"
2
+ VERSION = "0.6.21"
3
3
  end
@@ -26,35 +26,53 @@ describe LucidWorks::Field do
26
26
  end
27
27
  end
28
28
 
29
- context :include_in_result do
29
+ context :short_field_boost do
30
+ it "cannot be set to 'none' for a non-indexed field" do
31
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :short_field_boost => 'none').tap do |field|
32
+ field.should_not be_valid
33
+ field.errors[:short_field_boost].should == ['cannot be set to "none" for a non-indexed field']
34
+ end
35
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :short_field_boost => true).should be_valid
36
+ end
37
+ end
38
+
39
+ context :include_in_results do
30
40
  it "requires the field to be stored" do
31
- field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :include_in_result => true)
32
- field.should_not be_valid
33
- field.errors[:include_in_results].should == ["a field must be stored to be included in results"]
41
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :include_in_results => true).tap do |field|
42
+ field.should_not be_valid
43
+ field.errors[:include_in_results].should == ["a field must be stored to be included in results"]
44
+ end
45
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :include_in_results => true).should be_valid
34
46
  end
35
47
  end
36
48
 
37
49
  context :highlight do
38
50
  it "requires the field to be stored" do
39
- field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :highlight => true)
40
- field.should_not be_valid
41
- field.errors[:highlight].should == ["a field must be stored to be highlighted"]
51
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => false, :highlight => true).tap do |field|
52
+ field.should_not be_valid
53
+ field.errors[:highlight].should == ["a field must be stored to be highlighted"]
54
+ end
55
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :stored => true, :highlighted => true).should be_valid
42
56
  end
43
57
  end
44
58
 
45
59
  context :facet do
46
60
  it "requires the field to be indexed" do
47
- field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :facet => true)
48
- field.should_not be_valid
49
- field.errors[:facet].should == ["a field must be indexed to be facetable"]
61
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :facet => true).tap do |field|
62
+ field.should_not be_valid
63
+ field.errors[:facet].should == ["a field must be indexed to be facetable"]
64
+ end
65
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :facet => true).should be_valid
50
66
  end
51
67
  end
52
68
 
53
69
  context :use_in_find_similar do
54
70
  it "requires the field to be indexed" do
55
- field = LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :use_in_find_similar => true)
56
- field.should_not be_valid
57
- field.errors[:use_in_find_similar].should == ["a field must be indexed for it to be used for find-similar"]
71
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => false, :use_in_find_similar => true).tap do |field|
72
+ field.should_not be_valid
73
+ field.errors[:use_in_find_similar].should == ["a field must be indexed for it to be used for find-similar"]
74
+ end
75
+ LucidWorks::Field.new(:parent => @collection, :name => 'my_field', :indexed => true, :use_in_find_similar => true).should be_valid
58
76
  end
59
77
  end
60
78
  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.6.20
5
+ version: 0.6.21
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sam Pierson