Simple reminder system for ringley tech test
You will find the reminder in lib/ringley_reminder.rb, it is fully configurable, check the code of reminder_controller#index of the sample rails app I provide.
You can add as many new rules you want, setting their due time with a simple ActiveSupport Date object (1.month, 1.day, (1.week - 1.day), …)
rules = [ { :period => 'quarterly', :time => 1.month }, { :period => 'twice_a_year', :time => 2.month } ] reminder = RingleyReminder.new(rules) check_date = Date.strptime('01/01/2013', '%d/%m/%Y') estates = ['0066S', '0123S', '0250S'] reminders = reminder.on(check_date, estates)
git clone git@github.com:htatche/ringley_reminder.git cd ringley_reminder rails s Open your browser and go to localhost:3000/reminder Finnally, you can add as many new estates and due dates you want on localhost:3000/charges
To use it in another rails app, just grab the migration files from db/migrate and do:
rails g model Charge rake db:migrate:all (this will create the charges table)
You could also run it in a console app just doing require ‘active_record’ and setting the database connection.
Just run rake test ! This will create the test database and feed it with db/fixtures/charges.yml
-
Test file for ReminderController was auto-generated by rails g scaffold reminders, I didn’t push it further because is out of scope of this tech test.
-
The RingleyReminder class has it’s own test file, that is the important one !
Hervé Tatche