require 'rails_helper'

RSpec.feature "Delete participants from an event", type: :feature do
  background do
    @user = create :user, admin: true
    login_as @user
  end

  given!(:wilma) { create :user, email: 'wilma@example.com' }
  given!(:event) { create :event, users: [wilma] }
  given!(:participation) { event.participations.first }


  scenario "Creating a new Participation" do
    visit event_participations_path event

    expect {
      click_link I18n.t('application.actions.delete')
    }.to change { wilma.reload.participations.count }.by -1

    expect(page).to have_content 'Participation was successfully destroyed.'
  end
end
