From 702e7182737d212c397ac9bb8565f5abf12caf91 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Sun, 26 Apr 2015 21:10:35 -0700 Subject: [PATCH] code comments and readme tweaks --- README.md | 32 ++++++++++++++++------- app/controllers/application_controller.rb | 20 ++++++++++---- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9a208f5..f521406 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,38 @@ # [snap-cloud][hk-app] A CS169 Project to create a new cloud sharing system for [Snap!][sbe]. -* [![Code Climate](https://codeclimate.com/github/snap-cloud/snap-cloud/badges/gpa.svg)](https://codeclimate.com/github/snap-cloud/snap-cloud) +[![Code Climate](https://codeclimate.com/github/snap-cloud/snap-cloud/badges/gpa.svg)](https://codeclimate.com/github/snap-cloud/snap-cloud) [![Build Status](https://travis-ci.org/snap-cloud/snap-cloud.svg?branch=master)](https://travis-ci.org/snap-cloud/snap-cloud) [![Coverage Status](https://coveralls.io/repos/snap-cloud/snap-cloud/badge.svg?branch=master)](https://coveralls.io/r/snap-cloud/snap-cloud?branch=master) [![Test Coverage](https://codeclimate.com/github/snap-cloud/snap-cloud/badges/coverage.svg)](https://codeclimate.com/github/snap-cloud/snap-cloud) [![Inline docs](http://inch-ci.org/github/snap-cloud/snap-cloud.svg?branch=master)](http://inch-ci.org/github/snap-cloud/snap-cloud) [![Dependency Status](https://gemnasium.com/snap-cloud/snap-cloud.svg)](https://gemnasium.com/snap-cloud/snap-cloud) -* [![Build Status](https://travis-ci.org/snap-cloud/snap-cloud.svg?branch=master)](https://travis-ci.org/snap-cloud/snap-cloud) +For CS169: Please see the [wiki][wiki] for documentation about each iteration. -* [![Coverage Status](https://coveralls.io/repos/snap-cloud/snap-cloud/badge.svg?branch=master)](https://coveralls.io/r/snap-cloud/snap-cloud?branch=master) - -Please see the [wiki][wiki] for documentation about each iteration. +# What is Snap!? +This section is `TODO` +- Snap! GH Repo +- Snap! homepage +- scratch site ## Setting Up -This project uses Rails 4.2 and Ruby 2.2.0. +This (currently) project uses Rails 4.2.1 and Ruby 2.2.1, and aims to be always +up to date! -The Heroku destination for the app is `http://ucbsnap.herokuapp.com` +The Heroku destination for the app is `https://ucbsnap.herokuapp.com` 1. **CLONE WITH `-r`** `git clone -r git@github.com:snap-cloud/snap-cloud.git` 1. You should have `rvm` or similar installed. 2. `bundle install --without production` 3. `git remote add heroku git@heroku.com:ucbsnap.git` -[hk-app]: http://ucbsnap.herokuapp.com +[hk-app]: https://ucbsnap.herokuapp.com [sbe]: http://snap.berkeley.edu -[wiki]: https://github.com/snap-cloud/snap-cloud/wiki/Iteration-0-Deliverables \ No newline at end of file +[wiki]: https://github.com/snap-cloud/snap-cloud/wiki/Iteration-0-Deliverables + +## Development Notes + +* GitHub Flow [link needed...] + +* The awesome print gem +``` +$ rails console +> require 'awesome_print' +ap SomeObject +``` \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 45e0f25..7659da0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,19 +10,26 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? - # Custom Error Methos + # Custom Error Methods + # These are app level errors that we can use to configure how to handle them + # They should be created when there is not an already applicable Rails error + # TODO: We need to determine for the best split up 401 and 404 errors. module SnapException class AccessDenied < StandardError; end end # Clean Error Handler Methods # Use these in place of handling errors individually. - def access_denied # Equivalent 401 - raise SnapException::AccessDenied.new('You don\'t have permission to view this.') + def access_denied(msg = nil) # Equivalent 401 + default = 'You don\'t have permission to view this.' + msg ||= default + raise SnapException::AccessDenied.new(msg) end - def item_not_found # Equivalent 404 - raise ActiveRecord::RecordNotFound.new('Not Found') + def item_not_found(msg = nil) # Equivalent 404 + default = "This item couldn't be found." + msg ||= default + raise ActiveRecord::RecordNotFound.new(msg) end rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found @@ -39,6 +46,9 @@ def configure_permitted_parameters devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) } end + # This method allows stubbing in rspec testing. + # FIXME -- name should be migrated to get_current_user + # TODO: can't we just stub current_user method? def getCurrentUser current_user end