Skip to content
Browse files

Issue #1295546 by c31ck, marcingy, amateescu, xjm: Fixed Weight and n…

…umber of votes not getting saved when updating a poll.
  • Loading branch information...
1 parent 84844cf commit 1c519917ad610f6922f3108c8313e613cbd071a1 @webchick webchick committed Jan 11, 2012
Showing with 13 additions and 4 deletions.
  1. +4 −2 modules/poll/poll.module
  2. +9 −2 modules/poll/poll.test
View
6 modules/poll/poll.module
@@ -586,8 +586,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();
}
View
11 modules/poll/poll.test
@@ -205,18 +205,25 @@ 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);
$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() {

0 comments on commit 1c51991

Please sign in to comment.
Something went wrong with that request. Please try again.