summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormnandri <mnandri@eumguccion.corporate.thoughtworks.com>2015-12-10 11:46:49 +0100
committermnandri <mnandri@eumguccion.corporate.thoughtworks.com>2015-12-10 11:46:54 +0100
commit87fb6c5f30131fc01820e82f9b812f31da6b2c0a (patch)
tree21b2090ce21046c6fa218b6e6d9de41bf4cfc6c6
parentd62ea0a762f4fa80ff2e0d2c3e4ea5bf3bb6c764 (diff)
#299 +@fbernitt made tag-refreshing to listen on document directly
-rw-r--r--web-ui/app/js/tags/data/tags.js9
-rw-r--r--web-ui/test/spec/tags/data/tags.spec.js12
2 files changed, 10 insertions, 11 deletions
diff --git a/web-ui/app/js/tags/data/tags.js b/web-ui/app/js/tags/data/tags.js
index 348c1832..31703b2a 100644
--- a/web-ui/app/js/tags/data/tags.js
+++ b/web-ui/app/js/tags/data/tags.js
@@ -35,10 +35,10 @@ define(['flight/lib/component', 'page/events', 'helpers/monitored_ajax', 'mixins
};
function dataTags() {
- function sendTagsBackTo(on, params) {
+ function sendTagsBackTo(on) {
return function(data) {
data.push(DataTags.all);
- on.trigger(params.caller, events.tags.received, {tags: data});
+ on.trigger(document, events.tags.received, {tags: data});
};
}
@@ -48,11 +48,12 @@ define(['flight/lib/component', 'page/events', 'helpers/monitored_ajax', 'mixins
this.fetchTags = function(event, params) {
monitoredAjax(this, this.attr.tagsResource)
- .done(sendTagsBackTo(this, params));
+ .done(sendTagsBackTo(this));
};
this.refreshTags = function() {
- this.fetchTags(null, {caller: document});
+ var notTriggeredByEvent = null;
+ this.fetchTags(notTriggeredByEvent);
};
this.after('initialize', function () {
diff --git a/web-ui/test/spec/tags/data/tags.spec.js b/web-ui/test/spec/tags/data/tags.spec.js
index 53978fb8..7c4cd4e0 100644
--- a/web-ui/test/spec/tags/data/tags.spec.js
+++ b/web-ui/test/spec/tags/data/tags.spec.js
@@ -23,14 +23,13 @@ describeComponent('tags/data/tags', function () {
var deferred = $.Deferred();
spyOn($, 'ajax').and.returnValue(deferred);
- var me = {};
- var eventSpy = spyOnEvent(me, Pixelated.events.tags.received);
+ var eventSpy = spyOnEvent(document, Pixelated.events.tags.received);
- this.component.trigger(Pixelated.events.tags.want, { caller: me});
+ this.component.trigger(Pixelated.events.tags.want);
deferred.resolve(['foo', 'bar', 'quux/bar']);
- expect(eventSpy).toHaveBeenTriggeredOn(me);
+ expect(eventSpy).toHaveBeenTriggeredOn(document);
});
it('triggers an event containing the returned tags', function() {
@@ -38,9 +37,8 @@ describeComponent('tags/data/tags', function () {
var deferred = $.Deferred();
spyOn($, 'ajax').and.returnValue(deferred);
- var me = {};
- var eventSpy = spyOnEvent(me, Pixelated.events.tags.received);
- this.component.trigger(Pixelated.events.tags.want, { caller: me });
+ var eventSpy = spyOnEvent(document, Pixelated.events.tags.received);
+ this.component.trigger(Pixelated.events.tags.want);
deferred.resolve(tags);