<commit_before>/* global emit */
import Ember from 'ember';
import { configurations, registerModels, registerQueries, cleanup } from '../helpers/setup';
import { Query, Model, prefix, belongsTo, hasMany } from 'sofa';

const {
  computed,
  RSVP: { all }
} = Ember;

const ddoc = {
  views: {
    'all': {
      map(doc) {
        if(doc.type !== 'duck') {
          return;
        }
        emit(doc._id, null);
      }
    }
  }
};

configurations(({ module, test, createStore }) => {

  let store;
  let db;

  let HouseDucks = Query.extend({
    find: computed(function() {
      return { ddoc: 'ducks', view: 'all' };
    })
  });

  let Duck = Model.extend({
    id: prefix(),
  });

  let Root = Model.extend({
    ducks: hasMany('duck', { inverse: null, query: 'house-ducks' })
  });

  function flush() {
    store = createStore();
    db = store.get('db.main');
    db.set('modelNames', [ 'root', 'duck' ]);
  }

  // from has-many-loaded
  module('has-many-collection', () => {
    registerModels({ Duck, Root });
    registerQueries({ HouseDucks });
    flush();
    return cleanup(store, [ 'main' ]).then(() => {<commit_msg>query name in test<commit_after>/* global emit */
import Ember from 'ember';
import { configurations, registerModels, registerQueries, cleanup } from '../helpers/setup';
import { Query, Model, prefix, belongsTo, hasMany } from 'sofa';

const {
  computed,
  RSVP: { all }
} = Ember;

const ddoc = {
  views: {
    'all': {
      map(doc) {
        if(doc.type !== 'duck') {
          return;
        }
        emit(doc._id, null);
      }
    }
  }
};

configurations(({ module, test, createStore }) => {

  let store;
  let db;

  let AllDucks = Query.extend({
    find: computed(function() {
      return { ddoc: 'ducks', view: 'all' };
    })
  });

  let Duck = Model.extend({
    id: prefix(),
  });

  let Root = Model.extend({
    ducks: hasMany('duck', { inverse: null, query: 'all-ducks' })
  });

  function flush() {
    store = createStore();
    db = store.get('db.main');
    db.set('modelNames', [ 'root', 'duck' ]);
  }

  // from has-many-loaded
  module('has-many-collection', () => {
    registerModels({ Duck, Root });
    registerQueries({ AllDucks });
    flush();
    return cleanup(store, [ 'main' ]).then(() => {
{'fraction_non_alphanumeric': 0.18637362637362637, 'fraction_numerical': 0.0, 'mean_word_length': 2.6591639871382635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3297845', 'n_tokens_mistral': 782, 'n_tokens_neox': 767, 'n_words': 185}