From e421dfe678eb50f27a105e6353816b0dec347704 Mon Sep 17 00:00:00 2001 From: Muhamed <Muhamedalici@hotmail.de> Date: Sun, 18 May 2025 04:40:13 +0200 Subject: [PATCH] Context: - You are working on a project that involves a web application. - The application uses a database to store user data. - You are implementing a feature that allows users to update their profile information. - The diffs include changes to the user profile update form and the backend logic to handle the update. Diffs: ```diff diff --git a/app/models/user.rb b/app/models/user.rb index 1234567..89abcde 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,7 @@ class User < ApplicationRecord # User attributes + attribute :name, :string + attribute :email, :string # Validations validates :name, presence: true diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 7654321..8765432 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,5 +1,7 @@ <h1>Edit Profile</h1> +<%= form.label :name %> +<%= form.text_field :name %> <%= form.label :email %> <%= form.text_field :email %> diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3456789..9876543 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,7 @@ class UsersController < ApplicationController before_action :set_user, only: [:show, :edit, :update, :destroy] + def update + @user.update(user_params) + redirect_to @user + end + private def set_user @@ -8,4 +10,6 @@ class UsersController < ApplicationController params.require(:user).permit(:name, :email) end end + +# Add user_params method to allow name and email attributes ``` Commit message: ``` feat: add name and email attributes to user model and update user profile form ``` --- test_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_api.py b/test_api.py index 8e45eec..4870a9f 100644 --- a/test_api.py +++ b/test_api.py @@ -2,6 +2,9 @@ import unittest import json from unittest.mock import patch from api import app, rover +from mission_control import MissionControl + + class TestDriveEndpoint(unittest.TestCase): """Testfälle für den /drive Endpunkt basierend auf der OpenAPI-Spezifikation""" @@ -58,7 +61,7 @@ class TestDriveEndpoint(unittest.TestCase): content_type='application/json') self.assertEqual(response.status_code, 200) data = json.loads(response.data) - self.assertIn('executed_commands', data) + self.assertIn('successful_commands', data) # Prüfen, dass nur die gültigen Befehle ausgeführt wurden self.assertEqual(data['executed_commands'], 'FB') -- GitLab