/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
test/controllers/sessions_controller_test.rb
64 строки
2 KB
Dmitriy-Filatov
test: завершение модульных тестов
27 мар 2026, 15:10
27 мар 2026, 15:10
5327127
Код
Авторство
О чём код?
require "test_helper" class SessionsControllerTest < ActionDispatch::IntegrationTest include FactoryBot::Syntax::Methods def setup @therapist = create(:therapist, email: "test@example.com", password: "password123") @client = create(:client, therapist: @therapist) post auth_signin_path, params: { email: @therapist.email, password: "password123" } end test "should get index" do get client_sessions_path(@client) assert_response :success end test "should get new" do get new_client_session_path(@client) assert_response :success end test "should create session" do assert_difference('Session.count', 1) do post client_sessions_path(@client), params: { session: { topic: "Новая сессия", session_date: Date.tomorrow, notes: "Заметки" } } end assert_redirected_to client_path(@client) end test "should not create session without topic" do assert_no_difference('Session.count') do post client_sessions_path(@client), params: { session: { topic: "", session_date: Date.tomorrow } } end assert_response :unprocessable_entity end test "should get show" do session = create(:session, client: @client, therapist: @therapist, session_date: Date.tomorrow) get client_session_path(@client, session) assert_response :success end test "should get edit" do session = create(:session, client: @client, therapist: @therapist, session_date: Date.tomorrow) get edit_client_session_path(@client, session) assert_response :success end test "should update session" do session = create(:session, client: @client, therapist: @therapist, session_date: Date.tomorrow) patch client_session_path(@client, session), params: { session: { topic: "Обновленная тема" } } assert_redirected_to client_session_path(@client, session) session.reload assert_equal "Обновленная тема", session.topic end test "should destroy session" do session = create(:session, client: @client, therapist: @therapist, session_date: Date.tomorrow) assert_difference('Session.count', -1) do delete client_session_path(@client, session) end assert_redirected_to client_path(@client) end end