Commit 76b2882a authored by catch's avatar catch
Browse files

Issue #1295546 by c31ck, marcingy, xjm, amateescu: Fixed Weight and number of...

Issue #1295546 by c31ck, marcingy, xjm, amateescu: Fixed Weight and number of votes not getting saved when updating a poll.
parent f15bc6f4
...@@ -582,8 +582,10 @@ function poll_update($node) { ...@@ -582,8 +582,10 @@ function poll_update($node) {
'weight' => $choice['weight'], 'weight' => $choice['weight'],
)) ))
->insertFields(array( ->insertFields(array(
'nid' => $node->nid, 'nid' => $node->nid,
'chtext' => $choice['chtext'], 'chtext' => $choice['chtext'],
'chvotes' => (int) $choice['chvotes'],
'weight' => $choice['weight'],
)) ))
->execute(); ->execute();
} }
......
...@@ -205,11 +205,12 @@ class PollCreateTestCase extends PollTestCase { ...@@ -205,11 +205,12 @@ class PollCreateTestCase extends PollTestCase {
$new_option = $this->randomName(); $new_option = $this->randomName();
$vote_count = '2000';
$node->choice[] = array( $node->choice[] = array(
'chid' => '', 'chid' => '',
'chtext' => $new_option, 'chtext' => $new_option,
'chvotes' => 0, 'chvotes' => (int) $vote_count,
'weight' => 0, 'weight' => 1000,
); );
node_save($node); node_save($node);
...@@ -217,6 +218,12 @@ class PollCreateTestCase extends PollTestCase { ...@@ -217,6 +218,12 @@ class PollCreateTestCase extends PollTestCase {
$this->drupalGet('poll'); $this->drupalGet('poll');
$this->clickLink($title); $this->clickLink($title);
$this->assertText($new_option, 'New option found.'); $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() { function testPollClose() {
......
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