~caneypuggies/reformedchurcheslocator/couchapp-backbone

« back to all changes in this revision

Viewing changes to _attachments/js/vendor/backbone/test/environment.js

  • Committer: Tim Black
  • Date: 2013-09-16 22:50:16 UTC
  • Revision ID: tim@alwaysreformed.com-20130916225016-zk8jiba25z33ew7h
Versioned Bower vendor directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(function() {
 
2
 
 
3
  var Environment = this.Environment = function(){};
 
4
 
 
5
  _.extend(Environment.prototype, {
 
6
 
 
7
    ajax: Backbone.ajax,
 
8
 
 
9
    sync: Backbone.sync,
 
10
 
 
11
    emulateHTTP: Backbone.emulateHTTP,
 
12
 
 
13
    emulateJSON: Backbone.emulateJSON,
 
14
 
 
15
    setup: function() {
 
16
      var env = this;
 
17
 
 
18
      // Capture ajax settings for comparison.
 
19
      Backbone.ajax = function(settings) {
 
20
        env.ajaxSettings = settings;
 
21
      };
 
22
 
 
23
      // Capture the arguments to Backbone.sync for comparison.
 
24
      Backbone.sync = function(method, model, options) {
 
25
        env.syncArgs = {
 
26
          method: method,
 
27
          model: model,
 
28
          options: options
 
29
        };
 
30
        env.sync.apply(this, arguments);
 
31
      };
 
32
    },
 
33
 
 
34
    teardown: function() {
 
35
      this.syncArgs = null;
 
36
      this.ajaxSettings = null;
 
37
      Backbone.sync = this.sync;
 
38
      Backbone.ajax = this.ajax;
 
39
      Backbone.emulateHTTP = this.emulateHTTP;
 
40
      Backbone.emulateJSON = this.emulateJSON;
 
41
    }
 
42
 
 
43
  });
 
44
 
 
45
})();