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

edit redirect to use current path #33

Merged
merged 1 commit into from
Feb 28, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/controllers/teachers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,12 @@ def destroy

def resend_welcome_email
if @teacher.validated? || @is_admin
TeacherMailer.welcome_email(@teacher).deliver_now
flash[:success] = "Welcome email resent successfully!"
TeacherMailer.welcome_email(@teacher).deliver_now
else
flash[:alert] = "Error resending welcome email. \
Please ensure that your account has been validated by an administrator."
flash[:alert] = "Error resending welcome email. Please ensure that your account has been validated by an administrator."
end
redirect_to edit_teacher_path(@teacher)
redirect_back(fallback_location: dashboard_path)
end

def import
Expand Down
7 changes: 4 additions & 3 deletions spec/controllers/teachers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
it "succeeds when teacher is validated, sets success" do
ApplicationController.any_instance.stub(:current_user).and_return(Teacher.find_by(first_name: "Validated"))
validated_teacher = Teacher.find_by(first_name: "Validated")
request.env["HTTP_REFERER"] = edit_teacher_path(validated_teacher.id)
post :resend_welcome_email, params: { id: validated_teacher.id }
expect(flash[:success]).to eq("Welcome email resent successfully!")
expect(response).to redirect_to(edit_teacher_path(validated_teacher.id))
Expand All @@ -196,10 +197,10 @@
it "fails when teacher is not validated, sets alert" do
ApplicationController.any_instance.stub(:current_user).and_return(Teacher.find_by(first_name: "Short"))
nonvalidated_teacher = Teacher.find_by(first_name: "Short")
request.env["HTTP_REFERER"] = teacher_path(nonvalidated_teacher.id)
post :resend_welcome_email, params: { id: nonvalidated_teacher.id }
expect(flash[:alert]).to eq("Error resending welcome email. \
Please ensure that your account has been validated by an administrator.")
expect(response).to redirect_to(edit_teacher_path(nonvalidated_teacher.id))
expect(flash[:alert]).to eq("Error resending welcome email. Please ensure that your account has been validated by an administrator.")
expect(response).to redirect_to(teacher_path(nonvalidated_teacher.id))
end
end
end
Loading