Skip to content

Commit fbb5f42

Browse files
committed
Additional tests for transactions and application emails
version bump, release
1 parent 05c0f93 commit fbb5f42

File tree

8 files changed

+165
-77
lines changed

8 files changed

+165
-77
lines changed

dist/component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gitana",
3-
"version": "1.0.117",
3+
"version": "1.0.118",
44
"main": ["gitana.js"],
55
"dependencies": {
66
}

dist/gitana.js

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Gitana JavaScript Driver - Version 1.0.117
2+
Gitana JavaScript Driver - Version 1.0.118
33

44
Copyright 2014 Gitana Software, Inc.
55

@@ -73,9 +73,9 @@ address:
7373
if (typeof window === "undefined")
7474
{
7575
window = {
76-
"setTimeout": function(func, seconds)
76+
"setTimeout": function(func, milliseconds)
7777
{
78-
setTimeout(func, seconds);
78+
setTimeout(func, milliseconds);
7979
}
8080
};
8181
}
@@ -2172,7 +2172,7 @@ if (typeof JSON !== 'object') {
21722172
Gitana.requestCount = 0;
21732173

21742174
// version of the driver
2175-
Gitana.VERSION = "1.0.117";
2175+
Gitana.VERSION = "1.0.118";
21762176

21772177
// allow for optional global assignment
21782178
// TODO: until we clean up the "window" variable reliance, we have to always set onto window again
@@ -32595,27 +32595,12 @@ Gitana.OAuth2Http.TICKET = "ticket";
3259532595
/**
3259632596
* Add a write action to the transaction
3259732597
*/
32598-
Transaction.prototype.write = function(existing, data) {
32598+
Transaction.prototype.write = function(data) {
3259932599

3260032600
if (typeof this.promise === 'undefined') {
3260132601
throw new Error('You must set the transaction\'s container with the "for" method before calling this method' );
3260232602
}
3260332603

32604-
if (typeof(data) === "undefined") {
32605-
data = existing;
32606-
existing = null;
32607-
}
32608-
32609-
if (typeof(data) === "string") {
32610-
data = {
32611-
"_doc": data
32612-
};
32613-
}
32614-
32615-
if (typeof(existing) !== "undefined") {
32616-
data._existing = existing;
32617-
}
32618-
3261932604
this.promise.then(function(self) {
3262032605
if (Gitana.isArray(data)) {
3262132606
for (var i = 0; i < data.length; i++) {
@@ -32645,27 +32630,18 @@ Gitana.OAuth2Http.TICKET = "ticket";
3264532630
/**
3264632631
* Add a delete action to the transaction
3264732632
*/
32648-
Transaction.prototype.del = function(existing, data) {
32633+
Transaction.prototype.del = function(data) {
3264932634

3265032635
if (typeof this.promise === 'undefined') {
3265132636
throw new Error('You must set the transaction\'s container with the "for" method before calling this method' );
3265232637
}
3265332638

32654-
if (typeof(data) === "undefined") {
32655-
data = existing;
32656-
existing = null;
32657-
}
32658-
3265932639
if (typeof(data) === "string") {
3266032640
data = {
3266132641
"_doc": data
3266232642
};
3266332643
}
3266432644

32665-
if (typeof(existing) !== "undefined") {
32666-
data._existing = existing;
32667-
}
32668-
3266932645
this.promise.then(function(self) {
3267032646
if (Gitana.isArray(data)) {
3267132647
for (var i = 0; i < data.length; i++) {

dist/gitana.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/gitana/Transaction.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -187,27 +187,12 @@
187187
/**
188188
* Add a write action to the transaction
189189
*/
190-
Transaction.prototype.write = function(existing, data) {
190+
Transaction.prototype.write = function(data) {
191191

192192
if (typeof this.promise === 'undefined') {
193193
throw new Error('You must set the transaction\'s container with the "for" method before calling this method' );
194194
}
195195

196-
if (typeof(data) === "undefined") {
197-
data = existing;
198-
existing = null;
199-
}
200-
201-
if (typeof(data) === "string") {
202-
data = {
203-
"_doc": data
204-
};
205-
}
206-
207-
if (typeof(existing) !== "undefined") {
208-
data._existing = existing;
209-
}
210-
211196
this.promise.then(function(self) {
212197
if (Gitana.isArray(data)) {
213198
for (var i = 0; i < data.length; i++) {
@@ -237,27 +222,18 @@
237222
/**
238223
* Add a delete action to the transaction
239224
*/
240-
Transaction.prototype.del = function(existing, data) {
225+
Transaction.prototype.del = function(data) {
241226

242227
if (typeof this.promise === 'undefined') {
243228
throw new Error('You must set the transaction\'s container with the "for" method before calling this method' );
244229
}
245230

246-
if (typeof(data) === "undefined") {
247-
data = existing;
248-
existing = null;
249-
}
250-
251231
if (typeof(data) === "string") {
252232
data = {
253233
"_doc": data
254234
};
255235
}
256236

257-
if (typeof(existing) !== "undefined") {
258-
data._existing = existing;
259-
}
260-
261237
this.promise.then(function(self) {
262238
if (Gitana.isArray(data)) {
263239
for (var i = 0; i < data.length; i++) {

js/gitana/compatibility.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
if (typeof window === "undefined")
1414
{
1515
window = {
16-
"setTimeout": function(func, seconds)
16+
"setTimeout": function(func, milliseconds)
1717
{
18-
setTimeout(func, seconds);
18+
setTimeout(func, milliseconds);
1919
}
2020
};
2121
}

tests/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
<script type="text/javascript" src="js/testApplication1.js"></script>
205205
<script type="text/javascript" src="js/testApplicationEmailProvider1.js"></script>
206206
<script type="text/javascript" src="js/testApplicationEmail1.js"></script>
207+
<script type="text/javascript" src="js/testApplicationEmail2.js"></script>
207208
<script type="text/javascript" src="js/testApplicationEmailAttachment1.js"></script>
208209
<script type="text/javascript" src="js/testApplicationRegistration1.js"></script>
209210
<script type="text/javascript" src="js/testApplicationSettings1.js"></script>

tests/js/testApplicationEmail2.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
(function($) {
2+
3+
module("applicationEmail2");
4+
5+
// Test case : Application Emails
6+
_asyncTest("Application Emails 2", function()
7+
{
8+
expect(1);
9+
10+
var gitana = GitanaTest.authenticateFullOAuth();
11+
gitana.then(function() {
12+
13+
// NOTE: this = platform
14+
15+
var platform = this;
16+
17+
// create a application
18+
this.createApplication().then(function() {
19+
20+
// NOTE: this = application
21+
22+
// create an email provider
23+
var emailProvider = null;
24+
this.createEmailProvider({
25+
"host": "smtp.gmail.com",
26+
"username": "buildtest@gitanasoftware.com",
27+
"password": "buildt@st11",
28+
"smtp_enabled": true,
29+
"smtp_requires_auth": true,
30+
"smtp_is_secure": true,
31+
"smtp_starttls_enabled": true
32+
}).then(function() {
33+
emailProvider = this;
34+
});
35+
36+
this.then(function() {
37+
38+
// create and send email
39+
var email = null;
40+
this.createEmail({
41+
"subject": "Test Email from JavaScript Driver test suite",
42+
"to": ["${to1}"],
43+
"cc": ["${cc1}", "${cc2}"],
44+
"bcc": ["${bcc1}", "${bcc2}"],
45+
"body": "Here is a test body: ${var1}",
46+
"from": "buildtest@gitanasoftware.com",
47+
"property": "v1"
48+
}).then(function() {
49+
50+
email = this;
51+
52+
// use a model
53+
var model = {
54+
"var1": "value1",
55+
"to1": "buildtest@gitanasoftware.com",
56+
"cc1": "buildtest@gitanasoftware.com",
57+
"cc2": "list-java@cloudcms.com",
58+
"bcc1": "buildtest@gitanasoftware.com",
59+
"bcc2": "list-java@cloudcms.com"
60+
};
61+
62+
// now flip around and send the other way
63+
this.subchain(emailProvider).send(email, model);
64+
65+
});
66+
});
67+
});
68+
69+
this.then(function() {
70+
ok(true, "Emails sent successfully");
71+
success();
72+
});
73+
74+
});
75+
76+
var success = function()
77+
{
78+
start();
79+
};
80+
81+
});
82+
83+
}(jQuery) );

tests/js/testNodeTransaction5.js

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
module("nodeTransaction5");
77

8-
return;
9-
108
// Test case : Node Transaction 5
119
_asyncTest("Node Transaction 5", function()
1210
{
@@ -25,33 +23,42 @@
2523
this.readBranch("master").then(function() {
2624
branch = this;
2725

28-
// create a bunch of nodes and remember the ids
26+
// create a bunch of nodes
2927
this.createNode({
30-
"property1": "value1"
28+
"property1": "value11",
29+
"x1": "y1"
3130
});
3231
this.createNode({
33-
"property1": "value1"
32+
"property1": "value12",
33+
"x1": "y1"
3434
});
3535
this.createNode({
36-
"property1": "value1"
36+
"property1": "value13",
37+
"x1": "y1"
3738
});
3839
this.createNode({
39-
"property1": "value1"
40+
"property1": "value14",
41+
"x1": "y1"
4042
});
4143
this.createNode({
42-
"property1": "value1"
44+
"property1": "value15",
45+
"x1": "y1"
4346
});
4447
this.createNode({
45-
"property1": "value1"
48+
"property1": "value16",
49+
"x1": "y1"
4650
});
4751
this.createNode({
48-
"property1": "value1"
52+
"property1": "value17",
53+
"x1": "y1"
4954
});
5055
this.createNode({
51-
"property1": "value1"
56+
"property1": "value18",
57+
"x1": "y1"
5258
});
5359
this.createNode({
54-
"property1": "value1"
60+
"property1": "value19",
61+
"x1": "y1"
5562
});
5663
this.createNode({
5764
"property2": "value2"
@@ -65,11 +72,55 @@
6572

6673
var t = Gitana.transactions().create(branch);
6774
t.del({
68-
"property1": "value1"
75+
"_existing": {
76+
"property1": "value11"
77+
}
78+
});
79+
t.del({
80+
"_existing": {
81+
"property1": "value12"
82+
}
83+
});
84+
t.del({
85+
"_existing": {
86+
"property1": "value13"
87+
}
88+
});
89+
t.del({
90+
"_existing": {
91+
"property1": "value14"
92+
}
93+
});
94+
t.del({
95+
"_existing": {
96+
"property1": "value15"
97+
}
98+
});
99+
t.del({
100+
"_existing": {
101+
"property1": "value16"
102+
}
103+
});
104+
t.del({
105+
"_existing": {
106+
"property1": "value17"
107+
}
108+
});
109+
t.del({
110+
"_existing": {
111+
"property1": "value18"
112+
}
113+
});
114+
t.del({
115+
"_existing": {
116+
"property1": "value19"
117+
}
69118
});
70119
t.write({
71-
"property2": "value2"
72-
}, {
120+
"_existing": {
121+
"property2": "value2"
122+
},
123+
"property2": "value2",
73124
"title": "Hello!"
74125
});
75126

@@ -79,15 +130,16 @@
79130
Chain(branch).then(function() {
80131

81132
this.queryNodes({
82-
"property1": "value1"
133+
"x1": "y1"
83134
}).count(function(count) {
84135
ok(count === 0, "All deletes processed");
85136
});
86137

87138
this.queryOne({
88139
"property2": "value2"
89140
}).then(function() {
90-
ok(this.title == "Hello!", "Property was updated");
141+
debugger;
142+
ok(this.title === "Hello!", "Property was updated");
91143
});
92144

93145
this.then(function() {

0 commit comments

Comments
 (0)