Skip to content

Commit

Permalink
Small refactoring and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tobie committed Feb 3, 2024
1 parent 36b3c86 commit ca04bd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
7 changes: 5 additions & 2 deletions lib/mixins/fetchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mustache.escape = v => v;
module.exports = (superclass) => class extends superclass {
getUrl(options) {
if (this.pr.processor == "bikeshed") {
return { method: "post", url: this.getBikeshedUrl(options) };
return this.getBikeshedUrl(options);
}

if (this.pr.processor == "respec") {
Expand Down Expand Up @@ -41,7 +41,10 @@ module.exports = (superclass) => class extends superclass {

getBikeshedUrl(data) {
let query = this.getQuery(data, "&", true);
return `https://api.csswg.org/bikeshed/?url=${ urlencode(this.github_url) }${ query }`;
return {
method: "post",
url: `https://api.csswg.org/bikeshed/?url=${ urlencode(this.github_url) }${ query }`
}
}

getRespecUrl(data) {
Expand Down
26 changes: 21 additions & 5 deletions test/models/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ suite("Branch model", function() {
type: "bikeshed",
src_file: "index.bs"
};
assert.equal(h.getUrl(h.urlOptions()).url, BIKESHED_URL + "index.bs");
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
url: BIKESHED_URL + "index.bs"
});
});

test('Test getUrl with non standard src file name', function() {
Expand All @@ -150,7 +153,11 @@ suite("Branch model", function() {
src_file: "url.bs",
type: "bikeshed"
};
assert.equal(h.getUrl(h.urlOptions()).url, BIKESHED_URL + "url.bs");

assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
url: BIKESHED_URL + "url.bs"
});
});

test('Test getUrl with specific status', function() {
Expand All @@ -160,7 +167,10 @@ suite("Branch model", function() {
type: "bikeshed",
params: { "md-status": "REC" }
};
assert.equal(h.getUrl(h.urlOptions()).url, BIKESHED_URL + "index.bs&md-status=REC");
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
url: BIKESHED_URL + "index.bs&md-status=REC"
});
});

test('Test getUrl using templating', function() {
Expand All @@ -173,7 +183,10 @@ suite("Branch model", function() {
"md-title": "{{config.title}} {{owner}}/{{repo}}/{{branch}}#{{pull_request.number}}-{{short_sha}}"
}
};
assert.equal(h.getUrl(h.urlOptions()).url, BIKESHED_URL + "index.bs&md-title=FOO%20BAR%20tobie%2Fwebidl%2Finterface-objs%23283-7dfd134");
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
url: BIKESHED_URL + "index.bs&md-title=FOO%20BAR%20tobie%2Fwebidl%2Finterface-objs%23283-7dfd134"
});
});

test('Test getUrl templating gracefully handles non strings', function() {
Expand All @@ -185,7 +198,10 @@ suite("Branch model", function() {
"force": 1
}
};
assert.equal(h.getUrl(h.urlOptions()).url, BIKESHED_URL + "index.bs&force=1");
assert.deepEqual(h.getUrl(h.urlOptions()), {
method: "post",
url: BIKESHED_URL + "index.bs&force=1"
});
});

test('Test urlOptions', function() {
Expand Down

0 comments on commit ca04bd6

Please sign in to comment.