<commit_before>require 'test_helper'
#require 'fixtures/sample_mail'

class EventInvitationTest < ActiveSupport::TestCase
  def setup
    @event = Event.create
    @invitation = Invitation.new
  end
  
  test "reverse reflections" do
    assert_equal(:event, Event.reflections[:invitees].reverseme.name)
    assert_equal(:invitees, Invitation.reflections[:event].reverseme.name)
    
    assert_equal(:events, Event.reflections[:user].reverseme.name)
    assert_equal(:user, User.reflections[:events].reverseme.name)
  end
  
  test "presence of counters accessors" do
    @event.invitees.pending
    @event.invitees.accepted
    @event.invitees.rejected
    assert @event.invitees.respond_to?(:pending)
    assert @event.invitees.respond_to?(:accepted)
    assert @event.invitees.respond_to?(:rejected)
  end
  test "event invitations counter increase on create,  and decrease on delete invitation" do
    assert_equal(0, @event.invitees.pending.to_s.count)
    assert_equal(@event, @event.invitees.owner)
    @event.invitees << @invitation
    assert_equal(1, @event.invitees.pending.count)
  end
  test "event invitations counter decrease/increase on update" do
    @event.invitees << @invitation
    @invitation.reload
    @invitation.update_attribute(:estat, Invitation::STATUS[:accepted])
    assert_equal([:pending, :accepted], Counter.all.map{|c| c.name.to_sym })
    assert_equal(0, @event.invitees.pending.count(:force => true))
    assert_equal(1, @event.invitees.accepted.count(:force => true))
  end
  test "event invitations counter decrease on destroy" do
    @event.invitees << @invitation
    @invitation.reload
    @invitation.destroy
    assert_equal(0, @event.invitees.pending.count(:force => true))
  end
end<commit_msg>Change test class name and add assertion for status name<commit_after>require 'test_helper'
#require 'fixtures/sample_mail'

class EventInvitationsTest < ActiveSupport::TestCase
  def setup
    @event = Event.create
    @invitation = Invitation.new
  end
  
  test "reverse reflections" do
    assert_equal(:event, Event.reflections[:invitees].reverseme.name)
    assert_equal(:invitees, Invitation.reflections[:event].reverseme.name)
    
    assert_equal(:events, Event.reflections[:user].reverseme.name)
    assert_equal(:user, User.reflections[:events].reverseme.name)
  end
  
  test "presence of counters accessors" do
    @event.invitees.pending
    @event.invitees.accepted
    @event.invitees.rejected
    assert @event.invitees.respond_to?(:pending)
    assert @event.invitees.respond_to?(:accepted)
    assert @event.invitees.respond_to?(:rejected)
  end
  test "event invitations counter increase on create,  and decrease on delete invitation" do
    assert_equal(0, @event.invitees.pending.to_s.count)
    assert_equal(@event, @event.invitees.owner)
    @event.invitees << @invitation
    assert_equal(1, @event.invitees.pending.count)
  end
  test "event invitations counter decrease/increase on update" do
    @event.invitees << @invitation
    @invitation.reload
    @invitation.update_attribute(:estat, Invitation::STATUS[:accepted])
    assert_equal([:pending, :accepted], Counter.all.map{|c| c.name.to_sym })
    assert_equal(0, @event.invitees.pending.count(:force => true))
    assert_equal(1, @event.invitees.accepted.count(:force => true))
    assert_equal(:accepted, @invitation.status.current.name)
  end
  test "event invitations counter decrease on destroy" do
    @event.invitees << @invitation
    @invitation.reload
    @invitation.destroy
    assert_equal(0, @event.invitees.pending.count(:force => true))
  end
end
{'fraction_non_alphanumeric': 0.11708948982436576, 'fraction_numerical': 0.0027878449958182324, 'mean_word_length': 4.562790697674418, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, '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': '2346908', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1148, 'n_words': 222}