Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial structure

  • Loading branch information...
commit 4e63fe27b2184df2e5c2034513c4cfda52481050 1 parent 0f74791
@ryanb authored
View
1  .gitignore
@@ -0,0 +1 @@
+*.sqlite3
View
4 Rakefile
@@ -0,0 +1,4 @@
+require 'rubygems'
+require 'rake'
+
+Dir["#{File.dirname(__FILE__)}/tasks/*.rb"].sort.each { |ext| load ext }
View
3  lib/xapit_sync.rb
@@ -0,0 +1,3 @@
+$:.unshift(File.dirname(__FILE__))
+require 'xapit_sync/membership'
+require 'xapit_sync/xapit_change'
View
9 lib/xapit_sync/membership.rb
@@ -0,0 +1,9 @@
+module XapitSync
+ module Membership
+ def self.included(base)
+ base.after_save do |record|
+ XapitChange.create!(:target_class => record.class.name)
+ end
+ end
+ end
+end
View
2  lib/xapit_sync/xapit_change.rb
@@ -0,0 +1,2 @@
+class XapitChange < ActiveRecord::Base
+end
View
11 spec/schema.rb
@@ -0,0 +1,11 @@
+ActiveRecord::Schema.define(:version => 0) do
+
+ create_table "recipes", :force => true do |t|
+ t.string "name"
+ end
+
+ create_table "xapit_changes", :force => true do |t|
+ t.string "target_class"
+ end
+
+end
View
4 spec/spec.opts
@@ -0,0 +1,4 @@
+--colour
+--format progress
+--loadby mtime
+--reverse
View
29 spec/spec_helper.rb
@@ -0,0 +1,29 @@
+require 'rubygems'
+require 'spec'
+require 'active_support'
+require 'active_record'
+require 'xapit' # gem install xapit
+
+# setup database adapter
+ActiveRecord::Base.establish_connection({
+ :adapter => "sqlite3",
+ :dbfile => File.dirname(__FILE__) + "/test.sqlite3"
+})
+
+load File.dirname(__FILE__) + '/schema.rb' unless File.exist?(File.dirname(__FILE__) + "/test.sqlite3")
+
+require File.dirname(__FILE__) + '/../lib/xapit_sync'
+
+class Recipe < ActiveRecord::Base
+ include Xapit::Membership # temporary until xapit gem properly does this
+ xapit do |index|
+ index.text :name
+ index.field :name
+ index.facet :name
+ end
+ include XapitSync::Membership # TODO this should happen automatically in xapit
+end
+
+Spec::Runner.configure do |config|
+ config.mock_with :rr
+end
View
9 spec/xapit_sync/membership_spec.rb
@@ -0,0 +1,9 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe Recipe do
+ it "should make xapit change when created" do
+ XapitChange.delete_all
+ Recipe.create!(:name => "foo")
+ XapitChange.first.target_class == "Recipe"
+ end
+end
View
9 tasks/spec.rb
@@ -0,0 +1,9 @@
+require 'spec/rake/spectask'
+
+spec_files = Rake::FileList["spec/**/*_spec.rb"]
+
+desc "Run specs"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = spec_files
+ t.spec_opts = ["-c"]
+end
Please sign in to comment.
Something went wrong with that request. Please try again.