2025-08-19 07:24:18 +02:00
|
|
|
# ZSTerminator -
|
2024-08-04 07:06:03 +02:00
|
|
|
|
|
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
## Setup
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
* Ruby version: 3.2.4
|
|
|
|
|
* Rails version: 7.1.5+
|
|
|
|
|
* Database: SQLite3
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
## Getting Started
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
1. Install dependencies:
|
|
|
|
|
```bash
|
|
|
|
|
bundle install
|
|
|
|
|
```
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
2. Setup database:
|
|
|
|
|
```bash
|
|
|
|
|
rails db:create
|
|
|
|
|
rails db:migrate
|
|
|
|
|
rails db:seed
|
|
|
|
|
```
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
3. Start the server:
|
|
|
|
|
```bash
|
|
|
|
|
rails server
|
|
|
|
|
```
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
4. Visit http://localhost:3000 and login with:
|
|
|
|
|
- Username: `admin`
|
|
|
|
|
- Password: `password123`
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
## User Management (Rake Tasks)
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
This project includes Rake tasks for managing users via command line:
|
2024-08-04 07:06:03 +02:00
|
|
|
|
2025-08-19 07:24:18 +02:00
|
|
|
### Available Commands
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# List all users
|
|
|
|
|
rails users:list
|
|
|
|
|
|
|
|
|
|
# Show user details
|
|
|
|
|
rails users:show[username]
|
|
|
|
|
|
|
|
|
|
# Create a new user
|
|
|
|
|
rails users:create[username,email,password,company_id]
|
|
|
|
|
|
|
|
|
|
# Change user password
|
|
|
|
|
rails users:change_password[username,new_password]
|
|
|
|
|
|
|
|
|
|
# Delete a user
|
|
|
|
|
rails users:delete[username]
|
|
|
|
|
|
|
|
|
|
# Clean up test users (users with 'test' in username/email)
|
|
|
|
|
rails users:cleanup_test_users
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Usage Examples
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Create a new user (company_id is optional, uses first company if blank)
|
|
|
|
|
rails "users:create[john,john@example.com,securepass123]"
|
|
|
|
|
|
|
|
|
|
# Change password
|
|
|
|
|
rails "users:change_password[john,newpassword456]"
|
|
|
|
|
|
|
|
|
|
# Show user information
|
|
|
|
|
rails users:show[john]
|
|
|
|
|
|
|
|
|
|
# Delete user (with confirmation)
|
|
|
|
|
rails users:delete[john]
|
|
|
|
|
|
|
|
|
|
# List all users in a formatted table
|
|
|
|
|
rails users:list
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Automated Testing
|
|
|
|
|
|
|
|
|
|
**Run complete CRUD test suite:**
|
|
|
|
|
```bash
|
|
|
|
|
# Single command to test all user operations automatically
|
|
|
|
|
rails users:test_crud
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This automated test will:
|
|
|
|
|
1. **Create** test users (dodavanje)
|
|
|
|
|
2. **List** created users
|
|
|
|
|
3. **Change** password (mijenjanje sifre)
|
|
|
|
|
4. **Show** user details
|
|
|
|
|
5. **Delete** user (brisanje)
|
|
|
|
|
6. **Clean up** all test data
|
|
|
|
|
|
|
|
|
|
### Manual Testing Workflow
|
|
|
|
|
|
|
|
|
|
1. **Create test users:**
|
|
|
|
|
```bash
|
|
|
|
|
rails "users:create[testuser1,test1@example.com,testpass123]"
|
|
|
|
|
rails "users:create[testuser2,test2@example.com,testpass456]"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. **Test your application** with the created users
|
|
|
|
|
|
|
|
|
|
3. **Clean up test data:**
|
|
|
|
|
```bash
|
|
|
|
|
# This will find and delete all users with 'test' in username or email
|
|
|
|
|
rails users:cleanup_test_users
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Notes
|
|
|
|
|
|
|
|
|
|
- All user passwords are encrypted using bcrypt
|
|
|
|
|
- Users must belong to a company
|
|
|
|
|
- Username and email must be unique
|
|
|
|
|
- Minimum password length is 6 characters
|
|
|
|
|
- The cleanup task only removes users with 'test' in their username or email for safety
|