<commit_before>require 'spec_helper'

describe 'managing stops as an admin' do
  before :each do
    admin = create :user, :admin
    @bus_stop = create :bus_stop
    
    when_current_user_is admin
    visit manage_bus_stops_url
  end
  context 'delete button' do
    it 'deletes the specific bus stop' do
      expect(page).to have_selector 'table.manage tbody tr', count: 1
      within 'tr', text: @bus_stop.name do
        click_button 'Delete'
      end
      page.driver.browser.switch_to.alert.accept
      expect(page).to have_selector 'p.notice',
        text: "#{@bus_stop.name} has been deleted."
      expect(page).not_to have_selector 'table.manage tbody tr', text: @bus_stop.name
    end
  end
  context 'edit button' do
    it 'redirects to edit bus stop page' do
      expect(page).to have_selector 'table.manage tbody tr', count: 1
      within 'tr', text: @bus_stop.name do
        click_link 'Edit'
      end
      expect(page).to have_content "Editing #{@bus_stop.name}"
      expect(page.current_url).to end_with edit_bus_stop_path(@bus_stop.hastus_id)
    end
  end
end

describe 'viewing outdated' do
  before :each do
    admin = create :user, :admin
    @present_stop = create :bus_stop
    @date = Date.today
    @stop_1 = create :bus_stop, updated_at: (@date - 2.months)
    @stop_2 = create :bus_stop, updated_at: (@date - 3.months)
    when_current_user_is admin
    visit manage_bus_stops_url

    click_link 'View Outdated'
  end
  it 'redirects to outdated page' do
    expect(page.current_url).to end_with outdated_bus_stops_path
  end
  it 'displays only outdated stops' do
    expect(page).to have_selector 'table.manage tbody tr', count: 2
    expect(page).to have_selector 'table.manage tbody tr', text: @stop_1.name
    expect(page).to have_selector 'table.manage tbody tr', text: @stop_2.name
  end
  it 'allows editing of outdated stops' do
    within 'tr', text: @stop_1.hastus_id do
      click_link 'Edit'
    end
    expect(page).to have_content "Editing #{@stop_1.name}"
  end
  it 'outdated can be narrowed down with a different date' do
  end
end

describe 'exporting all as CSV' do
  it 'exports a CSV of all stops' do
  end
end<commit_msg>Test except for datepicker<commit_after>require 'spec_helper'

describe 'managing stops as an admin' do
  before :each do
    admin = create :user, :admin
    @bus_stop = create :bus_stop
    
    when_current_user_is admin
    visit manage_bus_stops_url
  end
  context 'delete button' do
    it 'deletes the specific bus stop' do
      expect(page).to have_selector 'table.manage tbody tr', count: 1
      within 'tr', text: @bus_stop.name do
        click_button 'Delete'
      end
      page.driver.browser.switch_to.alert.accept
      expect(page).to have_selector 'p.notice',
        text: "#{@bus_stop.name} has been deleted."
      expect(page).not_to have_selector 'table.manage tbody tr', text: @bus_stop.name
    end
  end
  context 'edit button' do
    it 'redirects to edit bus stop page' do
      expect(page).to have_selector 'table.manage tbody tr', count: 1
      within 'tr', text: @bus_stop.name do
        click_link 'Edit'
      end
      expect(page).to have_content "Editing #{@bus_stop.name}"
      expect(page.current_url).to end_with edit_bus_stop_path(@bus_stop.hastus_id)
    end
  end
end

describe 'viewing outdated' do
  before :each do
    admin = create :user, :admin
    @present_stop = create :bus_stop
    @date = Date.today
    @stop_1 = create :bus_stop, updated_at: (@date - 2.months)
    @stop_2 = create :bus_stop, updated_at: (@date - 3.months)
    when_current_user_is admin
    visit manage_bus_stops_url

    click_link 'View Outdated'
  end
  it 'redirects to outdated page' do
    expect(page.current_url).to end_with outdated_bus_stops_path
  end
  it 'displays only outdated stops' do
    expect(page).to have_selector 'table.manage tbody tr', count: 2
    expect(page).to have_selector 'table.manage tbody tr', text: @stop_1.name
    expect(page).to have_selector 'table.manage tbody tr', text: @stop_2.name
  end
  it 'allows editing of outdated stops' do
    within 'tr', text: @stop_1.hastus_id do
      click_link 'Edit'
    end
    expect(page).to have_content "Editing #{@stop_1.name}"
  end
  it 'outdated can be narrowed down with a different date' do
    within '#date' do
      # datepickers guh
      fill_in 'date', with: @date
      binding.pry
      click_button 'Change date'
    end
  end
end

describe 'exporting all as CSV' do
  it 'exports a CSV of all stops' do
  end
end
{'fraction_non_alphanumeric': 0.0913907284768212, 'fraction_numerical': 0.004856512141280353, 'mean_word_length': 3.2266791044776117, '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': '1881161', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1491, 'n_words': 472}