<commit_before>describe 'Integration: Sessions', ->
  before ->
    invalidateSession()

  after ->
    $.mockjaxClear()
    Dashboard.reset()

  it 'redirects to new session page', ->
    expect(1)
    visit '/'
    andThen ->
      equal(currentRouteName(), 'sessionsNew')

  it 'has page title in the header', ->
    expect(1)
    visit '/sessions/new'
    andThen ->
      equal find('.header').text(), 'Sign In'

  describe 'sign in', ->
    context 'When it succeeds', ->
      it 'redirects to index and shows the user name', ->
        expect(2)
        stubAjax 'POST', '/api/sessions', 201,
          {
            user_id: 1,
            access_token: 'some_token'
          }

        stubAjax 'GET', '/api/users/1', 200,
          {
            user: { id: 1, name: '<NAME>' }
          }

        visit '/sessions/new'

        andThen ->
          fillIn('input[type=text]', '<EMAIL>')
          fillIn('input[type=password]', '<EMAIL>')
          click('input[type=submit]')
<commit_msg>Use user fixture on sessions spec<commit_after>describe 'Integration: Sessions', ->
  before ->
    invalidateSession()

  after ->
    $.mockjaxClear()
    Dashboard.reset()

  it 'redirects to new session page', ->
    expect(1)
    visit '/'
    andThen ->
      equal(currentRouteName(), 'sessionsNew')

  it 'has page title in the header', ->
    expect(1)
    visit '/sessions/new'
    andThen ->
      equal find('.header').text(), 'Sign In'

  describe 'sign in', ->
    context 'When it succeeds', ->
      it 'redirects to index and shows the user name', ->
        expect(2)
        stubAjax 'POST', '/api/sessions', 201,
          {
            user_id: 1,
            access_token: 'some_token'
          }

        stubAjax 'GET', '/api/users/1', 200, FIXTURES.user(1)

        visit '/sessions/new'

        andThen ->
          fillIn('input[type=text]', '<EMAIL>')
          fillIn('input[type=password]', '<PASSWORD> <EMAIL>')
          click('input[type=submit]')

{'fraction_non_alphanumeric': 0.15458207452165157, 'fraction_numerical': 0.012084592145015106, 'mean_word_length': 2.066358024691358, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, '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': '5389212', 'n_tokens_mistral': 647, 'n_tokens_neox': 616, 'n_words': 154}