diff options
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/node.pages.inc | 2 | ||||
-rw-r--r-- | modules/node/node.test | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index dee92e16c..75ed0ddb8 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -470,7 +470,7 @@ function node_form_submit($form, &$form_state) { if ($node->nid) { $form_state['values']['nid'] = $node->nid; $form_state['nid'] = $node->nid; - $form_state['redirect'] = 'node/' . $node->nid; + $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>'; } else { // In the unlikely case something went wrong on save, the node will be diff --git a/modules/node/node.test b/modules/node/node.test index 2180f5838..0256fecfd 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -573,6 +573,25 @@ class NodeCreationTestCase extends DrupalWebTestCase { $records = db_query("SELECT wid FROM {watchdog} WHERE variables LIKE '%Test exception for rollback.%'")->fetchAll(); $this->assertTrue(count($records) > 0, t('Rollback explanatory error logged to watchdog.')); } + + /** + * Create an unpublished node and confirm correct redirect behavior. + */ + function testUnpublishedNodeCreation() { + // Set "Basic page" content type to be unpublished by default. + variable_set('node_options_page', array()); + // Set the front page to the default "node" page. + variable_set('site_frontpage', 'node'); + + // Create a node. + $edit = array(); + $edit["title"] = $this->randomName(8); + $edit["body[" . LANGUAGE_NONE . "][0][value]"] = $this->randomName(16); + $this->drupalPost('node/add/page', $edit, t('Save')); + + // Check that the user was redirected to the home page. + $this->assertText(t('Welcome to Drupal'), t('The user is redirected to the home page.')); + } } /** |