Sha256: e9b96c1d284aa996e8d3fbc0a2517e6a40e52f8fa6d64c9bab1b85061016ac6d

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

// ==========================================================================
// Project:   TestRunner.Target
// Copyright: ©2009 My Company, Inc.
// ==========================================================================
/*globals TestRunner */

/** @class

  Describes a single target in the current project.  A target can have a name,
  a type and one or more tests that are loaded on demand.

  @extends SC.Record
  @author Charles Jolley
*/
TestRunner.Target = SC.Record.extend(
/** @scope TestRunner.Target.prototype */ {
  
  /** Load the tests for the target. */
  tests: function() {
    this.refreshTests();
    return this._tests;
  }.property().cacheable(),
  
  /**
    Loads the targets from the server.  When the targets have loaded, adds 
    them to the store and then sets the local content.
  */
  refreshTests: function() {
    if (!this._tests) this._tests = [] ;
    SC.Request.getUrl(this.get('link_tests'))
      .notify(this, 'testsDidRefresh').set('isJSON', YES).send();
  },
  
  testsDidRefresh: function(request) {
    var json = request.get('response'), len = json.length, idx;
    for(idx=0;idx<len;idx++) json[idx].guid = json[idx].url ; // patch
    var tests = SC.Store.updateRecords(json, SC.Store, TestRunner.Test);
    tests = tests.sort(function(a,b) { 
      a = a.get('filename'); 
      b = b.get('filename');
      return (a<b) ? -1 : (a>b) ? 1 : 0;
    });

    this.propertyWillChange('tests');
    this._tests = tests ;
    this.propertyDidChange('tests');
  }

}) ;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090408130025 frameworks/sproutcore/apps/tests/models/target.js
sproutit-sproutcore-1.0.0.20090416161445 frameworks/sproutcore/apps/tests/models/target.js