Skip to content
Snippets Groups Projects
Commit ede9de3c authored by Benoit Alessandroni's avatar Benoit Alessandroni
Browse files

Merge branch 'no-cache-on-total-votes' into 'master'

update: no cache on TotalVotes serializer

See merge request !20
parents c937fe56 949592df
No related branches found
No related tags found
1 merge request!20update: no cache on TotalVotes serializer
Pipeline #9460 failed
...@@ -5,6 +5,7 @@ from djangoldp_polls.models import PollOption ...@@ -5,6 +5,7 @@ from djangoldp_polls.models import PollOption
class PollOptionSerializer(LDPSerializer): class PollOptionSerializer(LDPSerializer):
total_votes = serializers.SerializerMethodField() total_votes = serializers.SerializerMethodField()
with_cache = False
class Meta: class Meta:
model = PollOption model = PollOption
......
...@@ -37,6 +37,16 @@ class PermissionsTestCase(APITestCase): ...@@ -37,6 +37,16 @@ class PermissionsTestCase(APITestCase):
'chosenOption': {'@id': option.urlid} 'chosenOption': {'@id': option.urlid}
} }
def test_get_total_votes_cache(self):
self.setUpPoll()
response = self.client.get('/polloptions/{}/'.format(self.poll_option_a.pk))
self.assertFalse('total_votes' in response.data)
response = self.client.get('/polls/total_votes/{}/'.format(self.poll.pk))
print(str(response.data))
self.assertTrue('total_votes' in response.data['ldp:contains'][0])
self.assertTrue('total_votes' in response.data['ldp:contains'][1])
def test_can_vote_view(self): def test_can_vote_view(self):
# I should be able to vote # I should be able to vote
self.setUpPoll() self.setUpPoll()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment