<commit_before># encoding: utf-8

require 'spec_helper'

describe 'Basket' do
  before do
    basket_create
  end


  it 'can be created' do
    expect(page).to have_content 'Share Link'
    expect(page).to have_link basket_with_uid_path('')

    click_link basket_with_uid_path(''), match: :first
    expect(page).to have_link 'Place New Order'
    expect(page).to have_link 'Submit Group Order'
  end

  it 'can be cancelled' do
    visit basket_path
    click_link 'Cancel Group Order'

    expect(page).to have_content 'has been cancelled'
    expect(page).to have_link 'Un-Cancel Group Order'
    expect(page).not_to have_link 'Submit Group Order'

    click_link 'Un-Cancel Group Order'
  end

  it 'is submittable' do
    visit basket_path
    order_create
    click_on 'Submit Group Order'

    within('#bestellform') do
      expect(page).to have_content 'Chicken Curry'
      expect(page).to have_field 'Nachname'

      fill_in 'Nachname', with: '<NAME>'
      # don’t care, only need to blur Nachname field
      fill_in 'Vorname', with: 'asd'
    end

    reload
    expect(page).to have_content('Warenkorb')

    # TODO: this works in normal browsers, but not when testing.
    # However, when echo debugging the JS it claims that it has
    # restored the field, although capybara-webkit doesn’t pick it
    # up for some reason.
    #~　expect(find_field('Nachname').value).to eq '<NAME>'

    click_on 'Cancel Submission'

    expect(page).to have_content 'Basket has been reopened'
    expect(page).to have_link 'Submit Group Order'
  end

  it 'doesn’t show any edit/destroy links after submit' do
    visit basket_path
    order_create
    click_on 'Submit Group Order'
    visit basket_path

    expect(page).not_to have_link('Edit')
    expect(page).not_to have_link('Destroy')

    click_on 'Delivery Has Arrived'
    expect(page).not_to have_link('Edit')
    expect(page).not_to have_link('Destroy')

    pp page.html
  end
<commit_msg>remove debug code [skip ci]<commit_after># encoding: utf-8

require 'spec_helper'

describe 'Basket' do
  before do
    basket_create
  end


  it 'can be created' do
    expect(page).to have_content 'Share Link'
    expect(page).to have_link basket_with_uid_path('')

    click_link basket_with_uid_path(''), match: :first
    expect(page).to have_link 'Place New Order'
    expect(page).to have_link 'Submit Group Order'
  end

  it 'can be cancelled' do
    visit basket_path
    click_link 'Cancel Group Order'

    expect(page).to have_content 'has been cancelled'
    expect(page).to have_link 'Un-Cancel Group Order'
    expect(page).not_to have_link 'Submit Group Order'

    click_link 'Un-Cancel Group Order'
  end

  it 'is submittable' do
    visit basket_path
    order_create
    click_on 'Submit Group Order'

    within('#bestellform') do
      expect(page).to have_content 'Chicken Curry'
      expect(page).to have_field 'Nachname'

      fill_in 'Nachname', with: '<NAME>'
      # don’t care, only need to blur Nachname field
      fill_in 'Vorname', with: 'asd'
    end

    reload
    expect(page).to have_content('Warenkorb')

    # TODO: this works in normal browsers, but not when testing.
    # However, when echo debugging the JS it claims that it has
    # restored the field, although capybara-webkit doesn’t pick it
    # up for some reason.
    #~　expect(find_field('Nachname').value).to eq '<NAME>23'

    click_on 'Cancel Submission'

    expect(page).to have_content 'Basket has been reopened'
    expect(page).to have_link 'Submit Group Order'
  end

  it 'doesn’t show any edit/destroy links after submit' do
    visit basket_path
    order_create
    click_on 'Submit Group Order'
    visit basket_path

    expect(page).not_to have_link('Edit')
    expect(page).not_to have_link('Destroy')

    click_on 'Delivery Has Arrived'
    expect(page).not_to have_link('Edit')
    expect(page).not_to have_link('Destroy')
  end

{'fraction_non_alphanumeric': 0.0932073544433095, 'fraction_numerical': 0.0010214504596527069, 'mean_word_length': 3.436013590033975, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6484482', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1229, 'n_words': 390}