Skip to content
Branch: master
Clone or download
Pull request Compare This branch is 206 commits ahead, 68 commits behind ets-berkeley-edu:master.
developish Merge pull request #119 from redconfetti/SISRP-46868-transfer-credit
SISRP-46868 - Fixes call for Student Overview Academic Standing
Latest commit 48f2a5b Jun 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app SISRP-44096: rename oauth token expire column May 31, 2019
bin SISRP-37608 - Upgrades Rails from 4.1.11 to 4.1.16 Apr 16, 2018
config Merge pull request #102 from redconfetti/SISRP-46771-remove-migrations Jun 5, 2019
db SISRP-44096: rename oauth token expire column May 31, 2019
docs Fix broken Markdown headings Apr 18, 2017
fixtures
lib SISRP-46771 - Remove database migration calls in CalCentral admin scr… Jun 5, 2019
log [NOJIRA] Add the log directory so `rake` works again Nov 16, 2012
public SISRP-45788 - Migrate PostgreSQL tables from CalCentral PostgreSQL to… May 17, 2019
script SISRP-46771 - Remove database migration calls in CalCentral admin scr… Jun 5, 2019
spec SISRP-44096: rename oauth token expire column May 31, 2019
src Merge pull request #119 from redconfetti/SISRP-46868-transfer-credit Jun 18, 2019
tmp CLC-4989 Set alternate tmp directory to prevent FFI error starting To… Mar 16, 2015
versions SISRP-46789: Bump version to 103 for next release Jun 10, 2019
webpack SISRP-45859 - CA Enrollment Ackn link doesn't show in IE/Firefox May 16, 2019
.csslintrc CLC-3930 - Ignore Canvas CSS file for CSSLint Jun 27, 2014
.editorconfig CalCentral-Rails start Nov 15, 2012
.eslintignore SISRP-40088 - Move from Gulp to Webpack for Front-End Build (ESLint c… Sep 6, 2018
.eslintrc.json SISRP-45745: On Academic Summary Law Student should not see UGRD Term… May 15, 2019
.gitattributes CLC-714 - Add Git Attributes file Nov 17, 2012
.gitignore SISRP-43372: adds package-lock to git and forces upgrade of errant de… Nov 2, 2018
.nvmrc NOJIRA: Update .nvmrc to latest LTS NodeJS version Apr 3, 2019
.rspec SISRP-22589 - Remove Berkeley::SummerSubTerm and dependencies Oct 2, 2017
.ruby-version NOJIRA: Specify ruby with .ruby-version Apr 3, 2019
.rvmrc Upgrades to to JRuby 9.1.14.0 Apr 16, 2018
.scss-lint.yml CLC-6433, enable ColorVariable linter (scss_lint) and fix correspondi… Aug 15, 2016
.travis.yml SISRP-44335 - Resolve Travis test failure caused by missing Bundler gem Jan 3, 2019
CONTRIBUTING.md SISRP-40088 - Move from Gulp to Webpack for Front-End Build (remove j… Sep 6, 2018
Capfile [CLC-506] Capistrano tasks for bamboo Jan 7, 2013
Gemfile SISRP-46195 - Rails update May 6, 2019
Gemfile.lock SISRP-46195 - Rails update May 6, 2019
Guardfile CLC-4015: Fix LiveReload Jul 29, 2014
LICENSE CLC-4664 - Update license to 2015 Jan 5, 2015
README.md SISRP-36642 - Mitigate remaining dependencies on legacy (ODS) databas… Apr 2, 2019
Rakefile SISRP-37608 - Downgrades Rails from 4.2.9 to 4.2.8 Apr 16, 2018
config.ru CalCentral-Rails start Nov 15, 2012
package-lock.json SISRP-46731 - Updates Axios package in CalCentral Jun 3, 2019
package.json SISRP-46731 - Updates Axios package in CalCentral Jun 3, 2019

README.md

CalCentral

Dependency Status devDependency Status Code Climate

  • Master Build: Build Status
  • QA Build: Build Status

Dependencies

Installation

  1. Install Java 8 JDK (8u172): http://www.oracle.com/technetwork/java/javase/downloads/index.html

  2. Install Postgres:

    Note: To install Postgres, you must first install Homebrew.

    Install Homebrew with the following command:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    Run the following command in Terminal after installation:

    brew --version

    Then run the following:

    brew update
    brew install postgresql
    1. For Mountain Lion & Mavericks users ONLY: Fix Postgres paths.

    2. For Mountain Lion & Mavericks users ONLY: If you can connect to Postgres via psql, but not via JDBC (you see "Connection refused" errors in the CalCentral app log), then edit /usr/local/var/postgres/pg_hba.conf and make sure you have these lines:

      host    all             all             127.0.0.1/32            md5
      host    all             all             samehost                md5
      
    3. For Mountain Lion & Mavericks users ONLY: Install XQuartz and make sure that /opt/X11/bin is on your PATH.

  3. Start Postgres, add users and create the necessary databases. (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.):

    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' createdb;
    grant all privileges on database calcentral_development to calcentral_development;
    alter database calcentral_development owner to calcentral_development;
    create database calcentral;
    create user calcentral with password 'secret' createdb;
    grant all privileges on database calcentral to calcentral;
    alter database calcentral owner to calcentral;
    create database calcentral_test;
    create user calcentral_test with password 'secret' createdb;
    grant all privileges on database calcentral_test to calcentral_test;
    alter database calcentral_test owner to calcentral_test;
    \q

    Note: At this point, exit out of Postgres. To do this, type "\q" and then press ENTER.

  4. Fork this repository, then:

    with ssh (note)

    git clone git@github.com:[your GitHub Account]/calcentral.git
    # e.g. git clone git@github.com:christianv/calcentral.git

    or via https - (note)

    git clone https://github.com/[your Github Account]/calcentral.git
    # e.g. git clone https://github.com/christianv/calcentral.git
    
  5. Go inside the calcentral repository:

    cd calcentral
    # Answer "yes" if it asks you to trust a new .rvmrc file.
  6. Install JRuby (requires ):

    Note: To install JRuby, you must first install rvm.

    rvm get head
    rvm install jruby-9.1.14.0
    cd ..
    cd calcentral
    # Answer "yes" again if it asks you to trust a new .rvmrc file.
    rvm list
    # Make sure that everything looks fine
    # If it mentions "broken", you'll need to reinstall
  7. Make JRuby faster for local development by running this or put in your .bashrc:

    export JRUBY_OPTS="--dev"
  8. Configure Default JRuby and Gemset

    cd ~
    rvm use jruby-9.1.14.0 --default # This may output 'Unknown ruby string (do not know how to handle): jruby-9.1.14.0.', which can be ignored.
    rvm gemset use global
    
  9. Download and install xvfb. On a Mac, you get xvfb by installing XQuartz.

  10. Download the appropriate gems with Bundler:

    Important: Make sure you have the JRuby-upgraded CalCentral codebase in your calcentral directory before running bundle install.

    rvm rubygems 2.5.1 --force
    gem --version
    # Should output '2.5.1'
    
    gem uninstall bundler --force -x
    gem install bundler --version="1.15.4"
    bundle install
  11. Set up a local settings directory:

    mkdir ~/.calcentral_config

    Default settings are loaded from your source code in config/settings.yml and config/settings/ENVIRONMENT_NAME.yml. For example, the configuration used when running tests with RAILS_ENV=test is determined by the combination of config/settings/test.yml and config/settings.yml. Because we don't store passwords and other sensitive data in source code, any RAILS_ENV other than test requires overriding some default settings. Do this by creating ENVIRONMENT.local.yml files in your ~/.calcentral_config directory. For example, your ~/.calcentral_config/development.local.yml file may include access tokens and URLs for a locally running Canvas server. You can also create Ruby configuration files like "settings.local.rb" and "development.local.rb" to amend the standard config/environments/*.rb files.

  12. Install JDBC driver (for Oracle connection)

    • Download ojdbc7_g.jar
    • Note: You do not have to open the file.
    • Rename the file to ojdbc7.jar
    • Copy ojdbc7.jar to ~/.rvm/rubies/jruby-9.1.14.0/lib/
  13. Initialize PostgreSQL database tables:

    bundle exec rake environment db:schema:load db:seed
  14. Make yourself powerful:

    bundle exec rake superuser:create UID=[your numeric CalNet UID]
    # e.g. rake superuser:create UID=61889
  15. Install the front-end tools:

    brew install node
    npm install
    npm install -g gulp
  16. Start the front-end development server, or kick off a Webpack build:

    # starts development server
    npm run dev
    
    # starts build process
    npm run build
  17. Start the server:

    rails s
  18. Access your rails server at localhost:3000, or the Webpack development server at localhost:3001. Do not use 127.0.0.1:3000, as you will not be able to grant access to bApps.

Note: Usually you won't have to do any of the following steps when you're developing on CalCentral.

Back-end Testing

Back-end (rspec) tests live in spec/*.

To run the tests from the command line:

rspec

To run the tests faster, use spork, which is a little server that keeps the Rails app initialized while you change code and run multiple tests against it. Command line:

spork
# (...wait a minute for startup...)
rspec --drb spec/lib/my_spec.rb

You can even run Spork right inside IntelliJ RubyMine or IDEA.

Front-end Linting

Front-end linting can be done by running the following commands:

npm run lint

This will check for any potential JavaScript issues and whether you formatted the code correctly.

Role-Aware Testing

Some features of CalCentral are only accessible to users with particular roles, such as student. These features may be invisible when logged in as yourself. In particular:

  • My Academics will only appear in the navigation if logged in as a student. However, the "Oski Bear" test student does not fake data loaded on dev and QA. To test My Academics, log in as user test-212385 or test-212381 (ask a developer for the passwords to these if you need them). Once logged in as a test student, append /academics to the URL to access My Academics.

Debugging

Emulating production mode locally

  1. Make sure you have a separate production database:

    psql postgres
    create database calcentral_production;
    grant all privileges on database calcentral_production to calcentral_development;
  2. In calcentral_config/production.local.yml, you'll need the following entries:

    secret_token: "Some random 30-char string"
    postgres: [credentials for your separate production db (copy/modify from development.local.yml)]
    google_proxy: and canvas_proxy: [copy from development.local.yml]
      application:
        serve_static_assets: true
  3. Populate the production db by invoking your production settings:

    RAILS_ENV="production" rake db:schema:load db:seed
  4. Precompile the front-end assets

    npm run build
  5. Start the server in production mode:

    rails s -e production
  6. If you're not able to connect to Google or Canvas, export the data in the oauth2 from your development db and import them into the same table in your production db.

  7. After testing, remember to remove the static assets, or run another build before the next task.

Start the server with TorqueBox

In production we use TorqueBox as this provides us with messaging, scheduling, caching, and daemons.

  1. Deploy into TorqueBox (only needs to happen once in a while):

    bundle exec torquebox deploy .
  2. Start the server:

    bundle exec torquebox run -p=3000

Test connection

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

Enable basic authentication

Basic authentication will enable you to log in without using CAS. This is necessary when your application can't be CAS authenticated or when you're testing mobile browsers. Note: only enable this in fake mode or in development.

  1. Add the following setting to your environment.yml file (e.g. development.yml):

    developer_auth:
      enabled: true
      password: topsecret!
  2. (Re)start the server for the changes to take effect.

  3. Click on the footer (Berkeley logo) when you load the page.

  4. You should be seeing the Basic Auth screen. As the login you should use a UID (e.g. 61889 for oski) and then the password from the settings file.

"Act As" another user

To help another user debug an issue, you can "become" them on CalCentral. To assume the identity of another user, you must:

  • Currently be logged in as a designated superuser
  • Be accessing a machine/server which the other user has previously logged into (e.g. from localhost, you can't act as a random student, since that student has probably never logged in at your terminal)

Access the URL:

https://[hostname]/act_as?uid=123456

where 123456 is the UID of the user to emulate.

Note: The Act As feature will only reveal data from data sources we control, e.g. Canvas. Google data will be completely suppressed, EXCEPT for test users. The following user uids have been configured as test users.

To become yourself again, access:

https://[hostname]/stop_act_as

Logging

Logging behavior and destination can be controlled from the command line or shell scripts via env variables:

  • LOGGER_STDOUT=false - Only log to the default files
  • LOGGER_STDOUT=true - Log to standard output as well as the default files
  • LOGGER_STDOUT=only - Only log to standard output
  • LOGGER_LEVEL=DEBUG - Set logging level; acceptable values are 'FATAL', 'ERROR', 'WARN', 'INFO', and 'DEBUG'

Tips

  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/RubyMine.app/Contents/MacOS/rubymine &
  2. If you want to explore the Oracle database on Mac OS X, use SQL Developer.

Styleguide

See docs/styleguide.md.

Creating timeshifted fake data feeds

Proxies running in fake mode use WebMock to substitute fixture data for connections to external services (Canvas, Google, etc). This fake data lives in fixtures/json and fixtures/xml.

Fixture files can represent time information by tokens that are substituted with appropriately shifted values when fixture data is loaded. See config/initializers/timeshift.rb for the dictionary of substitutions.

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

Installing Memcached:

Dev, QA, and Production CalCentral environments use memcached as a cache store in place of the default ActiveSupport cache store.

To set this up locally, perform the following steps:

  1. Install and run memcached.

  2. Add the following lines to development.local.yml:

cache:
  store: "memcached"

Memcached tasks:

A few rake tasks to help monitor statistics and more:

  • rake memcached:clear - Invalidate all memcached keys and reset memcached stats from all cluster nodes.

  • rake memcached:get_stats - Fetch memcached stats from all cluster nodes. Per-slab stats may point out specific types of data which are being overcached or undercached, or indicate a need to reconfigure memcached.

  • rake memcached:dump_slab slab=NUMBER - Shows which cached items are currently stored in the "slab" with the given ID. The list won't include the keys of expired or evicted items.

  • WARNING: do not run rake memcached:clear on the production cluster unless you know what you're doing!

  • All memcached tasks take the optional param of hosts. So, if say you weren't running these tasks on the cluster layers themselves, or only wanted to tinker with a certain subset of clusters: rake memcached:get_stats hosts="localhost:11212,localhost:11213,localhost:11214"

Using the feature toggle:

To selectively enable/disable a feature, add a property to the features section of settings.yml, e.g.:

features:
  wizbang: false
  neato: true

After server restart, these properties will appear in each users' status feed. You can now use data-ng-if in Angular to wrap the feature:

<div data-ng-if="user.profile.features.neato">
  Some neato feature...
</div>

Keeping developer seed data updated

seeds.rb is intended for use only on developer machines, so they have a semi-realistic copy of production lists of superusers, links, etc. ./db/developer-seed-data.sql has the data used by rake db:seed. Occasionally we'll want to update it from production. To do that, log into a prod node and do:

pg_dump calcentral -O -x --inserts --clean -f developer-seed-data.sql -t link_categories \
-t link_categories_link_sections -t link_sections -t link_sections_links -t links \
-t links_user_roles -t user_auths -t user_roles -t fin_aid_years \
-h postgres-hostname -p postgres-port-number -U calcentral

Copy the file into your source tree and get it merged into master.

Living Styleguide

The SCSS files under src/assets/stylesheets contain a style of notation known as KSS, which are used to generate a living styleguide via SC-5 Styleguide. See source at Github.

To generate this styleguide run:

gulp styleguide

This will generate the styleguide in public/styleguide, which will open automatically in your browser at http://localhost:3006/. Modifications to SCSS files under /src/assets/stylesheets are watched and reloaded into the guide on-the-fly.

You can’t perform that action at this time.