Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clortho now adding #{searchable_field}_keywords String and #{searchab…

…le_field}_keywords_array methods to included MongoMapper Document.
  • Loading branch information...
commit faa5e4961df328d549abbef6b5651bbd37a8c7d6 1 parent 1fe140f
Mark Coates authored
View
3  Gemfile
@@ -10,4 +10,7 @@ group :development do
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.4"
gem "rcov", ">= 0"
+ gem "mongo_mapper", "~> 0.9.0"
+ gem "taggregator"
+ gem "pry"
end
View
52 Gemfile.lock
@@ -0,0 +1,52 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activemodel (3.0.9)
+ activesupport (= 3.0.9)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activesupport (3.0.9)
+ bson (1.3.1)
+ builder (2.1.2)
+ coderay (0.9.8)
+ git (1.2.5)
+ i18n (0.5.0)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ method_source (0.6.0)
+ ruby_parser (>= 2.0.5)
+ mongo (1.3.1)
+ bson (>= 1.3.1)
+ mongo_mapper (0.9.1)
+ activemodel (~> 3.0)
+ activesupport (~> 3.0)
+ plucky (~> 0.3.8)
+ plucky (0.3.8)
+ mongo (~> 1.3)
+ pry (0.9.3)
+ coderay (>= 0.9.8)
+ method_source (>= 0.6.0)
+ ruby_parser (>= 2.0.5)
+ slop (~> 1.9.0)
+ rake (0.9.2)
+ rcov (0.9.9)
+ ruby_parser (2.0.6)
+ sexp_processor (~> 3.0)
+ sexp_processor (3.0.5)
+ shoulda (2.11.3)
+ slop (1.9.1)
+ taggregator (0.0.2.dev)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundler (~> 1.0.0)
+ jeweler (~> 1.6.4)
+ mongo_mapper (~> 0.9.0)
+ pry
+ rcov
+ shoulda
+ taggregator
View
25 lib/clortho.rb
@@ -0,0 +1,25 @@
+module MongoMapper
+ module Plugins
+ module Clortho
+ extend ActiveSupport::Concern
+
+ included do
+ end
+
+ module ClassMethods
+
+ def search_on(*args)
+ args.each do |arg|
+ key :"#{arg}_keywords", String
+ key :"#{arg}_keywords_array", Array
+ end
+ end
+
+ end
+
+ module InstanceMethods
+ end
+
+ end
+ end
+end
View
13 test/helper.rb
@@ -1,5 +1,9 @@
require 'rubygems'
require 'bundler'
+require 'active_support'
+require 'pry'
+require 'mongo_mapper'
+require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
@@ -14,5 +18,14 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'clortho'
+MongoMapper.database = 'testing_clortho'
+
+require 'models/post'
+
class Test::Unit::TestCase
end
+
+@lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porttitor, ipsum a commodo aliquet,
+ velit ligula porttitor eros, sit amet consequat purus massa sit amet quam. Aliquam tempus magna faucibus
+ lacus ultricies rhoncus. In ut metus purus, at venenatis est. Donec vel elementum turpis. Nullam feugiat
+ massa quis elit egestas."
View
11 test/models/post.rb
@@ -0,0 +1,11 @@
+class Post
+ include MongoMapper::Document
+ include MongoMapper::Plugins::Clortho
+
+ key :title, String
+ key :body, String
+ key :authors, Array
+
+ search_on :body
+
+end
View
25 test/test_clortho.rb
@@ -1,7 +1,28 @@
require 'helper'
class TestClortho < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+ def setup
+ @posts = [
+ (@fridge = Post.new( title: 'Is your refrigerator running? Better catch it',
+ body: @lipsum,
+ authors: ['Thomas Mann', 'Jim Byrd'])),
+ (@colonial = Post.new( title: 'The Colonial: In Full Swing',
+ body: @lipsum,
+ authors: ['Rebecca Simmons']))
+ ]
+ save_posts
end
+
+ should 'have a body_keywords field' do
+ @posts.each do |post|
+ assert post.respond_to? :body_keywords
+ assert post.respond_to? :body_keywords_array
+ end
+ end
+
+ private
+ def save_posts
+ @posts.each{ |post| post.save }
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.