erp_search 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/app/models/party_search_fact.rb +2 -2
- data/lib/erp_search.rb +1 -0
- data/lib/erp_search/engine.rb +7 -1
- data/lib/erp_search/version.rb +7 -1
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +46 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/spec.rb +27 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/party_search_fact_spec.rb +11 -0
- data/spec/solr_spec.rb +254 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/support/enable_sunspot.rb +45 -0
- metadata +175 -29
data/README.rdoc
CHANGED
@@ -53,7 +53,7 @@ class PartySearchFact < ActiveRecord::Base
|
|
53
53
|
:roles => (party.user.roles.map { |role| role.internal_identifier }.join(',') rescue ''),
|
54
54
|
:party_description => party.description,
|
55
55
|
:party_business_party_type => party.business_party_type,
|
56
|
-
:user_login => (party.user.
|
56
|
+
:user_login => (party.user.username rescue ''),
|
57
57
|
:individual_current_last_name => (party.business_party.current_last_name rescue ''),
|
58
58
|
:individual_current_first_name => (party.business_party.current_first_name rescue ''),
|
59
59
|
:individual_current_middle_name => (party.business_party.current_middle_name rescue ''),
|
@@ -77,4 +77,4 @@ class PartySearchFact < ActiveRecord::Base
|
|
77
77
|
Sunspot.commit
|
78
78
|
end
|
79
79
|
|
80
|
-
end
|
80
|
+
end
|
data/lib/erp_search.rb
CHANGED
data/lib/erp_search/engine.rb
CHANGED
@@ -8,6 +8,12 @@ module ErpSearch
|
|
8
8
|
#this is ugly need a better way
|
9
9
|
observers = [:party_observer, :contact_observer]
|
10
10
|
(config.active_record.observers.nil?) ? config.active_record.observers = observers : config.active_record.observers += observers
|
11
|
-
|
11
|
+
|
12
|
+
#TODO
|
13
|
+
#this will be removed once rails 3.2 adds the ability to set the order of engine loading
|
14
|
+
engine = self
|
15
|
+
config.to_prepare do
|
16
|
+
ErpBaseErpSvcs.register_compass_ae_engine(engine)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
data/lib/erp_search/version.rb
CHANGED
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "erp_base_erp_svcs"
|
7
|
+
require "erp_tech_svcs"
|
8
|
+
require "erp_app"
|
9
|
+
require "knitkit"
|
10
|
+
require "erp_search"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
|
42
|
+
# Enable the asset pipeline
|
43
|
+
config.assets.enabled = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Warning: The database defined as "test" will be erased and
|
2
|
+
# re-generated from your development database when you run "rake".
|
3
|
+
# Do not set this db to the same as development or production.
|
4
|
+
spec:
|
5
|
+
adapter: sqlite3
|
6
|
+
database: db/spec.sqlite3
|
7
|
+
pool: 5
|
8
|
+
timeout: 5000
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Do not compress assets
|
26
|
+
config.assets.compress = false
|
27
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = 'ae0d58840f73a49e40850c9d815a6a135e169865cdb8721cec7f335a738af09f3483de0f99d7c131f8fdecf2d8b508f8fd5e2e33c8d0565dcc9030eadb227695'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActionController::Base.wrap_parameters :format => [:json]
|
8
|
+
|
9
|
+
# Disable root element in JSON by default.
|
10
|
+
if defined?(ActiveRecord)
|
11
|
+
ActiveRecord::Base.include_root_in_json = false
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
@@ -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'
|
data/spec/solr_spec.rb
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/enable_sunspot'
|
3
|
+
|
4
|
+
describe 'test content' do
|
5
|
+
include EnableSunspot
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@c = Article.create!(
|
9
|
+
:title => 'title',
|
10
|
+
:excerpt_html => 'excerpt',
|
11
|
+
:body_html => 'test content'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return results specified by search' do
|
16
|
+
Content.search do
|
17
|
+
keywords 'test content'
|
18
|
+
end.results.should == [@c]
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should not return results excluded by search' do
|
22
|
+
Content.search do
|
23
|
+
keywords 'bogus content'
|
24
|
+
end.results.should be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should update correctly' do
|
28
|
+
@c.update_attribute(:body_html, 'updated content')
|
29
|
+
|
30
|
+
Content.search do
|
31
|
+
keywords 'updated content'
|
32
|
+
end.results.should == [@c]
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should destroy correctly' do
|
36
|
+
@c.destroy
|
37
|
+
|
38
|
+
Content.search do
|
39
|
+
keywords 'test content'
|
40
|
+
end.results.should be_empty
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
describe 'test party' do
|
46
|
+
include EnableSunspot
|
47
|
+
|
48
|
+
before :each do
|
49
|
+
@party = Party.new
|
50
|
+
@party.description = 'John Doe'
|
51
|
+
@party.save
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should return results specified by search' do
|
55
|
+
PartySearchFact.search do
|
56
|
+
with :party_description, 'John Doe'
|
57
|
+
end.results.should == [@party.party_search_fact]
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should not return results excluded by search' do
|
61
|
+
PartySearchFact.search do
|
62
|
+
with :party_description, 'Bogus Party'
|
63
|
+
end.results.should be_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should update correctly' do
|
67
|
+
@party.description = 'Bob Doe'
|
68
|
+
@party.save
|
69
|
+
|
70
|
+
PartySearchFact.search do
|
71
|
+
with :party_description, 'Bob Doe'
|
72
|
+
end.results.should == [@party.party_search_fact]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'test individual' do
|
77
|
+
include EnableSunspot
|
78
|
+
|
79
|
+
before :each do
|
80
|
+
@i = Individual.new
|
81
|
+
@i.current_first_name = 'John'
|
82
|
+
@i.current_last_name = 'Doe'
|
83
|
+
@i.save
|
84
|
+
|
85
|
+
@party = @i.party
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should return results specified by search' do
|
89
|
+
PartySearchFact.search do
|
90
|
+
with :party_description, 'John Doe'
|
91
|
+
end.results.should == [@party.party_search_fact]
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should not return results excluded by search' do
|
95
|
+
PartySearchFact.search do
|
96
|
+
with :party_description, 'Bogus Party'
|
97
|
+
end.results.should be_empty
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should update correctly' do
|
101
|
+
@party.business_party.current_first_name = 'Bob'
|
102
|
+
@party.business_party.current_last_name = 'Doe'
|
103
|
+
@party.business_party.save
|
104
|
+
|
105
|
+
PartySearchFact.search do
|
106
|
+
keywords 'Bob Doe'
|
107
|
+
end.results.should == [@party.party_search_fact]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'test phone number' do
|
112
|
+
include EnableSunspot
|
113
|
+
|
114
|
+
before :each do
|
115
|
+
personal = ContactPurpose.find_by_internal_identifier('personal')
|
116
|
+
personal = ContactPurpose.create(:internal_identifier => 'personal', :description => 'Personal') if personal.nil?
|
117
|
+
|
118
|
+
@party = Party.new
|
119
|
+
@party.description = 'John Doe'
|
120
|
+
@party.save
|
121
|
+
@party.update_or_add_contact_with_purpose(PhoneNumber, personal, :phone_number => '123-456-7890')
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should return results specified by search' do
|
125
|
+
PartySearchFact.search do
|
126
|
+
keywords '123-456-7890'
|
127
|
+
end.results.should == [@party.party_search_fact]
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should not return results excluded by search' do
|
131
|
+
PartySearchFact.search do
|
132
|
+
keywords '000-000-0000'
|
133
|
+
end.results.should be_empty
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should update correctly' do
|
137
|
+
phone = @party.personal_phone_number
|
138
|
+
phone.phone_number = '333-333-3333'
|
139
|
+
phone.save
|
140
|
+
|
141
|
+
PartySearchFact.search do
|
142
|
+
keywords '333-333-3333'
|
143
|
+
end.results.should == [@party.party_search_fact]
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should destroy correctly' do
|
147
|
+
phone = @party.personal_phone_number
|
148
|
+
phone.destroy
|
149
|
+
|
150
|
+
PartySearchFact.search do
|
151
|
+
keywords '123-456-7890'
|
152
|
+
end.results.should be_empty
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe 'test email address' do
|
157
|
+
include EnableSunspot
|
158
|
+
|
159
|
+
before :each do
|
160
|
+
personal = ContactPurpose.find_by_internal_identifier('personal')
|
161
|
+
personal = ContactPurpose.create(:internal_identifier => 'personal', :description => 'Personal') if personal.nil?
|
162
|
+
|
163
|
+
@party = Party.new
|
164
|
+
@party.description = 'John Doe'
|
165
|
+
@party.save
|
166
|
+
@party.update_or_add_contact_with_purpose(EmailAddress, personal, :email_address => 'john@doe.com')
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should return results specified by search' do
|
170
|
+
PartySearchFact.search do
|
171
|
+
keywords 'john@doe.com'
|
172
|
+
end.results.should == [@party.party_search_fact]
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should not return results excluded by search' do
|
176
|
+
PartySearchFact.search do
|
177
|
+
keywords 'no@email.com'
|
178
|
+
end.results.should be_empty
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should update correctly' do
|
182
|
+
email = @party.personal_email_address
|
183
|
+
email.email_address = 'updated@email.com'
|
184
|
+
email.save
|
185
|
+
|
186
|
+
PartySearchFact.search do
|
187
|
+
keywords 'updated@email.com'
|
188
|
+
end.results.should == [@party.party_search_fact]
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should destroy correctly' do
|
192
|
+
email = @party.personal_email_address
|
193
|
+
email.destroy
|
194
|
+
|
195
|
+
PartySearchFact.search do
|
196
|
+
keywords 'john@doe.com'
|
197
|
+
end.results.should be_empty
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe 'test postal address' do
|
202
|
+
include EnableSunspot
|
203
|
+
|
204
|
+
before :each do
|
205
|
+
home = ContactPurpose.find_by_internal_identifier('home')
|
206
|
+
home = ContactPurpose.create(:internal_identifier => 'home', :description => 'Home') if home.nil?
|
207
|
+
|
208
|
+
@party = Party.new
|
209
|
+
@party.description = 'John Doe'
|
210
|
+
@party.save
|
211
|
+
|
212
|
+
postal_address_args = {
|
213
|
+
:address_line_1 => '123 Main Street',
|
214
|
+
:address_line_2 => 'BOX 123',
|
215
|
+
:city => 'Orlando',
|
216
|
+
:state => 'FL',
|
217
|
+
:zip => '32724',
|
218
|
+
:country => 'US'
|
219
|
+
}
|
220
|
+
|
221
|
+
@party.update_or_add_contact_with_purpose(PostalAddress, home, postal_address_args)
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should return results specified by search' do
|
225
|
+
PartySearchFact.search do
|
226
|
+
with :party_address_1, '123 Main Street'
|
227
|
+
end.results.should == [@party.party_search_fact]
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should not return results excluded by search' do
|
231
|
+
PartySearchFact.search do
|
232
|
+
with :party_address_1, 'Bogus Address'
|
233
|
+
end.results.should be_empty
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should update correctly' do
|
237
|
+
address = @party.home_postal_address
|
238
|
+
address.address_line_1 = '1 Orange Ave'
|
239
|
+
address.save
|
240
|
+
|
241
|
+
PartySearchFact.search do
|
242
|
+
with :party_address_1, '1 Orange Ave'
|
243
|
+
end.results.should == [@party.party_search_fact]
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should destroy correctly' do
|
247
|
+
address = @party.home_postal_address
|
248
|
+
address.destroy
|
249
|
+
|
250
|
+
PartySearchFact.search do
|
251
|
+
with :party_address_1, '123 Main Street'
|
252
|
+
end.results.should be_empty
|
253
|
+
end
|
254
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spork'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
# Loading more in this block will cause your tests to run faster. However,
|
6
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
7
|
+
# need to restart spork for it take effect.
|
8
|
+
|
9
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
10
|
+
DUMMY_APP_ROOT=File.join(File.dirname(__FILE__), '/dummy')
|
11
|
+
|
12
|
+
require 'active_support'
|
13
|
+
require 'active_model'
|
14
|
+
require 'active_record'
|
15
|
+
require 'action_controller'
|
16
|
+
|
17
|
+
# Configure Rails Envinronment
|
18
|
+
ENV["RAILS_ENV"] = "spec"
|
19
|
+
require File.expand_path(DUMMY_APP_ROOT + "/config/environment.rb", __FILE__)
|
20
|
+
|
21
|
+
ActiveRecord::Base.configurations = YAML::load(IO.read(DUMMY_APP_ROOT + "/config/database.yml"))
|
22
|
+
ActiveRecord::Base.establish_connection(ENV["DB"] || "spec")
|
23
|
+
ActiveRecord::Migration.verbose = false
|
24
|
+
|
25
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
26
|
+
# in spec/support/ and its subdirectories.
|
27
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
28
|
+
|
29
|
+
require 'rspec/rails'
|
30
|
+
require 'erp_dev_svcs'
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
config.use_transactional_fixtures = true
|
34
|
+
config.include Sorcery::TestHelpers::Rails
|
35
|
+
config.include ErpDevSvcs
|
36
|
+
config.include ErpDevSvcs::ControllerSupport, :type => :controller
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Spork.each_run do
|
41
|
+
#We have to execute the migrations from dummy app directory
|
42
|
+
Dir.chdir DUMMY_APP_ROOT
|
43
|
+
`rake db:drop`
|
44
|
+
Dir.chdir ENGINE_RAILS_ROOT
|
45
|
+
|
46
|
+
#We have to execute the migrations from dummy app directory
|
47
|
+
Dir.chdir DUMMY_APP_ROOT
|
48
|
+
`rake db:migrate`
|
49
|
+
Dir.chdir ENGINE_RAILS_ROOT
|
50
|
+
|
51
|
+
ErpDevSvcs::FactorySupport.load_engine_factories
|
52
|
+
|
53
|
+
require 'simplecov'
|
54
|
+
SimpleCov.start 'rails' do
|
55
|
+
add_filter "spec/"
|
56
|
+
end
|
57
|
+
#Need to explictly load the files in lib/ until we figure out how to
|
58
|
+
#get rails to autoload them for spec like it used to...
|
59
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "lib/**/*.rb")].each {|f| load f}
|
60
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Put this in spec/support/
|
3
|
+
# Will use a sunspot stub session as default in all tests,
|
4
|
+
# but if you include the EnableSunspot module inside of a describe block
|
5
|
+
# it will index record and make them searchable inside of that block.
|
6
|
+
#
|
7
|
+
|
8
|
+
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
|
9
|
+
|
10
|
+
module EnableSunspot
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
before(:all) do
|
15
|
+
Sunspot.session = Sunspot.session.original_session
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
Sunspot.remove_all!
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Make sunspot index right away in test environment.
|
30
|
+
#
|
31
|
+
module Sunspot
|
32
|
+
module Rails
|
33
|
+
module Searchable
|
34
|
+
module InstanceMethods
|
35
|
+
def solr_index
|
36
|
+
solr_index!
|
37
|
+
end
|
38
|
+
|
39
|
+
def solr_remove_from_index
|
40
|
+
solr_remove_from_index!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erp_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,41 +9,129 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: knitkit
|
16
|
+
requirement: &81100010 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81100010
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: erp_dev_svcs
|
27
|
+
requirement: &81099220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 3.0.1
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *81099220
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: railties
|
38
|
+
requirement: &81098510 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.0
|
33
44
|
type: :runtime
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *81098510
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
48
|
+
name: actionmailer
|
49
|
+
requirement: &81097360 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *81097360
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: actionpack
|
60
|
+
requirement: &81095260 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 3.1.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *81095260
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: &81094360 !ruby/object:Gem::Requirement
|
39
72
|
none: false
|
40
73
|
requirements:
|
41
|
-
- -
|
74
|
+
- - ~>
|
42
75
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
76
|
+
version: 3.1.0
|
44
77
|
type: :runtime
|
45
78
|
prerelease: false
|
46
|
-
version_requirements: *
|
79
|
+
version_requirements: *81094360
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: activeresource
|
82
|
+
requirement: &81093290 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 3.1.0
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *81093290
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: activesupport
|
93
|
+
requirement: &81118940 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.1.0
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *81118940
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: rails
|
104
|
+
requirement: &81117250 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 3.1.0
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *81117250
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: sunspot_rails
|
115
|
+
requirement: &81116380 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - =
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.3.1
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *81116380
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: sunspot_solr
|
126
|
+
requirement: &81115680 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - =
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.3.1
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *81115680
|
47
135
|
description: The CompassAE Search Engine provides functionality to facilitate both
|
48
136
|
dimensional and index-based searches. CompassAE by default will search for an instance
|
49
137
|
of SOLR/Sunspot and use it if it is available, otherwise it will attempt to use
|
@@ -55,31 +143,60 @@ executables: []
|
|
55
143
|
extensions: []
|
56
144
|
extra_rdoc_files: []
|
57
145
|
files:
|
58
|
-
- app/assets/javascripts/erp_search/application.js
|
59
146
|
- app/assets/stylesheets/erp_search/application.css
|
60
|
-
- app/
|
61
|
-
- app/
|
62
|
-
- app/models/extensions/content.rb
|
63
|
-
- app/models/extensions/party.rb
|
147
|
+
- app/assets/javascripts/erp_search/application.js
|
148
|
+
- app/views/layouts/erp_search/application.html.erb
|
64
149
|
- app/models/party_search_fact.rb
|
65
|
-
- app/
|
66
|
-
- app/
|
67
|
-
- app/observers/individual_observer.rb
|
68
|
-
- app/observers/organization_observer.rb
|
69
|
-
- app/observers/party_observer.rb
|
150
|
+
- app/models/extensions/party.rb
|
151
|
+
- app/models/extensions/content.rb
|
70
152
|
- app/observers/phone_number_observer.rb
|
153
|
+
- app/observers/party_observer.rb
|
154
|
+
- app/observers/organization_observer.rb
|
155
|
+
- app/observers/contact_observer.rb
|
71
156
|
- app/observers/postal_address_observer.rb
|
72
|
-
- app/
|
157
|
+
- app/observers/individual_observer.rb
|
158
|
+
- app/observers/email_address_observer.rb
|
159
|
+
- app/helpers/erp_search/application_helper.rb
|
160
|
+
- app/controllers/erp_search/application_controller.rb
|
73
161
|
- config/routes.rb
|
74
162
|
- config/sunspot.yml
|
75
163
|
- db/migrate/20110817165116_recreate_party_search_facts_table.rb
|
76
|
-
- lib/erp_search/engine.rb
|
77
|
-
- lib/erp_search/version.rb
|
78
164
|
- lib/erp_search.rb
|
79
165
|
- lib/tasks/solr_index.rake
|
166
|
+
- lib/erp_search/engine.rb
|
167
|
+
- lib/erp_search/version.rb
|
80
168
|
- GPL-3-LICENSE
|
81
169
|
- Rakefile
|
82
170
|
- README.rdoc
|
171
|
+
- spec/support/enable_sunspot.rb
|
172
|
+
- spec/solr_spec.rb
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
- spec/models/party_search_fact_spec.rb
|
175
|
+
- spec/dummy/public/422.html
|
176
|
+
- spec/dummy/public/404.html
|
177
|
+
- spec/dummy/public/500.html
|
178
|
+
- spec/dummy/public/favicon.ico
|
179
|
+
- spec/dummy/config.ru
|
180
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
181
|
+
- spec/dummy/app/assets/javascripts/application.js
|
182
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
183
|
+
- spec/dummy/app/helpers/application_helper.rb
|
184
|
+
- spec/dummy/app/controllers/application_controller.rb
|
185
|
+
- spec/dummy/config/routes.rb
|
186
|
+
- spec/dummy/config/locales/en.yml
|
187
|
+
- spec/dummy/config/boot.rb
|
188
|
+
- spec/dummy/config/application.rb
|
189
|
+
- spec/dummy/config/environments/spec.rb
|
190
|
+
- spec/dummy/config/initializers/mime_types.rb
|
191
|
+
- spec/dummy/config/initializers/session_store.rb
|
192
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
193
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
194
|
+
- spec/dummy/config/initializers/inflections.rb
|
195
|
+
- spec/dummy/config/initializers/secret_token.rb
|
196
|
+
- spec/dummy/config/environment.rb
|
197
|
+
- spec/dummy/config/database.yml
|
198
|
+
- spec/dummy/Rakefile
|
199
|
+
- spec/dummy/script/rails
|
83
200
|
homepage: http://development.compassagile.com
|
84
201
|
licenses: []
|
85
202
|
post_install_message:
|
@@ -105,4 +222,33 @@ signing_key:
|
|
105
222
|
specification_version: 3
|
106
223
|
summary: The CompassAE Search Engine provides functionality to facilitate both dimensional
|
107
224
|
and index-based searches.
|
108
|
-
test_files:
|
225
|
+
test_files:
|
226
|
+
- spec/support/enable_sunspot.rb
|
227
|
+
- spec/solr_spec.rb
|
228
|
+
- spec/spec_helper.rb
|
229
|
+
- spec/models/party_search_fact_spec.rb
|
230
|
+
- spec/dummy/public/422.html
|
231
|
+
- spec/dummy/public/404.html
|
232
|
+
- spec/dummy/public/500.html
|
233
|
+
- spec/dummy/public/favicon.ico
|
234
|
+
- spec/dummy/config.ru
|
235
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
236
|
+
- spec/dummy/app/assets/javascripts/application.js
|
237
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
238
|
+
- spec/dummy/app/helpers/application_helper.rb
|
239
|
+
- spec/dummy/app/controllers/application_controller.rb
|
240
|
+
- spec/dummy/config/routes.rb
|
241
|
+
- spec/dummy/config/locales/en.yml
|
242
|
+
- spec/dummy/config/boot.rb
|
243
|
+
- spec/dummy/config/application.rb
|
244
|
+
- spec/dummy/config/environments/spec.rb
|
245
|
+
- spec/dummy/config/initializers/mime_types.rb
|
246
|
+
- spec/dummy/config/initializers/session_store.rb
|
247
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
248
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
249
|
+
- spec/dummy/config/initializers/inflections.rb
|
250
|
+
- spec/dummy/config/initializers/secret_token.rb
|
251
|
+
- spec/dummy/config/environment.rb
|
252
|
+
- spec/dummy/config/database.yml
|
253
|
+
- spec/dummy/Rakefile
|
254
|
+
- spec/dummy/script/rails
|