Skip to content

Commit

Permalink
Merge branch 'downstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat Brown committed Sep 21, 2009
2 parents bd4e91d + 6abdcca commit 20a34e6
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -6,7 +6,7 @@ task :default => :spec

desc 'Run all specs'
Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_files = FileList['spec/*_spec.rb']
t.spec_opts << '--color'
end

Expand Down
35 changes: 24 additions & 11 deletions lib/sunspot/rails/configuration.rb
Expand Up @@ -142,18 +142,13 @@ def auto_commit_after_request?
def log_file
@log_file ||= (user_configuration_from_key('solr', 'log_file') || default_log_file_location )
end

def data_path
@data_path ||= user_configuration_from_key('solr', 'data_path') || File.join(::Rails.root, 'solr', 'data', ::Rails.env)
end

#
# The solr home directory. Sunspot::Rails expects this directory
# to contain a config, data and pids directory. See
# Sunspot::Rails::Server.bootstrap for more information.
#
# ==== Returns
#
# String:: solr_home
#
def solr_home
@solr_home ||= (user_configuration_from_key('solr', 'solr_home') || File.join( ::Rails.root, 'solr' ))
def pid_path
@pids_path ||= user_configuration_from_key('solr', 'pid_path') || File.join(::Rails.root, 'solr', 'pids', ::Rails.env)
end

#
Expand All @@ -168,6 +163,24 @@ def auto_commit_after_request?
@auto_commit_after_request ||=
user_configuration_from_key('auto_commit_after_request') != false
end

#
# The solr home directory. Sunspot::Rails expects this directory
# to contain a config, data and pids directory. See
# Sunspot::Rails::Server.bootstrap for more information.
#
# ==== Returns
#
# String:: solr_home
#
def solr_home
@solr_home ||=
if user_configuration_from_key('solr', 'solr_home')
user_configuration_from_key('solr', 'solr_home')
elsif %w(solrconfig schema).all? { |file| File.exist?(File.join(::Rails.root, 'solr', 'conf', "#{file}.xml")) }
File.join(::Rails.root, 'solr')
end
end

private

Expand Down
1 change: 0 additions & 1 deletion spec/.gitignore

This file was deleted.

47 changes: 39 additions & 8 deletions spec/configuration_spec.rb
@@ -1,8 +1,8 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require File.dirname(__FILE__) + '/spec_helper'

describe Sunspot::Rails::Configuration, "default values" do
before(:each) do
File.should_receive(:exist?).and_return(false)
File.should_receive(:exist?).at_least(:once).and_return(false)
@config = Sunspot::Rails::Configuration.new
end

Expand Down Expand Up @@ -31,23 +31,39 @@
@config.solr_home.should == '/some/path/solr'
end

it "should handle the 'data_path' property when not set" do
config = Sunspot::Rails::Configuration.new
config.data_path.should == File.dirname(__FILE__) + '/mock_app/solr/data/test'
end

it "should handle the 'pid_path' property when not set" do
config = Sunspot::Rails::Configuration.new
config.pid_path.should == File.dirname(__FILE__) + '/mock_app/solr/pids/test'
end

it "should handle the 'solr_home' property when not set" do
config = Sunspot::Rails::Configuration.new
config.solr_home.should == nil
end

it "should handle the 'auto_commit_after_request' propery when not set" do
@config.auto_commit_after_request?.should == true
end
end

describe Sunspot::Rails::Configuration, "user settings" do
before(:each) do
Rails.stub!(:env => 'config_test')
@config = Sunspot::Rails::Configuration.new
::Rails.stub!(:env => 'config_test')
end

it "should handle the 'hostname' property when not set" do
@config.hostname.should == 'some.host'
it "should handle the 'hostname' property when set" do
config = Sunspot::Rails::Configuration.new
config.hostname.should == 'some.host'
end

it "should handle the 'port' property when not set" do
@config.port.should == 1234
it "should handle the 'port' property when set" do
config = Sunspot::Rails::Configuration.new
config.port.should == 1234
end

it "should handle the 'path' property when set" do
Expand All @@ -62,6 +78,21 @@
@config.solr_home.should == '/another/path/solr'
end

it "should handle the 'data_path' property when set" do
config = Sunspot::Rails::Configuration.new
config.data_path.should == '/my_superior_path/data'
end

it "should handle the 'pid_path' property when set" do
config = Sunspot::Rails::Configuration.new
config.pid_path.should == '/my_superior_path/pids'
end

it "should handle the 'solr_home' property when set" do
config = Sunspot::Rails::Configuration.new
config.solr_home.should == '/my_superior_path'
end

it "should handle the 'auto_commit_after_request' propery when set" do
@config.auto_commit_after_request?.should == false
end
Expand Down
1 change: 1 addition & 0 deletions spec/mock_app/.gitignore
@@ -1 +1,2 @@
solr
db/test.db
17 changes: 17 additions & 0 deletions spec/mock_app/Rakefile
@@ -0,0 +1,17 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'

# Try to load gem tasks. rake gems:install fails if these gems have not yet been
# installed because the Rakefile falls over when it tries to require their tasks.
begin
require 'sunspot/rails/tasks'
rescue Exception => e
puts "Warning, couldn't load gem tasks: #{e.message}! Skipping..."
end
2 changes: 1 addition & 1 deletion spec/mock_app/config/database.yml
@@ -1,4 +1,4 @@
test: &test
:adapter: sqlite3
:dbfile: vendor/plugins/sunspot_rails/spec/test.db
:dbfile: db/test.db
development: *test
3 changes: 2 additions & 1 deletion spec/mock_app/config/environment.rb
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = ENV['RAILS_GEM_VERSION'] || '2.3.2' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = ENV['RAILS_GEM_VERSION'] || '2.3.3' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand All @@ -19,6 +19,7 @@
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
config.gem "qoobaa-sqlite3-ruby", :lib => 'sqlite3', :source => "http://gems.github.com" if RUBY_VERSION > '1.9'

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
Expand Down
4 changes: 3 additions & 1 deletion spec/mock_app/config/sunspot.yml
Expand Up @@ -12,5 +12,7 @@ config_test:
port: 1234
path: /solr/idx
log_level: WARNING
solr_home: /another/path/solr
data_path: /my_superior_path/data
pid_path: /my_superior_path/pids
solr_home: /my_superior_path
auto_commit_after_request: false
File renamed without changes.
3 changes: 3 additions & 0 deletions spec/mock_app/script/console
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
2 changes: 1 addition & 1 deletion spec/model_lifecycle_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require File.dirname(__FILE__) + '/spec_helper'

describe 'searchable with lifecycle' do
integrate_sunspot
Expand Down
2 changes: 1 addition & 1 deletion spec/model_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require File.dirname(__FILE__) + '/spec_helper'

describe 'ActiveRecord mixin' do
integrate_sunspot
Expand Down
2 changes: 1 addition & 1 deletion spec/request_lifecycle_spec.rb
@@ -1,4 +1,4 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
require File.dirname(__FILE__) + '/spec_helper'

describe 'request lifecycle', :type => :controller do
before(:each) do
Expand Down
1 change: 1 addition & 0 deletions spec/spec.opts
@@ -0,0 +1 @@
--color
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -6,14 +6,14 @@
require 'spec'
require 'spec/rails'
require 'rake'
require 'ruby-debug' unless RUBY_VERSION =~ /1\.9/
require 'ruby-debug' unless RUBY_VERSION > '1.9'
require 'sunspot/rails/tasks'
require 'sunspot/spec/extension'

def load_schema
stdout = $stdout
$stdout = StringIO.new # suppress output while building the schema
load File.join(File.dirname(__FILE__), 'schema.rb')
load File.join(ENV['RAILS_ROOT'], 'db', 'schema.rb')
$stdout = stdout
end

Expand Down
35 changes: 16 additions & 19 deletions sunspot_rails.gemspec
@@ -1,26 +1,27 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{sunspot_rails}
s.version = "0.10.5"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Mat Brown", "Peer Allan", "Michael Moen", "Benjamin Krause", "Adam Salter", "Brandon Keepers"]
s.date = %q{2009-09-16}
s.authors = ["Mat Brown", "Peer Allan", "Michael Moen", "Benjamin Krause"]
s.date = %q{2009-09-01}
s.description = %q{Rails integration for the Sunspot Solr search library}
s.email = %q{mat@patch.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
]
s.files = [
"History.txt",
"LICENSE",
"LICENSE",
"MIT-LICENSE",
"MIT-LICENSE",
"README.rdoc",
"Rakefile",
"TODO",
"VERSION.yml",
"dev_tasks/gemspec.rake",
"dev_tasks/rdoc.rake",
Expand All @@ -34,9 +35,7 @@ Gem::Specification.new do |s|
"lib/sunspot/rails/configuration.rb",
"lib/sunspot/rails/request_lifecycle.rb",
"lib/sunspot/rails/searchable.rb",
"lib/sunspot/rails/server.rb",
"lib/sunspot/rails/tasks.rb",
"lib/sunspot/spec/extension.rb",
"rails/init.rb",
"spec/configuration_spec.rb",
"spec/mock_app/app/controllers/application.rb",
Expand All @@ -58,16 +57,13 @@ Gem::Specification.new do |s|
"spec/model_spec.rb",
"spec/request_lifecycle_spec.rb",
"spec/schema.rb",
"spec/server_spec.rb",
"spec/spec_helper.rb",
"spec/sunspot_mocking_spec.rb"
"spec/spec_helper.rb"
]
s.has_rdoc = true
s.homepage = %q{http://github.com/outoftime/sunspot_rails}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{sunspot}
s.rubygems_version = %q{1.3.1}
s.rubygems_version = %q{1.3.3}
s.summary = %q{Rails integration for the Sunspot Solr search library}
s.test_files = [
"spec/configuration_spec.rb",
Expand All @@ -88,33 +84,34 @@ Gem::Specification.new do |s|
"spec/model_spec.rb",
"spec/request_lifecycle_spec.rb",
"spec/schema.rb",
"spec/server_spec.rb",
"spec/spec_helper.rb",
"spec/sunspot_mocking_spec.rb"
"spec/spec_helper.rb"
]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
s.specification_version = 3

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rails>, ["~> 2.1"])
s.add_runtime_dependency(%q<escape>, [">= 0.0.4"])
s.add_runtime_dependency(%q<outoftime-sunspot>, [">= 0.9.7"])
s.add_runtime_dependency(%q<outoftime-sunspot>, [">= 0.8.2"])
s.add_development_dependency(%q<rspec>, ["~> 1.2"])
s.add_development_dependency(%q<rspec-rails>, ["~> 1.2"])
s.add_development_dependency(%q<ruby-debug>, ["~> 0.10"])
s.add_development_dependency(%q<technicalpickles-jeweler>, ["~> 1.0"])
else
s.add_dependency(%q<rails>, ["~> 2.1"])
s.add_dependency(%q<escape>, [">= 0.0.4"])
s.add_dependency(%q<outoftime-sunspot>, [">= 0.9.7"])
s.add_dependency(%q<outoftime-sunspot>, [">= 0.8.2"])
s.add_dependency(%q<rspec>, ["~> 1.2"])
s.add_dependency(%q<rspec-rails>, ["~> 1.2"])
s.add_dependency(%q<ruby-debug>, ["~> 0.10"])
s.add_dependency(%q<technicalpickles-jeweler>, ["~> 1.0"])
end
else
s.add_dependency(%q<rails>, ["~> 2.1"])
s.add_dependency(%q<escape>, [">= 0.0.4"])
s.add_dependency(%q<outoftime-sunspot>, [">= 0.9.7"])
s.add_dependency(%q<outoftime-sunspot>, [">= 0.8.2"])
s.add_dependency(%q<rspec>, ["~> 1.2"])
s.add_dependency(%q<rspec-rails>, ["~> 1.2"])
s.add_dependency(%q<ruby-debug>, ["~> 0.10"])
Expand Down

0 comments on commit 20a34e6

Please sign in to comment.