summaryrefslogtreecommitdiff
path: root/modules/poll
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-01-11 23:19:53 -0500
committerwebchick <webchick@24967.no-reply.drupal.org>2012-01-11 23:19:53 -0500
commit1c519917ad610f6922f3108c8313e613cbd071a1 (patch)
tree6eb51590a8daf98ef9f935a99752981bc4162fa0 /modules/poll
parent84844cf37d999d59b0262c0573b89fbe4c9e7486 (diff)
downloadbrdo-1c519917ad610f6922f3108c8313e613cbd071a1.tar.gz
brdo-1c519917ad610f6922f3108c8313e613cbd071a1.tar.bz2
Issue #1295546 by c31ck, marcingy, amateescu, xjm: Fixed Weight and number of votes not getting saved when updating a poll.
Diffstat (limited to 'modules/poll')
-rw-r--r--modules/poll/poll.module6
-rw-r--r--modules/poll/poll.test11
2 files changed, 13 insertions, 4 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 13d2606de..aebb9f259 100644
--- a/modules/poll/poll.module
+++ b/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();
}
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index d7648a6ba..f6f82dfd6 100644
--- a/modules/poll/poll.test
+++ b/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() {