Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back-End Engineering Intern Assessment #202

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ab-syntaxerror
Copy link

This pull request introduces several changes to the Article model and its corresponding database table. The main goal of these changes was to add new attributes to the Article model and ensure that our unit tests pass successfully.

I started with adding the content attribute to the Article model: My initial approach was addressing each test failure as it came up in each unit test, and working my way down. The first test failure that was caused by the Article model not having a content attribute.

To fix this, I generated a migration to add a content column to the articles table in the database. The content attribute is of type text, which allows me to store large amounts of text.

Next was adding the author attribute to the Article model. The second test failure that I encountered was due to the Article model not having an author attribute. I generated another migration to add an author column to the articles table. The author attribute is of type string.

Next, I had to add the search method to the Article model. I learned this when I encountered a test failure because the Article model did not have a search method. I added a search class method to the Article model. This method takes a query parameter and returns all articles where the title or content contains the query string.

Finally, I had to add the date attribute to the Article model. I learned this when I encountered a test failure due to the Article model not having a date attribute. I generated a migration to add a date column to the articles table. The date attribute is of type datetime.

After each migration, I ran rails db:migrate to apply the changes to the database, and rails db:test:prepare to ensure that the test database was up to date with the development database.

Conclusion
With these changes, we have extended the Article model with new attributes and ensured that our unit tests pass successfully. These additions will allow us to store more detailed information about each article and provide better functionality in our application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant