resource_index 0.0.2 → 0.0.3

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.rdoc CHANGED
@@ -1,7 +1,7 @@
1
- = ResourceIndex
1
+ = Resource Index
2
2
 
3
3
  Uses Xapian index search to speed up searching ActiveResource objects and reduce
4
- calls to backend service.
4
+ calls to backend services.
5
5
 
6
6
  ActiveResource is good for gathering all objects or one object from a remote
7
7
  service api. ResourceIndex provides tools to help you identify the one from
@@ -27,21 +27,18 @@ the 'xapian-ruby' gem.
27
27
 
28
28
  However, if you already have xapian installed, or wish to use a shared
29
29
  Xapian engine, you may wish to install Xapian and the ruby bindings manually.
30
- For installation information see: http://xapian.org/
30
+ For installation information see: http://xapian.org
31
31
 
32
32
 
33
33
  == Usage
34
34
 
35
- Extend ResourceIndex::SearchEngine on any objects you wish to use ResourceIndex.
36
- For example:
37
-
38
35
  class Thing < ActiveResource::Base
39
36
 
40
37
  extend ResourceIndex::SearchEngine
41
38
 
42
39
  end
43
40
 
44
- Thing then gets the the following class methods:
41
+ Thing gets the the following class methods:
45
42
 
46
43
  [Thing.search] The main method used to find objects
47
44
 
@@ -83,6 +80,15 @@ will be installed at /db/resource_index. You can specify a different location:
83
80
  If you specify the location, the path to that location should exist or you will
84
81
  get errors.
85
82
 
83
+ Each indexed object gets its own folder within the search root, so you do not
84
+ have to specify a root for each object. For example, the index files for Thing
85
+ will be created in db/resource_index/thing/
86
+
87
+ To prevent these files being version controlled, add this to your project root
88
+ .gitignore file (or equivalent):
89
+
90
+ /db/resource_index/*
91
+
86
92
  === Populate Search Engine
87
93
 
88
94
  The populate_search_engine method will replace the existing Xapian database
@@ -90,10 +96,9 @@ with one populated from all the objects currently returned by the remote service
90
96
 
91
97
  Thing.populate_search_engine
92
98
 
93
- Will add all the things gathered by Thing.all, and create index entries for them.
99
+ This will add all the things gathered by Thing.all, and create index entries for them.
94
100
 
95
- There is also a rake task to aid population being triggered externally; for
96
- example by a cron job:
101
+ There is also a rake task that runs this method on a given resource:
97
102
 
98
103
  rake resource_index:populate resource=Thing
99
104
 
@@ -112,3 +117,15 @@ search:
112
117
  puts "Did you mean '#{results.corrected_query}'" --> "Did you mean 'moose'"
113
118
  end
114
119
 
120
+ === Search options
121
+
122
+ You can pass options through to the underlying xapian_fu object.
123
+ See https://github.com/johnl/xapian-fu
124
+
125
+ For example:
126
+
127
+ Thing.search(:all, :page => 1, :per_page => 20)
128
+
129
+ Note that by default, search returns the first 10 results.
130
+
131
+
@@ -13,8 +13,8 @@ module ResourceIndex
13
13
  "#{self.to_s} search index populated with #{engine.size} entries."
14
14
  end
15
15
 
16
- def search(text)
17
- search_engine.search(text)
16
+ def search(text, args={})
17
+ search_engine.search(text, args)
18
18
  end
19
19
  end
20
20
  end
@@ -1,17 +1,19 @@
1
1
  module ResourceIndex
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
5
5
  # History
6
6
  # =======
7
7
  #
8
- # Version 0.0.2
8
+ # Version 0.0.3
9
9
  # -------------
10
+ # Adds facility to pass xapian_fu options through from search call.
10
11
  #
12
+ # Version 0.0.2
13
+ # -------------
11
14
  # Removes dependency on xapian-ruby. This is now a recommended option
12
15
  #
13
16
  # Version 0.0.1
14
17
  # -------------
15
- #
16
18
  # Initial release
17
19
  #
@@ -1 +1 @@
1
- IAmChert�� ��%ތUCE�0��M
1
+ IAmChert�� (rb�dN��•�,�]
Binary file
@@ -34,3 +34,4 @@ Connecting to database specified by database.yml
34
34
  Connecting to database specified by database.yml
35
35
  Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
36
36
  Thing Load (0.2ms) SELECT "things".* FROM "things"
37
+ Connecting to database specified by database.yml
@@ -3050,3 +3050,195 @@ Connecting to database specified by database.yml
3050
3050
   (0.1ms) rollback transaction
3051
3051
   (0.1ms) begin transaction
3052
3052
   (0.1ms) rollback transaction
3053
+ Connecting to database specified by database.yml
3054
+  (2.6ms) begin transaction
3055
+ Fixture Delete (2.6ms) DELETE FROM "things"
3056
+ Fixture Insert (1.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (1, 'DAVIS', 'ED GAUGHAN', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3057
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (2, 'BENNETT', 'ANDREW BUCKLEY', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3058
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (3, 'THE COLONEL', 'JASON ISAACS', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3059
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (4, 'JANE', 'PAPRIKA STEEN', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3060
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (5, 'REBECCA', 'TUPPENCE MIDDLETON', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3061
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (6, 'JO-JO', 'JOSEF WHITFIELD', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3062
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (7, 'WRITER/DIRECTOR', 'NICK WHITFIELD', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3063
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (8, 'PRODUCER', 'TRACY BRIMM', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3064
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (9, 'PRODUCER', 'KATE MYERS', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3065
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (10, 'PRODUCER', 'PAUL WELSH', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3066
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (11, 'EXECUTIVE PRODUCER', 'SUZANNE ALIZART', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3067
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (12, 'EXECUTIVE PRODUCER', 'ROBBIE ALLEN', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3068
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (13, 'EXECUTIVE PRODUCER', 'ANNA SEIFERT-SPECK', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3069
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (14, 'DIRECTOR OF PHOTOGRAPHY', 'ZAC NICHOLSON', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3070
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (15, 'EDITOR', 'RACHEL TUNNARD', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3071
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (16, 'COMPOSER', 'SIMON WHITFIELD', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3072
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (17, 'PRODUCTION DESIGN', 'JAMES LAPSLEY', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3073
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (18, 'HAIR & MAKE UP DESIGN', 'SUSANNA PERETZ', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3074
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (19, 'COSTUME DESIGN', 'ALISON MCLAUGHLIN', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3075
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (20, 'SUPERVISING SOUND EDITOR', 'JOAKIM SUNDSTROM', '2013-02-20 11:44:12', '2013-02-20 11:44:12')
3076
+  (334.7ms) commit transaction
3077
+  (0.2ms) begin transaction
3078
+  (0.1ms) rollback transaction
3079
+  (0.2ms) begin transaction
3080
+  (0.1ms) rollback transaction
3081
+  (0.1ms) begin transaction
3082
+  (0.1ms) rollback transaction
3083
+  (1.0ms) begin transaction
3084
+ Thing Load (0.3ms) SELECT "things".* FROM "things" LIMIT 1
3085
+  (0.1ms) rollback transaction
3086
+  (0.1ms) begin transaction
3087
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3088
+  (0.1ms) rollback transaction
3089
+  (0.1ms) begin transaction
3090
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3091
+  (0.1ms) rollback transaction
3092
+  (0.1ms) begin transaction
3093
+  (0.1ms) rollback transaction
3094
+  (0.1ms) begin transaction
3095
+  (0.1ms) rollback transaction
3096
+  (0.1ms) begin transaction
3097
+ Thing Load (0.1ms) SELECT "things".* FROM "things" LIMIT 1
3098
+  (0.2ms) rollback transaction
3099
+  (0.1ms) begin transaction
3100
+ Thing Load (0.5ms) SELECT "things".* FROM "things" LIMIT 1
3101
+ Thing Load (0.5ms) SELECT "things".* FROM "things"
3102
+  (0.6ms) SELECT COUNT(*) FROM "things" 
3103
+ Thing Load (0.3ms) SELECT "things".* FROM "things" LIMIT 1
3104
+  (0.3ms) rollback transaction
3105
+  (0.1ms) begin transaction
3106
+  (0.1ms) rollback transaction
3107
+  (0.1ms) begin transaction
3108
+  (0.1ms) rollback transaction
3109
+  (0.1ms) begin transaction
3110
+ Thing Load (0.3ms) SELECT "things".* FROM "things" WHERE (role LIKE '%PRODUCER%')
3111
+  (0.1ms) rollback transaction
3112
+  (0.0ms) begin transaction
3113
+  (0.0ms) rollback transaction
3114
+  (0.1ms) begin transaction
3115
+  (0.1ms) SELECT COUNT(*) FROM "things"
3116
+  (0.0ms) rollback transaction
3117
+ Connecting to database specified by database.yml
3118
+  (1.9ms) begin transaction
3119
+ Fixture Delete (2.8ms) DELETE FROM "things"
3120
+ Fixture Insert (0.9ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (1, 'DAVIS', 'ED GAUGHAN', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3121
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (2, 'BENNETT', 'ANDREW BUCKLEY', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3122
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (3, 'THE COLONEL', 'JASON ISAACS', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3123
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (4, 'JANE', 'PAPRIKA STEEN', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3124
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (5, 'REBECCA', 'TUPPENCE MIDDLETON', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3125
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (6, 'JO-JO', 'JOSEF WHITFIELD', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3126
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (7, 'WRITER/DIRECTOR', 'NICK WHITFIELD', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3127
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (8, 'PRODUCER', 'TRACY BRIMM', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3128
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (9, 'PRODUCER', 'KATE MYERS', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3129
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (10, 'PRODUCER', 'PAUL WELSH', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3130
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (11, 'EXECUTIVE PRODUCER', 'SUZANNE ALIZART', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3131
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (12, 'EXECUTIVE PRODUCER', 'ROBBIE ALLEN', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3132
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (13, 'EXECUTIVE PRODUCER', 'ANNA SEIFERT-SPECK', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3133
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (14, 'DIRECTOR OF PHOTOGRAPHY', 'ZAC NICHOLSON', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3134
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (15, 'EDITOR', 'RACHEL TUNNARD', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3135
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (16, 'COMPOSER', 'SIMON WHITFIELD', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3136
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (17, 'PRODUCTION DESIGN', 'JAMES LAPSLEY', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3137
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (18, 'HAIR & MAKE UP DESIGN', 'SUSANNA PERETZ', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3138
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (19, 'COSTUME DESIGN', 'ALISON MCLAUGHLIN', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3139
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (20, 'SUPERVISING SOUND EDITOR', 'JOAKIM SUNDSTROM', '2013-02-20 11:45:07', '2013-02-20 11:45:07')
3140
+  (318.6ms) commit transaction
3141
+  (0.1ms) begin transaction
3142
+  (0.6ms) rollback transaction
3143
+  (0.2ms) begin transaction
3144
+  (0.1ms) rollback transaction
3145
+  (0.1ms) begin transaction
3146
+  (0.1ms) rollback transaction
3147
+  (0.1ms) begin transaction
3148
+ Thing Load (0.4ms) SELECT "things".* FROM "things" LIMIT 1
3149
+  (0.0ms) rollback transaction
3150
+  (0.1ms) begin transaction
3151
+ Thing Load (2.0ms) SELECT "things".* FROM "things" LIMIT 1
3152
+  (0.1ms) rollback transaction
3153
+  (0.0ms) begin transaction
3154
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3155
+  (0.0ms) rollback transaction
3156
+  (0.0ms) begin transaction
3157
+  (0.0ms) rollback transaction
3158
+  (0.1ms) begin transaction
3159
+  (0.1ms) rollback transaction
3160
+  (0.1ms) begin transaction
3161
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3162
+  (0.1ms) rollback transaction
3163
+  (0.0ms) begin transaction
3164
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3165
+ Thing Load (0.2ms) SELECT "things".* FROM "things"
3166
+  (0.6ms) SELECT COUNT(*) FROM "things" 
3167
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3168
+  (0.2ms) rollback transaction
3169
+  (0.1ms) begin transaction
3170
+  (0.0ms) rollback transaction
3171
+  (0.1ms) begin transaction
3172
+  (0.1ms) rollback transaction
3173
+  (0.0ms) begin transaction
3174
+ Thing Load (0.3ms) SELECT "things".* FROM "things" WHERE (role LIKE '%PRODUCER%')
3175
+  (0.1ms) rollback transaction
3176
+  (0.0ms) begin transaction
3177
+  (0.0ms) rollback transaction
3178
+  (0.0ms) begin transaction
3179
+  (0.1ms) SELECT COUNT(*) FROM "things"
3180
+  (0.0ms) rollback transaction
3181
+ Connecting to database specified by database.yml
3182
+  (2.3ms) begin transaction
3183
+ Fixture Delete (3.1ms) DELETE FROM "things"
3184
+ Fixture Insert (0.8ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (1, 'DAVIS', 'ED GAUGHAN', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3185
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (2, 'BENNETT', 'ANDREW BUCKLEY', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3186
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (3, 'THE COLONEL', 'JASON ISAACS', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3187
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (4, 'JANE', 'PAPRIKA STEEN', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3188
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (5, 'REBECCA', 'TUPPENCE MIDDLETON', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3189
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (6, 'JO-JO', 'JOSEF WHITFIELD', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3190
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (7, 'WRITER/DIRECTOR', 'NICK WHITFIELD', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3191
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (8, 'PRODUCER', 'TRACY BRIMM', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3192
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (9, 'PRODUCER', 'KATE MYERS', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3193
+ Fixture Insert (1.9ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (10, 'PRODUCER', 'PAUL WELSH', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3194
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (11, 'EXECUTIVE PRODUCER', 'SUZANNE ALIZART', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3195
+ Fixture Insert (0.2ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (12, 'EXECUTIVE PRODUCER', 'ROBBIE ALLEN', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3196
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (13, 'EXECUTIVE PRODUCER', 'ANNA SEIFERT-SPECK', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3197
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (14, 'DIRECTOR OF PHOTOGRAPHY', 'ZAC NICHOLSON', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3198
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (15, 'EDITOR', 'RACHEL TUNNARD', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3199
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (16, 'COMPOSER', 'SIMON WHITFIELD', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3200
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (17, 'PRODUCTION DESIGN', 'JAMES LAPSLEY', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3201
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (18, 'HAIR & MAKE UP DESIGN', 'SUSANNA PERETZ', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3202
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (19, 'COSTUME DESIGN', 'ALISON MCLAUGHLIN', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3203
+ Fixture Insert (0.1ms) INSERT INTO "things" ("id", "role", "name", "created_at", "updated_at") VALUES (20, 'SUPERVISING SOUND EDITOR', 'JOAKIM SUNDSTROM', '2013-02-20 11:45:40', '2013-02-20 11:45:40')
3204
+  (193.2ms) commit transaction
3205
+  (0.2ms) begin transaction
3206
+  (0.2ms) rollback transaction
3207
+  (0.1ms) begin transaction
3208
+  (0.0ms) rollback transaction
3209
+  (0.1ms) begin transaction
3210
+  (0.1ms) rollback transaction
3211
+  (0.1ms) begin transaction
3212
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3213
+  (0.1ms) rollback transaction
3214
+  (0.0ms) begin transaction
3215
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3216
+  (0.1ms) rollback transaction
3217
+  (0.0ms) begin transaction
3218
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3219
+  (0.1ms) rollback transaction
3220
+  (0.1ms) begin transaction
3221
+  (0.1ms) rollback transaction
3222
+  (0.1ms) begin transaction
3223
+  (0.1ms) rollback transaction
3224
+  (0.1ms) begin transaction
3225
+ Thing Load (0.2ms) SELECT "things".* FROM "things" LIMIT 1
3226
+  (0.1ms) rollback transaction
3227
+  (0.0ms) begin transaction
3228
+ Thing Load (0.3ms) SELECT "things".* FROM "things" LIMIT 1
3229
+ Thing Load (0.2ms) SELECT "things".* FROM "things"
3230
+  (0.5ms) SELECT COUNT(*) FROM "things" 
3231
+ Thing Load (0.1ms) SELECT "things".* FROM "things" LIMIT 1
3232
+  (0.2ms) rollback transaction
3233
+  (0.1ms) begin transaction
3234
+  (0.0ms) rollback transaction
3235
+  (0.0ms) begin transaction
3236
+  (0.0ms) rollback transaction
3237
+  (0.0ms) begin transaction
3238
+ Thing Load (0.2ms) SELECT "things".* FROM "things" WHERE (role LIKE '%PRODUCER%')
3239
+  (0.0ms) rollback transaction
3240
+  (0.0ms) begin transaction
3241
+  (0.0ms) rollback transaction
3242
+  (0.0ms) begin transaction
3243
+  (0.1ms) SELECT COUNT(*) FROM "things"
3244
+  (0.1ms) rollback transaction
@@ -34,4 +34,12 @@ class ThingTest < ActiveSupport::TestCase
34
34
  assert_equal(producers.length, things.length)
35
35
  assert_equal(producers.collect(&:id).sort, things.collect(&:id).sort)
36
36
  end
37
+
38
+ def test_search_with_pagination
39
+ thing_count = Thing.count
40
+ [1, 5, 10, 15, 20, 30].each do |page_length|
41
+ expected = page_length > thing_count ? thing_count : page_length
42
+ assert_equal(expected, Thing.search(:all, :page => 1, :per_page => page_length).length)
43
+ end
44
+ end
37
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: