Skip to content

Commit eb94acb

Browse files
committed
add testing for slashes in branch names
1 parent 60a07ed commit eb94acb

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

unit/notifier.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,51 @@ describe('Notifier', function () {
7777
slack.notifyOnBuild(githubPushInfo, done);
7878
});
7979

80+
it('should render proper escaped branch name and commit message on slack.notifyOnBuild call', function (done) {
81+
var slack = new Slack({});
82+
slack.send = function (text, cb) {
83+
var message = 'podviaznikov\'s ';
84+
message += '<' + headCommit.url + '|changes>';
85+
message += ' (init &amp; commit &amp; push) to CodeNow/api (feature-1/fix) are ready.\n';
86+
message += '<http://runnable3.net/';
87+
message += 'podviaznikov/boxSelection/api/feature-1%2Ffix/init%20%26%20commit%20%26%20push';
88+
message += '/a240edf982d467201845b3bf10ccbe16f6049ea9';
89+
message += '|Choose a server to run feature-1/fix>.';
90+
expect(text).to.equal(message);
91+
cb();
92+
};
93+
94+
var headCommit = {
95+
id: 'a240edf982d467201845b3bf10ccbe16f6049ea9',
96+
message: 'init & commit & push',
97+
url: 'https://github.com/CodeNow/api/commit/a240edf982d467201845b3bf10ccbe16f6049ea9'
98+
};
99+
var githubPushInfo = {
100+
commitLog: [headCommit],
101+
repo: 'CodeNow/api',
102+
repoName: 'api',
103+
branch: 'feature-1/fix',
104+
commit: 'a240edf982d467201845b3bf10ccbe16f6049ea9',
105+
headCommit: headCommit,
106+
user: {
107+
login: 'podviaznikov'
108+
},
109+
owner: {
110+
login: 'podviaznikov'
111+
}
112+
};
113+
114+
slack.notifyOnBuild(githubPushInfo, done);
115+
});
116+
80117
it('should render proper text on slack.notifyOnInstances call', function (done) {
81118
var slack = new Slack({});
82119
slack.send = function (message, cb) {
83120
var text = 'tjmehta\'s ';
84121
text += '<' + headCommit.url + '|changes>';
85122
text += ' (init &amp; commit &lt;p&gt;Hello&lt;/p&gt; and ';
86123
text += '<https://github.com/CodeNow/api/compare/b240edf982d4...a240edf982d4|1 more>)';
87-
text += ' to CodeNow/api (develop) are deployed on servers:';
124+
text += ' to CodeNow/api (feature-1/fix) are deployed on servers:';
88125
expect(text).to.equal(message.text);
89126
expect(message.attachments.length).to.equal(1);
90127
var attachment = message.attachments[0];
@@ -116,7 +153,7 @@ describe('Notifier', function () {
116153
}],
117154
repo: 'CodeNow/api',
118155
repoName: 'api',
119-
branch: 'develop',
156+
branch: 'feature-1/fix',
120157
commit: 'a240edf982d46720,1845b3bf10ccbe16f6049ea9',
121158
headCommit: headCommit,
122159
user: {
@@ -131,9 +168,9 @@ describe('Notifier', function () {
131168
hipchat.send = function (text, cb) {
132169
var message = 'podviaznikov\'s ';
133170
message += '<a href="' + headCommit.url + '">changes</a>';
134-
message += ' (hey there) to Runnable/api (develop) are ready.\n';
135-
message += '<a href="http://runnable3.net/podviaznikov/boxSelection/api/develop';
136-
message += '/hey%20there/a240edf982d467201845b3bf10ccbe16f6049ea9">Choose a server to run develop</a>.';
171+
message += ' (hey there) to Runnable/api (feature-1/fix) are ready.\n';
172+
message += '<a href="http://runnable3.net/podviaznikov/boxSelection/api/feature-1%2Ffix';
173+
message += '/hey%20there/a240edf982d467201845b3bf10ccbe16f6049ea9">Choose a server to run feature-1/fix</a>.';
137174
expect(text).to.equal(message);
138175
cb();
139176
};
@@ -146,7 +183,7 @@ describe('Notifier', function () {
146183
commitLog: [headCommit],
147184
repo: 'Runnable/api',
148185
repoName: 'api',
149-
branch: 'develop',
186+
branch: 'feature-1/fix',
150187
commit: 'a240edf982d467201845b3bf10ccbe16f6049ea9',
151188
headCommit: headCommit,
152189
user: {
@@ -164,7 +201,7 @@ describe('Notifier', function () {
164201
hipchat.send = function (text, cb) {
165202
var message = 'podviaznikov\'s ';
166203
message += '<a href="' + headCommit.url + '">changes</a>';
167-
message += ' (init) to CodeNow/api (develop) are deployed on servers:<br/>\n ';
204+
message += ' (init) to CodeNow/api (feature-1/fix) are deployed on servers:<br/>\n ';
168205
message += '<a href="http://runnable3.net/podviaznikov/instance1">instance1</a><br/>\n ';
169206
message += '<a href="http://runnable3.net/podviaznikov/instance2">instance2</a><br/>\n';
170207

@@ -180,7 +217,7 @@ describe('Notifier', function () {
180217
commitLog: [headCommit],
181218
repo: 'CodeNow/api',
182219
repoName: 'api',
183-
branch: 'develop',
220+
branch: 'feature-1/fix',
184221
commit: 'a240edf982d467201845b3bf10ccbe16f6049ea9',
185222
headCommit: headCommit,
186223
user: {
@@ -252,7 +289,7 @@ describe('Notifier', function () {
252289
});
253290
done();
254291
});
255-
}, 2200);
292+
}, 2500);
256293
});
257294
});
258295
});

0 commit comments

Comments
 (0)