A RESTful API built with Ruby on Rails 7 to manage a collection of GitHub-style events.
This project supports creating events, retrieving all events, viewing a specific event by ID, and filtering events by repository — all with proper validations and status codes.
- Ruby version:
3.2.2 - Rails version:
7.0.0 - Default Port:
8000 - Test Framework:
RSpec - Provided model:
Event(already implemented) - Files like
spec/*anddb/migrate/*are read-only
Each event includes the following fields:
{
"id": 1,
"event_type": "PushEvent", // Must be PushEvent, ReleaseEvent, or WatchEvent
"public": true,
"repo_id": 1,
"actor_id": 1
}
---| Field | Type | Description |
|---|---|---|
id |
Integer | Auto-assigned unique ID for each event |
event_type |
String | Must be one of "PushEvent", "ReleaseEvent", "WatchEvent" |
public |
Boolean | Indicates if the event is public |
repo_id |
Integer | ID of the repository this event belongs to |
actor_id |
Integer | ID of the user who triggered the event |
-
🔹
POST /events– Create a new event
Validations:- Only accepts valid
event_typevalues - ID is auto-assigned (starts at 1)
Responses: 201 Created– Returns full event JSON if valid400 Bad Request– Ifevent_typeis invalid
- Only accepts valid
-
🔹
GET /events– Return all events
Response:200 OK– Returns an array of events ordered by id
-
🔹
GET /events/:id– Return a specific event
Responses:200 OK– If found404 Not Found– If not found
-
🔹
GET /repos/:repo_id/events– Return all events for a repo
Response:-
200 OK– Array of events for therepo_id, ordered by id
-
git clone https://github.com/anushagundeti/github-events-api.git
cd github-events-api
🧪 Running Tests
Run the test suite using:
RAILS_ENV=test bin/rails db:migrate
RAILS_ENV=test bin/bundle exec rspec