An example Ruby on Rails application that can import information and display it.
The application comes from a coding test, and I decided to take it on just because I felt like I had not created a Rails application from scratch for a while.
The application is currently deployed here using Heroku.
I wrote more about this codebase, and my rationale for all the major development decisions, in the following blog post:
- Ruby 3.1.2
- Rails 6.1.6
- NodeJS 14.6.1 (locked to version 14.x since it is the latest node-sass currently supports)
git clone https://github.com/paulfioravanti/sentia-coding-test.git
cd senta-coding-test
bundle install
bin/rails db:init
yarnbin/rails serverOpen http://localhost:3000 in a browser and you should be greeted with an empty table.
The original CSV file containing the data that the application must be able to import can be found at:
test/fixtures/files/SentiaCodingTestData.csvThis is the file that can be selected upon pressing the "Import Data" button to import the required data.
During development, I also recreated the seed data in Rails fixtures files,
which can be found under the test/fixtures directory. These can be loaded
into the database on the command line:
bin/rails db:fixtures:loadI often tested the logic in the file importer modules themselves via the Rails console, so the data can also be imported in the following way:
bin/rails console
irb(main):001:0> file = File.open("#{Rails.root}/test/fixtures/files/SentiaCodingTestData.csv")
irb(main):002:0> DataImporter.import(file)Push to Heroku with the following command:
git push heroku mainNo tests. Too lazy for this one.
You will be required to create a Ruby on Rails application with the following features below. The sample CSV data required for the test can be found here. This application can be built in 1 hour.
Below is a list of user stories and requirements for each section of this application.
PART 1
-
As a user, I should be able to upload this sample CSV and import the data into a database.
IMPORTER REQUIREMENTS
a. The data needs to load into 3 tables. People, Locations and Affiliations
b. A Person can belong to many Locations
c. A Person can belong to many Affiliations
d. A Person without an Affiliation should be skipped
e. A Person should have both a first_name and last_name. All fields need to be validated except for last_name, weapon and vehicle which are optional.
f. Names and Locations should all be titlecased
PART 2
- As a user, I should be able to view these results from the importer in a table.
- As a user, I should be able to paginate through the results so that I can see a maximum of 10 results at a time.
- As a user, I want to type in a search box so that I can filter the results I want to see.
- As a user, I want to be able to click on a table column heading to reorder the visible results.
Once the test has been completed. Please upload to Git Repo/Google Drive/DropBox or zip and email over back to <person> at <person's email>.
