lucid_works 0.6.19 → 0.6.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,6 +64,21 @@ module LucidWorks
64
64
  ]
65
65
 
66
66
  validates_presence_of :name
67
+ validates_each :name, :allow_blank => true do |model, attr, value|
68
+ model.errors.add(attr, 'must be unique') if model.collection.fields.any? {|f| f.name == value }
69
+ end
70
+ 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?
72
+ end
73
+ validates_each :highlight do |model, attr, value|
74
+ model.errors.add(attr, 'a field must be stored to be highlighted') unless model.stored?
75
+ end
76
+ validates_each :facet do |model, attr, value|
77
+ model.errors.add(attr, 'a field must be indexed to be facetable') unless model.indexed?
78
+ end
79
+ 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?
81
+ end
67
82
 
68
83
  def t_field_type
69
84
  self.class.t_field_type(self.field_type)
@@ -1,3 +1,3 @@
1
1
  module LucidWorks
2
- VERSION = "0.6.19"
2
+ VERSION = "0.6.20"
3
3
  end
@@ -12,10 +12,50 @@ describe LucidWorks::Field do
12
12
  end
13
13
 
14
14
  describe "validations" do
15
- it "requires a name" do
16
- field = LucidWorks::Field.new(:parent => @collection)
17
- field.should_not be_valid
18
- field.errors[:name].should == ["can't be blank"]
15
+ context :name do
16
+ it "is required" do
17
+ field = LucidWorks::Field.new(:parent => @collection)
18
+ field.should_not be_valid
19
+ field.errors[:name].should == ["can't be blank"]
20
+ end
21
+
22
+ it "needs to be unique" do
23
+ field = LucidWorks::Field.new(:parent => @collection, :name => 'data_source')
24
+ field.should_not be_valid
25
+ field.errors[:name].should == ["must be unique"]
26
+ end
27
+ end
28
+
29
+ context :include_in_result do
30
+ 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"]
34
+ end
35
+ end
36
+
37
+ context :highlight do
38
+ 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"]
42
+ end
43
+ end
44
+
45
+ context :facet do
46
+ 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"]
50
+ end
51
+ end
52
+
53
+ context :use_in_find_similar do
54
+ 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"]
58
+ end
19
59
  end
20
60
  end
21
61
 
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.19
5
+ version: 0.6.20
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-06-15 00:00:00 -07:00
13
+ date: 2011-06-18 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency