Remove support for Ruby 1.8
This commit is contained in:
parent
af08da6596
commit
6b2c541f45
|
@ -3,5 +3,4 @@ before_script: bundle exec rake db:create db:schema:load
|
|||
bundler_args: --without assets:development:production
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.2
|
||||
- 1.9.3
|
||||
|
|
14
README.md
14
README.md
|
@ -80,19 +80,13 @@ Ideally, a bug report should include a pull request with failing specs.
|
|||
[branch]: http://learn.github.com/p/branching.html
|
||||
[pr]: http://help.github.com/send-pull-requests/
|
||||
|
||||
## Supported Ruby Versions
|
||||
This library aims to support and is [tested against][travis] the following Ruby
|
||||
implementations:
|
||||
## Supported Ruby Version
|
||||
This library aims to support and is [tested against][travis] Ruby version 1.9.3.
|
||||
|
||||
* Ruby 1.9.2
|
||||
* Ruby 1.9.3
|
||||
|
||||
If something doesn't work on one of these interpreters, it should be considered
|
||||
a bug.
|
||||
If something doesn't work on this version, it should be considered a bug.
|
||||
|
||||
This library may inadvertently work (or seem to work) on other Ruby
|
||||
implementations, however support will only be provided for the versions listed
|
||||
above.
|
||||
implementations, however support will only be provided for the version above.
|
||||
|
||||
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
|
||||
|
|
1
Rakefile
1
Rakefile
|
@ -1,3 +1,4 @@
|
|||
#!/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.
|
||||
|
||||
|
|
|
@ -399,7 +399,7 @@ $(function() {
|
|||
data: {
|
||||
'thing_id': activeThingId,
|
||||
'flash': {
|
||||
'notice': "<%= I18n.t("notices.adopted", :thing => I18n.t("defaults.thing")) %>"
|
||||
'notice': "<%= I18n.t("notices.adopted", thing: I18n.t("defaults.thing")) %>"
|
||||
}
|
||||
},
|
||||
success: function(data) {
|
||||
|
@ -442,7 +442,7 @@ $(function() {
|
|||
data: {
|
||||
'thing_id': activeThingId,
|
||||
'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) {
|
||||
|
@ -664,7 +664,6 @@ $(function() {
|
|||
'utf8': '✓',
|
||||
'authenticity_token': $('#reminder_form input[name="authenticity_token"]').val(),
|
||||
'reminder': {
|
||||
'from_user_id': $('#reminder_from_user_id').val(),
|
||||
'to_user_id': $('#reminder_to_user_id').val(),
|
||||
'thing_id': activeThingId
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
*
|
||||
*= require_self
|
||||
*= require_tree .
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
class PasswordsController < Devise::PasswordsController
|
||||
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?
|
||||
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
|
||||
self.resource = resource_class.reset_password_by_token(params[resource_name])
|
||||
redirect_to(:controller => "main", :action => "index")
|
||||
self.resource = resource_class.reset_password_by_token(resource_params)
|
||||
redirect_to(controller: "main", action: "index")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,12 +3,13 @@ class RemindersController < ApplicationController
|
|||
|
||||
def create
|
||||
@reminder = Reminder.new(params[:reminder])
|
||||
@reminder.from_user = current_user
|
||||
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
|
||||
end
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
class SessionsController < Devise::SessionsController
|
||||
def new
|
||||
redirect_to root_path
|
||||
redirect_to(root_path)
|
||||
end
|
||||
|
||||
def create
|
||||
resource = warden.authenticate(:scope => resource_name)
|
||||
if resource
|
||||
sign_in(resource_name, resource)
|
||||
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
|
||||
|
||||
def destroy
|
||||
signed_in = signed_in?(resource_name)
|
||||
sign_out(resource_name) if signed_in
|
||||
render(:json => {"success" => signed_in})
|
||||
render(json: {success: signed_in})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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(params[:thing])
|
||||
respond_with @thing
|
||||
else
|
||||
render(:json => {"errors" => @thing.errors}, :status => 500)
|
||||
render(json: {errors: @thing.errors}, status: 500)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class UsersController < Devise::RegistrationsController
|
||||
def edit
|
||||
render("sidebar/edit_profile", :layout => "sidebar")
|
||||
render("sidebar/edit_profile", layout: "sidebar")
|
||||
end
|
||||
|
||||
def update
|
||||
if resource.update_with_password(params[resource_name])
|
||||
sign_in(resource_name, resource, :bypass => true)
|
||||
if resource.update_with_password(resource_params)
|
||||
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
|
||||
|
||||
|
@ -18,10 +18,10 @@ class UsersController < Devise::RegistrationsController
|
|||
build_resource
|
||||
if resource.save
|
||||
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
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Reminder < ActiveRecord::Base
|
||||
attr_accessible :thing_id, :to_user_id
|
||||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class Thing < ActiveRecord::Base
|
||||
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
|
||||
belongs_to :user
|
||||
has_many :reminders
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
|
||||
:trackable, :validatable
|
||||
attr_accessible :address_1, :address_2, :city, :email, :name, :organization,
|
||||
:password, :password_confirmation, :remember_me, :sms_number, :state,
|
||||
:voice_number, :zip
|
||||
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
|
||||
|
|
|
@ -4,7 +4,7 @@ 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)))
|
||||
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
|
||||
|
@ -31,7 +31,7 @@ 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 = :en
|
||||
# config.i18n.default_locale = :de
|
||||
|
||||
# Configure the default encoding used in templates for Ruby 1.9.
|
||||
config.encoding = "utf-8"
|
||||
|
@ -39,6 +39,9 @@ module AdoptAThing
|
|||
# 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
|
||||
|
@ -48,7 +51,7 @@ module AdoptAThing
|
|||
# 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
|
||||
config.active_record.whitelist_attributes = true
|
||||
|
||||
# Enable the asset pipeline
|
||||
config.assets.enabled = true
|
||||
|
|
|
@ -15,15 +15,12 @@ AdoptAThing::Application.configure do
|
|||
config.assets.compress = true
|
||||
|
||||
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||
# config.assets.compile = false
|
||||
|
||||
# Fallback to assets pipeline if a precompiled asset is missed
|
||||
config.assets.compile = true
|
||||
config.assets.compile = false
|
||||
|
||||
# Generate digests for assets URLs
|
||||
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
|
||||
|
||||
# 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)
|
||||
# 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.delivery_method = :smtp
|
||||
config.action_mailer.default_url_options = {:host => 'adoptahydrant.org'}
|
||||
|
@ -73,10 +68,10 @@ AdoptAThing::Application.configure do
|
|||
end
|
||||
|
||||
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'],
|
||||
address: "smtp.sendgrid.net",
|
||||
port: "25",
|
||||
authentication: :plain,
|
||||
user_name: ENV['SENDGRID_USERNAME'],
|
||||
password: ENV['SENDGRID_PASSWORD'],
|
||||
domain: ENV['SENDGRID_DOMAIN'],
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ Devise.setup do |config|
|
|||
# the user cannot access the website without confirming his account.
|
||||
# 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
|
||||
# db field (see migrations). Until confirmed new email is stored in
|
||||
# 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
|
||||
# :secure => true in order to force SSL only cookies.
|
||||
# config.cookie_options = {}
|
||||
# config.rememberable_options = {}
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# 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.
|
||||
# config.timeout_in = 30.minutes
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# config.expire_auth_token_on_timeout = false
|
||||
|
||||
# ==> Configuration for :lockable
|
||||
# Defines which strategy will be used to lock an account.
|
||||
# :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).
|
||||
# config.default_scope = :user
|
||||
|
||||
# Configure sign_out behavior.
|
||||
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
||||
# The default is true, which means any logout action will sign out all active scopes.
|
||||
# Set this configuration to false if you want /users/sign_out to sign out
|
||||
# only the current scope. By default, Devise signs out all scopes.
|
||||
# config.sign_out_all_scopes = true
|
||||
|
||||
# ==> Navigation configuration
|
||||
|
@ -213,4 +215,18 @@ Devise.setup do |config|
|
|||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# 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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
RailsAdmin.config do |config|
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# 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,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
|
|
|
@ -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']
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# 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]
|
||||
end
|
||||
|
||||
# Disable root element in JSON by default.
|
||||
|
|
|
@ -28,10 +28,11 @@ en:
|
|||
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_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:
|
||||
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.'
|
||||
registrations:
|
||||
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.'
|
||||
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:
|
||||
success: 'Successfully authorized from %{kind} account.'
|
||||
failure: 'Could not authorize you from %{kind} because "%{reason}".'
|
||||
success: 'Successfully authenticated from %{kind} account.'
|
||||
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Confirmation instructions'
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
AdoptAThing::Application.routes.draw do
|
||||
devise_for :users, :controllers => {
|
||||
:passwords => 'passwords',
|
||||
:registrations => 'users',
|
||||
:sessions => 'sessions',
|
||||
passwords: 'passwords',
|
||||
registrations: 'users',
|
||||
sessions: 'sessions',
|
||||
}
|
||||
|
||||
get 'address' => 'addresses#show', :as => 'address'
|
||||
get 'info_window' => 'info_window#index', :as => 'info_window'
|
||||
get 'sitemap' => 'sitemaps#index', :as => 'sitemap'
|
||||
get '/address', to: 'addresses#show', as: 'address'
|
||||
get '/info_window', to:'info_window#index', as: 'info_window'
|
||||
get '/sitemap', to: 'sitemaps#index', as: 'sitemap'
|
||||
|
||||
scope "sidebar", :controller => :sidebar do
|
||||
get :search, :as => 'search'
|
||||
get :combo_form, :as => 'combo_form'
|
||||
get :edit_profile , :as => 'edit_profile'
|
||||
scope '/sidebar', controller: :sidebar do
|
||||
get :search, as: 'search'
|
||||
get :combo_form, as: 'combo_form'
|
||||
get :edit_profile , as: 'edit_profile'
|
||||
end
|
||||
|
||||
resource :reminders
|
||||
resource :things
|
||||
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
|
||||
root :to => 'main#index'
|
||||
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
||||
root to: 'main#index'
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -3,12 +3,12 @@ class CreateThings < ActiveRecord::Migration
|
|||
create_table :things do |t|
|
||||
t.timestamps
|
||||
t.string :name
|
||||
t.decimal :lat, :null => false, :precision => 16, :scale => 14
|
||||
t.decimal :lng, :null => false, :precision => 17, :scale => 14
|
||||
t.decimal :lat, null: false, precision: 16, scale: 14
|
||||
t.decimal :lng, null: false, precision: 17, scale: 14
|
||||
t.integer :city_id
|
||||
t.integer :user_id
|
||||
end
|
||||
|
||||
add_index :things, :city_id, :unique => true
|
||||
add_index :things, :city_id, unique: true
|
||||
end
|
||||
end
|
|
@ -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
|
|
@ -2,10 +2,10 @@ class CreateReminders < ActiveRecord::Migration
|
|||
def change
|
||||
create_table :reminders do |t|
|
||||
t.timestamps
|
||||
t.integer :from_user_id, :null => false
|
||||
t.integer :to_user_id, :null => false
|
||||
t.integer :thing_id, :null => false
|
||||
t.boolean :sent, :default => false
|
||||
t.integer :from_user_id, null: false
|
||||
t.integer :to_user_id, null: false
|
||||
t.integer :thing_id, null: false
|
||||
t.boolean :sent, default: false
|
||||
end
|
||||
|
||||
add_index :reminders, :from_user_id
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
43
db/schema.rb
43
db/schema.rb
|
@ -11,24 +11,24 @@
|
|||
#
|
||||
# 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|
|
||||
t.string "message"
|
||||
t.string "username"
|
||||
t.integer "item"
|
||||
t.string "table"
|
||||
t.integer "month"
|
||||
t.integer "month", :limit => 2
|
||||
t.integer "year", :limit => 8
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories"
|
||||
|
||||
create_table "reminders", :force => true do |t|
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "from_user_id", :null => false
|
||||
t.integer "to_user_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"
|
||||
|
||||
create_table "things", :force => true do |t|
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name"
|
||||
t.decimal "lat", :precision => 16, :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
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "name", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name", :null => false
|
||||
t.string "organization"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "email", :null => false
|
||||
t.string "voice_number"
|
||||
t.string "sms_number"
|
||||
t.boolean "admin", :default => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.string "remember_token"
|
||||
t.datetime "remember_created_at"
|
||||
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"
|
||||
t.string "address_1"
|
||||
t.string "address_2"
|
||||
t.string "city"
|
||||
t.string "state"
|
||||
t.string "zip"
|
||||
t.boolean "admin", :default => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
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"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||
|
|
26506
db/seeds.rb
26506
db/seeds.rb
File diff suppressed because it is too large
Load Diff
|
@ -3,17 +3,17 @@ 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?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)
|
||||
get :show, :address => 'City Hall', :city_state => "Boston, MA"
|
||||
to_return(body: File.read(File.expand_path('../../fixtures/city_hall.kml', __FILE__)))
|
||||
get :show, address: 'City Hall', city_state: "Boston, MA"
|
||||
assert_not_nil assigns :address
|
||||
end
|
||||
|
||||
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').
|
||||
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+').
|
||||
to_return(:body => '', :status => 204)
|
||||
get :show, :address => '', :city_state => ''
|
||||
to_return(body: '', status: 204)
|
||||
get :show, address: '', city_state: ''
|
||||
assert_response :missing
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -9,39 +9,39 @@ 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
|
||||
assert_equal [@user.email], email.to
|
||||
assert_equal "Reset password instructions", email.subject
|
||||
assert_equal 'Reset password instructions', email.subject
|
||||
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
|
||||
@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
|
||||
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 :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
|
||||
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
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RemindersControllerTest < ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
setup do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
@thing = things(:thing_1)
|
||||
@dan = users(:dan)
|
||||
@erik = users(:erik)
|
||||
@user = users(:erik)
|
||||
@thing.user = @dan
|
||||
@thing.save!
|
||||
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, :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_response :success
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
assert_equal [@dan.email], email.to
|
||||
assert_equal "Remember to shovel", email.subject
|
||||
assert_equal 'Remember to shovel', email.subject
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,12 +19,12 @@ class SessionsControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
@ -26,27 +26,27 @@ class UsersControllerTest < ActionController::TestCase
|
|||
|
||||
test 'should update user if password is correct' do
|
||||
sign_in @user
|
||||
assert_not_equal @user.name, 'New Name'
|
||||
put :update, :user => {:name => 'New Name', :current_password => 'correct'}
|
||||
assert_not_equal 'New Name', @user.name
|
||||
put :update, user: {name: 'New Name', current_password: 'correct'}
|
||||
@user.reload
|
||||
assert_equal @user.name, 'New Name'
|
||||
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
|
||||
|
|
|
@ -3,8 +3,8 @@ require 'rails/performance_test_help'
|
|||
|
||||
class BrowsingTest < ActionDispatch::PerformanceTest
|
||||
# Refer to the documentation for all available options
|
||||
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
||||
# :output => 'tmp/performance', :formats => [:flat] }
|
||||
# self.profile_options = { runs: 5, metrics: [:wall_time, :memory]
|
||||
# output: 'tmp/performance', formats: [:flat] }
|
||||
|
||||
def test_homepage
|
||||
get '/'
|
||||
|
|
Loading…
Reference in New Issue