<commit_before>require "rails_helper"

describe User do

  describe "#headings_voted_within_group" do
    it "returns the headings voted by a user" do
      user1 = create(:user)
      user2 = create(:user)

      budget = create(:budget)
      group = create(:budget_group, budget: budget)

      new_york = create(:budget_heading, group: group, name: "New york")
      san_franciso = create(:budget_heading, group: group, name: "San Franciso")
      wyoming = create(:budget_heading, group: group, name: "Wyoming")
      another_heading = create(:budget_heading, group: group)

      new_york_investment = create(:budget_investment, heading: new_york)
      san_franciso_investment = create(:budget_investment, heading: san_franciso)
      wyoming_investment = create(:budget_investment, heading: wyoming)

      create(:vote, votable: wyoming_investment, voter: user1)
      create(:vote, votable: san_franciso_investment, voter: user1)
      create(:vote, votable: new_york_investment, voter: user1)

      headings_names = "#{new_york.name}, #{san_franciso.name}, and #{wyoming.name}"

      expect(user1.headings_voted_within_group(group)).to include(new_york)
      expect(user1.headings_voted_within_group(group)).to include(san_franciso)
      expect(user1.headings_voted_within_group(group)).to include(wyoming)
      expect(user1.headings_voted_within_group(group)).not_to include(another_heading)
      expect(user1.headings_voted_within_group(group).map(&:name).to_sentence).to eq(headings_names)

      expect(user2.headings_voted_within_group(group)).not_to include(new_york)
      expect(user2.headings_voted_within_group(group)).not_to include(san_franciso)
      expect(user2.headings_voted_within_group(group)).not_to include(another_heading)
    end<commit_msg>Simplify test for heading names<commit_after>require "rails_helper"

describe User do

  describe "#headings_voted_within_group" do
    it "returns the headings voted by a user" do
      user1 = create(:user)
      user2 = create(:user)

      budget = create(:budget)
      group = create(:budget_group, budget: budget)

      new_york = create(:budget_heading, group: group, name: "New york")
      san_francisco = create(:budget_heading, group: group, name: "San Franciso")
      wyoming = create(:budget_heading, group: group, name: "Wyoming")
      another_heading = create(:budget_heading, group: group)

      new_york_investment = create(:budget_investment, heading: new_york)
      san_franciso_investment = create(:budget_investment, heading: san_francisco)
      wyoming_investment = create(:budget_investment, heading: wyoming)

      create(:vote, votable: wyoming_investment, voter: user1)
      create(:vote, votable: san_franciso_investment, voter: user1)
      create(:vote, votable: new_york_investment, voter: user1)

      expect(user1.headings_voted_within_group(group)).to match_array [new_york, san_francisco, wyoming]
      expect(user1.headings_voted_within_group(group)).not_to include(another_heading)

      expect(user2.headings_voted_within_group(group)).to be_empty
    end
{'fraction_non_alphanumeric': 0.10275526742301459, 'fraction_numerical': 0.006807131280388979, 'mean_word_length': 4.957528957528957, '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': '1648379', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1002, 'n_words': 191}