HR Presence is an API for managing the moment when an employee of a company arrives and leaves on a certain day. It generates reports with the presence of employees through time.
It has two types of users:
- Employee: can log in to the system and check a report with the moment they arrived and left in the last days
- Administrator: can manage employees, their reports and the precise moment when an employee arrived or left on a certain day. This type of user is in charge of "marking" those moments.
A sample API can be found here.
Sample data includes:
- 2 employees: both with days worked for a period of 1 month
- User 1 (
[email protected]
). No report created - User 2 (
[email protected]
). A report created including half a month
- User 1 (
- 1 administrator:
- Administrator (
[email protected]
)
- Administrator (
- Only administrators can manage employees reports. Employees can only see their corresponding report.
- The system was built thinking on a single company or organization. Multiple companies would require different running instances of the API.
- Administrators have the ability to register new employees. There is no registration or sign up process. Administrators can also modify/remove existing users, and create new administrator users.
- Authentication is needed to perform every operation on the system. This is accomplished using JWTs. When a user enters their credentials, a token is sent back to them, and it's the user's (client) responsibility to include it inside the
Authorization
header on subsequent requests. - Reports are not automatically generated, but they should be created by an administrator. When this happens, that administrator needs to specify a start date and an end date for the employee report. By doing so, the report will consist of the days the employee worked, limited by the mentioned dates. If no report exists, then the last month will be shown by default.
- Related to the previous point, an administrator can (and very likely will) update the dates of an employee report, to keep them aware of their presence on the company, or can even delete the report (which will cause to use the default dates).
The API endpoints specification can be found on the wiki.
- Ruby 2.6.5
- Ruby on Rails 5.2.3
- PostgreSQL 11.5
- Heroku (Sample API)
For development follow the next steps.
- Install Ruby version
2.6.5
- Clone the repository
- Inside the root of the repository, run
bundle install
to install gem dependencies - Configure database running the following:
rails db:create db:migrate rails db:seed
- Set the
DEVISE_JWT_SECRET_KEY
env variable to a convenient key. A random key can be generated runningbundle exec rake secret
. If you usedirenv
shell extension, you can create a.envrc
file on the root of the project and add this env variable there. - Run
rails server
, which will initiate a local web server with the application running on port3000
.
RSpec is used in this project. You can run the test suite with the following:
bundle exec rspec
The types of specs present are:
- Request specs for all endpoints
- Model specs for all models
- Paginate resources
- Standardize errors