pose 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +12 -3
- data/lib/generators/templates/migration.rb +4 -4
- data/lib/pose/model_additions.rb +2 -2
- data/lib/pose/models/pose_assignment.rb +2 -2
- data/lib/pose/models/pose_word.rb +1 -1
- data/lib/pose/static_helpers.rb +7 -5
- data/lib/pose/version.rb +1 -1
- data/spec/factories.rb +12 -9
- data/spec/pose_assignment_spec.rb +6 -6
- data/spec/pose_spec.rb +42 -33
- data/spec/spec_helper.rb +6 -6
- metadata +60 -20
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # Pose  | 
| 1 | 
            +
            # Pose <a href="http://travis-ci.org/#!/kevgo/pose" target="_blank"><img src="https://secure.travis-ci.org/kevgo/pose.png" alt="Build status"></a>
         | 
| 2 2 |  | 
| 3 3 | 
             
            Pose  ("Polymorphic Search") allows fulltext search for ActiveRecord objects.
         | 
| 4 4 |  | 
| @@ -118,8 +118,8 @@ Happy searching!  :) | |
| 118 118 | 
             
            ```ruby
         | 
| 119 119 | 
             
            result = Pose.search 'foo',
         | 
| 120 120 | 
             
                                 MyClass,
         | 
| 121 | 
            -
                                 : | 
| 122 | 
            -
                                 : | 
| 121 | 
            +
                                 limit: 3,            # Limit the result count to 3.
         | 
| 122 | 
            +
                                 result_type: :ids    # Don't load the resulting objects, return just their ids.
         | 
| 123 123 | 
             
            ```
         | 
| 124 124 |  | 
| 125 125 |  | 
| @@ -153,6 +153,15 @@ Or, clone the repository, make your changes, and submit a pull request. | |
| 153 153 |  | 
| 154 154 | 
             
            ## Run the unit tests for the Pose Gem
         | 
| 155 155 |  | 
| 156 | 
            +
            Pose uses Postgresql for tests, since it is the most strict database.
         | 
| 157 | 
            +
            To run tests, first, create a test database.
         | 
| 158 | 
            +
             | 
| 159 | 
            +
            ```bash
         | 
| 160 | 
            +
            createdb pose_test
         | 
| 161 | 
            +
            ```
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            Then run the tests.
         | 
| 164 | 
            +
             | 
| 156 165 | 
             
            ```bash
         | 
| 157 166 | 
             
            $ rake spec
         | 
| 158 167 | 
             
            ```
         | 
| @@ -2,16 +2,16 @@ class AddPoseTables < ActiveRecord::Migration | |
| 2 2 |  | 
| 3 3 | 
             
              def self.up
         | 
| 4 4 | 
             
                create_table "pose_assignments" do |t|
         | 
| 5 | 
            -
                  t.integer "pose_word_id", | 
| 6 | 
            -
                  t.integer "posable_id", | 
| 7 | 
            -
                  t.string  "posable_type", : | 
| 5 | 
            +
                  t.integer "pose_word_id",            null: false
         | 
| 6 | 
            +
                  t.integer "posable_id",              null: false
         | 
| 7 | 
            +
                  t.string  "posable_type", limit: 40, null: false
         | 
| 8 8 | 
             
                end
         | 
| 9 9 |  | 
| 10 10 | 
             
                add_index "pose_assignments", :pose_word_id
         | 
| 11 11 | 
             
                add_index "pose_assignments", :posable_id
         | 
| 12 12 |  | 
| 13 13 | 
             
                create_table "pose_words" do |t|
         | 
| 14 | 
            -
                  t.string "text", : | 
| 14 | 
            +
                  t.string "text", limit: 80, null: false
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                add_index "pose_words", :text
         | 
    
        data/lib/pose/model_additions.rb
    CHANGED
    
    | @@ -4,8 +4,8 @@ module Pose | |
| 4 4 | 
             
                extend ActiveSupport::Concern
         | 
| 5 5 |  | 
| 6 6 | 
             
                included do
         | 
| 7 | 
            -
                  has_many :pose_assignments, : | 
| 8 | 
            -
                  has_many :pose_words, : | 
| 7 | 
            +
                  has_many :pose_assignments, as: :posable, dependent: :delete_all
         | 
| 8 | 
            +
                  has_many :pose_words, through: :pose_assignments
         | 
| 9 9 |  | 
| 10 10 | 
             
                  after_save :update_pose_index
         | 
| 11 11 | 
             
                  before_destroy :delete_pose_index
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # Assigns searchable objects to words in the search index.
         | 
| 2 2 | 
             
            class PoseAssignment < ActiveRecord::Base
         | 
| 3 3 | 
             
              belongs_to :pose_word
         | 
| 4 | 
            -
              belongs_to :posable, : | 
| 4 | 
            +
              belongs_to :posable, polymorphic: true
         | 
| 5 5 |  | 
| 6 6 | 
             
              # Removes all PoseAssignments for the given class.
         | 
| 7 7 | 
             
              def self.delete_class_index clazz
         | 
| @@ -10,7 +10,7 @@ class PoseAssignment < ActiveRecord::Base | |
| 10 10 |  | 
| 11 11 | 
             
              # Removes all PoseAssignments that aren't used anymore.
         | 
| 12 12 | 
             
              def self.cleanup_orphaned_pose_assignments progress_bar = nil
         | 
| 13 | 
            -
                PoseAssignment.find_each(: | 
| 13 | 
            +
                PoseAssignment.find_each(include: [:posable, :pose_word], batch_size: 5000) do |assignment|
         | 
| 14 14 | 
             
                  progress_bar.inc if progress_bar
         | 
| 15 15 |  | 
| 16 16 | 
             
                  # Delete the assignment if the posable object no longer exists.
         | 
| @@ -3,7 +3,7 @@ class PoseWord < ActiveRecord::Base | |
| 3 3 | 
             
              has_many :pose_assignments
         | 
| 4 4 |  | 
| 5 5 | 
             
              def self.remove_unused_words progress_bar = nil
         | 
| 6 | 
            -
                PoseWord.find_each(: | 
| 6 | 
            +
                PoseWord.find_each(include: [:pose_assignments], batch_size: 5000) do |pose_word|
         | 
| 7 7 | 
             
                  pose_word.delete if pose_word.pose_assignments.size == 0
         | 
| 8 8 | 
             
                  progress_bar.inc if progress_bar
         | 
| 9 9 | 
             
                end
         | 
    
        data/lib/pose/static_helpers.rb
    CHANGED
    
    | @@ -4,11 +4,12 @@ module Pose | |
| 4 4 |  | 
| 5 5 | 
             
              # By default, doesn't run in tests.
         | 
| 6 6 | 
             
              # Set this to true to test the search functionality.
         | 
| 7 | 
            -
              CONFIGURATION = { : | 
| 7 | 
            +
              CONFIGURATION = { search_in_tests: false }
         | 
| 8 8 |  | 
| 9 9 | 
             
              class <<self
         | 
| 10 10 |  | 
| 11 | 
            -
                #  | 
| 11 | 
            +
                # Returns whether Pose is configured to perform search.
         | 
| 12 | 
            +
                # This setting exists to disable search in tests.
         | 
| 12 13 | 
             
                #
         | 
| 13 14 | 
             
                # @return [false, true]
         | 
| 14 15 | 
             
                def perform_search?
         | 
| @@ -102,7 +103,8 @@ module Pose | |
| 102 103 |  | 
| 103 104 | 
             
                  # Get the ids of the results.
         | 
| 104 105 | 
             
                  result_classes_and_ids = {}
         | 
| 105 | 
            -
                  query.split(' '). | 
| 106 | 
            +
                  query_words = query.split(' ').map{|query_word| Pose.root_word query_word}.flatten
         | 
| 107 | 
            +
                  query_words.each do |query_word|
         | 
| 106 108 | 
             
                    current_word_classes_and_ids = {}
         | 
| 107 109 | 
             
                    classes.each { |clazz| current_word_classes_and_ids[clazz.name] = [] }
         | 
| 108 110 | 
             
                    query = PoseAssignment.joins(:pose_word) \
         | 
| @@ -110,7 +112,7 @@ module Pose | |
| 110 112 | 
             
                                          .where('pose_words.text LIKE ?', "#{query_word}%") \
         | 
| 111 113 | 
             
                                          .where('posable_type IN (?)', classes_names)
         | 
| 112 114 | 
             
                    PoseAssignment.connection.select_all(query.to_sql).each do |pose_assignment|
         | 
| 113 | 
            -
                      current_word_classes_and_ids[pose_assignment['posable_type']] << pose_assignment['posable_id']
         | 
| 115 | 
            +
                      current_word_classes_and_ids[pose_assignment['posable_type']] << pose_assignment['posable_id'].to_i
         | 
| 114 116 | 
             
                    end
         | 
| 115 117 | 
             
                    # This is the old ActiveRecord way. Removed for performance reasons.
         | 
| 116 118 | 
             
                    # query.each do |pose_assignment|
         | 
| @@ -133,7 +135,7 @@ module Pose | |
| 133 135 |  | 
| 134 136 | 
             
                      if ids.any? && classes.include?(result_class)
         | 
| 135 137 | 
             
                        ids = ids.slice(0, options[:limit]) if options[:limit]
         | 
| 136 | 
            -
                        result[result_class] = options[:result_type] == :ids ? ids : result_class.where(: | 
| 138 | 
            +
                        result[result_class] = options[:result_type] == :ids ? ids : result_class.where(id: ids)
         | 
| 137 139 | 
             
                      else
         | 
| 138 140 | 
             
                        result[result_class] = []
         | 
| 139 141 | 
             
                      end
         | 
    
        data/lib/pose/version.rb
    CHANGED
    
    
    
        data/spec/factories.rb
    CHANGED
    
    | @@ -1,12 +1,15 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              word.text { Faker::Lorem.words(1).first }
         | 
| 3 | 
            -
            end
         | 
| 1 | 
            +
            FactoryGirl.define do
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
               | 
| 8 | 
            -
             | 
| 3 | 
            +
              factory :pose_word do
         | 
| 4 | 
            +
                text { Faker::Lorem.words(1).first }
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              factory :pose_assignment do
         | 
| 8 | 
            +
                pose_word
         | 
| 9 | 
            +
                posable factory: :posable_one
         | 
| 10 | 
            +
              end
         | 
| 9 11 |  | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            +
              factory :posable_one do
         | 
| 13 | 
            +
                text { Faker::Lorem.words(3).join ' ' }
         | 
| 14 | 
            +
              end
         | 
| 12 15 | 
             
            end
         | 
| @@ -9,31 +9,31 @@ describe PoseAssignment do | |
| 9 9 | 
             
              describe "delete_class_index" do
         | 
| 10 10 |  | 
| 11 11 | 
             
                before :each do
         | 
| 12 | 
            -
                  FactoryGirl.create :pose_assignment, : | 
| 13 | 
            -
                  FactoryGirl.create :pose_assignment, : | 
| 12 | 
            +
                  FactoryGirl.create :pose_assignment, posable_id: 1, posable_type: 'PosableOne'
         | 
| 13 | 
            +
                  FactoryGirl.create :pose_assignment, posable_id: 2, posable_type: 'PosableTwo'
         | 
| 14 14 | 
             
                  PoseAssignment.delete_class_index PosableOne
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                it "deletes all PoseAssignments for the given class" do
         | 
| 18 | 
            -
                  PoseAssignment.where(: | 
| 18 | 
            +
                  PoseAssignment.where(posable_type: 'PosableOne').should have(0).items
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 21 | 
             
                it "doesn't delete PoseAssignments for other classes" do
         | 
| 22 | 
            -
                  PoseAssignment.where(: | 
| 22 | 
            +
                  PoseAssignment.where(posable_type: 'PosableTwo').should have(1).items
         | 
| 23 23 | 
             
                end
         | 
| 24 24 | 
             
              end
         | 
| 25 25 |  | 
| 26 26 | 
             
              describe "cleanup_orphaned_pose_assignments" do
         | 
| 27 27 |  | 
| 28 28 | 
             
                it "deletes the assignment if the posable object doesn't exist" do
         | 
| 29 | 
            -
                  FactoryGirl.create :pose_assignment, : | 
| 29 | 
            +
                  FactoryGirl.create :pose_assignment, posable_id: 2, posable_type: 'PosableOne'
         | 
| 30 30 | 
             
                  PoseAssignment.count.should > 0
         | 
| 31 31 | 
             
                  PoseAssignment.cleanup_orphaned_pose_assignments
         | 
| 32 32 | 
             
                  PoseAssignment.should have(0).items
         | 
| 33 33 | 
             
                end
         | 
| 34 34 |  | 
| 35 35 | 
             
                it "deletes the assignment if the pose_word doesn't exist" do
         | 
| 36 | 
            -
                  assignment = FactoryGirl.create :pose_assignment, : | 
| 36 | 
            +
                  assignment = FactoryGirl.create :pose_assignment, pose_word: nil, pose_word_id: 27
         | 
| 37 37 | 
             
                  PoseAssignment.cleanup_orphaned_pose_assignments
         | 
| 38 38 | 
             
                  PoseAssignment.find_by_id(assignment.id).should be_nil
         | 
| 39 39 | 
             
                end
         | 
    
        data/spec/pose_spec.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require "spec_helper"
         | 
| 4 4 |  | 
| 5 | 
            -
            ActiveRecord::Base.establish_connection | 
| 5 | 
            +
            ActiveRecord::Base.establish_connection adapter: 'postgresql', database: 'pose_test', min_messages: 'WARNING'
         | 
| 6 6 |  | 
| 7 7 | 
             
            describe Pose do
         | 
| 8 8 | 
             
              subject { PosableOne.new }
         | 
| @@ -17,7 +17,7 @@ describe Pose do | |
| 17 17 | 
             
              describe 'associations' do
         | 
| 18 18 | 
             
                it 'allows to access the associated words of a posable object directly' do
         | 
| 19 19 | 
             
                  subject.should have(0).pose_words
         | 
| 20 | 
            -
                  subject.pose_words << PoseWord.new(: | 
| 20 | 
            +
                  subject.pose_words << PoseWord.new(text: 'one')
         | 
| 21 21 | 
             
                  subject.should have_pose_words(['one'])
         | 
| 22 22 | 
             
                end
         | 
| 23 23 | 
             
              end
         | 
| @@ -88,8 +88,8 @@ describe Pose do | |
| 88 88 | 
             
              describe 'get_words_to_remove' do
         | 
| 89 89 |  | 
| 90 90 | 
             
                it "returns an array of word objects that need to be removed" do
         | 
| 91 | 
            -
                  word1 = PoseWord.new : | 
| 92 | 
            -
                  word2 = PoseWord.new : | 
| 91 | 
            +
                  word1 = PoseWord.new text: 'one'
         | 
| 92 | 
            +
                  word2 = PoseWord.new text: 'two'
         | 
| 93 93 | 
             
                  existing_words = [word1, word2]
         | 
| 94 94 | 
             
                  new_words = ['one', 'three']
         | 
| 95 95 |  | 
| @@ -99,8 +99,8 @@ describe Pose do | |
| 99 99 | 
             
                end
         | 
| 100 100 |  | 
| 101 101 | 
             
                it 'returns an empty array if there are no words to be removed' do
         | 
| 102 | 
            -
                  word1 = PoseWord.new : | 
| 103 | 
            -
                  word2 = PoseWord.new : | 
| 102 | 
            +
                  word1 = PoseWord.new text: 'one'
         | 
| 103 | 
            +
                  word2 = PoseWord.new text: 'two'
         | 
| 104 104 | 
             
                  existing_words = [word1, word2]
         | 
| 105 105 | 
             
                  new_words = ['one', 'two']
         | 
| 106 106 |  | 
| @@ -113,8 +113,8 @@ describe Pose do | |
| 113 113 | 
             
              describe 'get_words_to_add' do
         | 
| 114 114 |  | 
| 115 115 | 
             
                it 'returns an array with strings that need to be added' do
         | 
| 116 | 
            -
                  word1 = PoseWord.new : | 
| 117 | 
            -
                  word2 = PoseWord.new : | 
| 116 | 
            +
                  word1 = PoseWord.new text: 'one'
         | 
| 117 | 
            +
                  word2 = PoseWord.new text: 'two'
         | 
| 118 118 | 
             
                  existing_words = [word1, word2]
         | 
| 119 119 | 
             
                  new_words = ['one', 'three']
         | 
| 120 120 |  | 
| @@ -124,8 +124,8 @@ describe Pose do | |
| 124 124 | 
             
                end
         | 
| 125 125 |  | 
| 126 126 | 
             
                it 'returns an empty array if there is nothing to be added' do
         | 
| 127 | 
            -
                  word1 = PoseWord.new : | 
| 128 | 
            -
                  word2 = PoseWord.new : | 
| 127 | 
            +
                  word1 = PoseWord.new text: 'one'
         | 
| 128 | 
            +
                  word2 = PoseWord.new text: 'two'
         | 
| 129 129 | 
             
                  existing_words = [word1, word2]
         | 
| 130 130 | 
             
                  new_words = ['one', 'two']
         | 
| 131 131 |  | 
| @@ -199,7 +199,7 @@ describe Pose do | |
| 199 199 | 
             
              describe 'search' do
         | 
| 200 200 |  | 
| 201 201 | 
             
                it 'works' do
         | 
| 202 | 
            -
                  pos1 = PosableOne.create : | 
| 202 | 
            +
                  pos1 = PosableOne.create text: 'one'
         | 
| 203 203 |  | 
| 204 204 | 
             
                  result = Pose.search 'one', PosableOne
         | 
| 205 205 |  | 
| @@ -210,8 +210,8 @@ describe Pose do | |
| 210 210 |  | 
| 211 211 | 
             
                describe 'classes parameter' do
         | 
| 212 212 | 
             
                  it 'returns all different classes by default' do
         | 
| 213 | 
            -
                    pos1 = PosableOne.create : | 
| 214 | 
            -
                    pos2 = PosableTwo.create : | 
| 213 | 
            +
                    pos1 = PosableOne.create text: 'foo'
         | 
| 214 | 
            +
                    pos2 = PosableTwo.create text: 'foo'
         | 
| 215 215 |  | 
| 216 216 | 
             
                    result = Pose.search 'foo', [PosableOne, PosableTwo]
         | 
| 217 217 |  | 
| @@ -221,8 +221,8 @@ describe Pose do | |
| 221 221 | 
             
                  end
         | 
| 222 222 |  | 
| 223 223 | 
             
                  it 'allows to provide different classes to return' do
         | 
| 224 | 
            -
                    pos1 = PosableOne.create : | 
| 225 | 
            -
                    pos2 = PosableTwo.create : | 
| 224 | 
            +
                    pos1 = PosableOne.create text: 'foo'
         | 
| 225 | 
            +
                    pos2 = PosableTwo.create text: 'foo'
         | 
| 226 226 |  | 
| 227 227 | 
             
                    result = Pose.search 'foo', [PosableOne, PosableTwo]
         | 
| 228 228 |  | 
| @@ -232,8 +232,8 @@ describe Pose do | |
| 232 232 | 
             
                  end
         | 
| 233 233 |  | 
| 234 234 | 
             
                  it 'returns only instances of the given classes' do
         | 
| 235 | 
            -
                    pos1 = PosableOne.create : | 
| 236 | 
            -
                    pos2 = PosableTwo.create : | 
| 235 | 
            +
                    pos1 = PosableOne.create text: 'one'
         | 
| 236 | 
            +
                    pos2 = PosableTwo.create text: 'one'
         | 
| 237 237 |  | 
| 238 238 | 
             
                    result = Pose.search 'one', PosableOne
         | 
| 239 239 |  | 
| @@ -245,7 +245,7 @@ describe Pose do | |
| 245 245 | 
             
                describe 'query parameter' do
         | 
| 246 246 |  | 
| 247 247 | 
             
                  it 'returns an empty array if nothing matches' do
         | 
| 248 | 
            -
                    pos1 = PosableOne.create : | 
| 248 | 
            +
                    pos1 = PosableOne.create text: 'one'
         | 
| 249 249 |  | 
| 250 250 | 
             
                    result = Pose.search 'two', PosableOne
         | 
| 251 251 |  | 
| @@ -253,9 +253,9 @@ describe Pose do | |
| 253 253 | 
             
                  end
         | 
| 254 254 |  | 
| 255 255 | 
             
                  it 'returns only objects that match all given query words' do
         | 
| 256 | 
            -
                    pos1 = PosableOne.create : | 
| 257 | 
            -
                    pos2 = PosableOne.create : | 
| 258 | 
            -
                    pos3 = PosableOne.create : | 
| 256 | 
            +
                    pos1 = PosableOne.create text: 'one two'
         | 
| 257 | 
            +
                    pos2 = PosableOne.create text: 'one three'
         | 
| 258 | 
            +
                    pos3 = PosableOne.create text: 'two three'
         | 
| 259 259 |  | 
| 260 260 | 
             
                    result = Pose.search 'two one', PosableOne
         | 
| 261 261 |  | 
| @@ -264,24 +264,33 @@ describe Pose do | |
| 264 264 | 
             
                  end
         | 
| 265 265 |  | 
| 266 266 | 
             
                  it 'returns nothing if searching for a non-existing word' do
         | 
| 267 | 
            -
                    pos1 = PosableOne.create : | 
| 267 | 
            +
                    pos1 = PosableOne.create text: 'one two'
         | 
| 268 268 |  | 
| 269 269 | 
             
                    result = Pose.search 'one zonk', PosableOne
         | 
| 270 270 |  | 
| 271 271 | 
             
                    result.should have(1).items
         | 
| 272 272 | 
             
                    result[PosableOne].should == []
         | 
| 273 273 | 
             
                  end
         | 
| 274 | 
            +
             | 
| 275 | 
            +
                  it 'works if the query is given in uppercase' do
         | 
| 276 | 
            +
                    pos1 = PosableOne.create text: 'one two'
         | 
| 277 | 
            +
             | 
| 278 | 
            +
                    result = Pose.search 'OnE TwO', PosableOne
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                    result.should have(1).items
         | 
| 281 | 
            +
                    result[PosableOne].should == [pos1]
         | 
| 282 | 
            +
                  end
         | 
| 274 283 | 
             
                end
         | 
| 275 284 |  | 
| 276 285 | 
             
                describe "'limit' parameter" do
         | 
| 277 286 |  | 
| 278 287 | 
             
                  it 'works' do
         | 
| 279 | 
            -
                    FactoryGirl.create :posable_one, : | 
| 280 | 
            -
                    FactoryGirl.create :posable_one, : | 
| 281 | 
            -
                    FactoryGirl.create :posable_one, : | 
| 282 | 
            -
                    FactoryGirl.create :posable_one, : | 
| 288 | 
            +
                    FactoryGirl.create :posable_one, text: 'foo one'
         | 
| 289 | 
            +
                    FactoryGirl.create :posable_one, text: 'foo two'
         | 
| 290 | 
            +
                    FactoryGirl.create :posable_one, text: 'foo three'
         | 
| 291 | 
            +
                    FactoryGirl.create :posable_one, text: 'foo four'
         | 
| 283 292 |  | 
| 284 | 
            -
                    result = Pose.search 'foo', PosableOne, : | 
| 293 | 
            +
                    result = Pose.search 'foo', PosableOne, limit: 3
         | 
| 285 294 |  | 
| 286 295 | 
             
                    result[PosableOne].should have(3).items
         | 
| 287 296 | 
             
                  end
         | 
| @@ -290,7 +299,7 @@ describe Pose do | |
| 290 299 | 
             
                describe "'result_type' parameter" do
         | 
| 291 300 |  | 
| 292 301 | 
             
                  before :each do
         | 
| 293 | 
            -
                    @foo_one = FactoryGirl.create :posable_one, : | 
| 302 | 
            +
                    @foo_one = FactoryGirl.create :posable_one, text: 'foo one'
         | 
| 294 303 | 
             
                  end
         | 
| 295 304 |  | 
| 296 305 | 
             
                  describe 'default behavior' do
         | 
| @@ -302,7 +311,7 @@ describe Pose do | |
| 302 311 |  | 
| 303 312 | 
             
                  context ':ids given' do
         | 
| 304 313 | 
             
                    it 'returns ids instead of objects' do
         | 
| 305 | 
            -
                      result = Pose.search 'foo', PosableOne, : | 
| 314 | 
            +
                      result = Pose.search 'foo', PosableOne, result_type: :ids
         | 
| 306 315 | 
             
                      result[PosableOne][0].should == @foo_one.id
         | 
| 307 316 | 
             
                    end
         | 
| 308 317 | 
             
                  end
         | 
| @@ -312,7 +321,7 @@ describe Pose do | |
| 312 321 | 
             
              describe 'autocomplete_words' do
         | 
| 313 322 |  | 
| 314 323 | 
             
                it 'returns words that start with the given phrase' do
         | 
| 315 | 
            -
                  PosableOne.create : | 
| 324 | 
            +
                  PosableOne.create text: 'great green pine tree'
         | 
| 316 325 |  | 
| 317 326 | 
             
                  result = Pose.autocomplete_words 'gr'
         | 
| 318 327 |  | 
| @@ -322,7 +331,7 @@ describe Pose do | |
| 322 331 | 
             
                end
         | 
| 323 332 |  | 
| 324 333 | 
             
                it 'returns words that match the given phrase exactly' do
         | 
| 325 | 
            -
                  PoseWord.create : | 
| 334 | 
            +
                  PoseWord.create text: 'cat'
         | 
| 326 335 |  | 
| 327 336 | 
             
                  result = Pose.autocomplete_words 'cat'
         | 
| 328 337 |  | 
| @@ -330,7 +339,7 @@ describe Pose do | |
| 330 339 | 
             
                end
         | 
| 331 340 |  | 
| 332 341 | 
             
                it 'stems the search query' do
         | 
| 333 | 
            -
                  PosableOne.create : | 
| 342 | 
            +
                  PosableOne.create text: 'car'
         | 
| 334 343 |  | 
| 335 344 | 
             
                  result = Pose.autocomplete_words 'cars'
         | 
| 336 345 |  | 
| @@ -339,7 +348,7 @@ describe Pose do | |
| 339 348 | 
             
                end
         | 
| 340 349 |  | 
| 341 350 | 
             
                it 'returns nothing if the search query is empty' do
         | 
| 342 | 
            -
                  PosableOne.create : | 
| 351 | 
            +
                  PosableOne.create text: 'foo bar'
         | 
| 343 352 | 
             
                  result = Pose.autocomplete_words ''
         | 
| 344 353 | 
             
                  result.should have(0).words
         | 
| 345 354 | 
             
                end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -13,7 +13,7 @@ FactoryGirl.find_definitions | |
| 13 13 |  | 
| 14 14 | 
             
            # Configure Rails Environment
         | 
| 15 15 | 
             
            ENV["RAILS_ENV"] = "test"
         | 
| 16 | 
            -
            Rails = Hashie::Mash.new({: | 
| 16 | 
            +
            Rails = Hashie::Mash.new({env: 'test'})
         | 
| 17 17 |  | 
| 18 18 | 
             
            # We have no Railtie in these tests --> load Pose manually.
         | 
| 19 19 | 
             
            ActiveRecord::Base.send :extend, Pose::BaseAdditions
         | 
| @@ -88,7 +88,7 @@ end | |
| 88 88 | 
             
            #
         | 
| 89 89 |  | 
| 90 90 | 
             
            def setup_db
         | 
| 91 | 
            -
              ActiveRecord::Schema.define(: | 
| 91 | 
            +
              ActiveRecord::Schema.define(version: 1) do
         | 
| 92 92 |  | 
| 93 93 | 
             
                create_table 'posable_ones' do |t|
         | 
| 94 94 | 
             
                  t.string 'text'
         | 
| @@ -99,13 +99,13 @@ def setup_db | |
| 99 99 | 
             
                end
         | 
| 100 100 |  | 
| 101 101 | 
             
                create_table "pose_assignments" do |t|
         | 
| 102 | 
            -
                  t.integer "pose_word_id", | 
| 103 | 
            -
                  t.integer "posable_id", | 
| 104 | 
            -
                  t.string  "posable_type", : | 
| 102 | 
            +
                  t.integer "pose_word_id",            null: false
         | 
| 103 | 
            +
                  t.integer "posable_id",              null: false
         | 
| 104 | 
            +
                  t.string  "posable_type", limit: 20, null: false
         | 
| 105 105 | 
             
                end
         | 
| 106 106 |  | 
| 107 107 | 
             
                create_table "pose_words" do |t|
         | 
| 108 | 
            -
                  t.string "text", : | 
| 108 | 
            +
                  t.string "text", limit: 80, null: false
         | 
| 109 109 | 
             
                end
         | 
| 110 110 | 
             
              end
         | 
| 111 111 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pose
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.1. | 
| 4 | 
            +
              version: 1.1.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-09-22 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rails
         | 
| 16 | 
            -
              requirement:  | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,15 @@ dependencies: | |
| 21 21 | 
             
                    version: 3.0.0
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 3.0.0
         | 
| 25 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 31 | 
             
              name: rake
         | 
| 27 | 
            -
              requirement:  | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 33 | 
             
                none: false
         | 
| 29 34 | 
             
                requirements:
         | 
| 30 35 | 
             
                - - ! '>='
         | 
| @@ -32,10 +37,15 @@ dependencies: | |
| 32 37 | 
             
                    version: '0'
         | 
| 33 38 | 
             
              type: :runtime
         | 
| 34 39 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 36 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 47 | 
             
              name: ruby-progressbar
         | 
| 38 | 
            -
              requirement:  | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 39 49 | 
             
                none: false
         | 
| 40 50 | 
             
                requirements:
         | 
| 41 51 | 
             
                - - ! '>='
         | 
| @@ -43,10 +53,15 @@ dependencies: | |
| 43 53 | 
             
                    version: '0'
         | 
| 44 54 | 
             
              type: :runtime
         | 
| 45 55 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements:  | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 47 62 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 63 | 
             
              name: factory_girl
         | 
| 49 | 
            -
              requirement:  | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 65 | 
             
                none: false
         | 
| 51 66 | 
             
                requirements:
         | 
| 52 67 | 
             
                - - ! '>='
         | 
| @@ -54,10 +69,15 @@ dependencies: | |
| 54 69 | 
             
                    version: '0'
         | 
| 55 70 | 
             
              type: :development
         | 
| 56 71 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements:  | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 58 78 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 59 79 | 
             
              name: faker
         | 
| 60 | 
            -
              requirement:  | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 61 81 | 
             
                none: false
         | 
| 62 82 | 
             
                requirements:
         | 
| 63 83 | 
             
                - - ! '>='
         | 
| @@ -65,10 +85,15 @@ dependencies: | |
| 65 85 | 
             
                    version: '0'
         | 
| 66 86 | 
             
              type: :development
         | 
| 67 87 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements:  | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ! '>='
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '0'
         | 
| 69 94 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 95 | 
             
              name: hashie
         | 
| 71 | 
            -
              requirement:  | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 97 | 
             
                none: false
         | 
| 73 98 | 
             
                requirements:
         | 
| 74 99 | 
             
                - - ! '>='
         | 
| @@ -76,10 +101,15 @@ dependencies: | |
| 76 101 | 
             
                    version: '0'
         | 
| 77 102 | 
             
              type: :development
         | 
| 78 103 | 
             
              prerelease: false
         | 
| 79 | 
            -
              version_requirements:  | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - ! '>='
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '0'
         | 
| 80 110 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 81 111 | 
             
              name: rspec
         | 
| 82 | 
            -
              requirement:  | 
| 112 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 83 113 | 
             
                none: false
         | 
| 84 114 | 
             
                requirements:
         | 
| 85 115 | 
             
                - - ! '>='
         | 
| @@ -87,10 +117,15 @@ dependencies: | |
| 87 117 | 
             
                    version: '0'
         | 
| 88 118 | 
             
              type: :development
         | 
| 89 119 | 
             
              prerelease: false
         | 
| 90 | 
            -
              version_requirements:  | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                none: false
         | 
| 122 | 
            +
                requirements:
         | 
| 123 | 
            +
                - - ! '>='
         | 
| 124 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                    version: '0'
         | 
| 91 126 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 92 | 
            -
              name:  | 
| 93 | 
            -
              requirement:  | 
| 127 | 
            +
              name: pg
         | 
| 128 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 94 129 | 
             
                none: false
         | 
| 95 130 | 
             
                requirements:
         | 
| 96 131 | 
             
                - - ! '>='
         | 
| @@ -98,7 +133,12 @@ dependencies: | |
| 98 133 | 
             
                    version: '0'
         | 
| 99 134 | 
             
              type: :development
         | 
| 100 135 | 
             
              prerelease: false
         | 
| 101 | 
            -
              version_requirements:  | 
| 136 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 137 | 
            +
                none: false
         | 
| 138 | 
            +
                requirements:
         | 
| 139 | 
            +
                - - ! '>='
         | 
| 140 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 141 | 
            +
                    version: '0'
         | 
| 102 142 | 
             
            description: Pose ('Polymorphic Search') allows fulltext search for ActiveRecord objects.
         | 
| 103 143 | 
             
            email:
         | 
| 104 144 | 
             
            - kevin.goslar@gmail.com
         | 
| @@ -164,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 164 204 | 
             
                  version: '0'
         | 
| 165 205 | 
             
            requirements: []
         | 
| 166 206 | 
             
            rubyforge_project: 
         | 
| 167 | 
            -
            rubygems_version: 1.8. | 
| 207 | 
            +
            rubygems_version: 1.8.24
         | 
| 168 208 | 
             
            signing_key: 
         | 
| 169 209 | 
             
            specification_version: 3
         | 
| 170 210 | 
             
            summary: A polymorphic, storage-system independent search engine for Ruby on Rails.
         |