lucid_works 0.7.2 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .idea
2
2
  *.gem
3
3
  .bundle
4
- Gemfile.lock
5
4
  pkg/*
6
5
  /rdoc
data/.rvmrc CHANGED
@@ -1 +1,4 @@
1
1
  rvm use 1.9.2-p180@lucidworks --create
2
+
3
+ # Enable the following to run the tests under MRI 1.8
4
+ # rvm use ruby-1.8.7-p352@lucidworks --create
data/Gemfile CHANGED
@@ -4,7 +4,12 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'ruby-debug19'
7
+ platforms :ruby_18 do
8
+ gem 'ruby-debug'
9
+ end
10
+ platforms :ruby_19 do
11
+ gem 'ruby-debug19', :require => 'ruby-debug'
12
+ end
8
13
  gem 'rspec'
9
14
  gem 'autotest'
10
15
  gem "autotest-fsevent"
data/Gemfile.lock ADDED
@@ -0,0 +1,83 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lucid_works (0.7.7)
5
+ activemodel (>= 3)
6
+ activesupport (>= 3)
7
+ json
8
+ nokogiri
9
+ rest-client (>= 1.6.1)
10
+ rsolr
11
+ rsolr-ext
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ ZenTest (4.5.0)
17
+ activemodel (3.0.10)
18
+ activesupport (= 3.0.10)
19
+ builder (~> 2.1.2)
20
+ i18n (~> 0.5.0)
21
+ activesupport (3.0.10)
22
+ archive-tar-minitar (0.5.2)
23
+ autotest (4.4.6)
24
+ ZenTest (>= 4.4.1)
25
+ autotest-fsevent (0.2.5)
26
+ sys-uname
27
+ builder (2.1.2)
28
+ columnize (0.3.4)
29
+ diff-lcs (1.1.2)
30
+ i18n (0.5.0)
31
+ json (1.5.3)
32
+ linecache (0.46)
33
+ rbx-require-relative (> 0.0.4)
34
+ linecache19 (0.5.12)
35
+ ruby_core_source (>= 0.1.4)
36
+ mime-types (1.16)
37
+ nokogiri (1.5.0)
38
+ rbx-require-relative (0.0.5)
39
+ rest-client (1.6.7)
40
+ mime-types (>= 1.16)
41
+ rsolr (1.0.2)
42
+ builder (>= 2.1.2)
43
+ rsolr-ext (1.0.3)
44
+ rsolr (>= 1.0.2)
45
+ rspec (2.5.0)
46
+ rspec-core (~> 2.5.0)
47
+ rspec-expectations (~> 2.5.0)
48
+ rspec-mocks (~> 2.5.0)
49
+ rspec-core (2.5.1)
50
+ rspec-expectations (2.5.0)
51
+ diff-lcs (~> 1.1.2)
52
+ rspec-mocks (2.5.0)
53
+ ruby-debug (0.10.4)
54
+ columnize (>= 0.1)
55
+ ruby-debug-base (~> 0.10.4.0)
56
+ ruby-debug-base (0.10.4)
57
+ linecache (>= 0.3)
58
+ ruby-debug-base19 (0.11.25)
59
+ columnize (>= 0.3.1)
60
+ linecache19 (>= 0.5.11)
61
+ ruby_core_source (>= 0.1.4)
62
+ ruby-debug19 (0.11.6)
63
+ columnize (>= 0.3.1)
64
+ linecache19 (>= 0.5.11)
65
+ ruby-debug-base19 (>= 0.11.19)
66
+ ruby_core_source (0.1.5)
67
+ archive-tar-minitar (>= 0.5.2)
68
+ sys-uname (0.8.5)
69
+ timecop (0.3.5)
70
+ tzinfo (0.3.27)
71
+
72
+ PLATFORMS
73
+ ruby
74
+
75
+ DEPENDENCIES
76
+ autotest
77
+ autotest-fsevent
78
+ lucid_works!
79
+ rspec
80
+ ruby-debug
81
+ ruby-debug19
82
+ timecop
83
+ tzinfo
@@ -154,7 +154,6 @@ en:
154
154
  autocomplete: Generate autocomplete index
155
155
  click: Process click logs
156
156
  optimize: Optimize index
157
- spelling: Generate spellcheck index
158
157
  collection:
159
158
  one: Collection
160
159
  other: Collections
@@ -214,12 +213,14 @@ en:
214
213
  name: ! 'Collection names may use the characters: A-Z, a-z, 0-9, dash and
215
214
  underscore'
216
215
  datasource:
217
- crawl_depth: Set to -1 to crawl with no depth limit.
216
+ crawl_depth: Leave blank or set to -1 to crawl with no depth limit.
218
217
  exclude_paths: A list of regular expressions, one per line, e.g. .*\.pdf will
219
218
  ignore filenames ending in .pdf.
220
219
  include_paths: A list of regular expressions, one per line, e.g. http://example\.com/.*
221
220
  will match everything within the site only.
222
221
  max_bytes: Default = 10 MiB. Set to -1 to indicate no file size limit.
223
222
  url: e.g. http://cnn.com. Please include protocol (http/https).
223
+ field:
224
+ copy_fields: A list of fields separated by spaces.
224
225
  synonym:
225
226
  mapping: ! 'Example: car, automobile, auto'
@@ -2,7 +2,7 @@ require 'active_support/core_ext/numeric/time.rb'
2
2
  module LucidWorks
3
3
 
4
4
  class Activity < Base
5
- TYPES = %w{ optimize spelling click autocomplete}
5
+ TYPES = %w{ optimize click autocomplete }
6
6
 
7
7
  # Unlike Datasource schedules, the API allows multiples of these
8
8
  # So, to be honest with gem users, we can't really say this:
@@ -36,9 +36,9 @@ module LucidWorks
36
36
  #
37
37
  def frequency=(frequency)
38
38
  self.period = case frequency
39
- when 'hourly' then 1.hours.seconds
40
- when 'daily' then 1.days.seconds
41
- when 'weekly' then 1.weeks.seconds
39
+ when 'hourly' then 1.hours.seconds.to_i
40
+ when 'daily' then 1.days.seconds.to_i
41
+ when 'weekly' then 1.weeks.seconds.to_i
42
42
  else raise "unknown frequency"
43
43
  end
44
44
  end
@@ -14,7 +14,7 @@ module LucidWorks
14
14
 
15
15
  schema do
16
16
  # Indexing Settings
17
- attribute :unknown_type_handling, :string, :values => LucidWorks::Field::TYPES
17
+ attribute :unknown_type_handling, :string
18
18
  attribute :de_duplication, :string, :values => DEDUP_OPTIONS
19
19
 
20
20
  # Querying Settings
@@ -14,6 +14,12 @@ module LucidWorks
14
14
  end
15
15
 
16
16
  LOGS_COLLECTION_NAME = 'LucidWorksLogs'
17
+ AD_FILTERING = 'adfiltering'
18
+ ROLE_FILTERING = 'filterbyrole'
19
+ STATIC_ACL_CONFIG = {
20
+ "filterer.class" => "com.lucid.security.WindowsACLQueryFilterer",
21
+ "provider.class" => "com.lucid.security.ad.ADACLTagProvider",
22
+ }
17
23
 
18
24
  validates_presence_of :name
19
25
 
@@ -81,13 +87,13 @@ module LucidWorks
81
87
  def prime_activities
82
88
  self.activities!.sort!{|a,b|a.id <=> b.id}
83
89
  num_created = 0
84
- activities_to_return = %w(optimize spelling autocomplete click).map do |type|
90
+ activities_to_return = ::LucidWorks::Activity::TYPES.map do |type|
85
91
  if act = self.activities.detect{|act| act.type == type}
86
92
  act
87
93
  else
88
94
  num_created += 1
89
95
  start_time = Time.now.change(:min => 0) + num_created.hours
90
- self.create_activity(:type => type, :active => false, :start_time => start_time, :period => 1.days.seconds)
96
+ self.create_activity(:type => type, :active => false, :start_time => start_time, :period => 1.days.seconds.to_i)
91
97
  end
92
98
  end
93
99
  self.activities! if num_created > 0
@@ -97,20 +103,13 @@ module LucidWorks
97
103
  # return the first for each kind of activity
98
104
  # don't use these if you need more than one activity
99
105
  # b/c each forces an API hit
100
- def optimize_activity
101
- prime_activities.detect{|act| act.type == 'optimize'}
102
- end
103
-
104
- def spelling_activity
105
- prime_activities.detect{|act| act.type == 'spelling'}
106
- end
107
-
108
- def click_activity
109
- prime_activities.detect{|act| act.type == 'click'}
110
- end
111
106
 
112
- def autocomplete_activity
113
- prime_activities.detect{|act| act.type == 'autocomplete'}
107
+ ::LucidWorks::Activity::TYPES.each do |activity|
108
+ class_eval <<-EOF
109
+ def #{activity}_activity # def optimize_activity
110
+ prime_activities.detect{|act| act.type == '#{activity}'} # prime_activities.detect{|act| act.type == 'optimize'}
111
+ end # end
112
+ EOF
114
113
  end
115
114
 
116
115
  # URL of Solr's build-in admin page
@@ -132,5 +131,56 @@ module LucidWorks
132
131
  JSON.parse RestClient.get(uri + "/jdbcdrivers/classes")
133
132
  end
134
133
 
134
+ def components
135
+ JSON.parse(RestClient.get(uri + "/components/all.json?handlerName=%2Flucid"))
136
+ end
137
+
138
+ def filtering_enabled?
139
+ # current core implementation requires exactly one of filterbyrole or adfiltering
140
+ assert_components_include_ad_xor_role
141
+ return self.components.include?(AD_FILTERING)
142
+ end
143
+
144
+ def assert_components_include_ad_xor_role
145
+ # require 'ruby-debug'; debugger
146
+ raise "conflicting filtering components" if self.components.include?(AD_FILTERING) && self.components.include?(ROLE_FILTERING)
147
+ raise "missing filtering components" if ! self.components.include?(AD_FILTERING) && ! self.components.include?(ROLE_FILTERING)
148
+ end
149
+
150
+ def filtering_settings
151
+ JSON.parse(RestClient.get(uri + "/filtering"))['adfiltering'] || {}
152
+ end
153
+
154
+ def compute_component_set(acl_filtering_enabled)
155
+ new_component_set = self.components.clone
156
+ new_component_set.delete(ROLE_FILTERING)
157
+ new_component_set.delete(AD_FILTERING)
158
+ new_component_set.unshift acl_filtering_enabled == 'true' ? AD_FILTERING : ROLE_FILTERING
159
+ end
160
+
161
+ def configure_filtering(opts)
162
+ if ! opts[:config]['java.naming.provider.url'].blank? && opts[:config]['java.naming.provider.url'] !~ %r(://)
163
+ opts[:config]['java.naming.provider.url'] = "ldap://#{opts[:config]['java.naming.provider.url']}"
164
+ end
165
+ filtering_settings = STATIC_ACL_CONFIG.merge('provider.config' => opts[:config])
166
+
167
+ errors = {}
168
+ method = RestClient.send(:get, uri+'/filtering')['adfiltering'] ? :put : :post
169
+ begin
170
+ response = RestClient.send(method, uri+'/filtering/adfiltering', filtering_settings.to_json, :content_type => :json)
171
+ rescue => exception
172
+ JSON.parse(exception.response)['errors'].each {|e| errors[e['code']] = e['message']}
173
+ end
174
+
175
+ new_component_set = compute_component_set(opts[:enabled])
176
+ if new_component_set.sort != self.components.sort
177
+ begin
178
+ response = RestClient.send(:put, uri+'/components/components?handlerName=/lucid', new_component_set.to_json, :content_type => :json)
179
+ rescue => exception
180
+ JSON.parse(exception.response)['errors'].each {|e| errors[e['code']] = e['message']}
181
+ end
182
+ end
183
+ raise LucidWorks::AclConfigInvalid.new(errors) unless errors.empty?
184
+ end
135
185
  end
136
186
  end
@@ -44,9 +44,9 @@ module LucidWorks
44
44
  #
45
45
  def frequency=(frequency)
46
46
  self.period = case frequency
47
- when 'hourly' then 1.hours.seconds
48
- when 'daily' then 1.days.seconds
49
- when 'weekly' then 1.weeks.seconds
47
+ when 'hourly' then 1.hours.seconds.to_i
48
+ when 'daily' then 1.days.seconds.to_i
49
+ when 'weekly' then 1.weeks.seconds.to_i
50
50
  else raise "unknown frequency"
51
51
  end
52
52
  end
@@ -32,12 +32,12 @@ module LucidWorks
32
32
  # common
33
33
  attributes :name, :crawler
34
34
  attribute :type, :string, :values => TYPES
35
- attributes :crawl_depth, :max_docs, :type => :integer
35
+ attribute :crawl_depth, :integer, :nil_when_blank => true
36
+ attribute :max_docs, :integer
36
37
  attributes :max_bytes, :commit_within, :type => :integer, :omit_when_blank => true
37
38
  attribute :commit_within_min, :custom
38
39
  attribute :commit_on_finish, :boolean
39
- attribute :include_paths
40
- attribute :exclude_paths
40
+ attributes :include_paths, :exclude_paths, :type => :list, :separator => "\n"
41
41
  attribute :mapping, :string, :omit_when_blank => true # Hash
42
42
  attribute :bounds, :string, :values => BOUNDS
43
43
  # web
@@ -95,7 +95,6 @@ module LucidWorks
95
95
  end
96
96
 
97
97
  validates_presence_of :type, :crawler, :name
98
- validates_presence_of :crawl_depth, :if => lambda { |d| %w{web file}.include?(d.type) }
99
98
  validates_numericality_of :max_bytes, :allow_blank => true
100
99
  validates_presence_of :url, :if => lambda { |d| d.type == 'web' }
101
100
 
@@ -2,17 +2,19 @@ module LucidWorks
2
2
 
3
3
  class DatasourceProperty
4
4
 
5
- attr_reader :description, :name, :allowed_values, :type, :default_value, :required, :read_only
5
+ attr_reader :description, :name, :allowed_values, :type, :default_value, :required, :read_only, :advanced
6
6
  alias :read_only? :read_only
7
+ alias :advanced? :advanced
7
8
 
8
9
  def initialize(attributes = {})
9
10
  @description = attributes['description']
10
11
  @name = attributes['name']
11
- @allowed_values = attributes['allowedValues']
12
+ @allowed_values = attributes['allowed_values']
12
13
  @type = attributes['type']
13
- @default_value = attributes['defaultValues']
14
+ @default_value = attributes['default_value']
14
15
  @required = attributes['required']
15
16
  @read_only = attributes['read_only']
17
+ @advanced = attributes['advanced']
16
18
  end
17
19
  end
18
- end
20
+ end
@@ -4,4 +4,8 @@ module LucidWorks
4
4
 
5
5
  class ResourceNotFound < Exception ; end
6
6
  class RecordInvalid < Exception ; end
7
+ class AclConfigInvalid < Exception
8
+ attr_accessor :messages;
9
+ def initialize(messages); @messages = messages; end
10
+ end
7
11
  end
@@ -22,50 +22,12 @@ module LucidWorks
22
22
  :use_in_find_similar,
23
23
  :type => :boolean
24
24
  attribute :default_boost, :integer
25
- attributes :field_type, :short_field_boost, :term_vectors, :default_value, :copy_fields, :type => :string
25
+ attributes :field_type, :short_field_boost, :term_vectors, :default_value, :type => :string
26
+ attribute :copy_fields, :list
26
27
 
27
28
  attribute :index_term_freq_and_pos, :custom, :values => INDEXING_OPTIONS
28
29
  end
29
30
 
30
- TYPES = [
31
- 'string',
32
- 'boolean',
33
- 'binary',
34
- 'int',
35
- 'float',
36
- 'long',
37
- 'double',
38
- 'tint',
39
- 'tfloat',
40
- 'tlong',
41
- 'tdouble',
42
- 'uri',
43
- 'date',
44
- 'tdate',
45
- 'text_ws',
46
- 'text_en',
47
- 'text_porter_en',
48
- 'textTight',
49
- 'text_cjk',
50
- 'text_da',
51
- 'text_de',
52
- 'text_es',
53
- 'text_fr',
54
- 'text_it',
55
- 'text_nl',
56
- 'text_pt',
57
- 'text_ru',
58
- 'text_se',
59
- 'text_fi',
60
- 'random',
61
- 'comma-separated',
62
- 'textSpell',
63
- 'payloads',
64
- 'point',
65
- 'location',
66
- 'geohash'
67
- ]
68
-
69
31
  BOOST_VALUES = [
70
32
  'none',
71
33
  'moderate',
@@ -1,3 +1,3 @@
1
1
  module LucidWorks
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.9"
3
3
  end
@@ -2,7 +2,7 @@ module LucidWorks
2
2
  class Schema
3
3
 
4
4
  class Attribute
5
- ATTRIBUTES_TYPES = [ :string, :integer, :boolean, :iso8601, :custom ]
5
+ ATTRIBUTES_TYPES = [ :string, :integer, :boolean, :iso8601, :custom, :list ]
6
6
  RESERVED_ATTRIBUTE_NAMES = %{ class nil? send caller object_id }
7
7
 
8
8
  attr_reader :schema, :name, :values, :origin
@@ -0,0 +1,44 @@
1
+ module LucidWorks
2
+ class Schema
3
+
4
+ class ListAttribute < Attribute
5
+
6
+ attr_reader :separator
7
+
8
+ def initialize(schema, name, options={})
9
+ @separator = options[:separator] || " "
10
+ super
11
+ end
12
+
13
+ def type
14
+ :list
15
+ end
16
+
17
+ def create_accessors_for_attribute(klass) # :nodoc:
18
+ super
19
+
20
+ klass.class_eval <<-EOF, __FILE__, __LINE__+1
21
+ def #{name}
22
+ list = @attributes[:#{name}]
23
+ list.nil? ? "" : list.join(self.class.schema[:#{name}].separator)
24
+ end
25
+
26
+ def #{name}=(new_value)
27
+ if new_value.kind_of?(Array)
28
+ @attributes[:#{name}] = new_value
29
+ elsif new_value.kind_of?(String)
30
+ separator = self.class.schema[:#{name}].separator
31
+ separator = /[\\r\\n]+/ if separator == "\n" # Special case
32
+ @attributes[:#{name}] = new_value.split(separator)
33
+ elsif new_value.nil?
34
+ @attributes[:#{name}] = []
35
+ else
36
+ raise "Can't interpret \#{new_value.inspect} as a #{name}"
37
+ end
38
+ @attributes[:#{name}]
39
+ end
40
+ EOF
41
+ end
42
+ end
43
+ end
44
+ end
data/lib/lucid_works.rb CHANGED
@@ -30,14 +30,15 @@ require 'lucid_works/schema/boolean_attribute'
30
30
  require 'lucid_works/schema/custom_attribute'
31
31
  require 'lucid_works/schema/integer_attribute'
32
32
  require 'lucid_works/schema/iso8601_attribute'
33
+ require 'lucid_works/schema/list_attribute'
33
34
  require 'lucid_works/schema/string_attribute'
34
35
 
36
+ require 'lucid_works/activity'
35
37
  require 'lucid_works/collection'
36
38
  require 'lucid_works/collection/info'
37
39
  require 'lucid_works/collection/index'
38
40
  require 'lucid_works/collection/settings'
39
41
  require 'lucid_works/collection/click'
40
- require 'lucid_works/activity'
41
42
  require 'lucid_works/activity/status'
42
43
  require 'lucid_works/activity/history'
43
44
  require 'lucid_works/crawler'
@@ -0,0 +1,165 @@
1
+ require 'spec_helper'
2
+
3
+ describe "LucidWorks::Collection ACL configuration utility methods" do
4
+ before :all do
5
+ @server = connect_to_live_server
6
+ @server.reset_collections!
7
+ end
8
+
9
+ describe "ACL filtering configuration" do
10
+ before :all do
11
+ @collection = @server.create_collection(:name => 'collection_for_acl_config_testing', :parent => @server)
12
+ @initial_components = [
13
+ "filterbyrole",
14
+ "query",
15
+ "mlt",
16
+ "stats",
17
+ "feedback",
18
+ "highlight",
19
+ "facet",
20
+ "spellcheck",
21
+ "debug"
22
+ ]
23
+ end
24
+
25
+ describe '#assert_components_include_ad_xor_role' do
26
+ before do
27
+ @collection_for_xor = @server.collection('collection_for_acl_config_testing')
28
+ end
29
+ it "should not raise an exception for a new collection" do
30
+ lambda {@collection_for_xor.assert_components_include_ad_xor_role}.should_not raise_error
31
+ end
32
+ it "should raise an exception if both are present" do;
33
+ @collection_for_xor.stub(:components).and_return(@initial_components + [LucidWorks::Collection::AD_FILTERING])
34
+ lambda {@collection_for_xor.assert_components_include_ad_xor_role}.should raise_error
35
+ end
36
+ it "should raise an exception if neither are present" do
37
+ @collection_for_xor.stub(:components).and_return(@initial_components[1..-1])
38
+ lambda {@collection_for_xor.assert_components_include_ad_xor_role}.should raise_error
39
+ end
40
+ end
41
+
42
+ describe "#filtering_enabled?" do
43
+ before do
44
+ @collection_for_enabled = @server.collection('collection_for_acl_config_testing')
45
+ end
46
+
47
+ it "should be false on a new collection" do
48
+ @collection_for_enabled.filtering_enabled?.should be_false
49
+ end
50
+
51
+ it "should be true if AD_FILTERING is in the list" do
52
+ @collection_for_enabled.stub(:components).and_return(@initial_components[1..-1]+[LucidWorks::Collection::AD_FILTERING])
53
+ @collection_for_enabled.filtering_enabled?.should be_true
54
+ end
55
+ end
56
+
57
+ describe "LucidWorks::Collection#components" do
58
+ it "should return a list of installed components" do
59
+ @collection.components.should be_a(Array)
60
+ @collection.components.sort.should == @initial_components.sort
61
+ end
62
+ end
63
+
64
+ describe '#filtering_settings' do
65
+ before do
66
+ @collection_for_settings = @server.collection('collection_for_acl_config_testing')
67
+ end
68
+ it "should return an empty hash for a new collection" do
69
+ @collection_for_settings.filtering_settings.should == {}
70
+ end
71
+ end
72
+
73
+ describe '#compute_component_set' do
74
+ before do
75
+ @collection_for_component_set = @server.collection('collection_for_acl_config_testing')
76
+ end
77
+
78
+ it "should put ACL_FILTERING at the front if enabling" do
79
+ initial_components = @initial_components.clone
80
+ enabled = 'true'
81
+ @collection_for_component_set.stub(:components).and_return(initial_components)
82
+ initial_components.first.should_not == LucidWorks::Collection::AD_FILTERING
83
+ @collection_for_component_set.compute_component_set(enabled).first.should == LucidWorks::Collection::AD_FILTERING
84
+ end
85
+
86
+ it "should remove ROLE_FILTERING if enabling" do
87
+ initial_components = @initial_components.clone
88
+ enabled = 'true'
89
+ @collection_for_component_set.stub(:components).and_return(initial_components)
90
+ initial_components.include?(LucidWorks::Collection::ROLE_FILTERING).should be_true
91
+ @collection_for_component_set.compute_component_set(enabled).include?(LucidWorks::Collection::ROLE_FILTERING).should be_false
92
+ end
93
+
94
+ it "should put ROLE_FILTERING at the front if disabling" do
95
+ initial_components = @initial_components.clone
96
+ initial_components.delete(LucidWorks::Collection::ROLE_FILTERING)
97
+ initial_components.unshift(LucidWorks::Collection::AD_FILTERING)
98
+ enabled = 'false'
99
+ @collection_for_component_set.stub(:components).and_return(initial_components)
100
+ initial_components.first.should == LucidWorks::Collection::AD_FILTERING
101
+ @collection_for_component_set.compute_component_set(enabled).first.should == LucidWorks::Collection::ROLE_FILTERING
102
+ end
103
+
104
+ it "should remove ACL_FILTERING if disabling" do
105
+ initial_components = @initial_components.clone
106
+ enabled = 'false'
107
+ initial_components.delete(LucidWorks::Collection::ROLE_FILTERING)
108
+ initial_components.unshift(LucidWorks::Collection::AD_FILTERING)
109
+ @collection_for_component_set.stub(:components).and_return(initial_components)
110
+ initial_components.include?(LucidWorks::Collection::AD_FILTERING).should be_true
111
+ @collection_for_component_set.compute_component_set(enabled).include?(LucidWorks::Collection::AD_FILTERING).should be_false
112
+ end
113
+ end
114
+
115
+ describe '#configure_filtering' do
116
+ before :all do
117
+ @collection_for_configure = @server.collection('collection_for_acl_config_testing')
118
+ @settings = {
119
+ "java.naming.provider.url"=>"ldap://184.72.197.18/",
120
+ "java.naming.security.principal"=>"wma@corp.lucid.com",
121
+ "java.naming.security.credentials"=>"secret",
122
+ }
123
+ end
124
+
125
+ it "should merge in the static settings and store all of the settings" do
126
+ final_settings = {
127
+ "provider.class"=>"com.lucid.security.ad.ADACLTagProvider",
128
+ "filterer.class"=>"com.lucid.security.WindowsACLQueryFilterer",
129
+ "provider.config"=>
130
+ {
131
+ "java.naming.provider.url"=>"ldap://184.72.197.18/",
132
+ "java.naming.security.principal"=>"wma@corp.lucid.com"
133
+ },
134
+ "filterer.config"=>{}
135
+ }
136
+
137
+ @collection_for_configure.filtering_settings.should be_blank
138
+ @collection_for_configure.configure_filtering(:config => @settings, :enabled => 'true')
139
+ @collection_for_configure.filtering_settings.should == final_settings
140
+ end
141
+
142
+ it "should work again after the settings have been saved once and a PUT is now required" do
143
+ @collection_for_configure.filtering_settings.should_not be_blank
144
+ lambda {
145
+ @collection_for_configure.configure_filtering(:config => @settings, :enabled => 'true')
146
+ }.should_not raise_error
147
+ end
148
+
149
+ it "should add ldap:// to url if protocol not specified" do
150
+ settings = @settings.clone
151
+ settings['java.naming.provider.url'] = 'foo.com'
152
+ @collection_for_configure.configure_filtering(:config => settings, :enabled => 'true')
153
+ @collection_for_configure.filtering_settings['provider.config']['java.naming.provider.url'].should == 'ldap://foo.com'
154
+ end
155
+
156
+ it "should not add ldap:// to url if blank" do
157
+ settings = @settings.clone
158
+ settings['java.naming.provider.url'] = ''
159
+ lambda {
160
+ @collection_for_configure.configure_filtering(:config => settings, :enabled => 'true')
161
+ }.should raise_error {|e| e.messages.keys.first.should =~ /url\.no_url/} # because url is required
162
+ end
163
+ end
164
+ end
165
+ end
@@ -17,8 +17,13 @@ require 'spec_helper'
17
17
  describe LucidWorks::Activity do
18
18
  context "Functionality shared with Datasource scheduling" do
19
19
  before :all do
20
+ @system_tz = ENV['TZ']
20
21
  ENV['TZ'] = 'UTC'
21
22
  end
23
+
24
+ after :all do
25
+ ENV['TZ'] = @system_tz
26
+ end
22
27
 
23
28
  before do
24
29
  @server = connect_to_live_server
@@ -278,7 +283,7 @@ describe LucidWorks::Activity do
278
283
  context 'sub-time convenience accessors' do
279
284
  describe '#hour' do
280
285
  it 'should return the hour component of the time' do
281
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
286
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
282
287
  @schedule.hour.should == 13
283
288
  end
284
289
 
@@ -290,7 +295,7 @@ describe LucidWorks::Activity do
290
295
 
291
296
  describe '#min' do
292
297
  it 'should return the minute component of the time' do
293
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
298
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
294
299
  @schedule.min.should == 11
295
300
  end
296
301
 
@@ -302,7 +307,7 @@ describe LucidWorks::Activity do
302
307
 
303
308
  describe '#day_of_week' do
304
309
  it 'should return the week component of the time' do
305
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
310
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
306
311
  @schedule.day_of_week.should == 4
307
312
  end
308
313
 
@@ -321,7 +326,7 @@ describe LucidWorks::Activity do
321
326
  end
322
327
 
323
328
  it 'should be true if period is standard but start_time is > 1 period from now' do
324
- some_random_time = Time.new(2011, 4, 15, 13, 11, 56)
329
+ some_random_time = Time.parse("2011-04-15 13:11:56")
325
330
  more_than_a_day_later = some_random_time.advance(:days => 2)
326
331
 
327
332
  Timecop.freeze some_random_time do
@@ -347,7 +352,7 @@ describe LucidWorks::Activity do
347
352
  end
348
353
 
349
354
  it 'should be false if period is standard and start time is > 1 period in the past' do
350
- some_random_time = Time.new(2011, 4, 15, 13, 11, 56)
355
+ some_random_time = Time.parse("2011-04-15 13:11:56")
351
356
  more_than_a_day_ago = some_random_time.advance(:days => -2)
352
357
  Timecop.freeze some_random_time do
353
358
  @schedule.frequency = 'daily'
@@ -22,8 +22,6 @@ describe "LucidWorks::Collection#prime_activities" do
22
22
  it "should produce activities of the appropriate type" do
23
23
  @collection.optimize_activity.should be_a LucidWorks::Activity
24
24
  @collection.optimize_activity.type.should == 'optimize'
25
- @collection.spelling_activity.should be_a LucidWorks::Activity
26
- @collection.spelling_activity.type.should == 'spelling'
27
25
  @collection.click_activity.should be_a LucidWorks::Activity
28
26
  @collection.click_activity.type.should == 'click'
29
27
  @collection.autocomplete_activity.should be_a LucidWorks::Activity
@@ -36,14 +34,14 @@ describe "LucidWorks::Collection#prime_activities" do
36
34
  context "there are already some activities" do
37
35
  before :all do
38
36
  @collection = @server.create_collection(:name => 'collection_with_no_activities_2', :parent => @server)
39
- spelling_activity = @collection.create_activity(:type => 'spelling', :start_time => 3600, :active => true)
40
- spelling_activity.should be_a LucidWorks::Activity
37
+ optimize_activity = @collection.create_activity(:type => 'optimize', :start_time => 3600, :active => true)
38
+ optimize_activity.should be_a LucidWorks::Activity
41
39
  end
42
40
 
43
41
  it "should not create duplicates for existing types" do
44
42
  lambda {
45
43
  @collection.prime_activities
46
- }.should change(@collection, :activities_count).by 3
44
+ }.should change(@collection, :activities_count).by (LucidWorks::Activity::TYPES.size - 1)
47
45
  end
48
46
  end
49
47
 
@@ -60,11 +58,9 @@ describe "LucidWorks::Collection#prime_activities" do
60
58
  end
61
59
 
62
60
  it "should have a virtual attribute for each activity type" do
63
- @collection.activities!.count.should == 4
61
+ @collection.activities!.count.should == LucidWorks::Activity::TYPES.size
64
62
  @collection.optimize_activity.should be_a LucidWorks::Activity
65
63
  @collection.optimize_activity.type.should == 'optimize'
66
- @collection.spelling_activity.should be_a LucidWorks::Activity
67
- @collection.spelling_activity.type.should == 'spelling'
68
64
  @collection.click_activity.should be_a LucidWorks::Activity
69
65
  @collection.click_activity.type.should == 'click'
70
66
  @collection.autocomplete_activity.should be_a LucidWorks::Activity
@@ -116,7 +116,7 @@ describe LucidWorks::Collection do
116
116
  )
117
117
  activity.should be_persisted
118
118
  activity = LucidWorks::Activity.create(
119
- :type => 'spelling',
119
+ :type => 'click',
120
120
  :start_time => 8600,
121
121
  :collection => @collection
122
122
  )
@@ -155,7 +155,7 @@ describe LucidWorks::Collection do
155
155
  LucidWorks::Activity.create(activity_params.merge(:parent => c))
156
156
  c.activities.size.should == 1
157
157
  c.prime_activities
158
- c.activities.size.should == 4
158
+ c.activities.size.should == LucidWorks::Activity::TYPES.size
159
159
  end
160
160
 
161
161
  context "with a new collection with no activities" do
@@ -167,11 +167,11 @@ describe LucidWorks::Collection do
167
167
 
168
168
  @collection2.activities.size.should == 0
169
169
  @collection2.prime_activities
170
- @collection2.activities.size.should == 4
170
+ @collection2.activities.size.should == LucidWorks::Activity::TYPES.size
171
171
  end
172
172
 
173
173
  it "should ensure at least one of each activity" do
174
- %w(optimize spelling click autocomplete).each do |type|
174
+ %w(optimize click autocomplete).each do |type|
175
175
  @collection2.activities.find_all{|a| a.type == type}.size.should == 1
176
176
  end
177
177
  end
@@ -394,10 +394,9 @@ describe LucidWorks::Collection do
394
394
  end
395
395
 
396
396
  it "should pass thru pagination variables" do
397
- @mock_rsolr_client.should_receive(:find)
398
- .with('/fake_access_path/solr/collection_to_search/select',
399
- :q => 'fake_query', :wt => :ruby, :page => 33, :per_page => 44)
400
- .and_return({})
397
+ @mock_rsolr_client.should_receive(:find).
398
+ with('/fake_access_path/solr/collection_to_search/select', :q => 'fake_query', :wt => :ruby, :page => 33, :per_page => 44).
399
+ and_return({})
401
400
 
402
401
  @collection.search(:q => 'fake_query', :wt => :ruby, :page => 33, :per_page => 44)
403
402
  end
@@ -408,10 +407,9 @@ describe LucidWorks::Collection do
408
407
  end
409
408
 
410
409
  it "should call RSolr.get to perform the search" do
411
- @mock_rsolr_client.should_receive(:find)
412
- .with('/fake_access_path/solr/collection_to_search/select',
413
- :q => 'fake_query', :wt => :xml, :page => 1, :per_page => 10)
414
- .and_return(@good_xml)
410
+ @mock_rsolr_client.should_receive(:find).
411
+ with('/fake_access_path/solr/collection_to_search/select', :q => 'fake_query', :wt => :xml, :page => 1, :per_page => 10).
412
+ and_return(@good_xml)
415
413
 
416
414
  @collection.search(:q => 'fake_query', :wt => :xml)
417
415
  end
@@ -15,9 +15,14 @@ require 'spec_helper'
15
15
 
16
16
  describe LucidWorks::Datasource::Schedule do
17
17
  before :all do
18
+ @system_tz = ENV['TZ']
18
19
  ENV['TZ'] = 'UTC'
19
20
  end
20
21
 
22
+ after :all do
23
+ ENV['TZ'] = @system_tz
24
+ end
25
+
21
26
  before do
22
27
  @server = connect_to_live_server
23
28
  @schedule = LucidWorks::Datasource::Schedule.new(:parent => @server)
@@ -271,7 +276,7 @@ describe LucidWorks::Datasource::Schedule do
271
276
  context 'sub-time convenience accessors' do
272
277
  describe '#hour' do
273
278
  it 'should return the hour component of the time' do
274
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
279
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
275
280
  @schedule.hour.should == 13
276
281
  end
277
282
 
@@ -283,7 +288,7 @@ describe LucidWorks::Datasource::Schedule do
283
288
 
284
289
  describe '#min' do
285
290
  it 'should return the minute component of the time' do
286
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
291
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
287
292
  @schedule.min.should == 11
288
293
  end
289
294
 
@@ -295,7 +300,7 @@ describe LucidWorks::Datasource::Schedule do
295
300
 
296
301
  describe '#day_of_week' do
297
302
  it 'should return the week component of the time' do
298
- @schedule.start_time = Time.new(2011, 4, 15, 13, 11, 56)
303
+ @schedule.start_time = Time.parse("2011-04-15 13:11:56")
299
304
  @schedule.day_of_week.should == 4
300
305
  end
301
306
 
@@ -314,7 +319,7 @@ describe LucidWorks::Datasource::Schedule do
314
319
  end
315
320
 
316
321
  it 'should be true if period is standard but start_time is > 1 period from now' do
317
- some_random_time = Time.new(2011, 4, 15, 13, 11, 56)
322
+ some_random_time = Time.parse("2011-04-15 13:11:56")
318
323
  more_than_a_day_later = some_random_time.advance(:days => 2)
319
324
 
320
325
  Timecop.freeze some_random_time do
@@ -340,7 +345,7 @@ describe LucidWorks::Datasource::Schedule do
340
345
  end
341
346
 
342
347
  it 'should be false if period is standard and start time is > 1 period in the past' do
343
- some_random_time = Time.new(2011, 4, 15, 13, 11, 56)
348
+ some_random_time = Time.parse("2011-04-15 13:11:56")
344
349
  more_than_a_day_ago = some_random_time.advance(:days => -2)
345
350
  Timecop.freeze some_random_time do
346
351
  @schedule.frequency = 'daily'
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'time'
2
3
 
3
4
  describe Time do
4
5
  describe ".iso8601" do
@@ -16,7 +17,9 @@ describe Time do
16
17
 
17
18
  context "when time is non-UTC" do
18
19
  it "should generate a time with a 4 digit timezone" do
19
- Time.new(2011, 4, 15, 13, 11, 56, "-07:00").iso8601.should == "2011-04-15T13:11:56-0700"
20
+ # In Ruby 1.8.7, the Time class only lets you use your local (system) time, or UTC.
21
+ # Use the Time stdlib's parse method to pass a time zone.
22
+ Time.parse("2011-04-15 13:11:56 -07:00").iso8601.should == "2011-04-15T13:11:56-0700"
20
23
  end
21
24
  end
22
25
  end
@@ -10,6 +10,8 @@ describe LucidWorks::Schema do
10
10
  attributes :anint, :baz, :type => :integer
11
11
  attribute :nullstring, :string, :nil_when_blank => true
12
12
  attribute :time, :iso8601
13
+ attribute :space_list, :list
14
+ attribute :comma_list, :list, :separator => ','
13
15
  end
14
16
  end
15
17
 
@@ -169,6 +171,35 @@ describe LucidWorks::Schema do
169
171
  @model.time.should == 12345678
170
172
  end
171
173
  end
174
+
175
+ context "for a list attribute with the default separator" do
176
+ it "setter should just store an array" do
177
+ @model.space_list = ['one', 'two']
178
+ @model.attributes[:space_list].should == ['one', 'two']
179
+ end
180
+
181
+ it "setter should convert a string to an array" do
182
+ @model.space_list = "three four"
183
+ @model.attributes[:space_list].should == ['three', 'four']
184
+ end
185
+
186
+ it "getter should convert array to space separated string" do
187
+ @model.attributes[:space_list] = ['seven', 'eight']
188
+ @model.space_list.should == 'seven eight'
189
+ end
190
+ end
191
+
192
+ context "for a list attribute with a , separator" do
193
+ it "setter should convert a string to an array" do
194
+ @model.comma_list = "five,six"
195
+ @model.attributes[:comma_list].should == ['five', 'six']
196
+ end
197
+
198
+ it "getter should convert array to , separated string" do
199
+ @model.attributes[:comma_list] = ['nine', 'ten']
200
+ @model.comma_list.should == 'nine,ten'
201
+ end
202
+ end
172
203
  end
173
204
 
174
205
  describe "#has_attribute?" do
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.2
5
+ version: 0.7.9
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-08-23 00:00:00 -04:00
13
+ date: 2011-09-02 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,7 @@ files:
105
105
  - .rspec
106
106
  - .rvmrc
107
107
  - Gemfile
108
+ - Gemfile.lock
108
109
  - LICENSE
109
110
  - NOTICE
110
111
  - README.rdoc
@@ -153,6 +154,7 @@ files:
153
154
  - lib/lucid_works/schema/custom_attribute.rb
154
155
  - lib/lucid_works/schema/integer_attribute.rb
155
156
  - lib/lucid_works/schema/iso8601_attribute.rb
157
+ - lib/lucid_works/schema/list_attribute.rb
156
158
  - lib/lucid_works/schema/string_attribute.rb
157
159
  - lib/lucid_works/server.rb
158
160
  - lib/lucid_works/simple_naming.rb
@@ -171,6 +173,7 @@ files:
171
173
  - spec/lib/lucid_works/associations/has_one_spec.rb
172
174
  - spec/lib/lucid_works/associations_spec.rb
173
175
  - spec/lib/lucid_works/base_spec.rb
176
+ - spec/lib/lucid_works/collection/acl_config_spec.rb
174
177
  - spec/lib/lucid_works/collection/activity/history_spec.rb
175
178
  - spec/lib/lucid_works/collection/activity/status_spec.rb
176
179
  - spec/lib/lucid_works/collection/activity_spec.rb
@@ -231,6 +234,7 @@ test_files:
231
234
  - spec/lib/lucid_works/associations/has_one_spec.rb
232
235
  - spec/lib/lucid_works/associations_spec.rb
233
236
  - spec/lib/lucid_works/base_spec.rb
237
+ - spec/lib/lucid_works/collection/acl_config_spec.rb
234
238
  - spec/lib/lucid_works/collection/activity/history_spec.rb
235
239
  - spec/lib/lucid_works/collection/activity/status_spec.rb
236
240
  - spec/lib/lucid_works/collection/activity_spec.rb