1
0
Fork 0
forked from OpenNeo/impress

is:nc filter

This commit is contained in:
Emi Matchu 2010-07-10 12:42:18 -04:00
parent 7d2ca526fc
commit 844be37abe
44 changed files with 50 additions and 23 deletions

View file

@ -18,5 +18,5 @@ end
group :test do
gem 'rspec-rails', '>= 2.0.0.beta.8'
gem 'factory_girl', :git => 'git://github.com/thoughtbot/factory_girl.git', :branch => 'rails3'
gem 'factory_girl_rails'
end

View file

@ -1,11 +1,6 @@
---
hash: 69933c49c3e95c92aa2fa74961dcafc1b817fff7
hash: a126f60340d5ff8894e44c49aca44bfd89843564
sources:
- Git:
git: git://github.com/thoughtbot/factory_girl.git
branch: rails3
uri: git://github.com/thoughtbot/factory_girl.git
ref: feac7298352a83fef0717d8beadd2eda9aabfe56
- Git:
git: http://github.com/mislav/will_paginate.git
branch: rails3
@ -63,37 +58,38 @@ specs:
- diff-lcs:
version: 1.1.2
- factory_girl:
version: 1.2.3
source: 0
- mysql:
version: 2.8.1
- nokogiri:
version: 1.4.2
version: 1.3.1
- thor:
version: 0.13.7
- railties:
version: 3.0.0.beta4
- rails:
version: 3.0.0.beta4
- factory_girl_rails:
version: "1.0"
- mysql:
version: 2.8.1
- nokogiri:
version: 1.4.2
- rdiscount:
version: 1.6.5
- rspec-core:
version: 2.0.0.beta.14
version: 2.0.0.beta.16
- rspec-expectations:
version: 2.0.0.beta.14
version: 2.0.0.beta.16
- rspec-mocks:
version: 2.0.0.beta.14
version: 2.0.0.beta.16
- rspec:
version: 2.0.0.beta.14
version: 2.0.0.beta.16
- webrat:
version: 0.7.1
- rspec-rails:
version: 2.0.0.beta.14.2
version: 2.0.0.beta.16
- sqlite3-ruby:
version: 1.3.0
version: 1.3.1
- will_paginate:
version: 3.0.pre
source: 1
source: 0
dependencies:
rails:
version: = 3.0.0.beta4
@ -129,7 +125,7 @@ dependencies:
version: ">= 2.0.0.beta.8"
group:
- :test
factory_girl:
factory_girl_rails:
version: ">= 0"
group:
- :test

View file

@ -88,6 +88,11 @@ class Item < ActiveRecord::Base
arel_table[:description].matches("%#{description}%")
end
search_filter :is do |is_what|
raise ArgumentError, "We don't know how an item can be \"#{is_what}\". Did you mean is:nc?" unless is_what == 'nc'
arel_table[:rarity_index].in([0, 500])
end
search_filter :only do |species_name|
id = Species.require_by_name(species_name).id
arel_table[:species_support_ids].eq(id.to_s)

View file

@ -43,12 +43,12 @@ ActiveRecord::Schema.define(:version => 24) do
t.string "category", :limit => 50, :null => false
t.string "type", :limit => 50, :null => false
t.string "rarity", :limit => 25, :null => false
t.integer "rarity_index", :limit => 1, :null => false
t.integer "rarity_index", :limit => 2, :null => false
t.integer "price", :limit => 3, :null => false
t.integer "weight_lbs", :limit => 2, :null => false
t.text "species_support_ids"
t.integer "sold_in_mall", :limit => 1, :null => false
t.timestamp "last_spidered"
t.timestamp "last_spidered", :null => false
end
add_index "objects", ["last_spidered"], :name => "objects_last_spidered"
@ -64,6 +64,12 @@ ActiveRecord::Schema.define(:version => 24) do
add_index "parents_swf_assets", ["parent_id"], :name => "parent_swf_assets_parent_id"
add_index "parents_swf_assets", ["swf_asset_id"], :name => "parents_swf_assets_swf_asset_id"
create_table "pet_loads", :force => true do |t|
t.string "pet_name", :limit => 20, :null => false
t.text "amf", :null => false
t.timestamp "created_at", :null => false
end
create_table "pet_states", :force => true do |t|
t.integer "pet_type_id", :limit => 3, :null => false
t.text "swf_asset_ids", :limit => 255, :null => false
@ -89,6 +95,10 @@ ActiveRecord::Schema.define(:version => 24) do
add_index "pets", ["name"], :name => "pets_name", :unique => true
add_index "pets", ["pet_type_id"], :name => "pets_pet_type_id"
create_table "schema_info", :id => false, :force => true do |t|
t.integer "version", :default => 0, :null => false
end
create_table "swf_assets", :id => false, :force => true do |t|
t.string "type", :limit => 0, :null => false
t.integer "id", :limit => 3, :null => false
@ -100,6 +110,7 @@ ActiveRecord::Schema.define(:version => 24) do
end
add_index "swf_assets", ["body_id"], :name => "swf_assets_body_id_and_object_id"
add_index "swf_assets", ["zone_id"], :name => "idx_swf_assets_zone_id"
create_table "users", :force => true do |t|
t.string "name", :limit => 20, :null => false

View file

@ -153,6 +153,21 @@ describe Item do
Item.search('-only:aisha').map(&:name).should == ['a', 'b', 'c']
end
specify "should search by is:nc" do
Factory.create :item, :name => 'mall', :rarity_index => 500
Factory.create :item, :name => 'also mall', :rarity_index => 500
Factory.create :item, :name => 'only mall', :rarity_index => 0, :sold_in_mall => true
Factory.create :item, :name => 'not mall', :rarity_index => 400
Factory.create :item, :name => 'also not mall', :rarity_index => 101
Item.search('is:nc').map(&:name).should == ['mall', 'also mall', 'only mall']
Item.search('!is:nc').map(&:name).should == ['not mall', 'also not mall']
end
specify "is:(anything but 'nc') should throw ArgumentError" do
lambda { Item.search('is:nc') }.should_not raise_error(ArgumentError)
lambda { Item.search('is:awesome') }.should raise_error(ArgumentError)
end
specify "should be able to negate word in search" do
query_should 'hat -blue',
:return => [

BIN
vendor/cache/abstract-1.0.0.gem vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
vendor/cache/actionpack-3.0.0.beta4.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/activemodel-3.0.0.beta4.gem vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
vendor/cache/arel-0.4.0.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/builder-2.1.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/bundler-0.9.26.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/compass-0.10.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/diff-lcs-1.1.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/erubis-2.6.6.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/factory_girl-1.3.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/factory_girl_rails-1.0.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/haml-3.0.13.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/i18n-0.4.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/mail-2.2.5.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/mime-types-1.16.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/mysql-2.8.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/nokogiri-1.4.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/polyglot-0.3.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rack-1.1.0.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rack-mount-0.6.6.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rack-test-0.5.4.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rails-3.0.0.beta4.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/railties-3.0.0.beta4.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rake-0.8.7.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rdiscount-1.6.5.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/rspec-2.0.0.beta.16.gem vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
vendor/cache/sqlite3-ruby-1.3.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/thor-0.13.7.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/treetop-1.4.8.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/tzinfo-0.3.22.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/webrat-0.7.1.gem vendored Normal file

Binary file not shown.