<commit_before>require "spec_helper"

describe "User locations" do

  let!(:location_category) { FactoryGirl.create(:location_category) }
  let(:location_attributes) { FactoryGirl.attributes_for(:user_location_with_json_loc) }

  context "view" do
    include_context "signed in as a site user"

    it "should show a page for a new user" do
      visit user_locations_path
      page.should have_content("My Locations")
    end

    it "should let you add a new location" do
      visit new_user_location_path
      page.should have_content("New Location")
      select "Route to School", from: "Category"
      # Note hidden map field
      find("#user_location_loc_json").set(location_attributes[:loc_json])
      click_on "Create User location"

      page.should have_content("Location Created")
      page.should have_content("Route to School")
    end
  end
end<commit_msg>Check for location editing and deleting too<commit_after>require "spec_helper"

describe "User locations" do

  let!(:location_category) { FactoryGirl.create(:location_category) }
  let(:location_attributes) { FactoryGirl.attributes_for(:user_location_with_json_loc) }

  context "view" do
    include_context "signed in as a site user"

    it "should show a page for a new user" do
      visit user_locations_path
      page.should have_content("My Locations")
    end

    it "should let you add a new location" do
      visit new_user_location_path
      page.should have_content("New Location")
      select "Route to School", from: "Category"
      # Note hidden map field
      find("#user_location_loc_json").set(location_attributes[:loc_json])
      click_on "Create User location"

      page.should have_content("Location Created")
      page.should have_content("Route to School")
    end

    context "edit" do
      let!(:location) { FactoryGirl.create(:user_location, user: current_user, category: location_category) }

      it "should let you edit an existing location" do
        visit user_locations_path
        click_on "Edit" # hmm, edit the right one?

        page.should have_content("Edit Location")
        find("#user_location_loc_json").set(location_attributes[:loc_json])
        click_on "Save"

        page.should have_content("Location Updated")
      end

      it "should let you delete a location" do
        visit user_locations_path
        click_on "Delete"
        page.should have_content("Location deleted")
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08258746948738813, 'fraction_numerical': 0.0, 'mean_word_length': 3.520220588235294, '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': '5814517', 'n_tokens_mistral': 706, 'n_tokens_neox': 677, 'n_words': 209}