Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RecordNotFound bug for application associated workshops that have been deleted #20905

Merged
merged 1 commit into from Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -56,7 +56,7 @@ def destroy_autoenrollment
end

def workshop
Pd::Workshop.find(pd_workshop_id) if pd_workshop_id
Pd::Workshop.find_by(id: pd_workshop_id) if pd_workshop_id
end

# override
Expand Down
2 changes: 2 additions & 0 deletions dashboard/test/factories/pd_factories.rb
Expand Up @@ -738,6 +738,8 @@
end
end

factory :pd_workshop_autoenrolled_application, parent: :pd_teacher1819_application

# default to do_you_approve: other
factory :pd_principal_approval1819_application_hash, parent: :pd_principal_approval1819_application_hash_common do
approved_other
Expand Down
@@ -0,0 +1,21 @@
require 'test_helper'
require 'cdo/shared_constants/pd/teacher1819_application_constants'

module Pd::Application
class WorkshopAutoenrolledApplicationTest < ActiveSupport::TestCase
self.use_transactional_test_case = true
setup_all do
@workshop = create :pd_workshop
@application = create :pd_workshop_autoenrolled_application, pd_workshop_id: @workshop.id
end

test 'application.workshop returns the workshop associated with the assigned id' do
assert_equal @workshop, @application.workshop
end

test 'application.workshop returns nil if the assigned workshop has been deleted' do
@workshop.destroy!
assert_nil @application.workshop
end
end
end