From 76b2882a832af2abf6237c7815d3293d87185815 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Fri, 30 Dec 2011 21:02:15 +0900 Subject: [PATCH] Issue #1295546 by c31ck, marcingy, xjm, amateescu: Fixed Weight and number of votes not getting saved when updating a poll. --- core/modules/poll/poll.module | 6 ++++-- core/modules/poll/poll.test | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module index 7fe34e412ec8..ef19dd964d2c 100644 --- a/core/modules/poll/poll.module +++ b/core/modules/poll/poll.module @@ -582,8 +582,10 @@ function poll_update($node) { 'weight' => $choice['weight'], )) ->insertFields(array( - 'nid' => $node->nid, - 'chtext' => $choice['chtext'], + 'nid' => $node->nid, + 'chtext' => $choice['chtext'], + 'chvotes' => (int) $choice['chvotes'], + 'weight' => $choice['weight'], )) ->execute(); } diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test index 20a46787ea3e..8c159ea70511 100644 --- a/core/modules/poll/poll.test +++ b/core/modules/poll/poll.test @@ -205,11 +205,12 @@ class PollCreateTestCase extends PollTestCase { $new_option = $this->randomName(); + $vote_count = '2000'; $node->choice[] = array( 'chid' => '', 'chtext' => $new_option, - 'chvotes' => 0, - 'weight' => 0, + 'chvotes' => (int) $vote_count, + 'weight' => 1000, ); node_save($node); @@ -217,6 +218,12 @@ class PollCreateTestCase extends PollTestCase { $this->drupalGet('poll'); $this->clickLink($title); $this->assertText($new_option, 'New option found.'); + + $option = $this->xpath('//div[@id="node-1"]//div[@class="poll"]//div[@class="text"]'); + $this->assertEqual(end($option), $new_option, 'Last item is equal to new option.'); + + $votes = $this->xpath('//div[@id="node-1"]//div[@class="poll"]//div[@class="percent"]'); + $this->assertTrue(strpos(end($votes), $vote_count) > 0, t("Votes saved.")); } function testPollClose() { -- GitLab