dolt 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +0 -1
- data/Gemfile +4 -0
- data/Gemfile.lock +13 -1
- data/Rakefile +10 -0
- data/dolt.gemspec +1 -1
- data/test/test_helper.rb +5 -0
- data/vendor/ui/.gitmodules +9 -0
- data/vendor/ui/Makefile +46 -0
- data/vendor/ui/buster.js +8 -3
- data/vendor/ui/css/gitorious.css +26 -1
- data/vendor/ui/dist/gitorious3-capillary.min.js +12 -0
- data/vendor/ui/dist/gitorious3.min.css +1 -1
- data/vendor/ui/dist/gitorious3.min.js +3 -3
- data/vendor/ui/js/src/cache.js +27 -0
- data/vendor/ui/js/src/capillary.js +7 -0
- data/vendor/ui/js/src/components/blob.js +1 -1
- data/vendor/ui/js/src/components/capillary.js +51 -0
- data/vendor/ui/js/src/components/clone-name-suggestion.js +38 -0
- data/vendor/ui/js/src/components/clone-url-selection.js +25 -15
- data/vendor/ui/js/src/components/collapse.js +17 -0
- data/vendor/ui/js/src/components/comments.js +111 -0
- data/vendor/ui/js/src/components/dropdown.js +4 -2
- data/vendor/ui/js/src/components/loading.js +33 -0
- data/vendor/ui/js/src/components/oid-ref-interpolator.js +9 -0
- data/vendor/ui/js/src/components/profile-menu.js +2 -0
- data/vendor/ui/js/src/components/rails-links.js +24 -0
- data/vendor/ui/js/src/components/ref-selector.js +3 -1
- data/vendor/ui/js/src/components/repository.js +161 -0
- data/vendor/ui/js/src/components/timeago.js +38 -0
- data/vendor/ui/js/src/components/url.js +1 -1
- data/vendor/ui/js/src/gitorious.js +75 -7
- data/vendor/ui/js/src/json-request.js +6 -0
- data/vendor/ui/js/src/spacer.js +5 -0
- data/vendor/ui/js/test/cache-test.js +47 -0
- data/vendor/ui/js/test/components/blob-test.js +4 -4
- data/vendor/ui/js/test/components/clone-name-suggestion-test.js +37 -0
- data/vendor/ui/js/test/components/clone-url-selection-test.js +10 -10
- data/vendor/ui/js/test/components/comments-test.js +139 -0
- data/vendor/ui/js/test/components/repository-admin-test.js +35 -0
- data/vendor/ui/js/test/components/repository-watching-test.js +74 -0
- data/vendor/ui/js/test/components/timeago-test.js +74 -0
- data/vendor/ui/js/test/test-helper.js +2 -0
- metadata +25 -3
- data/vendor/ui/build +0 -51
@@ -0,0 +1,33 @@
|
|
1
|
+
/*global Spinner, dome*/
|
2
|
+
this.gts = this.gts || {};
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Put a spinner in an element that's waiting to be loaded with some content.
|
6
|
+
*/
|
7
|
+
this.gts.loading = function (element, options) {
|
8
|
+
dome.cn.add("loading", element);
|
9
|
+
element.innerHTML = "";
|
10
|
+
options = options || {};
|
11
|
+
|
12
|
+
var spinner = new Spinner({
|
13
|
+
lines: options.hasOwnProperty("lines") ? options.lines : 8,
|
14
|
+
length: options.hasOwnProperty("length") ? options.length : 2,
|
15
|
+
width: options.hasOwnProperty("width") ? options.width : 2,
|
16
|
+
radius: options.hasOwnProperty("radius") ? options.radius : 3,
|
17
|
+
color: options.color || "#000",
|
18
|
+
speed: options.hasOwnProperty("speed") ? options.speed : 1,
|
19
|
+
trail: options.hasOwnProperty("trail") ? options.trail : 100,
|
20
|
+
shadow: options.hasOwnProperty("shadow") ? options.shadow : false
|
21
|
+
}).spin();
|
22
|
+
|
23
|
+
spinner.el.style.top = options.topPos || "10px";
|
24
|
+
element.appendChild(spinner.el);
|
25
|
+
|
26
|
+
var text = options.hasOwnProperty("text") ? options.text : "Loading...";
|
27
|
+
|
28
|
+
if (text) {
|
29
|
+
var textEl = document.createElement("span");
|
30
|
+
textEl.innerHTML = text;
|
31
|
+
element.appendChild(textEl);
|
32
|
+
}
|
33
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
this.gts = this.gts || {};
|
2
|
+
|
3
|
+
this.gts.oidRefInterpolator = function (element, refs, urlTemplate) {
|
4
|
+
var current = this.gts.refSelector.getCurrentRef("heads", element.innerHTML, refs);
|
5
|
+
if (current) {
|
6
|
+
element.title = current[1];
|
7
|
+
element.innerHTML = current[0];
|
8
|
+
}
|
9
|
+
};
|
@@ -8,6 +8,7 @@ var gts = this.gts || {};
|
|
8
8
|
*/
|
9
9
|
(function (d, e) {
|
10
10
|
function button(text, path, icon) {
|
11
|
+
text = " " + text;
|
11
12
|
var content = icon ? [e.i({className: "icon-" + icon}), text] : [text];
|
12
13
|
return e.li(e.a({ href: path }, content));
|
13
14
|
}
|
@@ -30,5 +31,6 @@ var gts = this.gts || {};
|
|
30
31
|
button("Log out", user.logoutPath)
|
31
32
|
])
|
32
33
|
], root);
|
34
|
+
gts.dropdown(root);
|
33
35
|
};
|
34
36
|
}(dome, dome.el));
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/*global dome*/
|
2
|
+
this.gts = this.gts || {};
|
3
|
+
|
4
|
+
this.gts.railsLinks = function (csrfParam, csrfToken) {
|
5
|
+
dome.on(document.body, "click", function (e) {
|
6
|
+
var method = dome.data.get("method", e.target);
|
7
|
+
if (!method || method === "get") { return true; }
|
8
|
+
e.preventDefault();
|
9
|
+
e.stopPropagation();
|
10
|
+
var href = e.target.href;
|
11
|
+
|
12
|
+
var form = dome.el("form", {
|
13
|
+
method: "post",
|
14
|
+
action: href,
|
15
|
+
style: { display: "none" }
|
16
|
+
}, [
|
17
|
+
dome.el("input", { name: "_method", value: method, type: "hidden" }),
|
18
|
+
dome.el("input", { name: csrfParam, value: csrfToken, type: "hidden" })
|
19
|
+
]);
|
20
|
+
|
21
|
+
document.body.appendChild(form);
|
22
|
+
form.submit();
|
23
|
+
});
|
24
|
+
};
|
@@ -105,10 +105,12 @@ this.gts.refSelector = (function (e) {
|
|
105
105
|
|
106
106
|
function refSelector(placeholder, refs, ref, refUrlTemplate) {
|
107
107
|
var selector = build(refs, ref, refUrlTemplate);
|
108
|
-
placeholder.
|
108
|
+
placeholder.parentNode.insertBefore(selector, placeholder);
|
109
|
+
placeholder.parentNode.removeChild(placeholder);
|
109
110
|
this.gts.dropdown(selector);
|
110
111
|
}
|
111
112
|
|
112
113
|
refSelector.build = build;
|
114
|
+
refSelector.getCurrentRef = getCurrent;
|
113
115
|
return refSelector;
|
114
116
|
}(dome.el));
|
@@ -0,0 +1,161 @@
|
|
1
|
+
/*global dome, gts*/
|
2
|
+
this.gts = this.gts || {};
|
3
|
+
|
4
|
+
this.gts.repository = (function (el) {
|
5
|
+
/**
|
6
|
+
* Build the repository admin tab into the menu if the data indicates that
|
7
|
+
* the current user can admin the repository. Initialize as a dropdown
|
8
|
+
* toggler if built.
|
9
|
+
*/
|
10
|
+
function bullet(type, text) {
|
11
|
+
return [el.i({ className: type }), " " + text];
|
12
|
+
}
|
13
|
+
|
14
|
+
function link(href, type, text) {
|
15
|
+
return el.a({ href: href }, bullet(type, text));
|
16
|
+
}
|
17
|
+
|
18
|
+
function build(data, tagName) {
|
19
|
+
return el[tagName || "li"]({ className: "pull-right dropdown" }, [
|
20
|
+
el.a({
|
21
|
+
href: "#",
|
22
|
+
"data-toggle": "dropdown",
|
23
|
+
className: "dropdown-toggle"
|
24
|
+
}, bullet("icon-cog", "Admin")),
|
25
|
+
el.ul({ className: "dropdown-menu" }, [
|
26
|
+
el.li(link(data.editPath, "icon-pencil", "Edit repository")),
|
27
|
+
el.li(link(data.destroyPath, "icon-trash", "Delete repository")),
|
28
|
+
el.li({ className: "divider" }),
|
29
|
+
el.li(link(data.ownershipPath, "i", "Transfer ownership")),
|
30
|
+
el.li(link(data.committershipsPath, "i", "Manage collaborators"))
|
31
|
+
])
|
32
|
+
]);
|
33
|
+
}
|
34
|
+
|
35
|
+
function repositoryAdmin(placeholder, data) {
|
36
|
+
var toggler = build(data, placeholder.tagName.toLowerCase());
|
37
|
+
dome.replace(placeholder, toggler);
|
38
|
+
this.gts.dropdown(toggler);
|
39
|
+
|
40
|
+
if (dome.data.get("gts-active", toggler.parentNode) === "admin") {
|
41
|
+
dome.cn.add("active", toggler);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
repositoryAdmin.build = build;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Generate and power the "Watch"/"Unwatch" button on repository pages. To
|
49
|
+
* use this component, put a placeholder on the page, and call
|
50
|
+
* repositoryWatching(placeHolder, repositoryWatch);
|
51
|
+
*
|
52
|
+
* The viewstate object is expected to contain at least
|
53
|
+
* - watching (boolean)
|
54
|
+
* - watchPath (string)
|
55
|
+
* - unwatchPath (string, only required if watching is true)
|
56
|
+
*/
|
57
|
+
function render(link, repository) {
|
58
|
+
if (repository.watching) {
|
59
|
+
link.innerHTML = "<i class=\"icon icon-star\"></i> Unwatch";
|
60
|
+
link.href = repository.unwatchPath;
|
61
|
+
} else {
|
62
|
+
link.innerHTML = "<i class=\"icon icon-star-empty\"></i> Watch";
|
63
|
+
link.href = repository.watchPath;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
function unwatch(link, repository) {
|
68
|
+
gts.request({
|
69
|
+
url: repository.unwatchPath,
|
70
|
+
method: "delete",
|
71
|
+
type: "js",
|
72
|
+
headers: {
|
73
|
+
"Accept": "application/javascript, text/javascript"
|
74
|
+
},
|
75
|
+
success: function (xhr) {
|
76
|
+
repository.watching = false;
|
77
|
+
render(link, repository);
|
78
|
+
},
|
79
|
+
error: function () {
|
80
|
+
link.innerHTML = "Failed, try watching again";
|
81
|
+
}
|
82
|
+
});
|
83
|
+
}
|
84
|
+
|
85
|
+
function watch(link, repository) {
|
86
|
+
gts.request({
|
87
|
+
url: repository.watchPath,
|
88
|
+
method: "post",
|
89
|
+
type: "text",
|
90
|
+
headers: {
|
91
|
+
"Accept": "application/javascript, text/javascript"
|
92
|
+
},
|
93
|
+
success: function (xhr) {
|
94
|
+
repository.watching = true;
|
95
|
+
repository.unwatchPath = xhr.getResponseHeader("location");
|
96
|
+
render(link, repository);
|
97
|
+
},
|
98
|
+
error: function () {
|
99
|
+
link.innerHTML = "Failed, try unwatching again";
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
function toggleState(link, repository) {
|
105
|
+
gts.loading(link);
|
106
|
+
if (repository.watching) {
|
107
|
+
unwatch(link, repository);
|
108
|
+
} else {
|
109
|
+
watch(link, repository);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function repositoryWatching(ph, repositoryWatch) {
|
114
|
+
var link = dome.el("a", { className: "btn" });
|
115
|
+
dome.replace(ph, link);
|
116
|
+
render(link, repositoryWatch);
|
117
|
+
dome.on(link, "click", function (e) {
|
118
|
+
e.preventDefault();
|
119
|
+
e.stopPropagation();
|
120
|
+
toggleState(link, repositoryWatch);
|
121
|
+
});
|
122
|
+
};
|
123
|
+
|
124
|
+
repositoryWatching.watch = watch;
|
125
|
+
repositoryWatching.unwatch = unwatch;
|
126
|
+
repositoryWatching.toggleState = toggleState;
|
127
|
+
repositoryWatching.render = render;
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Display button to clone repository if the current user is
|
131
|
+
* offered a clone URL
|
132
|
+
*/
|
133
|
+
function repositoryCloning(placeholder, repository) {
|
134
|
+
if (!repository.clonePath) { return; }
|
135
|
+
dome.replace(placeholder, dome.el("a", {
|
136
|
+
href: repository.clonePath,
|
137
|
+
className: "btn"
|
138
|
+
}, "Clone"));
|
139
|
+
}
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Display button to merge repository clone if the current user
|
143
|
+
* is offered a request merge URL.
|
144
|
+
*/
|
145
|
+
function mergeRequest(placeholder, repository) {
|
146
|
+
if (!repository.requestMergePath) { return; }
|
147
|
+
dome.replace(placeholder, dome.el("li", { className: "pull-right" }, [
|
148
|
+
dome.el("a", { href: repository.requestMergePath }, [
|
149
|
+
dome.el("i", { className: "icon icon-random" }),
|
150
|
+
" Request merge"
|
151
|
+
])
|
152
|
+
]));
|
153
|
+
}
|
154
|
+
|
155
|
+
return {
|
156
|
+
admin: repositoryAdmin,
|
157
|
+
watching: repositoryWatching,
|
158
|
+
cloning: repositoryCloning,
|
159
|
+
mergeRequest: mergeRequest
|
160
|
+
};
|
161
|
+
}(dome.el));
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/*global timeago, gts*/
|
2
|
+
this.gts = this.gts || {};
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Replace content of <abbr> elements with a casual representation of the
|
6
|
+
* ISO8601 date in its title attribute.
|
7
|
+
*/
|
8
|
+
this.gts.timeago = (function (ta) {
|
9
|
+
function timeago(el, time) {
|
10
|
+
var date = ta.parse(time || el.title);
|
11
|
+
if (isNaN(date.getTime())) { return el; }
|
12
|
+
var text = el.innerHTML.trim() || el.title;
|
13
|
+
el.innerHTML = ta.relative(date);
|
14
|
+
el.title = text;
|
15
|
+
return el;
|
16
|
+
};
|
17
|
+
|
18
|
+
var cache = {};
|
19
|
+
|
20
|
+
timeago.periodic = function (timeout) {
|
21
|
+
if (!cache[timeout]) {
|
22
|
+
cache[timeout] = [];
|
23
|
+
setInterval(function () {
|
24
|
+
for (var i = 0, l = cache[timeout].length, item; i < l; ++i) {
|
25
|
+
item = cache[timeout][i];
|
26
|
+
gts.timeago(item.element, item.time);
|
27
|
+
}
|
28
|
+
}, timeout);
|
29
|
+
}
|
30
|
+
|
31
|
+
return function (el) {
|
32
|
+
cache[timeout].push({ element: el, time: el.title });
|
33
|
+
return timeago(el, el.title);
|
34
|
+
};
|
35
|
+
};
|
36
|
+
|
37
|
+
return timeago;
|
38
|
+
}(timeago));
|
@@ -52,7 +52,7 @@ this.gts.url = (function () {
|
|
52
52
|
}
|
53
53
|
|
54
54
|
function currentRef(url) {
|
55
|
-
var regexp = /(blame|blob|tree|history|raw|source|readme)\//;
|
55
|
+
var regexp = /(blame|blob|tree|history|raw|source|readme|commits)\//;
|
56
56
|
var refPath = url.split(regexp)[2];
|
57
57
|
return (refPath && refPath.split(":")[0]) || null;
|
58
58
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*global gts,
|
1
|
+
/*global gts, cull, reqwest*/
|
2
2
|
|
3
3
|
// Environment variables
|
4
4
|
gts.app.env("url", window.location.href);
|
@@ -10,6 +10,21 @@ if (window.hasOwnProperty("onpopstate")) {
|
|
10
10
|
};
|
11
11
|
}
|
12
12
|
|
13
|
+
cull.doall(function (meta) {
|
14
|
+
if (meta.name === "csrf-param") {
|
15
|
+
gts.app.env("csrf-param", meta.content);
|
16
|
+
}
|
17
|
+
if (meta.name === "csrf-token") {
|
18
|
+
gts.app.env("csrf-token", meta.content);
|
19
|
+
}
|
20
|
+
}, document.getElementsByTagName("meta"));
|
21
|
+
|
22
|
+
gts.request = function (options) {
|
23
|
+
options.headers = options.headers || {};
|
24
|
+
options.headers["X-CSRF-Token"] = gts.app.env["csrf-token"];
|
25
|
+
reqwest(options);
|
26
|
+
};
|
27
|
+
|
13
28
|
// Data
|
14
29
|
gts.app.data("ref-url-template", function (url, ref) {
|
15
30
|
return gts.url.templatize(url, { ref: ref });
|
@@ -18,17 +33,23 @@ gts.app.data("ref-url-template", function (url, ref) {
|
|
18
33
|
serializeArgs: function (url, ref) { return [url.split("#")[0], ref]; }
|
19
34
|
});
|
20
35
|
|
21
|
-
gts.app.data("repository-refs",
|
22
|
-
return reqwest({ url: url, type: "json" });
|
23
|
-
}, { depends: ["repository-refs-url"] });
|
24
|
-
|
36
|
+
gts.app.data("repository-refs", this.gts.jsonRequest, { depends: ["repository-refs-url"] });
|
25
37
|
gts.app.data("current-ref", gts.url.currentRef, { depends: ["url"] });
|
26
|
-
gts.app.data("user-repo-view-state", gts.userRepoViewState, {
|
38
|
+
gts.app.data("user-repo-view-state", gts.cache(gts.userRepoViewState), {
|
27
39
|
depends: ["user-repository-path"]
|
28
40
|
});
|
29
41
|
gts.app.data("current-user", cull.prop("user"), {
|
30
42
|
depends: ["user-repo-view-state"]
|
31
43
|
});
|
44
|
+
gts.app.data("current-repository", cull.prop("repository"), {
|
45
|
+
depends: ["user-repo-view-state"]
|
46
|
+
});
|
47
|
+
gts.app.data("repository-watch", cull.prop("watch"), {
|
48
|
+
depends: ["current-repository"]
|
49
|
+
});
|
50
|
+
gts.app.data("repository-admin", cull.prop("admin"), {
|
51
|
+
depends: ["current-repository"]
|
52
|
+
});
|
32
53
|
gts.app.data("blob-region", gts.blob.regionFromUrl, { depends: ["url"] });
|
33
54
|
|
34
55
|
// Features
|
@@ -40,11 +61,20 @@ gts.app.feature("google-analytics", gts.googleAnalytics, {
|
|
40
61
|
depends: ["analytics-account", "analytics-domain-name"]
|
41
62
|
});
|
42
63
|
|
64
|
+
gts.app.feature("dropdown", gts.dropdown, {
|
65
|
+
elements: ["dropdown"]
|
66
|
+
});
|
67
|
+
|
43
68
|
gts.app.feature("ref-selector", gts.refSelector, {
|
44
69
|
elements: ["gts-ref-selector-ph"],
|
45
70
|
depends: ["repository-refs", "current-ref", "ref-url-template"]
|
46
71
|
});
|
47
72
|
|
73
|
+
gts.app.feature("oid-ref-interpolator", gts.oidRefInterpolator, {
|
74
|
+
elements: ["gts-oid"],
|
75
|
+
depends: ["repository-refs", "ref-url-template"]
|
76
|
+
});
|
77
|
+
|
48
78
|
gts.app.feature("tree-history", gts.treeHistory, {
|
49
79
|
elements: ["gts-tree-explorer"],
|
50
80
|
depends: ["tree-history-url"]
|
@@ -78,11 +108,49 @@ gts.app.feature("live-markdown-preview", gts.liveMarkdownPreview, {
|
|
78
108
|
elements: ["gts-live-markdown-preview"]
|
79
109
|
});
|
80
110
|
|
111
|
+
gts.app.feature("timeago", gts.timeago.periodic(60000), {
|
112
|
+
elements: ["timeago"]
|
113
|
+
});
|
114
|
+
|
115
|
+
gts.app.feature("collapse", gts.collapse);
|
116
|
+
|
117
|
+
gts.app.feature("clone-name-suggestion", gts.cloneNameSuggestion, {
|
118
|
+
elements: ["clone-repository-form"]
|
119
|
+
});
|
120
|
+
|
121
|
+
gts.app.feature("loading", gts.loading, {
|
122
|
+
elements: ["loading"]
|
123
|
+
});
|
124
|
+
|
125
|
+
gts.app.feature("rails-links", gts.railsLinks, {
|
126
|
+
depends: ["csrf-param", "csrf-token"]
|
127
|
+
});
|
128
|
+
|
129
|
+
gts.app.feature("repository-admin-menu", gts.repository.admin, {
|
130
|
+
elements: ["gts-repository-admin-ph"],
|
131
|
+
depends: ["repository-admin"]
|
132
|
+
});
|
133
|
+
|
134
|
+
gts.app.feature("repository-watching", gts.repository.watching, {
|
135
|
+
elements: ["gts-watch-repository-ph"],
|
136
|
+
depends: ["repository-watch"]
|
137
|
+
});
|
138
|
+
|
139
|
+
gts.app.feature("repository-cloning", gts.repository.cloning, {
|
140
|
+
elements: ["gts-clone-repository-ph"],
|
141
|
+
depends: ["current-repository"]
|
142
|
+
});
|
143
|
+
|
144
|
+
gts.app.feature("repository-merge-request", gts.repository.mergeRequest, {
|
145
|
+
elements: ["gts-request-merge-ph"],
|
146
|
+
depends: ["current-repository"]
|
147
|
+
});
|
148
|
+
|
81
149
|
// Spin off app asynchronously so subsequent scripts have a chance
|
82
150
|
// to register loggers etc before we roll
|
83
151
|
setTimeout(function () {
|
84
152
|
// Scan the document for data-gts-* attributes that set
|
85
153
|
// "environment variables"
|
86
154
|
gts.app.scanEnvAttrs(document.body, "data-gts-env-");
|
87
|
-
gts.app.load(document.
|
155
|
+
gts.app.load(document.documentElement);
|
88
156
|
}, 10);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*global gts*/
|
2
|
+
|
3
|
+
buster.testCase("Cache", {
|
4
|
+
"caches function": function () {
|
5
|
+
var spy = this.spy();
|
6
|
+
var fn = gts.cache(spy);
|
7
|
+
fn();
|
8
|
+
fn();
|
9
|
+
fn();
|
10
|
+
|
11
|
+
assert.calledOnce(spy);
|
12
|
+
},
|
13
|
+
|
14
|
+
"caches function's return value": function () {
|
15
|
+
var stub = this.stub().returns(42);
|
16
|
+
var fn = gts.cache(stub);
|
17
|
+
|
18
|
+
assert.equals(fn(), 42);
|
19
|
+
assert.equals(fn(), 42);
|
20
|
+
assert.equals(fn(), 42);
|
21
|
+
},
|
22
|
+
|
23
|
+
"caches function's return value per argument": function () {
|
24
|
+
var adder = 1;
|
25
|
+
var fn = gts.cache(function (a) {
|
26
|
+
return a + adder;
|
27
|
+
});
|
28
|
+
|
29
|
+
assert.equals(fn(1), 2);
|
30
|
+
adder = 2;
|
31
|
+
assert.equals(fn(1), 2);
|
32
|
+
assert.equals(fn(2), 4);
|
33
|
+
},
|
34
|
+
|
35
|
+
"caches function's return value per arguent set": function () {
|
36
|
+
var adder = 1;
|
37
|
+
var fn = gts.cache(function (a, b) {
|
38
|
+
return a + b + adder;
|
39
|
+
});
|
40
|
+
|
41
|
+
var object = { valueOf: this.stub().returns(1) };
|
42
|
+
assert.equals(fn(1, object), 3);
|
43
|
+
adder = 2;
|
44
|
+
assert.equals(fn(1, object), 3);
|
45
|
+
assert.equals(fn(2, object), 5);
|
46
|
+
}
|
47
|
+
});
|
@@ -3,10 +3,10 @@
|
|
3
3
|
buster.testCase("Blob", {
|
4
4
|
setUp: function () {
|
5
5
|
this.el = dome.el("ol", [
|
6
|
-
dome.el("li", { className: "
|
7
|
-
dome.el("li", { className: "
|
8
|
-
dome.el("li", { className: "
|
9
|
-
dome.el("li", { className: "
|
6
|
+
dome.el("li", { className: "L1" }, "First line"),
|
7
|
+
dome.el("li", { className: "L2" }, "Second line"),
|
8
|
+
dome.el("li", { className: "L3" }, "Third line"),
|
9
|
+
dome.el("li", { className: "L4" }, "Fourth line")
|
10
10
|
]);
|
11
11
|
},
|
12
12
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/*global buster, dome, gts*/
|
2
|
+
|
3
|
+
buster.testCase("Clone name suggestion", {
|
4
|
+
setUp: function () {
|
5
|
+
this.form = dome.el("form", {
|
6
|
+
"data": { "gts-repository-to-clone": "gitorious" }
|
7
|
+
}, [
|
8
|
+
dome.el("input", {
|
9
|
+
checked: "checked",
|
10
|
+
id: "repository_owner_type_user",
|
11
|
+
name: "repository[owner_type]",
|
12
|
+
value: "User",
|
13
|
+
type: "radio",
|
14
|
+
data: { "gts-cloning-user": "christian" }
|
15
|
+
}),
|
16
|
+
|
17
|
+
dome.el("input", {
|
18
|
+
id: "repository_owner_type_group",
|
19
|
+
name: "repository[owner_type]",
|
20
|
+
type: "radio",
|
21
|
+
value: "Group"
|
22
|
+
}),
|
23
|
+
|
24
|
+
dome.el("select", {
|
25
|
+
id: "repository_owner_id_group_select",
|
26
|
+
name: "repository[owner_id]"
|
27
|
+
}, [
|
28
|
+
dome.el("option", { value: 1 }, "gitorians"),
|
29
|
+
dome.el("option", { value: 2 }, "blargians")
|
30
|
+
])
|
31
|
+
]);
|
32
|
+
},
|
33
|
+
|
34
|
+
"//suggests username-scoped clone name": function () {
|
35
|
+
|
36
|
+
}
|
37
|
+
});
|
@@ -5,21 +5,21 @@ buster.testCase("Clone URL selection", {
|
|
5
5
|
/*:DOC element = <div class="btn-group gts-repo-urls">
|
6
6
|
<a class="btn gts-repo-url" href="git://gitorious.org/gitorious/mainline.git">Git</a>
|
7
7
|
<a class="btn gts-repo-url" href="http://git.gitorious.org/gitorious/mainline.git">HTTP</a>
|
8
|
-
<a class="active btn gts-repo-url" href="git@gitorious.org:gitorious/mainline.git">SSH</a>
|
8
|
+
<a class="active btn gts-repo-url" href="ssh://git@gitorious.org:gitorious/mainline.git">SSH</a>
|
9
9
|
<input class="span4 gts-current-repo-url gts-select-onfocus" type="url" value="git@gitorious.org:gitorious/mainline.git">
|
10
10
|
<button data-toggle="collapse" data-target="#repo-url-help" class="gts-repo-url-help btn">?</button>
|
11
11
|
</div>*/
|
12
12
|
this.input = this.element.getElementsByTagName("input")[0];
|
13
|
-
|
14
|
-
var buttons = this.element.getElementsByTagName("a");
|
15
|
-
this.click = function (num) {
|
16
|
-
jQuery(buttons[num]).trigger("click");
|
17
|
-
};
|
13
|
+
this.buttons = this.element.getElementsByTagName("a");
|
18
14
|
},
|
19
15
|
|
20
|
-
"
|
21
|
-
|
22
|
-
this.click(0);
|
16
|
+
"copies git:// href to input": function () {
|
17
|
+
gts.cloneUrlSelection.select(this.element, this.buttons[0]);
|
23
18
|
assert.equals(this.input.value, "git://gitorious.org/gitorious/mainline.git");
|
24
|
-
}
|
19
|
+
},
|
20
|
+
|
21
|
+
"copies ssh:// href to input": function () {
|
22
|
+
gts.cloneUrlSelection.select(this.element, this.buttons[2]);
|
23
|
+
assert.equals(this.input.value, "git@gitorious.org:gitorious/mainline.git");
|
24
|
+
}
|
25
25
|
});
|