Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

212 lines (167 sloc) 7.781 kb


Home of CalCentral. Build status for calcentral Dependency Status Code Climate



  1. Install postgres
brew update
brew install postgresql
initdb /usr/local/var/postgres
  1. Start postgres, add the user and create the necessary databases
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
psql postgres
create database calcentral_development;
create user calcentral_development with password 'secret';
grant all privileges on database calcentral_development to calcentral_development;
create database calcentral;
create user calcentral with password 'secret';
grant all privileges on database calcentral to calcentral;
create database calcentral_test;
create user calcentral_test with password 'secret';
grant all privileges on database calcentral_test to calcentral_test;

(If your PostgreSQL server is managed externally, you'll probably need to create a schema that matches the database username. See CLC-893 for details.)

  1. Fork this repository, then:
git clone[your_github_acct]/calcentral.git
  1. Go inside the calcentral repository
cd calcentral
# Answer "yes" if it asks you to trust a new .rvmrc file.
  1. Install jruby
rvm get head
rvm install jruby-1.7.2
cd ..
cd calcentral
# Answer "yes" again if it asks you to trust a new .rvmrc file.
  1. (Optional for development) Make JRuby faster & enable C extensions by running this or put in your .bashrc:
export JRUBY_OPTS="-Xcext.enabled=true -J-d32 -J-client -X-C"
  • WARNING: Do not switch between 32-bit and 64-bit JRuby after your gemset has been initialized (your bundle library will have serious issues). If you do need to change settings, make sure to reinitialize your gemset:
    • rvm gemset delete calcentral
    • (set your JRUBY_OPTS)
    • bundle install
  1. Download the appropriate gems with Bundler
bundle install
  1. Copy and update the settings
mkdir ~/.calcentral_config
cp config/settings.yml ~/.calcentral_config/settings.local.yml
cp config/settings/testext.yml ~/.calcentral_config/testext.local.yml
cp config/settings/development.yml ~/.calcentral_config/development.local.yml
cp config/settings/production.yml ~/.calcentral_config/production.local.yml

and update the settings in the .local.yml files. Settings live outside of the project dir to prevent accidental commits to the repo. You can also create Ruby configuration files like "settings.local.rb" and "development.local.rb" to amend the standard config/environments/*.rb files.

  1. Install JDBC driver (for Oracle connection) You may already have an Oracle driver from MyBerkeley-OAE development, in which case you just need to copy it to your local JRuby installation: cp ~/.m2/repository/com/oracle/ojdbc6/ ~/.rvm/rubies/jruby-1.7.2/lib/

    • Otherwise, download ojdbc6.jar
    • Copy ojdbc6.jar to your local JRuby installation; e.g. ~/.rvm/rubies/jruby-1.7.2/lib/
  2. Initialize PostgreSQL database tables

rake db:schema:load
  1. Start the server
rails s
  1. Access your development server at localhost:3000. Do not use, as you will not be able to grant access to bApps.

Front-end Testing

Front-end jasmine tests live in spec/javascripts/calcentral/*.

To view results of front-end tests, run rake jasmine in a separate terminal, then visit localhost:8888.


Emulating production mode locally

  1. Precompile the assets: (more info)
bundle exec rake assets:precompile
  1. Serve static assets through rails
config.serve_static_assets = true
  1. Start the server in production mode
rails s -e production
  1. After testing, remove the static assets and generated pages
bundle exec rake assets:clean
rm public/index.html
# remove other pages ...

Test connection

Make sure you are on the Berkeley network or connected through preconfigured VPN for the Oracle connection. If you use VPN, use group #1 (1-Campus_VPN)


  1. On Mac OS X, to get RubyMine to pick up the necessary environment variables, open a new shell, set the environment variables, and:
/Applications/ &
  1. If you want to explore the Oracle database on Mac OS X, use SQL Developer


  • Use an editor that supports .editorconfig. Feel free to have a look at the editor plug-ins
  • Use 2 spaces for indentation
  • List items/properties alphabetically
  • Remove console.log() messages when committing your code.
  • Only use anchor tags <a> for actual links, otherwise use <button> instead. This is especially important for IE9.
  • Use single quotes when possible


var name="Christian Vuerings";


var name='Christian Vuerings';
  • Use data-ng- instead of ng- or ng: and add data- for directives


<span ng-bind="name"></span>
<input mmddyyvalidator />


<div data-ng-view></div>
<span data-ng-bind="name"></span>
<input data-mmddyyvalidator />

Recording fake data feeds and timeshifting them

Make sure your testext.local.yml file has real connections to real external services that are fakeable (Canvas, Google, etc). Now do:

rake vcr:record
rake vcr:prettify
  • vcr:record can also take a SPEC=".../my_favorite_spec.rb" to help limit the recordings.
  • vcr:prettify can also take a REGEX_FILTER="my_raw_recording.json" to target a specific raw file.

You can now find the prettified files in fixtures/pretty_vcr_recordings. You can edit these files to put in tokens that will be substituted on server startup. See config/initializers/timeshift.rb for the dictionary of substitutions. Edit the debug_json property of each response, and timeshift.rb will automatically convert debug_json to the format actually used by VCR.

Rake tasks:

To view other rake task for the project: rake -T

  • rake spec:xml - Runs rake spec, but pipes the output to xml using the rspec_junit_formatter gem, for JUnit compatible test result reports
  • rake vcr:record - Refresh vcr recordings and reformats the fixtures with formatted JSON output. Will also parse the reponse body's string into json output for legibility.
  • rake vcr:list - List the available recordings captured in the fixtures.
Jump to Line
Something went wrong with that request. Please try again.