Skip to content

Commit

Permalink
Merge pull request #245 from Ilhasoft/add-category-icons-to-myReposit…
Browse files Browse the repository at this point in the history
…ories

Add category icons to my repositories
  • Loading branch information
johncordeiro committed Mar 1, 2019
2 parents d3aa088 + 9c03cf2 commit 6bc8fe7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions bothub/api/v1/serializers/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class Meta:
fields = [
'id',
'name',
'icon',
]
3 changes: 3 additions & 0 deletions bothub/api/v1/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class Meta:
source='owner',
slug_field='nickname',
read_only=True)
categories = RepositoryCategorySerializer(
many=True,
read_only=True)
categories_list = serializers.SerializerMethodField()
entities = serializers.SerializerMethodField()
labels = RepositoryEntityLabelSerializer(many=True)
Expand Down
17 changes: 16 additions & 1 deletion bothub/api/v1/tests/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def setUp(self):
self.factory = RequestFactory()

self.category = RepositoryCategory.objects.create(name='Category 1')
self.business_category = RepositoryCategory.objects.create(
name='Business',
icon='business')

def request(self):
request = self.factory.get('/api/categories/')
Expand All @@ -22,8 +25,20 @@ def request(self):
content_data = json.loads(response.content)
return (response, content_data,)

def test_okay(self):
def test_default_category_icon(self):
response, content_data = self.request()
self.assertEqual(
content_data[0].get('id'),
self.category.id)
self.assertEqual(
content_data[0].get('icon'),
'botinho')

def test_custom_category_icon(self):
response, content_data = self.request()
self.assertEqual(
content_data[1].get('id'),
self.business_category.id)
self.assertEqual(
content_data[1].get('icon'),
self.business_category.icon)

0 comments on commit 6bc8fe7

Please sign in to comment.