<commit_before>require 'rails_helper'

RSpec.describe Vote, type: :model do
  pending "add some examples to (or delete) #{__FILE__}"
end<commit_msg>Add tests for Vote model<commit_after>require 'rails_helper'

RSpec.describe Vote, type: :model do
	describe 'Vote#place_vote' do
		it 'creates a new Vote if user has not voted' do 
			Vote.create(vote: true, ip: '127.0.0.1')
			expect{Vote.place_vote(true, '127.0.0.2')}.to change{Vote.count}.by(1)
		end

		it 'does not create a new Vote if user has voted' do
			Vote.create(vote: true, ip: '127.0.0.1')
			expect{Vote.place_vote(true, '127.0.0.1')}.to change{Vote.count}.by(0)
		end
	end

	describe 'Vote#already_voted?' do
		it 'returns true if IP has already voted' do
			Vote.create(vote: true, ip: '127.0.0.1')
			expect(Vote.already_voted?('127.0.0.1')).to be true
		end

		it 'returns false if IP has not voted' do
			Vote.create(vote: true, ip: '127.0.0.1')
			expect(Vote.already_voted?('127.0.0.2')).to be false
		end
	end

	describe 'Vote#clear_votes' do
		it 'deletes all votes' do 
			Vote.create(vote: false, ip: '127.0.0.1')
			Vote.clear_votes
			expect(Vote.count).to eq(0)
		end
	end
end
{'fraction_non_alphanumeric': 0.1445887445887446, 'fraction_numerical': 0.04935064935064935, 'mean_word_length': 3.757201646090535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, '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': '5076291', 'n_tokens_mistral': 533, 'n_tokens_neox': 466, 'n_words': 125}