~bcsaller/juju-gui/viewmodel-improvements

« back to all changes in this revision

Viewing changes to app/app.js

  • Committer: Benjamin Saller
  • Author(s): Benjamin Saller
  • Date: 2013-01-24 14:22:53 UTC
  • mfrom: (340.1.4 phantom-testing)
  • Revision ID: bcsaller@gmail.com-20130124142253-7iy334tw9shdvs8x
PhantomJS Testing support

Change test server to use phantomjs. To get this branch working you'll need

sudo npm install -g phantomjs
sudo npm install -g mocha-phantomjs

After that make test-debug and test-prod should work with CLI exit codes
and .lbox.check should run the tests as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
     */
195
195
    initializer: function() {
196
196
      // If this flag is true, start the application with the console activated
197
 
      if (this.get('consoleEnabled')) {
198
 
        consoleManager.native();
199
 
      } else {
200
 
        consoleManager.noop();
 
197
      var consoleEnabled = this.get('consoleEnabled');
 
198
 
 
199
      // Concession to testing, they need muck
 
200
      // with console, we can't as well.
 
201
      if (window.mochaPhantomJS === undefined) {
 
202
        if (consoleEnabled) {
 
203
          consoleManager.native();
 
204
        } else {
 
205
          consoleManager.noop();
 
206
        }
201
207
      }
202
208
      // Create a client side database to store state.
203
209
      this.db = new models.Database();
236
242
        env: this.env,
237
243
        notifications: this.db.notifications});
238
244
 
239
 
      // Event subscriptions
240
 
 
241
 
      this.on('*:navigateTo', function(e) {
242
 
        console.log('navigateTo', e);
243
 
        this.navigate(e.url);
244
 
      }, this);
245
 
 
246
245
      // Notify user attempts to modify the environment without permission.
247
246
      this.env.on('permissionDenied', this.onEnvPermissionDenied, this);
248
247
 
271
270
      // TODO - Bound views will automatically update this on individual models
272
271
      this.db.on('update', this.on_database_changed, this);
273
272
 
274
 
      this.on('navigate', function(e) {
275
 
        console.log('app navigate', e);
276
 
      });
277
 
 
278
273
      this.enableBehaviors();
279
274
 
280
275
      this.once('ready', function(e) {
281
276
        if (this.get('socket_url')) {
282
277
          // Connect to the environment.
283
 
          console.log('App: Connecting to environment');
284
278
          this.env.connect();
285
279
        }
286
 
 
287
 
        console.log(
288
 
            'App: Re-rendering current view', this.getPath(), 'info');
289
 
 
290
280
        if (this.get('activeView')) {
291
281
          this.get('activeView').render();
292
282
        } else {
381
371
     * @method show_unit
382
372
     */
383
373
    show_unit: function(req) {
384
 
      console.log(
385
 
          'App: Route: Unit', req.params.id, req.path, req.pendingRoutes);
386
374
      // This replacement honors service names that have a hyphen in them.
387
375
      var unit_id = req.params.id.replace(/^(\S+)-(\d+)$/, '$1/$2');
388
376
      var unit = this.db.units.getById(unit_id);
657
645
     * @method load_service
658
646
     */
659
647
    loadService: function(evt) {
660
 
      console.log('load service', evt);
661
648
      if (evt.err) {
662
649
        this.db.notifications.add(
663
650
            new models.Notification({