<commit_before>require 'rails_helper'

feature "Planting a crop", js: true do
  let!(:garden) { create :garden }
  let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
  let!(:tomato) { create :tomato }
  let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato }

  background do
    login_as garden.owner
  end

  scenario "View gardens" do
    visit gardens_path
    expect(page).to have_content "Everyone's gardens"
    click_link "My Gardens"
    expect(page).to have_content "#{garden.owner.login_name}'s gardens"
    click_link "Everyone's gardens"
    expect(page).to have_content "Everyone's gardens"
  end

  scenario "Marking a garden as inactive" do
    visit garden_path(garden)
    click_link "Mark as inactive"
    expect(page).to have_content "Garden was successfully updated"
    expect(page).to have_content "This garden is inactive"
    expect(page).to have_content "Mark as active"
    expect(page).not_to have_content "Mark as inactive"
  end

  scenario "Create new garden" do
    visit new_garden_path
    fill_in "Name", with: "<NAME>"
    click_button "Save"
    expect(page).to have_content "Garden was successfully created"
    expect(page).to have_content "New garden"
  end

  scenario "Refuse to create new garden with negative area" do
    visit new_garden_path
    fill_in "Name", with: "<NAME>"
    fill_in "Area", with: -5
    click_button "Save"
    expect(page).not_to have_content "Garden was successfully created"
    expect(page).to have_content "Area must be greater than or equal to 0"
  end

  context "Clicking edit from the index page" do
    background do
      visit gardens_path
    end

    scenario "button on index to edit garden" do
      first(".panel-title").click_link("edit_garden_glyphicon")<commit_msg>spec only show active gardens<commit_after>require 'rails_helper'

feature "Planting a crop", js: true do
  let!(:garden) { create :garden }
  let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
  let!(:tomato) { create :tomato }
  let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato }

  background do
    login_as garden.owner
  end

  scenario "View gardens" do
    visit gardens_path
    expect(page).to have_content "Everyone's gardens"
    click_link "My Gardens"
    expect(page).to have_content "#{garden.owner.login_name}'s gardens"
    click_link "Everyone's gardens"
    expect(page).to have_content "Everyone's gardens"
  end

  scenario "Marking a garden as inactive" do
    visit garden_path(garden)
    click_link "Mark as inactive"
    expect(page).to have_content "Garden was successfully updated"
    expect(page).to have_content "This garden is inactive"
    expect(page).to have_content "Mark as active"
    expect(page).not_to have_content "Mark as inactive"
  end

  scenario "List only active gardens" do
    visit garden_path(garden)
    click_link "Mark as inactive"
    visit gardens_path
    expect(page).not_to have_link garden_path(garden)
  end

  scenario "Create new garden" do
    visit new_garden_path
    fill_in "Name", with: "New garden"
    click_button "Save"
    expect(page).to have_content "Garden was successfully created"
    expect(page).to have_content "New garden"
  end

  scenario "Refuse to create new garden with negative area" do
    visit new_garden_path
    fill_in "Name", with: "Negative Garden"
    fill_in "Area", with: -5
    click_button "Save"
    expect(page).not_to have_content "Garden was successfully created"
    expect(page).to have_content "Area must be greater than or equal to 0"
  end

  context "Clicking edit from the index page" do
    background do
      visit gardens_path
    end

    scenario "button on index to edit garden" do
      first(".panel-title").click_link("edit_garden_glyphicon")
{'fraction_non_alphanumeric': 0.0914034179181771, 'fraction_numerical': 0.004660797514241326, 'mean_word_length': 3.9462227912932137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2463730', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1177, 'n_words': 385}