Skip to content

Commit

Permalink
Merge pull request #3167 from karlcow/3140/1
Browse files Browse the repository at this point in the history
Fixes #3140 - Publish private issue in public after moderation

closes #3141
  • Loading branch information
karlcow authored Feb 5, 2020
2 parents 59ec79f + 8ec394b commit d8797bd
Show file tree
Hide file tree
Showing 11 changed files with 638 additions and 58 deletions.
3 changes: 2 additions & 1 deletion tests/fixtures/webhooks/new_event_invalid.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"title": "www.netflix.com - test invalid event",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests",
"number": 600,
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n\n**URL**: https://www.netflix.com/"
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n\n**URL**: https://www.netflix.com/",
"state": "open"
}
}
3 changes: 2 additions & 1 deletion tests/fixtures/webhooks/new_event_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"default": false,
"description": "issue in the process of being moderated"
}
]
],
"state": "open"
}
}
24 changes: 24 additions & 0 deletions tests/fixtures/webhooks/private_milestone_accepted.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"action": "milestoned",
"issue": {
"title": "www.netflix.com - test private issue accepted",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests-private",
"number": 600,
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n<!-- @public_url: https://github.com/webcompat/webcompat-tests/issues/1 -->\n\n**URL**: https://www.netflix.com/",
"labels": [
{
"id": 1788251357,
"node_id": "MDU6TGFiZWwxNzg4MjUxMzU3",
"url": "https://api.github.com/repos/webcompat/webcompat-tests/labels/action-needsmoderation",
"name": "action-needsmoderation",
"color": "d36200",
"default": false,
"description": "issue in the process of being moderated"
}
],
"state": "open"
},
"milestone": {
"title": "accepted"
}
}
24 changes: 24 additions & 0 deletions tests/fixtures/webhooks/private_milestone_accepted_wrong_repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"action": "milestoned",
"issue": {
"title": "www.netflix.com - test private issue accepted",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests-foobar",
"number": 600,
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n<!-- @public_url: https://github.com/webcompat/webcompat-tests/issues/1 -->\n\n**URL**: https://www.netflix.com/",
"labels": [
{
"id": 1788251357,
"node_id": "MDU6TGFiZWwxNzg4MjUxMzU3",
"url": "https://api.github.com/repos/webcompat/webcompat-tests/labels/action-needsmoderation",
"name": "action-needsmoderation",
"color": "d36200",
"default": false,
"description": "issue in the process of being moderated"
}
],
"state": "open"
},
"milestone": {
"title": "accepted"
}
}
24 changes: 24 additions & 0 deletions tests/fixtures/webhooks/private_milestone_closed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"action": "closed",
"issue": {
"title": "www.netflix.com - test private issue accepted",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests-private",
"number": 600,
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n<!-- @public_url: https://github.com/webcompat/webcompat-tests/issues/1 -->\n\n**URL**: https://www.netflix.com/",
"labels": [
{
"id": 1788251357,
"node_id": "MDU6TGFiZWwxNzg4MjUxMzU3",
"url": "https://api.github.com/repos/webcompat/webcompat-tests/labels/action-needsmoderation",
"name": "action-needsmoderation",
"color": "d36200",
"default": false,
"description": "issue in the process of being moderated"
}
],
"state": "closed"
},
"milestone": {
"title": "needstriage"
}
}
5 changes: 3 additions & 2 deletions tests/fixtures/webhooks/wrong_repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"action": "opened",
"issue": {
"title": "www.netflix.com - test wrong repo",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests-private",
"repository_url": "https://api.github.com/repos/webcompat/webcompat-tests-foobar",
"number": 600,
"body": "<!-- @browser: Firefox 55.0 -->\n<!-- @ua_header: Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 -->\n<!-- @reported_with: web -->\n\n**URL**: https://www.netflix.com/",
"labels": [
Expand All @@ -15,6 +15,7 @@
"default": false,
"description": "issue in the process of being moderated"
}
]
],
"state": "open"
}
}
23 changes: 22 additions & 1 deletion tests/unit/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,28 @@ def test_moderation_template(self):
- must be a dictionary
- must contain the keys: title, body
"""
actual = moderation_template()
actual = moderation_template('ongoing')
self.assertIs(type(actual), dict)
self.assertIn('title', actual.keys())
self.assertIn('body', actual.keys())

def test_moderation_template_rejected(self):
"""Check the return values are for the rejected case."""
actual = moderation_template('rejected')
self.assertEqual(actual['title'], 'Issue rejected.')
self.assertIn('Its original content has been deleted', actual['body'])

def test_moderation_template_ongoing(self):
"""Check the return values are for the needsmoderation case."""
# test the default
actual = moderation_template()
self.assertEqual(actual['title'], 'In the moderation queue.')
self.assertIn('put in the moderation queue.', actual['body'])
# test the keyword
actual = moderation_template('ongoing')
self.assertEqual(actual['title'], 'In the moderation queue.')
self.assertIn('put in the moderation queue.', actual['body'])
# bad keyword, we go back to the default.
actual = moderation_template('punkcat')
self.assertEqual(actual['title'], 'In the moderation queue.')
self.assertIn('put in the moderation queue.', actual['body'])
Loading

0 comments on commit d8797bd

Please sign in to comment.