From 4cfa9ad5c7c503243739536f6b2150ccc607bef0 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 2 Dec 2013 22:47:02 +0100 Subject: [PATCH] Update rails dependency to version 4.0.1 --- .gitignore | 9 +- Gemfile | 3 +- Gemfile.lock | 140 ++++++++---------- Rakefile | 1 - app/assets/images/.keep | 0 app/assets/javascripts/application.js | 6 +- app/assets/javascripts/main.js.erb | 8 +- app/controllers/addresses_controller.rb | 2 +- app/controllers/application_controller.rb | 4 +- app/controllers/concerns/.keep | 0 app/controllers/passwords_controller.rb | 8 +- app/controllers/reminders_controller.rb | 4 +- app/controllers/sessions_controller.rb | 8 +- app/controllers/things_controller.rb | 4 +- app/controllers/users_controller.rb | 12 +- app/mailers/.keep | 0 app/mailers/thing_mailer.rb | 6 +- app/models/.keep | 0 app/models/concerns/.keep | 0 app/models/reminder.rb | 4 +- app/models/thing.rb | 2 +- app/models/user.rb | 12 +- bin/bundle | 3 + bin/rails | 4 + bin/rake | 4 + config.ru | 2 +- config/application.rb | 46 +----- config/boot.rb | 2 - config/environment.rb | 4 +- config/environments/development.rb | 30 ++-- config/environments/production.rb | 68 +++++---- config/environments/test.rb | 27 ++-- .../initializers/filter_parameter_logging.rb | 4 + config/initializers/inflections.rb | 11 +- config/initializers/secret_token.rb | 13 +- config/initializers/session_store.rb | 5 - config/initializers/wrap_parameters.rb | 12 +- lib/assets/.keep | 0 lib/tasks/.keep | 0 log/.keep | 0 public/404.html | 54 +++++-- public/422.html | 54 +++++-- public/500.html | 54 +++++-- public/robots.txt | 2 +- test/controllers/.keep | 0 test/fixtures/.keep | 0 test/functional/addresses_controller_test.rb | 16 +- .../functional/info_window_controller_test.rb | 8 +- test/functional/passwords_controller_test.rb | 14 +- test/functional/reminders_controller_test.rb | 6 +- test/functional/sessions_controller_test.rb | 6 +- test/functional/sitemaps_controller_test.rb | 2 +- test/functional/things_controller_test.rb | 4 +- test/functional/users_controller_test.rb | 14 +- test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/test_helper.rb | 6 +- vendor/assets/javascripts/.keep | 0 vendor/assets/stylesheets/.keep | 0 61 files changed, 385 insertions(+), 323 deletions(-) create mode 100644 app/assets/images/.keep create mode 100644 app/controllers/concerns/.keep create mode 100644 app/mailers/.keep create mode 100644 app/models/.keep create mode 100644 app/models/concerns/.keep create mode 100755 bin/bundle create mode 100755 bin/rails create mode 100755 bin/rake create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 lib/assets/.keep create mode 100644 lib/tasks/.keep create mode 100644 log/.keep create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 vendor/assets/javascripts/.keep create mode 100644 vendor/assets/stylesheets/.keep diff --git a/.gitignore b/.gitignore index d6f866f..6590129 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Gemfile b/Gemfile index a5a289c..9e938a9 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 64f263e..0374943 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/Rakefile b/Rakefile index f1ab634..5a4d7c2 100644 --- a/Rakefile +++ b/Rakefile @@ -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. diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 15ebed9..5bc2e1c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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 . diff --git a/app/assets/javascripts/main.js.erb b/app/assets/javascripts/main.js.erb index b37c2b8..fdfe7a5 100644 --- a/app/assets/javascripts/main.js.erb +++ b/app/assets/javascripts/main.js.erb @@ -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(), diff --git a/app/controllers/addresses_controller.rb b/app/controllers/addresses_controller.rb index 022bc2f..1d160b9 100644 --- a/app/controllers/addresses_controller.rb +++ b/app/controllers/addresses_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 00ee32f..f5b13c6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index d7d87cd..68eba0f 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -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 diff --git a/app/controllers/reminders_controller.rb b/app/controllers/reminders_controller.rb index acfa5ed..c3b6694 100644 --- a/app/controllers/reminders_controller.rb +++ b/app/controllers/reminders_controller.rb @@ -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 diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index e477831..f9c1d90 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/controllers/things_controller.rb b/app/controllers/things_controller.rb index f6680ae..db2b520 100644 --- a/app/controllers/things_controller.rb +++ b/app/controllers/things_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 23738ff..c29af21 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/mailers/thing_mailer.rb b/app/mailers/thing_mailer.rb index 3483172..a6e863a 100644 --- a/app/mailers/thing_mailer.rb +++ b/app/mailers/thing_mailer.rb @@ -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 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/reminder.rb b/app/models/reminder.rb index 543ffa2..967664c 100644 --- a/app/models/reminder.rb +++ b/app/models/reminder.rb @@ -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 diff --git a/app/models/thing.rb b/app/models/thing.rb index 12782bb..c42b2b6 100644 --- a/app/models/thing.rb +++ b/app/models/thing.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index aa21768..a276496 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/config.ru b/config.ru index c4beb3f..5bc2a61 100644 --- a/config.ru +++ b/config.ru @@ -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 diff --git a/config/application.rb b/config/application.rb index 0f224c2..d62d316 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 diff --git a/config/boot.rb b/config/boot.rb index 4489e58..3596736 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,5 +1,3 @@ -require 'rubygems' - # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/config/environment.rb b/config/environment.rb index 674fea8..d0bf34d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -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! diff --git a/config/environments/development.rb b/config/environments/development.rb index 4b1d299..e2a2fcf 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/config/environments/production.rb b/config/environments/production.rb index 10d8ad7..32d3616 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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 = { diff --git a/config/environments/test.rb b/config/environments/test.rb index 084b949..a636251 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -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 diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -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] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be..ac033bf 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -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 diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index f357808..087e396 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -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' \ No newline at end of file +# 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' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 4e77007..7f97dc9 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -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 diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df20..33725e9 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -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 diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/public/404.html b/public/404.html index 9a48320..a0daa0c 100644 --- a/public/404.html +++ b/public/404.html @@ -2,17 +2,48 @@ The page you were looking for doesn't exist (404) - @@ -22,5 +53,6 @@

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

+

If you are the application owner check the logs for more information.

diff --git a/public/422.html b/public/422.html index 83660ab..fbb4b84 100644 --- a/public/422.html +++ b/public/422.html @@ -2,17 +2,48 @@ The change you wanted was rejected (422) - @@ -22,5 +53,6 @@

The change you wanted was rejected.

Maybe you tried to change something you didn't have access to.

+

If you are the application owner check the logs for more information.

diff --git a/public/500.html b/public/500.html index f3648a0..e9052d3 100644 --- a/public/500.html +++ b/public/500.html @@ -2,17 +2,48 @@ We're sorry, but something went wrong (500) - @@ -21,5 +52,6 @@

We're sorry, but something went wrong.

+

If you are the application owner check the logs for more information.

diff --git a/public/robots.txt b/public/robots.txt index 085187f..1a3a5e4 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -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: / diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/functional/addresses_controller_test.rb b/test/functional/addresses_controller_test.rb index 93e4e50..064f069 100644 --- a/test/functional/addresses_controller_test.rb +++ b/test/functional/addresses_controller_test.rb @@ -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 diff --git a/test/functional/info_window_controller_test.rb b/test/functional/info_window_controller_test.rb index 3b1f0fa..85839fc 100644 --- a/test/functional/info_window_controller_test.rb +++ b/test/functional/info_window_controller_test.rb @@ -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' diff --git a/test/functional/passwords_controller_test.rb b/test/functional/passwords_controller_test.rb index 96ad973..54ad572 100644 --- a/test/functional/passwords_controller_test.rb +++ b/test/functional/passwords_controller_test.rb @@ -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 diff --git a/test/functional/reminders_controller_test.rb b/test/functional/reminders_controller_test.rb index 48edc1b..2561241 100644 --- a/test/functional/reminders_controller_test.rb +++ b/test/functional/reminders_controller_test.rb @@ -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 diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb index 8da6a28..e7886a9 100644 --- a/test/functional/sessions_controller_test.rb +++ b/test/functional/sessions_controller_test.rb @@ -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 diff --git a/test/functional/sitemaps_controller_test.rb b/test/functional/sitemaps_controller_test.rb index 7d6d746..1ae7e82 100644 --- a/test/functional/sitemaps_controller_test.rb +++ b/test/functional/sitemaps_controller_test.rb @@ -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 diff --git a/test/functional/things_controller_test.rb b/test/functional/things_controller_test.rb index def4bf2..c8b2281 100644 --- a/test/functional/things_controller_test.rb +++ b/test/functional/things_controller_test.rb @@ -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 diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index ad39b97..4e8ee77 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -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 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/test_helper.rb b/test/test_helper.rb index 2f20b69..7922c92 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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 diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29