Created
October 28, 2008 21:31
-
-
Save mmmurf/20524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/spec/fixtures/data.sql b/spec/fixtures/data.sql | |
index 3baaf35..a1ead87 100644 | |
--- a/spec/fixtures/data.sql | |
+++ b/spec/fixtures/data.sql | |
@@ -1023,3 +1023,7 @@ insert into `animals` (name, type) values ('nat', 'Cat'); | |
insert into `animals` (name, type) values ('molly', 'Cat'); | |
insert into `animals` (name, type) values ('jasper', 'Cat'); | |
insert into `animals` (name, type) values ('moggy', 'Cat'); | |
+insert into `cities` (name, zip) values ('Jackson', 49201); | |
+insert into `cities` (name, zip) values ('Rives.', 49201); | |
+insert into `cities` (name, zip) values ('Hillsdale', 49201); | |
+insert into `cities` (name, zip) values ('Jackson', 49277); | |
diff --git a/spec/fixtures/models.rb b/spec/fixtures/models.rb | |
index b63c7a7..8bf3e73 100644 | |
--- a/spec/fixtures/models.rb | |
+++ b/spec/fixtures/models.rb | |
@@ -80,4 +80,12 @@ end | |
class Cat < Animal | |
# | |
-end | |
\ No newline at end of file | |
+end | |
+ | |
+class City < ActiveRecord::Base | |
+ define_index do | |
+ indexes :name | |
+ has :zip | |
+ set_property :delta => true | |
+ end | |
+end | |
diff --git a/spec/fixtures/structure.sql b/spec/fixtures/structure.sql | |
index 8e4f4b0..9f4e06c 100644 | |
--- a/spec/fixtures/structure.sql | |
+++ b/spec/fixtures/structure.sql | |
@@ -83,4 +83,14 @@ CREATE TABLE `animals` ( | |
`type` varchar(50) NOT NULL, | |
`delta` tinyint(1) NOT NULL DEFAULT 0, | |
PRIMARY KEY (`id`) | |
-) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
\ No newline at end of file | |
+) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
+ | |
+DROP TABLE IF EXISTS `cities`; | |
+ | |
+CREATE TABLE `cities` ( | |
+ `id` int(11) NOT NULL auto_increment, | |
+ `name` varchar(50) NOT NULL, | |
+ `zip` int(11) NOT NULL, | |
+ `delta` tinyint(1) NOT NULL DEFAULT 0, | |
+ PRIMARY KEY (`id`) | |
+) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
diff --git a/spec/unit/thinking_sphinx/search_spec.rb b/spec/unit/thinking_sphinx/search_spec.rb | |
index d6cb1eb..203f93c 100644 | |
--- a/spec/unit/thinking_sphinx/search_spec.rb | |
+++ b/spec/unit/thinking_sphinx/search_spec.rb | |
@@ -200,4 +200,16 @@ describe ThinkingSphinx::Search do | |
Beta.search("two").should be_empty | |
end | |
+ | |
+ it "should have three items with the 49201 zip in the db" do | |
+ City.search(:with => {:zip => 49201}).total_entries.should == 3 | |
+ end | |
+ | |
+ it "should still have three items with 49201 if we update another attribute" do | |
+ record = City.search(:with => {:zip => 49201}).first | |
+ record.update_attributes(:name => "Horton") | |
+ City.search(:with => {:zip => 49201}).total_entries.should == 3 | |
+ end | |
+ | |
+ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment