mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-31 11:35:45 +00:00
Fixed reset password after the Devise migration.
This commit is contained in:
70
test/integration/tournament_job_status_test.rb
Normal file
70
test/integration/tournament_job_status_test.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
require "test_helper"
|
||||
|
||||
class TournamentJobStatusIntegrationTest < ActionDispatch::IntegrationTest
|
||||
include Devise::Test::IntegrationHelpers
|
||||
|
||||
setup do
|
||||
@tournament = tournaments(:one)
|
||||
@user = users(:admin) # Assuming an admin user exists in your fixtures
|
||||
@running_job = tournament_job_statuses(:running_job)
|
||||
@errored_job = tournament_job_statuses(:errored_job)
|
||||
|
||||
sign_in @user
|
||||
end
|
||||
|
||||
test "tournament director sees active jobs on tournament show page" do
|
||||
get tournament_path(@tournament)
|
||||
assert_response :success
|
||||
|
||||
# Should display the running job but not the errored job
|
||||
assert_match @running_job.job_name, response.body
|
||||
assert_match "Background Jobs In Progress", response.body
|
||||
assert_no_match @errored_job.job_name, response.body
|
||||
end
|
||||
|
||||
test "tournament director does not see job section when no active jobs" do
|
||||
# Delete all active jobs
|
||||
TournamentJobStatus.where.not(status: "Errored").destroy_all
|
||||
|
||||
get tournament_path(@tournament)
|
||||
assert_response :success
|
||||
|
||||
# Should not display the job section
|
||||
assert_no_match "Background Jobs In Progress", response.body
|
||||
end
|
||||
|
||||
test "non-director user does not see job information" do
|
||||
sign_out @user
|
||||
@regular_user = users(:one) # Assuming a regular user exists in fixtures
|
||||
sign_in @regular_user
|
||||
|
||||
# Assuming regular users don't have permission to manage the tournament
|
||||
get tournament_path(@tournament)
|
||||
assert_response :success
|
||||
|
||||
# Should not display job information
|
||||
assert_no_match "Background Jobs In Progress", response.body
|
||||
end
|
||||
|
||||
test "jobs get cleaned up after successful completion" do
|
||||
# Test that CalculateSchoolScoreJob removes job status when complete
|
||||
school = schools(:one)
|
||||
job_name = "Calculating team score for #{school.name}"
|
||||
|
||||
# Create a job status for this school
|
||||
TournamentJobStatus.create!(
|
||||
tournament: @tournament,
|
||||
job_name: job_name,
|
||||
status: "Running"
|
||||
)
|
||||
|
||||
# Verify the job exists
|
||||
assert TournamentJobStatus.exists?(tournament: @tournament, job_name: job_name)
|
||||
|
||||
# Run the job synchronously
|
||||
CalculateSchoolScoreJob.perform_sync(school)
|
||||
|
||||
# Verify the job status was removed
|
||||
assert_not TournamentJobStatus.exists?(tournament: @tournament, job_name: job_name)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user