<commit_before># coding: utf-8

require 'rails_helper'

RSpec.feature 'Processing refund application with valid date received date', type: :feature do

  let(:jurisdiction) { create :jurisdiction }
  let(:office) { create :office, jurisdictions: [jurisdiction] }
  let(:user) { create :user, office: office }

  let(:online_application_1) do
    create(:online_application, :completed, :with_reference,
      married: false,
      children: 3,
      benefits: true,
      fee: 1550,
      form_name: 'D11',
      income_min_threshold_exceeded: false,
      refund: true,
      date_fee_paid: 4.months.ago,
      date_received: 2.months.ago,
      jurisdiction: jurisdiction)
  end

  let(:online_application_2) do
    create(:online_application, :completed, :with_reference,
      married: false,
      children: 3,
      benefits: true,
      fee: 1550,
      form_name: 'D11',
      income_min_threshold_exceeded: false,
      refund: true,
      date_fee_paid: 5.months.ago,
      date_received: 3.months.ago,
      jurisdiction: jurisdiction)
  end

  before do
    login_as user
    dwp_api_response 'Yes'
  end

  it "do not fail when valid date" do
    visit '/'
    fill_in :online_search_reference, with: online_application_1.reference
    click_button 'Look up'
    expect(page).to have_content "Application details"
    choose jurisdiction.name
    click_button 'Next'
    expect(page).to have_content "Check details"
    click_button 'Complete processing'

    expect(page).to have_content 'Savings and investments✓ Passed'
    expect(page).to have_content 'Benefits✓ Passed'
    expect(page).to have_content 'Eligible for help with fees'
  end

  it "ingnore online application when invalid date" do
    visit '/'
    fill_in :online_search_reference, with: online_application_2.reference
    click_button 'Look up'
    expect(page).to have_content "Application details"
    choose jurisdiction.name
    click_button 'Next'
    expect(page).to have_content "Check details"
    click_button 'Complete processing'

    expect(page).to have_content 'Savings and investments✓ Passed'
    expect(page).to have_content 'Benefits✓ Passed'
    expect(page).to have_content 'Eligible for help with fees'
  end
end<commit_msg>Online application doesn't validate date when processing.<commit_after># coding: utf-8

require 'rails_helper'

RSpec.feature 'Processing refund application with valid date received date', type: :feature do

  let(:jurisdiction) { create :jurisdiction }
  let(:office) { create :office, jurisdictions: [jurisdiction] }
  let(:user) { create :user, office: office }

  let(:online_application_1) do
    create(:online_application, :completed, :with_reference,
      married: false,
      children: 3,
      benefits: true,
      fee: 1550,
      form_name: 'D11',
      income_min_threshold_exceeded: false,
      refund: true,
      date_fee_paid: 4.months.ago,
      date_received: 2.months.ago,
      jurisdiction: jurisdiction)
  end

  let(:online_application_2) do
    create(:online_application, :completed, :with_reference,
      married: false,
      children: 3,
      benefits: true,
      fee: 1550,
      form_name: 'D11',
      income_min_threshold_exceeded: false,
      refund: true,
      date_fee_paid: 5.months.ago,
      date_received: 3.months.ago,
      jurisdiction: jurisdiction)
  end

  before do
    login_as user
    dwp_api_response 'Yes'
  end

  context 'Online refund application' do
    it "do not fail when valid date" do
      visit '/'
      fill_in :online_search_reference, with: online_application_1.reference
      click_button 'Look up'
      expect(page).to have_content "Application details"
      choose jurisdiction.name
      date_received = find(:xpath, './/input[@id="online_application_date_received"]').value
      expect(date_received).to eq(online_application_1.date_received.to_s)

      click_button 'Next'
      expect(page).to have_content "Check details"
      click_button 'Complete processing'

      expect(page).to have_content 'Savings and investments✓ Passed'
      expect(page).to have_content 'Benefits✓ Passed'
      expect(page).to have_content 'Eligible for help with fees'
    end

    it "ignore date_received date because it was already validated" do
      visit '/'
      fill_in :online_search_reference, with: online_application_2.reference
      click_button 'Look up'
      expect(page).to have_content "Application details"
      choose jurisdiction.name
      date_received = find(:xpath, './/input[@id="online_application_date_received"]').value
      expect(date_received).to eq(online_application_2.date_received.to_s)

      click_button 'Next'
      expect(page).to have_content "Check details"
      click_button 'Complete processing'

      expect(page).to have_content 'Savings and investments✓ Passed'
      expect(page).to have_content 'Benefits✓ Passed'
      expect(page).to have_content 'Eligible for help with fees'
    end

  end
end
{'fraction_non_alphanumeric': 0.0904319741622931, 'fraction_numerical': 0.009689140088817117, 'mean_word_length': 3.558417663293468, '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': '3139594', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1470, 'n_words': 399}