Update rails dependency to version 4.0.1

This commit is contained in:
Erik Michaels-Ober 2013-12-02 22:47:02 +01:00
parent 11ac7148c3
commit 4cfa9ad5c7
61 changed files with 385 additions and 323 deletions

9
.gitignore vendored
View File

@ -1,17 +1,18 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config
# Ignore bundler config.
/.bundle
# Include SimpleCov directory
# Ignore SimpleCov directory.
/coverage
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log

View File

@ -1,7 +1,7 @@
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '~> 3.2'
gem 'rails', '~> 4.0.1'
gem 'arel'
gem 'devise'
@ -12,7 +12,6 @@ gem 'nokogiri'
gem 'pg'
gem 'rails_12factor'
gem 'rails_admin'
gem 'strong_parameters'
gem 'validates_formatting_of'
platforms :ruby_18 do

View File

@ -1,46 +1,41 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.15)
actionpack (= 3.2.15)
actionmailer (4.0.1)
actionpack (= 4.0.1)
mail (~> 2.5.4)
actionpack (3.2.15)
activemodel (= 3.2.15)
activesupport (= 3.2.15)
builder (~> 3.0.0)
actionpack (4.0.1)
activesupport (= 4.0.1)
builder (~> 3.1.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.15)
activesupport (= 3.2.15)
builder (~> 3.0.0)
activerecord (3.2.15)
activemodel (= 3.2.15)
activesupport (= 3.2.15)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.15)
activemodel (= 3.2.15)
activesupport (= 3.2.15)
activesupport (3.2.15)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.1)
activesupport (= 4.0.1)
builder (~> 3.1.0)
activerecord (4.0.1)
activemodel (= 4.0.1)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.1)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.1)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.3.5)
arel (3.0.3)
arel (4.0.1)
atomic (1.1.14)
bcrypt-ruby (3.1.2)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (2.3.2.2)
sass (~> 3.2)
builder (3.0.4)
builder (3.1.4)
coderay (1.1.0)
coffee-rails (3.2.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
@ -71,7 +66,7 @@ GEM
erubis (2.7.0)
execjs (2.0.2)
fastercsv (1.5.5)
font-awesome-rails (3.2.1.3)
font-awesome-rails (4.0.3.0)
railties (>= 3.2, < 5.0)
geokit (1.7.1)
multi_json (>= 1.3.2)
@ -81,12 +76,10 @@ GEM
http_accept_language (2.0.0)
i18n (0.6.5)
interception (0.3)
journey (1.0.4)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (3.0.1)
jquery-rails
jquery-ui-rails (4.1.0)
railties (>= 3.1.0)
json (1.8.1)
kaminari (0.15.0)
@ -98,6 +91,7 @@ GEM
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.8.2)
nested_form (0.3.2)
nokogiri (1.6.0)
@ -120,79 +114,70 @@ GEM
pry (>= 0.9.11)
puma (2.6.0)
rack (>= 1.1, < 2.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack (1.5.2)
rack-pjax (0.7.0)
nokogiri (~> 1.5)
rack (~> 1.3)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.15)
actionmailer (= 3.2.15)
actionpack (= 3.2.15)
activerecord (= 3.2.15)
activeresource (= 3.2.15)
activesupport (= 3.2.15)
bundler (~> 1.0)
railties (= 3.2.15)
rails (4.0.1)
actionmailer (= 4.0.1)
actionpack (= 4.0.1)
activerecord (= 4.0.1)
activesupport (= 4.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.1)
sprockets-rails (~> 2.0.0)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_admin (0.4.9)
bootstrap-sass (~> 2.2)
builder (~> 3.0)
coffee-rails (>= 3.1, < 5)
font-awesome-rails (~> 3.0)
rails_admin (0.6.0)
builder (~> 3.1)
coffee-rails (~> 4.0)
font-awesome-rails (>= 3.0)
haml (~> 4.0)
jquery-rails (>= 2.1, < 4)
jquery-ui-rails (~> 3.0)
jquery-rails (~> 3.0)
jquery-ui-rails (~> 4.0)
kaminari (~> 0.14)
nested_form (~> 0.3)
rack-pjax (~> 0.6)
rails (~> 3.1)
rack-pjax (~> 0.7)
rails (~> 4.0.0)
remotipart (~> 1.0)
safe_yaml (~> 0.6)
sass-rails (~> 3.1)
safe_yaml (~> 0.9)
sass-rails (~> 4.0)
rails_serve_static_assets (0.0.1)
rails_stdout_logging (0.0.3)
railties (3.2.15)
actionpack (= 3.2.15)
activesupport (= 3.2.15)
rack-ssl (~> 1.3.2)
railties (4.0.1)
actionpack (= 4.0.1)
activesupport (= 4.0.1)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
thor (>= 0.18.1, < 2.0)
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
remotipart (1.2.1)
rest-client (1.6.7)
mime-types (>= 1.16)
safe_yaml (0.9.7)
sass (3.2.12)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets-rails (~> 2.0.0)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.4.7)
sprockets (2.2.2)
sprockets (2.10.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
strong_parameters (0.2.1)
actionpack (~> 3.0)
activemodel (~> 3.0)
railties (~> 3.0)
term-ansicolor (1.2.2)
tins (~> 0.8)
thor (0.18.1)
@ -207,8 +192,8 @@ GEM
uglifier (2.3.2)
execjs (>= 0.3.0)
json (>= 1.8.0)
validates_formatting_of (0.8.0)
activemodel (~> 3.0)
validates_formatting_of (0.8.1)
activemodel (~> 4.0)
warden (1.2.3)
rack (>= 1.0)
webmock (1.16.0)
@ -233,13 +218,12 @@ DEPENDENCIES
pry-rescue
pry-stack_explorer
puma
rails (~> 3.2)
rails (~> 4.0.1)
rails_12factor
rails_admin
sass-rails
simplecov
sqlite3
strong_parameters
uglifier
validates_formatting_of
webmock

View File

@ -1,4 +1,3 @@
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

0
app/assets/images/.keep Normal file
View File

View File

@ -5,9 +5,9 @@
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .

View File

@ -91,7 +91,6 @@ $(function() {
url: '/things.json',
data: {
'utf8': '✓',
'authenticity_token': $('#address_form input[name="authenticity_token"]').val(),
'lat': lat,
'lng': lng,
'limit': $('#address_form input[name="limit"]').val()
@ -145,7 +144,6 @@ $(function() {
url: '/address.json',
data: {
'utf8': '✓',
'authenticity_token': $('#address_form input[name="authenticity_token"]').val(),
'city_state': $('#city_state').val(),
'address': $('#address').val()
},
@ -380,10 +378,10 @@ $(function() {
type: 'POST',
url: '/things.json',
data: {
'_method': 'patch',
'id': $('#thing_id').val(),
'utf8': '✓',
'authenticity_token': $('#adoption_form input[name="authenticity_token"]').val(),
'_method': 'put',
'thing': {
'user_id': $('#thing_user_id').val(),
'name': $('#thing_name').val()
@ -423,10 +421,10 @@ $(function() {
type: 'POST',
url: '/things.json',
data: {
'_method': 'patch',
'id': $('#thing_id').val(),
'utf8': '✓',
'authenticity_token': $('#abandon_form input[name="authenticity_token"]').val(),
'_method': 'put',
'thing': {
'user_id': $('#thing_user_id').val(),
'name': $('#thing_name').val()
@ -515,11 +513,11 @@ $(function() {
type: 'POST',
url: '/users.json',
data: {
'_method': 'patch',
'id': $('#id').val(),
'thing_id': activeThingId,
'utf8': '✓',
'authenticity_token': $('#edit_form input[name="authenticity_token"]').val(),
'_method': 'put',
'user': {
'email': $('#user_email').val(),
'name': $('#user_name').val(),

View File

@ -6,7 +6,7 @@ class AddressesController < ApplicationController
unless @address.blank?
respond_with @address
else
render(json: {errors: {address: [t("errors.not_found", thing: t("defaults.address"))]}}, status: 404)
render(:json => {:errors => {:address => [t("errors.not_found", :thing => t("defaults.address"))]}}, :status => 404)
end
end
end

View File

@ -1,5 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery :with => :exception
before_filter :set_flash_from_params
before_filter :set_locale

View File

View File

@ -3,16 +3,16 @@ class PasswordsController < Devise::PasswordsController
self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
render(json: {success: true})
render(:json => {:success => true})
else
render(json: {errors: resource.errors}, status: 500)
render(:json => {:errors => resource.errors}, :status => 500)
end
end
def edit
self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token]
render("edit", layout: "info_window")
render("edit", :layout => "info_window")
end
def update
@ -22,7 +22,7 @@ class PasswordsController < Devise::PasswordsController
resource.unlock_access! if unlockable?(resource)
sign_in(resource_name, resource)
end
redirect_to(controller: "main", action: "index")
redirect_to(:controller => "main", :action => "index")
end
private

View File

@ -7,9 +7,9 @@ class RemindersController < ApplicationController
if @reminder.save
ThingMailer.reminder(@reminder.thing).deliver
@reminder.update_attribute(:sent, true)
render(json: @reminder)
render(:json => @reminder)
else
render(json: {errors: @reminder.errors}, status: 500)
render(:json => {:errors => @reminder.errors}, :status => 500)
end
end

View File

@ -1,4 +1,6 @@
class SessionsController < Devise::SessionsController
skip_before_filter :verify_authenticity_token, :only => [:destroy]
def new
redirect_to(root_path)
end
@ -8,9 +10,9 @@ class SessionsController < Devise::SessionsController
if resource
sign_in(resource_name, resource)
yield resource if block_given?
render(json: resource)
render(:json => resource)
else
render(json: {errors: {password: [t("errors.password")]}}, status: 401)
render(:json => {:errors => {:password => [t("errors.password")]}}, :status => 401)
end
end
@ -19,6 +21,6 @@ class SessionsController < Devise::SessionsController
sign_out(resource_name) if signed_in
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
yield resource if block_given?
render(json: {success: signed_in})
render(:json => {:success => signed_in})
end
end

View File

@ -6,7 +6,7 @@ class ThingsController < ApplicationController
unless @things.blank?
respond_with @things
else
render(json: {errors: {address: [t("errors.not_found", thing: t("defaults.thing"))]}}, status: 404)
render(:json => {:errors => {:address => [t("errors.not_found", :thing => t("defaults.thing"))]}}, :status => 404)
end
end
@ -15,7 +15,7 @@ class ThingsController < ApplicationController
if @thing.update_attributes(thing_params)
respond_with @thing
else
render(json: {errors: @thing.errors}, status: 500)
render(:json => {:errors => @thing.errors}, :status => 500)
end
end

View File

@ -1,6 +1,6 @@
class UsersController < Devise::RegistrationsController
def edit
render("sidebar/edit_profile", layout: "sidebar")
render("sidebar/edit_profile", :layout => "sidebar")
end
def update
@ -8,12 +8,12 @@ class UsersController < Devise::RegistrationsController
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
if update_resource(resource, account_update_params)
yield resource if block_given?
sign_in(resource_name, resource, bypass: true)
sign_in(resource_name, resource, :bypass => true)
flash[:notice] = "Profile updated!"
redirect_to(controller: "sidebar", action: "search")
redirect_to(:controller => "sidebar", :action => "search")
else
clean_up_passwords(resource)
render(json: {errors: resource.errors}, status: 500)
render(:json => {:errors => resource.errors}, :status => 500)
end
end
@ -22,10 +22,10 @@ class UsersController < Devise::RegistrationsController
if resource.save
yield resource if block_given?
sign_in(resource_name, resource)
render(json: resource)
render(:json => resource)
else
clean_up_passwords(resource)
render(json: {errors: resource.errors}, status: 500)
render(:json => {:errors => resource.errors}, :status => 500)
end
end

0
app/mailers/.keep Normal file
View File

View File

@ -1,13 +1,13 @@
class ThingMailer < ActionMailer::Base
default from: "adoptahydrant@cityofboston.gov"
default :from => "adoptahydrant@cityofboston.gov"
def reminder(thing)
@thing = thing
@user = thing.user
mail(
{
to: thing.user.email,
subject: ["Remember to shovel", thing.name].compact.join(' '),
:to => thing.user.email,
:subject => ["Remember to shovel", thing.name].compact.join(' '),
}
)
end

0
app/models/.keep Normal file
View File

View File

View File

@ -1,7 +1,7 @@
class Reminder < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
validates_presence_of :from_user, :to_user, :thing
belongs_to :from_user, class_name: "User"
belongs_to :to_user, class_name: "User"
belongs_to :from_user, :class_name => "User"
belongs_to :to_user, :class_name => "User"
belongs_to :thing
end

View File

@ -1,7 +1,7 @@
class Thing < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
include Geokit::Geocoders
validates_uniqueness_of :city_id, allow_nil: true
validates_uniqueness_of :city_id, :allow_nil => true
validates_presence_of :lat, :lng
belongs_to :user
has_many :reminders

View File

@ -5,13 +5,13 @@ class User < ActiveRecord::Base
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable
validates_formatting_of :email, using: :email
validates_formatting_of :sms_number, using: :us_phone, allow_blank: true
validates_formatting_of :voice_number, using: :us_phone, allow_blank: true
validates_formatting_of :zip, using: :us_zip, allow_blank: true
validates_formatting_of :email, :using => :email
validates_formatting_of :sms_number, :using => :us_phone, :allow_blank => true
validates_formatting_of :voice_number, :using => :us_phone, :allow_blank => true
validates_formatting_of :zip, :using => :us_zip, :allow_blank => true
validates_presence_of :name
has_many :reminders_to, class_name: "Reminder", foreign_key: "to_user_id"
has_many :reminders_from, class_name: "Reminder", foreign_key: "from_user_id"
has_many :reminders_to, :class_name => "Reminder", :foreign_key => "to_user_id"
has_many :reminders_from, :class_name => "Reminder", :foreign_key => "from_user_id"
has_many :things
before_validation :remove_non_digits_from_phone_numbers
def remove_non_digits_from_phone_numbers

3
bin/bundle Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
bin/rails Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
bin/rake Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

View File

@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run AdoptAThing::Application
run Rails.application

View File

@ -2,12 +2,9 @@ require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module AdoptAThing
class Application < Rails::Application
@ -15,16 +12,6 @@ module AdoptAThing
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
@ -32,32 +19,5 @@ module AdoptAThing
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end
end

View File

@ -1,5 +1,3 @@
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

View File

@ -1,5 +1,5 @@
# Load the rails application
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the rails application
# Initialize the Rails application.
AdoptAThing::Application.initialize!

View File

@ -1,38 +1,30 @@
AdoptAThing::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
# Print deprecation notices to the Rails logger
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
end

View File

@ -1,70 +1,84 @@
AdoptAThing::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests
# Code is not reloaded between requests.
config.cache_classes = true
# Full error reports are disabled and caching is turned on
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs
# Generate digests for assets URLs.
config.assets.digest = true
# Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {:host => 'adoptahydrant.org'}
# Enable threaded mode
config.threadsafe! unless $rails_rake_task
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end
ActionMailer::Base.smtp_settings = {

View File

@ -1,5 +1,5 @@
AdoptAThing::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@ -7,22 +7,24 @@ AdoptAThing::Application.configure do
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
@ -30,9 +32,6 @@ AdoptAThing::Application.configure do
config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
end

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@ -1,15 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
#
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections do |inflect|
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@ -1,12 +1,17 @@
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
if Rails.env.production? && ENV['SECRET_TOKEN'].blank?
raise 'The SECRET_TOKEN environment variable is not set.\n
To generate it, run "rake secret", then set it with "heroku config:set SECRET_TOKEN=the_token_you_generated"'
raise 'The SECRET_TOKEN environment variable is not set.\n
To generate it, run "rake secret", then set it with "heroku config:set SECRET_TOKEN=the_token_you_generated"'
end
AdoptAThing::Application.config.secret_token = ENV['SECRET_TOKEN'] || '4dc0354d5050c89c7f151a0bae3d2a7506a7ca66435ae9e0eb6754cb4be808089c7726c65dc8ae9b49870507fbe0de1fa36fa703491078b2c7122897892d6f69'
# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
AdoptAThing::Application.config.secret_key_base = ENV['SECRET_TOKEN'] || 'cfc501e00aeb29750826f86459cccec45ea2c7dd84e8fc0b800dced308be95059b51c3402d215d267cfc09f03bd6f1f531a65456212b3531ef2b10cf605dc39a'

View File

@ -1,8 +1,3 @@
# Be sure to restart your server when you modify this file.
AdoptAThing::Application.config.session_store :cookie_store, key: '_adopt-a-thing_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# AdoptAThing::Application.config.session_store :active_record_store

View File

@ -1,14 +1,14 @@
# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json]
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
# Disable root element in JSON by default.
ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# end

0
lib/assets/.keep Normal file
View File

0
lib/tasks/.keep Normal file
View File

0
log/.keep Normal file
View File

View File

@ -2,17 +2,48 @@
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
@ -22,5 +53,6 @@
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View File

@ -2,17 +2,48 @@
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
@ -22,5 +53,6 @@
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View File

@ -2,17 +2,48 @@
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
margin: 4em auto 0 auto;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 4em 0 4em;
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
body > p {
width: 33em;
margin: 0 auto 1em;
padding: 1em 0;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
@ -21,5 +52,6 @@
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</body>
</html>

View File

@ -1,5 +1,5 @@
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-Agent: *
# User-agent: *
# Disallow: /

0
test/controllers/.keep Normal file
View File

0
test/fixtures/.keep vendored Normal file
View File

View File

@ -3,20 +3,20 @@ require 'test_helper'
class AddressesControllerTest < ActionController::TestCase
test 'should return latitude and longitude for a valid address' do
stub_request(:get, "http://maps.google.com/maps/geo").
with(query: {key: "REPLACE_WITH_YOUR_GOOGLE_KEY", oe: "utf-8", output: "xml", q: "City Hall, Boston, MA"}).
to_return(body: File.read(File.expand_path('../../fixtures/city_hall.kml', __FILE__)))
get :show, address: 'City Hall', city_state: "Boston, MA", format: 'json'
with(:query => {:key => "REPLACE_WITH_YOUR_GOOGLE_KEY", :oe => "utf-8", :output => "xml", :q => "City Hall, Boston, MA"}).
to_return(:body => File.read(File.expand_path('../../fixtures/city_hall.kml', __FILE__)))
get :show, :address => 'City Hall', :city_state => "Boston, MA", :format => 'json'
assert_not_nil assigns :address
end
test 'should return an error for an invalid address' do
stub_request(:get, "http://geocoder.us/service/csv/geocode").
with(query: {address: ", "}).
to_return(body: File.read(File.expand_path('../../fixtures/unknown_address.txt', __FILE__)))
with(:query => {:address => ", "}).
to_return(:body => File.read(File.expand_path('../../fixtures/unknown_address.txt', __FILE__)))
stub_request(:get, "http://maps.google.com/maps/geo").
with(query: {key: "REPLACE_WITH_YOUR_GOOGLE_KEY", oe: "utf-8", output: "xml", q: ", "}).
to_return(body: File.read(File.expand_path('../../fixtures/unknown_address.kml', __FILE__)))
get :show, address: '', city_state: '', format: 'json'
with(:query => {:key => "REPLACE_WITH_YOUR_GOOGLE_KEY", :oe => "utf-8", :output => "xml", :q => ", "}).
to_return(:body => File.read(File.expand_path('../../fixtures/unknown_address.kml', __FILE__)))
get :show, :address => '', :city_state => '', :format => 'json'
assert_response :missing
end
end

View File

@ -11,7 +11,7 @@ class InfoWindowControllerTest < ActionController::TestCase
sign_in @user
@thing.user_id = @user.id
@thing.save!
get :index, thing_id: @thing.id
get :index, :thing_id => @thing.id
assert_not_nil assigns :thing
assert_response :success
assert_template 'users/thank_you'
@ -33,7 +33,7 @@ class InfoWindowControllerTest < ActionController::TestCase
test 'should show the profile if the hydrant is adopted' do
@thing.user_id = @user.id
@thing.save!
get :index, thing_id: @thing.id
get :index, :thing_id => @thing.id
assert_not_nil assigns :thing
assert_response :success
assert_template 'users/profile'
@ -42,7 +42,7 @@ class InfoWindowControllerTest < ActionController::TestCase
test 'should show adoption form if hydrant is not adopted' do
sign_in @user
get :index, thing_id: @thing.id
get :index, :thing_id => @thing.id
assert_not_nil assigns :thing
assert_response :success
assert_template :adopt
@ -62,7 +62,7 @@ class InfoWindowControllerTest < ActionController::TestCase
end
test 'should show sign-in form if signed out' do
get :index, thing_id: @thing.id
get :index, :thing_id => @thing.id
assert_not_nil assigns :thing
assert_response :success
assert_template 'users/sign_in'

View File

@ -9,7 +9,7 @@ class PasswordsControllerTest < ActionController::TestCase
test 'should send password reset instructions if email address is found' do
num_deliveries = ActionMailer::Base.deliveries.size
post :create, user: {email: @user.email}
post :create, :user => {:email => @user.email}
assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success
email = ActionMailer::Base.deliveries.last
@ -18,30 +18,30 @@ class PasswordsControllerTest < ActionController::TestCase
end
test 'should not send password reset instructions if email address is not found' do
post :create, user: {email: 'not_found@example.com'}
post :create, :user => {:email => 'not_found@example.com'}
assert_response :error
end
test 'should render edit view' do
get :edit, reset_password_token: 'token'
get :edit, :reset_password_token => 'token'
assert_response :success
end
test 'should reset user password with an valid reset password token' do
token = @user.send_reset_password_instructions
put :update, user: {reset_password_token: token, password: 'new_password'}
put :update, :user => {:reset_password_token => token, :password => 'new_password'}
@user.reload
assert @user.valid_password?('new_password')
assert_response :redirect
assert_redirected_to controller: 'main', action: 'index'
assert_redirected_to :controller => 'main', :action => 'index'
end
test 'should not reset user password with an invalid reset password token' do
@user.send_reset_password_instructions
put :update, user: {reset_password_token: 'invalid_token', password: 'new_password'}
put :update, :user => {:reset_password_token => 'invalid_token', :password => 'new_password'}
@user.reload
assert !@user.valid_password?('new_password')
assert_response :redirect
assert_redirected_to controller: 'main', action: 'index'
assert_redirected_to :controller => 'main', :action => 'index'
end
end

View File

@ -10,14 +10,14 @@ class RemindersControllerTest < ActionController::TestCase
@thing.user = @dan
@thing.save!
stub_request(:get, "http://maps.google.com/maps/geo").
with(query: {key: "REPLACE_WITH_YOUR_GOOGLE_KEY", ll: "42.383339,-71.049226", oe: "utf-8", output: "xml"}).
to_return(body: File.read(File.expand_path('../../fixtures/geo.kml', __FILE__)))
with(:query => {:key => "REPLACE_WITH_YOUR_GOOGLE_KEY", :ll => "42.383339,-71.049226", :oe => "utf-8", :output => "xml"}).
to_return(:body => File.read(File.expand_path('../../fixtures/geo.kml', __FILE__)))
end
test 'should send a reminder email' do
sign_in @user
num_deliveries = ActionMailer::Base.deliveries.size
post :create, format: :json, reminder: {thing_id: @thing.id, to_user_id: @dan.id}
post :create, :format => :json, :reminder => {:thing_id => @thing.id, :to_user_id => @dan.id}
assert_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success
email = ActionMailer::Base.deliveries.last

View File

@ -19,18 +19,18 @@ class SessionsControllerTest < ActionController::TestCase
end
test 'should authenticate user if password is correct' do
post :create, user: {email: @user.email, password: 'correct'}, format: :json
post :create, :user => {:email => @user.email, :password => 'correct'}, :format => :json
assert_response :success
end
test 'should return error if password is incorrect' do
post :create, user: {email: @user.email, password: 'incorrect'}, format: :json
post :create, :user => {:email => @user.email, :password => 'incorrect'}, :format => :json
assert_response 401
end
test 'should empty session on sign out' do
sign_in @user
get :destroy, format: :json
get :destroy, :format => :json
assert_equal {}, session
assert_response :success
end

View File

@ -2,7 +2,7 @@ require 'test_helper'
class SitemapsControllerTest < ActionController::TestCase
test 'should return an XML sitemap' do
get :index, format: 'xml'
get :index, :format => 'xml'
assert_response :success
end
end

View File

@ -6,14 +6,14 @@ class ThingsControllerTest < ActionController::TestCase
end
test 'should list hydrants' do
get :show, format: 'json', lat: 42.358431, lng: -71.059773
get :show, :format => 'json', :lat => 42.358431, :lng => -71.059773
assert_not_nil assigns :things
assert_response :success
end
test 'should update hydrant' do
assert_not_equal 'Birdsill', @thing.name
put :update, format: 'json', id: @thing.id, thing: {name: 'Birdsill'}
put :update, :format => 'json', :id => @thing.id, :thing => {:name => 'Birdsill'}
@thing.reload
assert_equal 'Birdsill', @thing.name
assert_not_nil assigns :thing

View File

@ -15,8 +15,8 @@ class UsersControllerTest < ActionController::TestCase
assert_select '[action=?]', '/users'
assert_select '[method=?]', 'post'
end
assert_select 'input', count: 15
assert_select 'label', count: 12
assert_select 'input', :count => 15
assert_select 'label', :count => 12
assert_select 'input[name="commit"]' do
assert_select '[type=?]', 'submit'
assert_select '[value=?]', 'Update'
@ -27,26 +27,26 @@ class UsersControllerTest < ActionController::TestCase
test 'should update user if password is correct' do
sign_in @user
assert_not_equal 'New Name', @user.name
put :update, user: {name: 'New Name', current_password: 'correct'}
put :update, :user => {:name => 'New Name', :current_password => 'correct'}
@user.reload
assert_equal 'New Name', @user.name
assert_response :redirect
assert_redirected_to controller: 'sidebar', action: 'search'
assert_redirected_to :controller => 'sidebar', :action => 'search'
end
test 'should return error if password is incorrect' do
sign_in @user
put :update, user: {name: 'New Name', current_password: 'incorrect'}
put :update, :user => {:name => 'New Name', :current_password => 'incorrect'}
assert_response :error
end
test 'should create user if information is valid' do
post :create, user: {email: 'user@example.com', name: 'User', password: 'correct', password_confirmation: 'correct'}
post :create, :user => {:email => 'user@example.com', :name => 'User', :password => 'correct', :password_confirmation => 'correct'}
assert_response :success
end
test 'should return error if information is invalid' do
post :create, user: {email: 'user@example.com', name: 'User', password: 'correct', password_confirmation: 'incorrect'}
post :create, :user => {:email => 'user@example.com', :name => 'User', :password => 'correct', :password_confirmation => 'incorrect'}
assert_response :error
end
end

0
test/helpers/.keep Normal file
View File

0
test/integration/.keep Normal file
View File

0
test/mailers/.keep Normal file
View File

0
test/models/.keep Normal file
View File

View File

@ -11,10 +11,12 @@ SimpleCov.start('rails')
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'webmock/test_unit'
require 'webmock/minitest'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting

0
vendor/assets/javascripts/.keep vendored Normal file
View File

0
vendor/assets/stylesheets/.keep vendored Normal file
View File