Commit 2079d300 authored by webchick's avatar webchick
Browse files

#617596 by ygerasimov, furamag: Fixed Non-empty Summary and empty Body both...

#617596 by ygerasimov, furamag: Fixed Non-empty Summary and empty Body both become empty when saved.
parent e8716ebf
......@@ -38,7 +38,7 @@ Drupal.behaviors.textSummary = {
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($(this).val() == '') {
if ($(this).find('.text-summary').val() == '') {
$link.click();
}
return;
......
......@@ -171,7 +171,12 @@ function text_field_load($entity_type, $entities, $field, $instances, $langcode,
*/
function text_field_is_empty($item, $field) {
if (empty($item['value']) && (string) $item['value'] !== '0') {
return TRUE;
if ($field['type'] == 'text_with_summary') {
return (empty($item['summary']) && (string)$item['summary'] !== '0');
}
else {
return TRUE;
}
}
return FALSE;
}
......
......@@ -242,6 +242,11 @@ class TextSummaryTestCase extends DrupalWebTestCase {
);
}
function setUp() {
parent::setUp();
$this->article_creator = $this->drupalCreateUser(array('create article content', 'edit own article content'));
}
/**
* Tests an edge case where the first sentence is a question and
* subsequent sentences are not. This edge case is documented at
......@@ -376,6 +381,24 @@ class TextSummaryTestCase extends DrupalWebTestCase {
$summary = text_summary($text, $format, $size);
$this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected)));
}
/**
* Test sending only summary.
*/
function testOnlyTextSummary() {
// Login as article creator.
$this->drupalLogin($this->article_creator);
// Create article with summary but empty body.
$summary = $this->randomName();
$edit = array(
"title" => $this->randomName(),
"body[und][0][summary]" => $summary,
);
$this->drupalPost('node/add/article', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertIdentical($node->body['und'][0]['summary'], $summary, t('Article with with summary and no body has been submitted.'));
}
}
class TextTranslationTestCase extends DrupalWebTestCase {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment