/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
test/controllers/therapists_controller_test.rb
94 строки
2 KB
Dmitriy-Filatov
test: завершение модульного тестирования
27 мар 2026, 16:31
27 мар 2026, 16:31
256daf8
Код
Авторство
О чём код?
require "test_helper" class TherapistsControllerTest < ActionDispatch::IntegrationTest include FactoryBot::Syntax::Methods def setup @therapist = create(:therapist, email: "existing@example.com", password: "password123") post auth_signin_path, params: { email: @therapist.email, password: "password123" } end test "should get new" do get new_therapist_path assert_response :success end test "should create therapist" do assert_difference('Therapist.count', 1) do post therapists_path, params: { therapist: { email: "new@example.com", password: "password123", name: "Новый Терапевт" } } end assert_redirected_to root_path assert_match /Добро пожаловать/, flash[:notice] end test "should not create therapist with existing email" do assert_no_difference('Therapist.count') do post therapists_path, params: { therapist: { email: "existing@example.com", password: "password123", name: "Дубль" } } end assert_response :unprocessable_entity end test "should not create therapist without name" do assert_no_difference('Therapist.count') do post therapists_path, params: { therapist: { email: "no-name@example.com", password: "password123", name: "" } } end assert_response :unprocessable_entity end test "should not create therapist without password" do assert_no_difference('Therapist.count') do post therapists_path, params: { therapist: { email: "no-password@example.com", password: "", name: "Без Пароля" } } end assert_response :unprocessable_entity end test "should get show" do get therapist_path(@therapist) assert_response :success end test "should get edit" do get edit_therapist_path(@therapist) assert_response :success end test "should update therapist" do patch therapist_path(@therapist), params: { therapist: { name: "Обновлённый Терапевт" } } assert_redirected_to therapist_path(@therapist) @therapist.reload assert_equal "Обновлённый Терапевт", @therapist.name end test "should destroy therapist" do assert_difference('Therapist.count', -1) do delete therapist_path(@therapist) end assert_redirected_to therapists_path end end