chore: init commit
in worker.../repo/GITFOLDER.zip is the .git folder.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
module Admin
|
||||
module Teachers
|
||||
class DeactivationsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@admin = create(:admin, admin: true)
|
||||
sign_in(@admin)
|
||||
|
||||
@classroom1 = create(:classroom, name: "Math 101")
|
||||
@teacher1 = create(:teacher, username: "teacher1", email: "teacher1@example.com")
|
||||
@teacher1.classrooms << @classroom1
|
||||
end
|
||||
|
||||
test "should deactivate teacher" do
|
||||
assert_no_difference("Teacher.count") do
|
||||
post admin_teacher_deactivation_path(@teacher1)
|
||||
end
|
||||
|
||||
assert_redirected_to admin_teachers_path
|
||||
assert_equal "Teacher teacher1@example.com deactivated successfully.", flash[:notice]
|
||||
assert @teacher1.reload.discarded?
|
||||
end
|
||||
|
||||
test "deactivate should soft delete teacher and remove from active list" do
|
||||
post admin_teacher_deactivation_path(@teacher1)
|
||||
|
||||
# Teacher should still exist in database
|
||||
assert_not_nil Teacher.with_discarded.find_by(id: @teacher1.id)
|
||||
# But should not appear in kept scope
|
||||
assert_nil Teacher.kept.find_by(id: @teacher1.id)
|
||||
|
||||
follow_redirect!
|
||||
|
||||
# Should not appear on the default (active) index
|
||||
assert_select "##{dom_id(@teacher1)}", count: 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
module Admin
|
||||
module Teachers
|
||||
class ReactivationsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@admin = create(:admin, admin: true)
|
||||
sign_in(@admin)
|
||||
|
||||
@classroom1 = create(:classroom, name: "Math 101")
|
||||
@teacher1 = create(:teacher, username: "teacher1", email: "teacher1@example.com")
|
||||
@teacher1.classrooms << @classroom1
|
||||
end
|
||||
|
||||
test "should reactivate deactivated teacher" do
|
||||
@teacher1.discard
|
||||
|
||||
assert @teacher1.discarded?
|
||||
|
||||
post admin_teacher_reactivation_path(@teacher1)
|
||||
|
||||
assert_redirected_to admin_teachers_path
|
||||
assert_equal "Teacher teacher1@example.com reactivated successfully.", flash[:notice]
|
||||
assert_not @teacher1.reload.discarded?
|
||||
end
|
||||
|
||||
test "reactivate should restore teacher to active status and appear in active list" do
|
||||
@teacher1.discard
|
||||
assert_not_nil @teacher1.reload.discarded_at
|
||||
|
||||
post admin_teacher_reactivation_path(@teacher1)
|
||||
|
||||
# Should clear discarded_at timestamp
|
||||
assert_nil @teacher1.reload.discarded_at
|
||||
|
||||
follow_redirect!
|
||||
|
||||
# Should appear on the default (active) index
|
||||
assert_select "##{dom_id(@teacher1)}", count: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user