<commit_before>require 'rails_helper'

feature 'Tags' do

  scenario 'Index' do
    earth = create(:debate, tag_list: 'Medio Ambiente')
    money = create(:debate, tag_list: 'Economía')

    visit debates_path

    within "#debate-#{earth.id}" do
      expect(page).to have_content "Medio Ambiente"
    end

    within "#debate-#{money.id}" do
      expect(page).to have_content "Economía"
    end
  end

  scenario 'Filtered' do
    2.times { create(:debate, tag_list: 'Salud') }
    2.times { create(:debate, tag_list: 'Hacienda') }

    visit debates_path
    first(:link, "Salud").click

    within('#debates') do
      expect(page).to have_css('.debate', count: 2)
      expect(page).to have_content('Salud')
      expect(page).to_not have_content('Hacienda')
    end
  end

  scenario 'Show' do
    debate = create(:debate, tag_list: 'Hacienda, Economía')

    visit debate_path(debate)

    expect(page).to have_content "Economía, Hacienda"
  end

  scenario 'Tag Cloud' do
    1.times  { create(:debate, tag_list: 'Medio Ambiente') }
    5.times  { create(:debate, tag_list: 'Corrupción') }
    10.times { create(:debate, tag_list: 'Economía') }

    visit debates_path

    within "#tag-cloud" do
      expect(page).to have_css(".s", text: "Medio Ambiente(1)")
      expect(page).to have_css(".m", text: "Corrupción(5)")
      expect(page).to have_css(".l", text: "Economía(10)")
    end
  end

  scenario 'Create' do
    user = create(:user)
    login_as(user)

    visit new_debate_path
    fill_in 'debate_title', with: 'Title'
    fill_in 'debate_description', with: 'Description'
    check 'debate_terms_of_service'

    fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda"

    click_button 'Create Debate'

    expect(page).to have_content 'Debate was successfully created.'
    expect(page).to have_content 'Economía, Hacienda, Impuestos'
  end

  scenario 'Update' do
    debate = create(:debate, tag_list: 'Economía')

    login_as(debate.author)
    visit edit_debate_path(debate)
<commit_msg>Fixes spec: Tags are not separated by commas any more<commit_after>require 'rails_helper'

feature 'Tags' do

  scenario 'Index' do
    earth = create(:debate, tag_list: 'Medio Ambiente')
    money = create(:debate, tag_list: 'Economía')

    visit debates_path

    within "#debate-#{earth.id}" do
      expect(page).to have_content "Medio Ambiente"
    end

    within "#debate-#{money.id}" do
      expect(page).to have_content "Economía"
    end
  end

  scenario 'Filtered' do
    2.times { create(:debate, tag_list: 'Salud') }
    2.times { create(:debate, tag_list: 'Hacienda') }

    visit debates_path
    first(:link, "Salud").click

    within('#debates') do
      expect(page).to have_css('.debate', count: 2)
      expect(page).to have_content('Salud')
      expect(page).to_not have_content('Hacienda')
    end
  end

  scenario 'Show' do
    debate = create(:debate, tag_list: 'Hacienda, Economía')

    visit debate_path(debate)

    expect(page).to have_content "Economía"
    expect(page).to have_content "Hacienda"
  end

  scenario 'Tag Cloud' do
    1.times  { create(:debate, tag_list: 'Medio Ambiente') }
    5.times  { create(:debate, tag_list: 'Corrupción') }
    10.times { create(:debate, tag_list: 'Economía') }

    visit debates_path

    within "#tag-cloud" do
      expect(page).to have_css(".s", text: "Medio Ambiente(1)")
      expect(page).to have_css(".m", text: "Corrupción(5)")
      expect(page).to have_css(".l", text: "Economía(10)")
    end
  end

  scenario 'Create' do
    user = create(:user)
    login_as(user)

    visit new_debate_path
    fill_in 'debate_title', with: 'Title'
    fill_in 'debate_description', with: 'Description'
    check 'debate_terms_of_service'

    fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda"

    click_button 'Create Debate'

    expect(page).to have_content 'Debate was successfully created.'
    expect(page).to have_content 'Economía'
    expect(page).to have_content 'Hacienda'
    expect(page).to have_content 'Impuestos'
  end

  scenario 'Update' do
    debate = create(:debate, tag_list: 'Economía')

    login_as(debate.author)
    visit edit_debate_path(debate)

{'fraction_non_alphanumeric': 0.13000954198473283, 'fraction_numerical': 0.005248091603053435, 'mean_word_length': 3.6127612761276127, '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': '6244175', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1462, 'n_words': 341}