Skip to content

Commit

Permalink
Merge pull request #94 from jonnybazookatone/enhancement/issue#93/fee…
Browse files Browse the repository at this point in the history
…dback-any-keyword

Issue #93: Feedback end point receive any key/values
  • Loading branch information
jonnybazookatone committed Apr 20, 2016
2 parents 75cf25c + 6ebbb10 commit 5f4139c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
24 changes: 16 additions & 8 deletions adsws/feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,23 @@ def prettify_post(post_data):

icon_emoji = ':goberserk:'

text = [
'```Incoming Feedback```',
'*Commenter*: {}'.format(name),
'*e-mail*: {}'.format(reply_to),
'*Feedback*: {}'.format(comments)
]

used = ['channel', 'username', 'name', '_replyto', 'comments']
for key in post_data:
if key in used:
continue
text.append('*{}*: {}'.format(key, post_data[key]))

text = '\n'.join(text)

prettified_data = {
'text': '```Incoming Feedback```\n'
'*Commenter*: {commenter}\n'
'*e-mail*: {email}\n'
'*Feedback*: {feedback}'.format(
commenter=name,
email=reply_to,
feedback=comments
),
'text': text,
'username': username,
'channel': channel,
'icon_emoji': icon_emoji
Expand Down
32 changes: 31 additions & 1 deletion adsws/tests/test_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,37 @@ def test_parser_parses_content(self):
form_data = {
'name': 'Commenter',
'comments': 'Why are my citations missing?',
'_subject': 'Bumblebee Feedback',
'_replyto': 'commenter@email.com'
}

prettified_post_data = SlackFeedback().prettify_post(form_data)

for key in post_data_sent.keys():
self.assertEqual(post_data_sent[key], prettified_post_data[key])

def test_can_send_abritrary_keyword_values(self):
"""
Test the end point is not restrictive on the keyword values it can
create content for.
"""

post_data_sent = {
'text': '```Incoming Feedback```\n'
'*Commenter*: Commenter\n'
'*e-mail*: commenter@email.com\n'
'*Feedback*: Why are my citations missing?\n'
'*IP Address*: 127.0.0.1\n'
'*Browser*: Firefox v42',
'username': 'TownCrier',
'channel': '#feedback',
'icon_emoji': ':goberserk:'
}

form_data = {
'name': 'Commenter',
'comments': 'Why are my citations missing?',
'Browser': 'Firefox v42',
'IP Address': '127.0.0.1',
'_replyto': 'commenter@email.com'
}

Expand Down

0 comments on commit 5f4139c

Please sign in to comment.