Remove support for Ruby 1.8

This commit is contained in:
Erik Michaels-Ober 2012-06-18 13:49:28 -04:00
parent af08da6596
commit 6b2c541f45
47 changed files with 13511 additions and 13469 deletions

View File

@ -3,5 +3,4 @@ before_script: bundle exec rake db:create db:schema:load
bundler_args: --without assets:development:production bundler_args: --without assets:development:production
language: ruby language: ruby
rvm: rvm:
- 1.9.2
- 1.9.3 - 1.9.3

View File

@ -80,19 +80,13 @@ Ideally, a bug report should include a pull request with failing specs.
[branch]: http://learn.github.com/p/branching.html [branch]: http://learn.github.com/p/branching.html
[pr]: http://help.github.com/send-pull-requests/ [pr]: http://help.github.com/send-pull-requests/
## Supported Ruby Versions ## Supported Ruby Version
This library aims to support and is [tested against][travis] the following Ruby This library aims to support and is [tested against][travis] Ruby version 1.9.3.
implementations:
* Ruby 1.9.2 If something doesn't work on this version, it should be considered a bug.
* Ruby 1.9.3
If something doesn't work on one of these interpreters, it should be considered
a bug.
This library may inadvertently work (or seem to work) on other Ruby This library may inadvertently work (or seem to work) on other Ruby
implementations, however support will only be provided for the versions listed implementations, however support will only be provided for the version above.
above.
If you would like this library to support another Ruby version, you may If you would like this library to support another Ruby version, you may
volunteer to be a maintainer. Being a maintainer entails making sure all tests volunteer to be a maintainer. Being a maintainer entails making sure all tests

View File

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

View File

@ -399,7 +399,7 @@ $(function() {
data: { data: {
'thing_id': activeThingId, 'thing_id': activeThingId,
'flash': { 'flash': {
'notice': "<%= I18n.t("notices.adopted", :thing => I18n.t("defaults.thing")) %>" 'notice': "<%= I18n.t("notices.adopted", thing: I18n.t("defaults.thing")) %>"
} }
}, },
success: function(data) { success: function(data) {
@ -442,7 +442,7 @@ $(function() {
data: { data: {
'thing_id': activeThingId, 'thing_id': activeThingId,
'flash': { 'flash': {
'warning': "<%= I18n.t("notices.abandoned", :thing => I18n.t("defaults.thing").capitalize) %>" 'warning': "<%= I18n.t("notices.abandoned", thing: I18n.t("defaults.thing").capitalize) %>"
} }
}, },
success: function(data) { success: function(data) {
@ -664,7 +664,6 @@ $(function() {
'utf8': '✓', 'utf8': '✓',
'authenticity_token': $('#reminder_form input[name="authenticity_token"]').val(), 'authenticity_token': $('#reminder_form input[name="authenticity_token"]').val(),
'reminder': { 'reminder': {
'from_user_id': $('#reminder_from_user_id').val(),
'to_user_id': $('#reminder_to_user_id').val(), 'to_user_id': $('#reminder_to_user_id').val(),
'thing_id': activeThingId 'thing_id': activeThingId
} }

View File

@ -6,7 +6,7 @@ class AddressesController < ApplicationController
unless @address.blank? unless @address.blank?
respond_with @address respond_with @address
else 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 end
end end

View File

@ -1,21 +1,21 @@
class PasswordsController < Devise::PasswordsController class PasswordsController < Devise::PasswordsController
def create def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name]) self.resource = resource_class.send_reset_password_instructions(resource_params)
if resource.errors.empty? if resource.errors.empty?
render(:json => {"success" => true}) render(json: {success: true})
else else
render(:json => {"errors" => resource.errors}, :status => 500) render(json: {errors: resource.errors}, status: 500)
end end
end end
def edit def edit
self.resource = resource_class.new self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token] resource.reset_password_token = params[:reset_password_token]
render("edit", :layout => "info_window") render("edit", layout: "info_window")
end end
def update def update
self.resource = resource_class.reset_password_by_token(params[resource_name]) self.resource = resource_class.reset_password_by_token(resource_params)
redirect_to(:controller => "main", :action => "index") redirect_to(controller: "main", action: "index")
end end
end end

View File

@ -3,12 +3,13 @@ class RemindersController < ApplicationController
def create def create
@reminder = Reminder.new(params[:reminder]) @reminder = Reminder.new(params[:reminder])
@reminder.from_user = current_user
if @reminder.save if @reminder.save
ThingMailer.reminder(@reminder.thing).deliver ThingMailer.reminder(@reminder.thing).deliver
@reminder.update_attribute(:sent, true) @reminder.update_attribute(:sent, true)
render(:json => @reminder) render(json: @reminder)
else else
render(:json => {"errors" => @reminder.errors}, :status => 500) render(json: {errors: @reminder.errors}, status: 500)
end end
end end
end end

View File

@ -1,21 +1,21 @@
class SessionsController < Devise::SessionsController class SessionsController < Devise::SessionsController
def new def new
redirect_to root_path redirect_to(root_path)
end end
def create def create
resource = warden.authenticate(:scope => resource_name) resource = warden.authenticate(:scope => resource_name)
if resource if resource
sign_in(resource_name, resource) sign_in(resource_name, resource)
render(:json => resource) render(json: resource)
else else
render(:json => {"errors" => {:password => [t("errors.password")]}}, :status => 401) render(json: {errors: {password: [t("errors.password")]}}, status: 401)
end end
end end
def destroy def destroy
signed_in = signed_in?(resource_name) signed_in = signed_in?(resource_name)
sign_out(resource_name) if signed_in sign_out(resource_name) if signed_in
render(:json => {"success" => signed_in}) render(json: {success: signed_in})
end end
end end

View File

@ -6,7 +6,7 @@ class ThingsController < ApplicationController
unless @things.blank? unless @things.blank?
respond_with @things respond_with @things
else 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
end end
@ -15,7 +15,7 @@ class ThingsController < ApplicationController
if @thing.update_attributes(params[:thing]) if @thing.update_attributes(params[:thing])
respond_with @thing respond_with @thing
else else
render(:json => {"errors" => @thing.errors}, :status => 500) render(json: {errors: @thing.errors}, status: 500)
end end
end end
end end

View File

@ -1,16 +1,16 @@
class UsersController < Devise::RegistrationsController class UsersController < Devise::RegistrationsController
def edit def edit
render("sidebar/edit_profile", :layout => "sidebar") render("sidebar/edit_profile", layout: "sidebar")
end end
def update def update
if resource.update_with_password(params[resource_name]) if resource.update_with_password(resource_params)
sign_in(resource_name, resource, :bypass => true) sign_in(resource_name, resource, bypass: true)
flash[:notice] = "Profile updated!" flash[:notice] = "Profile updated!"
redirect_to(:controller => "sidebar", :action => "search") redirect_to(controller: "sidebar", action: "search")
else else
clean_up_passwords(resource) clean_up_passwords(resource)
render(:json => {"errors" => resource.errors}, :status => 500) render(json: {errors: resource.errors}, status: 500)
end end
end end
@ -18,10 +18,10 @@ class UsersController < Devise::RegistrationsController
build_resource build_resource
if resource.save if resource.save
sign_in(resource_name, resource) sign_in(resource_name, resource)
render(:json => resource) render(json: resource)
else else
clean_up_passwords(resource) clean_up_passwords(resource)
render(:json => {"errors" => resource.errors}, :status => 500) render(json: {errors: resource.errors}, status: 500)
end end
end end
end end

View File

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

View File

@ -1,6 +1,7 @@
class Reminder < ActiveRecord::Base class Reminder < ActiveRecord::Base
attr_accessible :thing_id, :to_user_id
validates_presence_of :from_user, :to_user, :thing validates_presence_of :from_user, :to_user, :thing
belongs_to :from_user, :class_name => "User" belongs_to :from_user, class_name: "User"
belongs_to :to_user, :class_name => "User" belongs_to :to_user, class_name: "User"
belongs_to :thing belongs_to :thing
end end

View File

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

View File

@ -1,16 +1,19 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :recoverable, :rememberable, devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable :trackable, :validatable
attr_accessible :address_1, :address_2, :city, :email, :name, :organization, attr_accessible :address_1, :address_2, :city, :email, :name, :organization,
:password, :password_confirmation, :remember_me, :sms_number, :state, :password, :password_confirmation, :remember_me, :sms_number, :state,
:voice_number, :zip :voice_number, :zip
validates_formatting_of :email, :using => :email validates_formatting_of :email, using: :email
validates_formatting_of :sms_number, :using => :us_phone, :allow_blank => true 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 :voice_number, using: :us_phone, allow_blank: true
validates_formatting_of :zip, :using => :us_zip, :allow_blank => true validates_formatting_of :zip, using: :us_zip, allow_blank: true
validates_presence_of :name validates_presence_of :name
has_many :reminders_to, :class_name => "Reminder", :foreign_key => "to_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 :reminders_from, class_name: "Reminder", foreign_key: "from_user_id"
has_many :things has_many :things
before_validation :remove_non_digits_from_phone_numbers before_validation :remove_non_digits_from_phone_numbers
def remove_non_digits_from_phone_numbers def remove_non_digits_from_phone_numbers

View File

@ -4,7 +4,7 @@ require 'rails/all'
if defined?(Bundler) if defined?(Bundler)
# If you precompile assets before deploying to production, use this line # If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test))) Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line # If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env) # Bundler.require(:default, :assets, Rails.env)
end end
@ -31,7 +31,7 @@ module AdoptAThing
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # 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.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :en # config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9. # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8" config.encoding = "utf-8"
@ -39,6 +39,9 @@ module AdoptAThing
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password] 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. # 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, # 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 # like if you have constraints or database-specific column types
@ -48,7 +51,7 @@ module AdoptAThing
# This will create an empty whitelist of attributes available for mass-assignment for all models # 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 # 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. # parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true config.active_record.whitelist_attributes = true
# Enable the asset pipeline # Enable the asset pipeline
config.assets.enabled = true config.assets.enabled = true

View File

@ -15,15 +15,12 @@ AdoptAThing::Application.configure do
config.assets.compress = true config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed # Don't fallback to assets pipeline if a precompiled asset is missed
# config.assets.compile = false config.assets.compile = false
# Fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs # Generate digests for assets URLs
config.assets.digest = true config.assets.digest = true
# Defaults to Rails.root.join("public/assets") # Defaults to nil and saved in location specified by config.assets.prefix
# config.assets.manifest = YOUR_PATH # config.assets.manifest = YOUR_PATH
# Specifies the header that your server uses for sending files # Specifies the header that your server uses for sending files
@ -51,8 +48,6 @@ AdoptAThing::Application.configure do
# 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 are already added)
# config.assets.precompile += %w( search.js ) # config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {:host => 'adoptahydrant.org'} config.action_mailer.default_url_options = {:host => 'adoptahydrant.org'}
@ -73,10 +68,10 @@ AdoptAThing::Application.configure do
end end
ActionMailer::Base.smtp_settings = { ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net", address: "smtp.sendgrid.net",
:port => "25", port: "25",
:authentication => :plain, authentication: :plain,
:user_name => ENV['SENDGRID_USERNAME'], user_name: ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'], password: ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN'], domain: ENV['SENDGRID_DOMAIN'],
} }

View File

@ -92,7 +92,7 @@ Devise.setup do |config|
# the user cannot access the website without confirming his account. # the user cannot access the website without confirming his account.
# config.allow_unconfirmed_access_for = 2.days # config.allow_unconfirmed_access_for = 2.days
# If true, requires any email changes to be confirmed (exctly the same way as # If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email # initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in # db field (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation. # unconfirmed email column, and copied to email column on successful confirmation.
@ -110,7 +110,7 @@ Devise.setup do |config|
# Options to be passed to the created cookie. For instance, you can set # Options to be passed to the created cookie. For instance, you can set
# :secure => true in order to force SSL only cookies. # :secure => true in order to force SSL only cookies.
# config.cookie_options = {} # config.rememberable_options = {}
# ==> Configuration for :validatable # ==> Configuration for :validatable
# Range for password length. Default is 6..128. # Range for password length. Default is 6..128.
@ -126,6 +126,9 @@ Devise.setup do |config|
# time the user will be asked for credentials again. Default is 30 minutes. # time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes # config.timeout_in = 30.minutes
# If true, expires auth token on session timeout.
# config.expire_auth_token_on_timeout = false
# ==> Configuration for :lockable # ==> Configuration for :lockable
# Defines which strategy will be used to lock an account. # Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in. # :failed_attempts = Locks an account after a number of failed attempts to sign in.
@ -181,9 +184,8 @@ Devise.setup do |config|
# devise role declared in your routes (usually :user). # devise role declared in your routes (usually :user).
# config.default_scope = :user # config.default_scope = :user
# Configure sign_out behavior. # Set this configuration to false if you want /users/sign_out to sign out
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). # only the current scope. By default, Devise signs out all scopes.
# The default is true, which means any logout action will sign out all active scopes.
# config.sign_out_all_scopes = true # config.sign_out_all_scopes = true
# ==> Navigation configuration # ==> Navigation configuration
@ -213,4 +215,18 @@ Devise.setup do |config|
# manager.intercept_401 = false # manager.intercept_401 = false
# manager.default_strategies(:scope => :user).unshift :some_external_strategy # manager.default_strategies(:scope => :user).unshift :some_external_strategy
# end # end
# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
# is mountable, there are some extra configurations to be taken into account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: "/my_engine"
#
# The router that invoked `devise_for`, in the example above, would be:
# config.router_name = :my_engine
#
# When using omniauth, Devise cannot automatically set Omniauth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = "/my_engine/users/auth"
end end

View File

@ -1,5 +1,5 @@
RailsAdmin.config do |config| RailsAdmin.config do |config|
config.authenticate_with do config.authenticate_with do
redirect_to(main_app.root_path, :flash => {:warning => "You must be signed-in as an administrator to access that page"}) unless signed_in? && current_user.admin? redirect_to(main_app.root_path, flash: {warning: "You must be signed-in as an administrator to access that page"}) unless signed_in? && current_user.admin?
end end
end end

View File

@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
AdoptAThing::Application.config.session_store :cookie_store, :key => '_adopt-a-thing_session' AdoptAThing::Application.config.session_store :cookie_store, key: '_adopt-a-thing_session'
# Use the database for sessions instead of the cookie-based default, # Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information # which shouldn't be used to store highly confidential information

View File

@ -1,8 +0,0 @@
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN']
}

View File

@ -5,7 +5,7 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
wrap_parameters :format => [:json] wrap_parameters format: [:json]
end end
# Disable root element in JSON by default. # Disable root element in JSON by default.

View File

@ -28,10 +28,11 @@ en:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.' updated: 'Your password was changed successfully. You are now signed in.'
updated_not_active: 'Your password was changed successfully.' updated_not_active: 'Your password was changed successfully.'
send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail" send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
confirmations: confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.' confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations: registrations:
signed_up: 'Welcome! You have signed up successfully.' signed_up: 'Welcome! You have signed up successfully.'
@ -46,8 +47,8 @@ en:
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.' unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.' send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
omniauth_callbacks: omniauth_callbacks:
success: 'Successfully authorized from %{kind} account.' success: 'Successfully authenticated from %{kind} account.'
failure: 'Could not authorize you from %{kind} because "%{reason}".' failure: 'Could not authenticate you from %{kind} because "%{reason}".'
mailer: mailer:
confirmation_instructions: confirmation_instructions:
subject: 'Confirmation instructions' subject: 'Confirmation instructions'

View File

@ -1,22 +1,22 @@
AdoptAThing::Application.routes.draw do AdoptAThing::Application.routes.draw do
devise_for :users, :controllers => { devise_for :users, :controllers => {
:passwords => 'passwords', passwords: 'passwords',
:registrations => 'users', registrations: 'users',
:sessions => 'sessions', sessions: 'sessions',
} }
get 'address' => 'addresses#show', :as => 'address' get '/address', to: 'addresses#show', as: 'address'
get 'info_window' => 'info_window#index', :as => 'info_window' get '/info_window', to:'info_window#index', as: 'info_window'
get 'sitemap' => 'sitemaps#index', :as => 'sitemap' get '/sitemap', to: 'sitemaps#index', as: 'sitemap'
scope "sidebar", :controller => :sidebar do scope '/sidebar', controller: :sidebar do
get :search, :as => 'search' get :search, as: 'search'
get :combo_form, :as => 'combo_form' get :combo_form, as: 'combo_form'
get :edit_profile , :as => 'edit_profile' get :edit_profile , as: 'edit_profile'
end end
resource :reminders resource :reminders
resource :things resource :things
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
root :to => 'main#index' root to: 'main#index'
end end

View File

@ -0,0 +1,20 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.timestamps
t.string :name, null: false
t.string :organization
t.string :email, null: false
t.string :voice_number
t.string :sms_number
t.string :address_1
t.string :address_2
t.string :city
t.string :state
t.string :zip
t.boolean :admin, default: false
end
add_index :users, :email, unique: true
end
end

View File

@ -1,20 +0,0 @@
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.timestamps
t.string :name, :null => false
t.string :organization
t.string :email, :null => false
t.string :voice_number
t.string :sms_number
t.boolean :admin, :default => false
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
end
end

View File

@ -0,0 +1,53 @@
class AddDeviseToUsers < ActiveRecord::Migration
def up
change_table(:users) do |t|
## Database authenticatable
# t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
# Uncomment below if timestamps were not included in your original model.
# t.timestamps
end
# add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true
end
def down
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -3,12 +3,12 @@ class CreateThings < ActiveRecord::Migration
create_table :things do |t| create_table :things do |t|
t.timestamps t.timestamps
t.string :name t.string :name
t.decimal :lat, :null => false, :precision => 16, :scale => 14 t.decimal :lat, null: false, precision: 16, scale: 14
t.decimal :lng, :null => false, :precision => 17, :scale => 14 t.decimal :lng, null: false, precision: 17, scale: 14
t.integer :city_id t.integer :city_id
t.integer :user_id t.integer :user_id
end end
add_index :things, :city_id, :unique => true add_index :things, :city_id, unique: true
end end
end end

View File

@ -1,14 +0,0 @@
class CreateRailsAdminHistoriesTable < ActiveRecord::Migration
def change
create_table :rails_admin_histories do |t|
t.string :message # title, name, or object_id
t.string :username
t.integer :item
t.string :table
t.integer :month, :limit => 2
t.integer :year, :limit => 5
t.timestamps
end
add_index(:rails_admin_histories, [:item, :table, :month, :year], :name => 'index_rails_admin_histories' )
end
end

View File

@ -2,10 +2,10 @@ class CreateReminders < ActiveRecord::Migration
def change def change
create_table :reminders do |t| create_table :reminders do |t|
t.timestamps t.timestamps
t.integer :from_user_id, :null => false t.integer :from_user_id, null: false
t.integer :to_user_id, :null => false t.integer :to_user_id, null: false
t.integer :thing_id, :null => false t.integer :thing_id, null: false
t.boolean :sent, :default => false t.boolean :sent, default: false
end end
add_index :reminders, :from_user_id add_index :reminders, :from_user_id

View File

@ -1,9 +0,0 @@
class AddAddressToUsers < ActiveRecord::Migration
def change
add_column :users, :address_1, :string
add_column :users, :address_2, :string
add_column :users, :city, :string
add_column :users, :state, :string
add_column :users, :zip, :string
end
end

View File

@ -0,0 +1,15 @@
class CreateRailsAdminHistoriesTable < ActiveRecord::Migration
def change
create_table :rails_admin_histories do |t|
t.string :message # title, name, or object_id
t.string :username
t.integer :item
t.string :table
t.integer :month, limit: 2
t.integer :year, limit: 5
t.timestamps
end
add_index(:rails_admin_histories, [:item, :table, :month, :year], name: 'index_rails_admin_histories' )
end
end

View File

@ -1,11 +0,0 @@
class AddRememberPasswordSentAtToUsers < ActiveRecord::Migration
def up
change_table :users do |t|
t.datetime :reset_password_sent_at
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -11,24 +11,24 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 6) do ActiveRecord::Schema.define(:version => 5) do
create_table "rails_admin_histories", :force => true do |t| create_table "rails_admin_histories", :force => true do |t|
t.string "message" t.string "message"
t.string "username" t.string "username"
t.integer "item" t.integer "item"
t.string "table" t.string "table"
t.integer "month" t.integer "month", :limit => 2
t.integer "year", :limit => 8 t.integer "year", :limit => 8
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
end end
add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories" add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories"
create_table "reminders", :force => true do |t| create_table "reminders", :force => true do |t|
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.integer "from_user_id", :null => false t.integer "from_user_id", :null => false
t.integer "to_user_id", :null => false t.integer "to_user_id", :null => false
t.integer "thing_id", :null => false t.integer "thing_id", :null => false
@ -41,8 +41,8 @@ ActiveRecord::Schema.define(:version => 6) do
add_index "reminders", ["to_user_id"], :name => "index_reminders_on_to_user_id" add_index "reminders", ["to_user_id"], :name => "index_reminders_on_to_user_id"
create_table "things", :force => true do |t| create_table "things", :force => true do |t|
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.string "name" t.string "name"
t.decimal "lat", :precision => 16, :scale => 14, :null => false t.decimal "lat", :precision => 16, :scale => 14, :null => false
t.decimal "lng", :precision => 17, :scale => 14, :null => false t.decimal "lng", :precision => 17, :scale => 14, :null => false
@ -53,29 +53,28 @@ ActiveRecord::Schema.define(:version => 6) do
add_index "things", ["city_id"], :name => "index_things_on_city_id", :unique => true add_index "things", ["city_id"], :name => "index_things_on_city_id", :unique => true
create_table "users", :force => true do |t| create_table "users", :force => true do |t|
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.string "name", :null => false t.string "name", :null => false
t.string "organization" t.string "organization"
t.string "email", :default => "", :null => false t.string "email", :null => false
t.string "voice_number" t.string "voice_number"
t.string "sms_number" t.string "sms_number"
t.string "address_1"
t.string "address_2"
t.string "city"
t.string "state"
t.string "zip"
t.boolean "admin", :default => false t.boolean "admin", :default => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token" t.string "reset_password_token"
t.string "remember_token" t.datetime "reset_password_sent_at"
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0 t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at" t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip" t.string "current_sign_in_ip"
t.string "last_sign_in_ip" t.string "last_sign_in_ip"
t.string "address_1"
t.string "address_2"
t.string "city"
t.string "state"
t.string "zip"
t.datetime "reset_password_sent_at"
end end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true add_index "users", ["email"], :name => "index_users_on_email", :unique => true

26506
db/seeds.rb

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -9,39 +9,39 @@ class PasswordsControllerTest < ActionController::TestCase
test 'should send password reset instructions if email address is found' do test 'should send password reset instructions if email address is found' do
num_deliveries = ActionMailer::Base.deliveries.size 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_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success assert_response :success
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
assert_equal [@user.email], email.to assert_equal [@user.email], email.to
assert_equal "Reset password instructions", email.subject assert_equal 'Reset password instructions', email.subject
end end
test 'should not send password reset instructions if email address is not found' do 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 assert_response :error
end end
test 'should render edit view' do test 'should render edit view' do
get :edit, :reset_password_token => 'token' get :edit, reset_password_token: 'token'
assert_response :success assert_response :success
end end
test 'should reset user password with an valid reset password token' do test 'should reset user password with an valid reset password token' do
@user.send :generate_reset_password_token! @user.send :generate_reset_password_token!
put :update, :user => {:reset_password_token => @user.reset_password_token, :password => 'new_password', :password_confirmation => 'new_password'} put :update, user: {reset_password_token: @user.reset_password_token, password: 'new_password', password_confirmation: 'new_password'}
@user.reload @user.reload
assert @user.valid_password?('new_password') assert @user.valid_password?('new_password')
assert_response :redirect assert_response :redirect
assert_redirected_to :controller => 'main', :action => 'index' assert_redirected_to controller: 'main', action: 'index'
end end
test 'should not reset user password with an invalid reset password token' do test 'should not reset user password with an invalid reset password token' do
@user.send :generate_reset_password_token! @user.send :generate_reset_password_token!
put :update, :user => {:reset_password_token => 'invalid_token', :password => 'new_password', :password_confirmation => 'new_password'} put :update, user: {reset_password_token: 'invalid_token', password: 'new_password', password_confirmation: 'new_password'}
@user.reload @user.reload
assert !@user.valid_password?('new_password') assert !@user.valid_password?('new_password')
assert_response :redirect assert_response :redirect
assert_redirected_to :controller => 'main', :action => 'index' assert_redirected_to controller: 'main', action: 'index'
end end
end end

View File

@ -1,21 +1,24 @@
require 'test_helper' require 'test_helper'
class RemindersControllerTest < ActionController::TestCase class RemindersControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do setup do
request.env["devise.mapping"] = Devise.mappings[:user]
@thing = things(:thing_1) @thing = things(:thing_1)
@dan = users(:dan) @dan = users(:dan)
@erik = users(:erik) @user = users(:erik)
@thing.user = @dan @thing.user = @dan
@thing.save! @thing.save!
end end
test 'should send a reminder email' do test 'should send a reminder email' do
sign_in @user
num_deliveries = ActionMailer::Base.deliveries.size num_deliveries = ActionMailer::Base.deliveries.size
post :create, :format => :json, :reminder => {:thing_id => @thing.id, :from_user_id => @erik.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_equal num_deliveries + 1, ActionMailer::Base.deliveries.size
assert_response :success assert_response :success
email = ActionMailer::Base.deliveries.last email = ActionMailer::Base.deliveries.last
assert_equal [@dan.email], email.to assert_equal [@dan.email], email.to
assert_equal "Remember to shovel", email.subject assert_equal 'Remember to shovel', email.subject
end end
end end

View File

@ -19,12 +19,12 @@ class SessionsControllerTest < ActionController::TestCase
end end
test 'should authenticate user if password is correct' do test 'should authenticate user if password is correct' do
post :create, :user => {:email => @user.email, :password => 'correct'} post :create, user: {email: @user.email, password: 'correct'}
assert_response :success assert_response :success
end end
test 'should return error if password is incorrect' do test 'should return error if password is incorrect' do
post :create, :user => {:email => @user.email, :password => 'incorrect'} post :create, user: {email: @user.email, password: 'incorrect'}
assert_response 401 assert_response 401
end end

View File

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

View File

@ -6,14 +6,14 @@ class ThingsControllerTest < ActionController::TestCase
end end
test 'should list hydrants' do 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_not_nil assigns :things
assert_response :success assert_response :success
end end
test 'should update hydrant' do test 'should update hydrant' do
assert_not_equal 'Birdsill', @thing.name 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 @thing.reload
assert_equal 'Birdsill', @thing.name assert_equal 'Birdsill', @thing.name
assert_not_nil assigns :thing assert_not_nil assigns :thing

View File

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

View File

@ -3,8 +3,8 @@ require 'rails/performance_test_help'
class BrowsingTest < ActionDispatch::PerformanceTest class BrowsingTest < ActionDispatch::PerformanceTest
# Refer to the documentation for all available options # Refer to the documentation for all available options
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] # self.profile_options = { runs: 5, metrics: [:wall_time, :memory]
# :output => 'tmp/performance', :formats => [:flat] } # output: 'tmp/performance', formats: [:flat] }
def test_homepage def test_homepage
get '/' get '/'

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

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

0
vendor/plugins/.gitkeep vendored Normal file
View File