aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/caldav/request/calendar_query.js2
-rw-r--r--lib/caldav/request/resources.js2
-rw-r--r--lib/caldav/resources/calendar.js7
-rw-r--r--test/caldav/request/resources_test.js8
-rw-r--r--test/caldav/resources/calendar_test.js21
-rw-r--r--test/helper.js1
6 files changed, 37 insertions, 4 deletions
diff --git a/lib/caldav/request/calendar_query.js b/lib/caldav/request/calendar_query.js
index 6fcf74d..6ee1ec4 100644
--- a/lib/caldav/request/calendar_query.js
+++ b/lib/caldav/request/calendar_query.js
@@ -12,7 +12,7 @@
* @param {CalDav.Connection} connection connection object.
* @param {Object} options options for calendar query.
*/
- function CalendarQuery(options) {
+ function CalendarQuery(connection, options) {
Propfind.apply(this, arguments);
this.xhr.headers['Depth'] = this.depth || 1;
diff --git a/lib/caldav/request/resources.js b/lib/caldav/request/resources.js
index f66a455..fbba186 100644
--- a/lib/caldav/request/resources.js
+++ b/lib/caldav/request/resources.js
@@ -45,6 +45,8 @@
self.connection,
collection
);
+
+ results[type][url].url = url;
}
});
}
diff --git a/lib/caldav/resources/calendar.js b/lib/caldav/resources/calendar.js
index a17c5c4..cc8a4d6 100644
--- a/lib/caldav/resources/calendar.js
+++ b/lib/caldav/resources/calendar.js
@@ -3,6 +3,8 @@
*/
(function(module, ns) {
+ var CalendarQuery = ns.require('request/calendar_query');
+
/**
* Represents a (Web/Cal)Dav resource type.
*
@@ -18,6 +20,7 @@
this.url = options.url;
}
+ this.connection = connection;
this.updateFromServer(options);
}
@@ -138,7 +141,9 @@
* @return {CalDav.Request.CalendarQuery} query object.
*/
createQuery: function() {
-
+ return new CalendarQuery(this.connection, {
+ url: this.url
+ });
}
};
diff --git a/test/caldav/request/resources_test.js b/test/caldav/request/resources_test.js
index ecea34a..19bebba 100644
--- a/test/caldav/request/resources_test.js
+++ b/test/caldav/request/resources_test.js
@@ -92,10 +92,14 @@ suite('caldav/resource_finder', function() {
});
assert.ok(result.calendar['a']);
- assert.instanceOf(result.calendar['a'], Handler);
+
+ var cal = result.calendar['a'];
+
+ assert.instanceOf(cal, Handler);
assert.equal(Object.keys(result.calendar).length, 1);
- assert.equal(result.calendar['a'].args[1].name.value, '1');
+ assert.equal(cal.args[1].name.value, '1');
+ assert.equal(cal.url, 'a');
});
});
diff --git a/test/caldav/resources/calendar_test.js b/test/caldav/resources/calendar_test.js
index aa23918..d7689c0 100644
--- a/test/caldav/resources/calendar_test.js
+++ b/test/caldav/resources/calendar_test.js
@@ -1,3 +1,7 @@
+requireRequest();
+
+testSupport.lib('request/calendar_query');
+
testSupport.lib('resources/calendar'),
testSupport.lib('xhr');
testSupport.lib('connection');
@@ -6,6 +10,7 @@ suite('caldav/resources/calendar', function() {
var Calendar;
var Connection;
+ var CalendarQuery;
var con;
var url = 'foobar.com';
var subject;
@@ -13,6 +18,7 @@ suite('caldav/resources/calendar', function() {
suiteSetup(function() {
Calendar = Caldav.require('resources/calendar');
Connection = Caldav.require('connection');
+ CalendarQuery = Caldav.require('request/calendar_query');
});
setup(function() {
@@ -26,6 +32,7 @@ suite('caldav/resources/calendar', function() {
test('without calendar data', function() {
assert.equal(subject.url, url);
+ assert.equal(subject.connection, con);
});
test('with calendar data', function() {
@@ -42,6 +49,20 @@ suite('caldav/resources/calendar', function() {
});
+ suite('#createQuery', function() {
+
+ var result;
+
+ setup(function() {
+ result = subject.createQuery();
+ });
+
+ test('result', function() {
+ assert.instanceOf(result, CalendarQuery);
+ assert.equal(result.url, url);
+ });
+ });
+
suite('#updateFromServer', function() {
function status(value, status) {
diff --git a/test/helper.js b/test/helper.js
index 306a426..efb2487 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -178,6 +178,7 @@
testSupport.lib('templates/calendar_data');
testSupport.lib('templates/calendar_filter');
testSupport.helper('fake_xhr');
+ testSupport.lib('request/propfind');
//in the future we need a callback for browser support.
if (typeof(callback) !== 'undefined') {