/
Dmitry-F
/
cbt_tool
Обзор
Документация
Войти
/
Dmitry-F
/
cbt_tool
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
python-ml-service
test/controllers/clients_controller_test.rb
56 строк
2 KB
Dmitriy-Filatov
test: завершение модульных тестов
27 мар 2026, 15:10
27 мар 2026, 15:10
5327127
Код
Авторство
О чём код?
require "test_helper" class ClientsControllerTest < ActionDispatch::IntegrationTest include FactoryBot::Syntax::Methods def setup @therapist = create(:therapist, email: "test@example.com", password: "password123") @client = create(:client, name: "Иван Петров", therapist: @therapist) post auth_signin_path, params: { email: @therapist.email, password: "password123" } end test "should get index" do get clients_path assert_response :success end test "should get show" do get client_path(@client) assert_response :success end test "should get new" do get new_client_path assert_response :success end test "should create client" do assert_difference('Client.count', 1) do post clients_path, params: { client: { name: "Новый Клиент", email: "new@example.com", therapist_id: @therapist.id } } end assert_redirected_to clients_path assert_equal "Клиент успешно создан", flash[:notice] end test "should not create client without name" do assert_no_difference('Client.count') do post clients_path, params: { client: { name: "", email: "new@example.com", therapist_id: @therapist.id } } end assert_response :unprocessable_entity end test "should update client" do patch client_path(@client), params: { client: { name: "Иван Сидоров" } } assert_redirected_to client_path(@client) @client.reload assert_equal "Иван Сидоров", @client.name end test "should destroy client" do assert_difference('Client.count', -1) do delete client_path(@client) end assert_redirected_to clients_path end end