<commit_before>import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
import Pretender from 'pretender';
import serverPostPolls from '../helpers/server-post-polls';
import moment from 'moment';
/* jshint proto: true */

let application, server;

module('Acceptance | create a poll', {
  beforeEach() {
    let lastCreatedPoll = {};
    const pollId = Math.random().toString(36).substr(2, 10);

    application = startApp();
    application.__container__.lookup('adapter:application').__proto__.namespace = '';

    server = new Pretender();

    server.post('/polls',
      function(request) {
        let ret = serverPostPolls(request.requestBody, pollId);
        lastCreatedPoll = ret[2];
        return ret;
      }
    );

    server.get(`/polls/${pollId}`,
      function() {
        return [
          200,
          { 'Content-Type': 'application/json' },
          lastCreatedPoll
        ];<commit_msg>Fix: String could be less than 10 characters which causes test to fail<commit_after>import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
import Pretender from 'pretender';
import serverPostPolls from '../helpers/server-post-polls';
import moment from 'moment';
/* jshint proto: true */

let application, server;

const randomString = function(length) {
  return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1);
};

module('Acceptance | create a poll', {
  beforeEach() {
    let lastCreatedPoll = {};
    const pollId = randomString(10);

    application = startApp();
    application.__container__.lookup('adapter:application').__proto__.namespace = '';

    server = new Pretender();

    server.post('/polls',
      function(request) {
        let ret = serverPostPolls(request.requestBody, pollId);
        lastCreatedPoll = ret[2];
        return ret;
      }
    );

    server.get(`/polls/${pollId}`,
      function() {
        return [
          200,
          { 'Content-Type': 'application/json' },
          lastCreatedPoll
        ];
{'fraction_non_alphanumeric': 0.1419141914191419, 'fraction_numerical': 0.011786892975011787, 'mean_word_length': 3.05736137667304, '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': '6424473', 'n_tokens_mistral': 636, 'n_tokens_neox': 614, 'n_words': 151}