Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.315
diff -u -r1.315 search.module
--- modules/search/search.module	18 Sep 2009 00:12:47 -0000	1.315
+++ modules/search/search.module	20 Sep 2009 15:37:21 -0000
@@ -678,7 +678,7 @@
       // Unset the link to mark it as processed.
       unset($links[$nid]);
     }
-    else {
+    else if ($sid != $nid) {
       // Insert the existing link and mark the node for reindexing.
       db_insert('search_node_links')
         ->fields(array(
Index: modules/search/search.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.test,v
retrieving revision 1.35
diff -u -r1.35 search.test
--- modules/search/search.test	11 Sep 2009 15:39:48 -0000	1.35
+++ modules/search/search.test	20 Sep 2009 15:37:21 -0000
@@ -528,3 +528,45 @@
     $this->assertNoText($comment_body, t('Comment body text not found in search results.'));
   }
 }
+
+/**
+ * Test config page.
+ */
+class SearchConfigSettingsForm extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Config settings form',
+      'description' => 'Verify the search config settings form.',
+      'group' => 'Search',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('search');
+
+    // Login as a user that can create and search content.
+    $this->drupalLogin($this->drupalCreateUser(array('search content', 'administer search', 'administer nodes')));
+  }
+
+  /**
+   * Verify the search settings form.
+   */
+  function testSearchSettingsPage() {
+    // Add a single piece of content and index it.
+    $node = $this->drupalCreateNode();
+    node_update_index();
+    search_update_totals();
+
+    // Test that the settings form displays the correct count of items left to index.
+    $this->drupalGet('admin/config/search/settings');
+    $this->assertText(t('There are @count items left to index.', array('@count' => 0)));
+
+    // Test the re-index button.
+    $this->drupalPost('admin/config/search/settings', array(), t('Re-index site'));
+    $this->assertText(t('Are you sure you want to re-index the site'));
+    $this->drupalPost('admin/config/search/settings/reindex', array(), t('Re-index site'));
+    $this->assertText(t('The index will be rebuilt'));
+    $this->drupalGet('admin/config/search/settings');
+    $this->assertText(t('There is 1 item left to index.'));
+  }
+}
