<commit_before>
var get = Ember.get,
set = Ember.set,
Person,
person,
adapter,
store;

module("Ember-data support", {
  setup: function() {

      Person = DS.Model.extend(Ember.Validations,{
        name: DS.attr('string'),
        tel: DS.attr('string'),

        validations: {
          name: {
            presence: true
          },
          tel: {
            normalize: {
              validator: function(obj, attr, val) {
                if (!val){
                  obj.get('validationErrors').add(attr, "is empty");
                } else if (!val.match(/^(?:0|\+?254)7\d{8}$/)) {
                  obj.get('validationErrors').add(attr, "is invalid");
                }
              }
            }
          }
        }
      });

      adapter = DS.Adapter.create({
        find: function(store, type, id) {
          store.load(Person, 1, { id: 1});
        },
        updateRecord: function(store, type, record) {
          equal(get(record, 'isSaving'), true, "record should be saving");
          equal(get(record, 'isDirty'), true, "record should be dirty");
        }
      });

      store = DS.Store.create({
        adapter: adapter
      });

      person = store.find(Person, 1);
  },

  teardown: function() {
    Person = null;
    store = null;
  }
});

test("ember-data records can be validated", function() {
  person.validate();
  equal(person.get('isValid'), false, "should set 'isValid' to false");
  person.set('name', 'ember');
  person.set('tel', '254700111222');
  person.validate();
  equal(person.get('isValid'), true, "should set 'isValid' to true");
  //store.commit();
});<commit_msg>Enforced em-data records should be saving on commit<commit_after>
var get = Ember.get,
set = Ember.set,
Person,
person,
adapter,
store;

module("Ember-data support", {
  setup: function() {

      Person = DS.Model.extend(Ember.Validations,{
        name: DS.attr('string'),
        tel: DS.attr('string'),

        validations: {
          name: {
            presence: true
          },
          tel: {
            normalize: {
              validator: function(obj, attr, val) {
                if (!val){
                  obj.get('validationErrors').add(attr, "is empty");
                } else if (!val.match(/^(?:0|\+?254)7\d{8}$/)) {
                  obj.get('validationErrors').add(attr, "is invalid");
                }
              }
            }
          }
        }
      });

      adapter = DS.Adapter.create({
        find: function(store, type, id) {
          store.load(Person, 1, { id: 1});
        },
        updateRecord: function(store, type, record) {
          equal(get(record, 'isSaving'), true, "record should be saving");
          equal(get(record, 'isDirty'), true, "record should be dirty");
        }
      });

      store = DS.Store.create({
        adapter: adapter
      });

      person = store.find(Person, 1);
  },

  teardown: function() {
    Person = null;
    store = null;
  }
});

test("ember-data records can be validated", function() {
  person.validate();
  equal(person.get('isValid'), false, "should set 'isValid' to false");
  person.set('name', 'ember');
  person.set('tel', '254700111222');
  person.validate();
  equal(person.get('isValid'), true, "should set 'isValid' to true");
  store.commit();
  equal(person.get('isSaving'), true, "should be saving");
});
{'fraction_non_alphanumeric': 0.1680095493882423, 'fraction_numerical': 0.012533572068039392, 'mean_word_length': 2.017101710171017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '9773', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1010, 'n_words': 230}