Skip to content

Commit

Permalink
Fix PR message rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilhelm Klopp committed Oct 21, 2017
1 parent 74df53b commit 148de45
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 102 deletions.
5 changes: 3 additions & 2 deletions lib/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ class PullRequest {
return cleanedAttachment;
}
getRenderedMessage() {
// handle unfurl case
if (this.unfurl || !this.major[this.eventType]) {
return {
attachments: [
Expand All @@ -338,7 +337,9 @@ class PullRequest {
});
attachments.push(...statuses);
}
return attachments;
return {
attachments,
};
}
}

Expand Down
204 changes: 104 additions & 100 deletions test/renderer/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -117,111 +117,115 @@ Object {
`;

exports[`Pull request rendering works for notifcation messages 1`] = `
Array [
Object {
"color": "#36a64f",
"fallback": "[github-slack/app] Pull request opened by wilhelmklopp",
"mrkdwn_in": Array [
"text",
],
"pretext": "[github-slack/app] Pull request opened by wilhelmklopp",
"text": "1 commit into \`github-slack:master\` from \`github-slack:wilhelmklopp/add-readme-badges\`",
},
Object {
"author_icon": "https://avatars1.githubusercontent.com/u/7718702?v=4",
"author_link": "https://github.com/wilhelmklopp",
"author_name": "wilhelmklopp",
"color": "#36a64f",
"fallback": "#31 Add badges to readme",
"fields": Array [],
"footer": "<https://github.com/github-slack/app/pull/31|View it on GitHub>",
"footer_icon": "https://assets-cdn.github.com/favicon.ico",
"mrkdwn_in": Array [
"text",
],
"text": "![image](https://user-images.githubusercontent.com/7718702/30750617-39e2fb52-9fb7-11e7-8da1-d6542317bee2.png)
Object {
"attachments": Array [
Object {
"color": "#36a64f",
"fallback": "[github-slack/app] Pull request opened by wilhelmklopp",
"mrkdwn_in": Array [
"text",
],
"pretext": "[github-slack/app] Pull request opened by wilhelmklopp",
"text": "1 commit into \`github-slack:master\` from \`github-slack:wilhelmklopp/add-readme-badges\`",
},
Object {
"author_icon": "https://avatars1.githubusercontent.com/u/7718702?v=4",
"author_link": "https://github.com/wilhelmklopp",
"author_name": "wilhelmklopp",
"color": "#36a64f",
"fallback": "#31 Add badges to readme",
"fields": Array [],
"footer": "<https://github.com/github-slack/app/pull/31|View it on GitHub>",
"footer_icon": "https://assets-cdn.github.com/favicon.ico",
"mrkdwn_in": Array [
"text",
],
"text": "![image](https://user-images.githubusercontent.com/7718702/30750617-39e2fb52-9fb7-11e7-8da1-d6542317bee2.png)
",
"title": "#31 Add badges to readme",
"title_link": "https://github.com/github-slack/app/pull/31",
"ts": 1506092298,
},
]
"title": "#31 Add badges to readme",
"title_link": "https://github.com/github-slack/app/pull/31",
"ts": 1506092298,
},
],
}
`;

exports[`Pull request rendering works for notifcation messages with statuses 1`] = `
Array [
Object {
"color": "#36a64f",
"fallback": "[github-slack/app] Pull request opened by wilhelmklopp",
"mrkdwn_in": Array [
"text",
],
"pretext": "[github-slack/app] Pull request opened by wilhelmklopp",
"text": "1 commit into \`github-slack:master\` from \`github-slack:wilhelmklopp/add-readme-badges\`",
},
Object {
"author_icon": "https://avatars1.githubusercontent.com/u/7718702?v=4",
"author_link": "https://github.com/wilhelmklopp",
"author_name": "wilhelmklopp",
"color": "#36a64f",
"fallback": "#31 Add badges to readme",
"fields": Array [],
"footer": "<https://github.com/github-slack/app/pull/31|View it on GitHub>",
"footer_icon": "https://assets-cdn.github.com/favicon.ico",
"mrkdwn_in": Array [
"text",
],
"text": "![image](https://user-images.githubusercontent.com/7718702/30750617-39e2fb52-9fb7-11e7-8da1-d6542317bee2.png)
Object {
"attachments": Array [
Object {
"color": "#36a64f",
"fallback": "[github-slack/app] Pull request opened by wilhelmklopp",
"mrkdwn_in": Array [
"text",
],
"pretext": "[github-slack/app] Pull request opened by wilhelmklopp",
"text": "1 commit into \`github-slack:master\` from \`github-slack:wilhelmklopp/add-readme-badges\`",
},
Object {
"author_icon": "https://avatars1.githubusercontent.com/u/7718702?v=4",
"author_link": "https://github.com/wilhelmklopp",
"author_name": "wilhelmklopp",
"color": "#36a64f",
"fallback": "#31 Add badges to readme",
"fields": Array [],
"footer": "<https://github.com/github-slack/app/pull/31|View it on GitHub>",
"footer_icon": "https://assets-cdn.github.com/favicon.ico",
"mrkdwn_in": Array [
"text",
],
"text": "![image](https://user-images.githubusercontent.com/7718702/30750617-39e2fb52-9fb7-11e7-8da1-d6542317bee2.png)
",
"title": "#31 Add badges to readme",
"title_link": "https://github.com/github-slack/app/pull/31",
"ts": 1506092298,
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/oa/1508?v=4",
"author_link": "https://travis-ci.org/github-slack/app/builds/278661171?utm_source=github_status&utm_medium=notification",
"author_name": "continuous-integration/travis-ci/pr",
"color": "#dbab09",
"fallback": "The Travis CI build is pending",
"mrkdwn_in": Array [
"text",
],
"text": "The Travis CI build is pending",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/oa/1508?v=4",
"author_link": "https://travis-ci.org/github-slack/app/builds/278661144?utm_source=github_status&utm_medium=notification",
"author_name": "continuous-integration/travis-ci/push",
"color": "#28a745",
"fallback": "The Travis CI build passed",
"mrkdwn_in": Array [
"text",
],
"text": "The Travis CI build passed",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/in/254?v=4",
"author_link": "https://codecov.io/gh/github-slack/app/compare/0143c3cd70052e00bb07dc09229b261b3afd807d...68c2ef08b77a144aeaa69b601ecbacb979e3a8fd",
"author_name": "codecov/patch",
"color": "#cb2431",
"fallback": "Coverage not affected when comparing 0143c3c...68c2ef0",
"mrkdwn_in": Array [
"text",
],
"text": "Coverage not affected when comparing 0143c3c...68c2ef0",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/in/254?v=4",
"author_link": "https://codecov.io/gh/github-slack/app/compare/0143c3cd70052e00bb07dc09229b261b3afd807d...68c2ef08b77a144aeaa69b601ecbacb979e3a8fd",
"author_name": "codecov/project",
"color": "#cb2431",
"fallback": "98.37% remains the same compared to 0143c3c",
"mrkdwn_in": Array [
"text",
],
"text": "98.37% remains the same compared to 0143c3c",
},
]
"title": "#31 Add badges to readme",
"title_link": "https://github.com/github-slack/app/pull/31",
"ts": 1506092298,
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/oa/1508?v=4",
"author_link": "https://travis-ci.org/github-slack/app/builds/278661171?utm_source=github_status&utm_medium=notification",
"author_name": "continuous-integration/travis-ci/pr",
"color": "#dbab09",
"fallback": "The Travis CI build is pending",
"mrkdwn_in": Array [
"text",
],
"text": "The Travis CI build is pending",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/oa/1508?v=4",
"author_link": "https://travis-ci.org/github-slack/app/builds/278661144?utm_source=github_status&utm_medium=notification",
"author_name": "continuous-integration/travis-ci/push",
"color": "#28a745",
"fallback": "The Travis CI build passed",
"mrkdwn_in": Array [
"text",
],
"text": "The Travis CI build passed",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/in/254?v=4",
"author_link": "https://codecov.io/gh/github-slack/app/compare/0143c3cd70052e00bb07dc09229b261b3afd807d...68c2ef08b77a144aeaa69b601ecbacb979e3a8fd",
"author_name": "codecov/patch",
"color": "#cb2431",
"fallback": "Coverage not affected when comparing 0143c3c...68c2ef0",
"mrkdwn_in": Array [
"text",
],
"text": "Coverage not affected when comparing 0143c3c...68c2ef0",
},
Object {
"author_icon": "https://avatars2.githubusercontent.com/in/254?v=4",
"author_link": "https://codecov.io/gh/github-slack/app/compare/0143c3cd70052e00bb07dc09229b261b3afd807d...68c2ef08b77a144aeaa69b601ecbacb979e3a8fd",
"author_name": "codecov/project",
"color": "#cb2431",
"fallback": "98.37% remains the same compared to 0143c3c",
"mrkdwn_in": Array [
"text",
],
"text": "98.37% remains the same compared to 0143c3c",
},
],
}
`;

exports[`Pull request rendering works for unfurls 1`] = `
Expand Down

0 comments on commit 148de45

Please sign in to comment.