On my first day at work, I worked on a few onboarding tasks like setting up the official mail id, Slack, Freshbooks and mailing my details to HR. Post that, I was assigned a task to build a leave management system and allotted a month to finish the project. The task was further sub-divided into several sub-tasks and after completing each sub-task, I needed to raise a PR(pull request) for review.
The above image is taken from Unsplash.
The second day, I started with the first sub-task which was to create the Rails app and to avoid fixtures from generating. Fixtures are dummy objects that can be fed to run the unit tests without using the actual Active Record objects. Instead of fixtures, we now use a gem called Factory bot (it was originally called Factory girl).
On the third day, I started setting up GitHub actions. It is similar to the pre-commit hooks, but the catch is that the checks happen when we raise a PR or when we push to a remote branch. I added Rubocop, Eslint, Prettier, and RSpec ( a testing framework for Ruby ) in the GitHub actions file, so that say if the test cases are failing then that check will fail.
It’s on this day that I started building the app. I created the model - the ‘M’ in the MVC - Model View Controller pattern which deals with databases for users. I added validations that the first name, last name, email id in the ‘users’ table are required fields. I also added length validation for names and deployed not-null constraints at the database level. Next, I added unit tests using RSpec for all the validations in the user model. I also set up factory bot gem (the one we are using now instead of fixtures) to set up dummy Active Record models for writing test cases.
On the same day, I also started working on adding two roles - admin and employee. I used enums to create the roles. The default role is of an employee. Since I couldn’t complete this task on the same day, I created a work-in-progress (WIP) PR for that. The next day, I had to add RSpec tests for this role attribute and set up a devise gem (used for authentication).
On the next day, i.e. fourth day, I set up the devise and also wrote the RSpec tests, and also began working on the next sub-task which was to add a rake task to create an admin user for the application. We just needed to run this rake task and voila! the admin user gets created, allowing the admin to create other users.”
I had a great learning experience completing the aforementioned tasks. I had never used the package.json file before. Hence, learning to work with these files using the yarn add command, add the packages to the package.json file, and the yarn command to build the yarn.lock file. was really beneficial to me. I also learned how to use GitHub actions. However, for the Rails part, it was relatively easier for me, though I had a few hiccups here and there in writing unit tests, my mentor helped me immensely for which I could complete the task at ease.