From eeb5bbe41e047ab5740f70445058132cf02a96e0 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Mon, 22 Aug 2011 03:45:41 +0100 Subject: [PATCH] Issue #1244784 by marcingy: Fixed Add another answer in edit poll, not saved. --- modules/poll/poll.module | 5 ++++- modules/poll/poll.test | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 861969573df5..01c6bcc801ec 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -583,7 +583,10 @@ function poll_update($node) { 'chvotes' => (int) $choice['chvotes'], 'weight' => $choice['weight'], )) - ->insertFields(array('nid' => $node->nid)) + ->insertFields(array( + 'nid' => $node->nid, + 'chtext' => $choice['chtext'], + )) ->execute(); } else { diff --git a/modules/poll/poll.test b/modules/poll/poll.test index 6fabf956723f..d6c4f4005ba5 100644 --- a/modules/poll/poll.test +++ b/modules/poll/poll.test @@ -188,7 +188,7 @@ class PollCreateTestCase extends PollTestCase { function testPollCreate() { $title = $this->randomName(); $choices = $this->_generateChoices(7); - $this->pollCreate($title, $choices, TRUE); + $poll_nid = $this->pollCreate($title, $choices, TRUE); // Verify poll appears on 'poll' page. $this->drupalGet('poll'); @@ -198,6 +198,25 @@ class PollCreateTestCase extends PollTestCase { // Click on the poll title to go to node page. $this->clickLink($title); $this->assertText('Total votes: 0', 'Link to poll correct.'); + + // Now add a new option to make sure that when we update the node the + // option is displayed. + $node = node_load($poll_nid); + + $new_option = $this->randomName(); + + $node->choice[] = array( + 'chid' => '', + 'chtext' => $new_option, + 'chvotes' => 0, + 'weight' => 0, + ); + + node_save($node); + + $this->drupalGet('poll'); + $this->clickLink($title); + $this->assertText($new_option, 'New option found.'); } function testPollClose() { -- GitLab