From 3c908f7487b36963384b4dd17229ed44e5fd8870 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Sat, 18 Mar 2017 21:08:55 -0500 Subject: [PATCH] update to rails 4.2.8 --- Gemfile | 4 +- Gemfile.lock | 155 ++++++++++++++++++------------ app/models/comment.rb | 4 +- app/models/invitation.rb | 2 +- app/models/invitation_request.rb | 4 +- app/models/message.rb | 2 +- app/models/user.rb | 2 +- config/application.rb | 8 +- config/environments/production.rb | 2 +- config/environments/test.rb | 6 +- db/schema.rb | 153 ++++++++++++++--------------- 11 files changed, 188 insertions(+), 154 deletions(-) diff --git a/Gemfile b/Gemfile index a214e924..e75d1c55 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "4.1.12" +gem "rails", "4.2.8" gem "unicorn" @@ -37,7 +37,7 @@ gem "oauth" gem "mail" group :test, :development do - gem "rspec-rails", "~> 2.6" + gem "rspec-rails", "~> 3.5", ">= 3.5.2" gem "machinist" gem "sqlite3" gem "faker" diff --git a/Gemfile.lock b/Gemfile.lock index 4704c281..21701951 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,39 +1,48 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.12) - actionpack (= 4.1.12) - actionview (= 4.1.12) + actionmailer (4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.12) - actionview (= 4.1.12) - activesupport (= 4.1.12) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.8) + actionview (= 4.2.8) + activesupport (= 4.2.8) + rack (~> 1.6) rack-test (~> 0.6.2) - actionview (4.1.12) - activesupport (= 4.1.12) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.12) - activesupport (= 4.1.12) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.8) + activesupport (= 4.2.8) + globalid (>= 0.3.0) + activemodel (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) - activerecord (4.1.12) - activemodel (= 4.1.12) - activesupport (= 4.1.12) - arel (~> 5.0.0) + activerecord (4.2.8) + activemodel (= 4.2.8) + activesupport (= 4.2.8) + arel (~> 6.0) activerecord-typedstore (0.6.1) activerecord (>= 3.2, < 5) - activesupport (4.1.12) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (4.2.8) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (5.0.1.20140414130214) + arel (6.0.4) bcrypt (3.1.7) - builder (3.2.2) + builder (3.2.3) chunky_png (1.3.8) - diff-lcs (1.2.5) + concurrent-ruby (1.0.5) + diff-lcs (1.3) dynamic_form (1.1.4) erubis (2.7.0) exception_notification (4.0.1) @@ -42,73 +51,91 @@ GEM execjs (2.2.1) faker (1.4.2) i18n (~> 0.5) + globalid (0.3.7) + activesupport (>= 4.1.0) htmlentities (4.3.4) - i18n (0.7.0) + i18n (0.8.1) innertube (1.1.0) joiner (0.3.4) activerecord (>= 4.1.0) jquery-rails (3.1.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.3) + json (2.0.3) kgio (2.9.2) + loofah (2.0.3) + nokogiri (>= 1.5.9) machinist (2.0) - mail (2.6.3) - mime-types (>= 1.16, < 3) + mail (2.6.4) + mime-types (>= 1.16, < 4) middleware (0.1.0) - mime-types (2.6.1) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_portile (0.5.3) - minitest (5.7.0) + minitest (5.10.1) mysql2 (0.3.20) nokogiri (1.6.1) mini_portile (~> 0.5.0) oauth (0.4.7) - rack (1.5.5) + rack (1.6.5) rack-test (0.6.3) rack (>= 1.0) - rails (4.1.12) - actionmailer (= 4.1.12) - actionpack (= 4.1.12) - actionview (= 4.1.12) - activemodel (= 4.1.12) - activerecord (= 4.1.12) - activesupport (= 4.1.12) + rails (4.2.8) + actionmailer (= 4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) + activemodel (= 4.2.8) + activerecord (= 4.2.8) + activesupport (= 4.2.8) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.12) - sprockets-rails (~> 2.0) - railties (4.1.12) - actionpack (= 4.1.12) - activesupport (= 4.1.12) + railties (= 4.2.8) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.8) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + railties (4.2.8) + actionpack (= 4.2.8) + activesupport (= 4.2.8) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) - rake (10.4.2) + rake (12.0.0) rdiscount (2.1.7.1) riddle (1.5.11) rotp (3.3.0) rqrcode (0.10.1) chunky_png (~> 1.0) - rspec-collection_matchers (1.0.0) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (2.99.1) - rspec-expectations (2.99.2) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.2) - rspec-rails (2.99.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-rails (3.5.2) actionpack (>= 3.0) - activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-collection_matchers - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) - sprockets (3.2.0) - rack (~> 1.0) - sprockets-rails (2.3.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sqlite3 (1.3.9) thinking-sphinx (3.1.2) activerecord (>= 3.1.0) @@ -117,8 +144,8 @@ GEM joiner (>= 0.2.0) middleware (>= 0.1.0) riddle (>= 1.5.11) - thor (0.19.1) - thread_safe (0.3.5) + thor (0.19.4) + thread_safe (0.3.6) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.5.3) @@ -145,11 +172,11 @@ DEPENDENCIES mysql2 (>= 0.3.14) nokogiri (= 1.6.1) oauth - rails (= 4.1.12) + rails (= 4.2.8) rdiscount rotp rqrcode - rspec-rails (~> 2.6) + rspec-rails (~> 3.5, >= 3.5.2) sqlite3 thinking-sphinx (~> 3.1.2) uglifier (>= 1.3.0) diff --git a/app/models/comment.rb b/app/models/comment.rb index f45f6221..bb6b2270 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -257,7 +257,7 @@ class Comment < ActiveRecord::Base if u.email_mentions? begin - EmailReply.mention(self, u).deliver + EmailReply.mention(self, u).deliver_now rescue => e Rails.logger.error "error e-mailing #{u.email}: #{e}" end @@ -281,7 +281,7 @@ class Comment < ActiveRecord::Base u.id != self.user.id if u.email_replies? begin - EmailReply.reply(self, u).deliver + EmailReply.reply(self, u).deliver_now rescue => e Rails.logger.error "error e-mailing #{u.email}: #{e}" end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 19773645..a246d644 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -24,6 +24,6 @@ class Invitation < ActiveRecord::Base end def send_email - InvitationMailer.invitation(self).deliver + InvitationMailer.invitation(self).deliver_now end end diff --git a/app/models/invitation_request.rb b/app/models/invitation_request.rb index 5abe5298..2678a764 100644 --- a/app/models/invitation_request.rb +++ b/app/models/invitation_request.rb @@ -26,8 +26,8 @@ class InvitationRequest < ActiveRecord::Base def markeddown_memo Markdowner.to_html(self.memo) end - + def send_email - InvitationRequestMailer.invitation_request(self).deliver + InvitationRequestMailer.invitation_request(self).deliver_now end end diff --git a/app/models/message.rb b/app/models/message.rb index 1797de79..e71c127e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -49,7 +49,7 @@ class Message < ActiveRecord::Base if self.recipient.email_messages? begin - EmailMessage.notify(self, self.recipient).deliver + EmailMessage.notify(self, self.recipient).deliver_now rescue => e Rails.logger.error "error e-mailing #{self.recipient.email}: #{e}" end diff --git a/app/models/user.rb b/app/models/user.rb index 6d1d3481..3a427879 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -312,7 +312,7 @@ class User < ActiveRecord::Base self.password_reset_token = "#{Time.now.to_i}-#{Utils.random_str(30)}" self.save! - PasswordReset.password_reset_link(self, ip).deliver + PasswordReset.password_reset_link(self, ip).deliver_now end def has_2fa? diff --git a/config/application.rb b/config/application.rb index c7c00228..f72ae951 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,7 +26,13 @@ module Lobsters # Raise an exception when using mass assignment with unpermitted attributes config.action_controller.action_on_unpermitted_parameters = :raise + config.active_record.raise_in_transactional_callbacks = true + config.cache_store = :file_store, "#{config.root}/tmp/cache/" + + config.after_initialize do + require "#{Rails.root}/lib/monkey.rb" + end end end @@ -68,5 +74,3 @@ class << Rails.application true end end - -require "#{Rails.root}/lib/monkey" diff --git a/config/environments/production.rb b/config/environments/production.rb index b4ee2c7d..a301912a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,7 +20,7 @@ Lobsters::Application.configure do # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + config.serve_static_files = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier diff --git a/config/environments/test.rb b/config/environments/test.rb index e21872ae..635a19d6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,7 +13,7 @@ Lobsters::Application.configure do config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. @@ -35,5 +35,7 @@ Lobsters::Application.configure do config.active_support.deprecation = :stderr # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + config.action_view.raise_on_missing_translations = true end + +RSpec::Expectations.configuration.on_potential_false_positives = :nothing diff --git a/db/schema.rb b/db/schema.rb index 284e65be..786ce894 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,23 +13,23 @@ ActiveRecord::Schema.define(version: 20170225201811) do - create_table "comments", force: true do |t| + create_table "comments", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at" t.string "short_id", limit: 10, default: "", null: false - t.integer "story_id", null: false - t.integer "user_id", null: false - t.integer "parent_comment_id" - t.integer "thread_id" + t.integer "story_id", limit: 4, null: false + t.integer "user_id", limit: 4, null: false + t.integer "parent_comment_id", limit: 4 + t.integer "thread_id", limit: 4 t.text "comment", limit: 16777215, null: false - t.integer "upvotes", default: 0, null: false - t.integer "downvotes", default: 0, null: false + t.integer "upvotes", limit: 4, default: 0, null: false + t.integer "downvotes", limit: 4, default: 0, null: false t.decimal "confidence", precision: 20, scale: 19, default: 0.0, null: false t.text "markeddown_comment", limit: 16777215 t.boolean "is_deleted", default: false t.boolean "is_moderated", default: false t.boolean "is_from_email", default: false - t.integer "hat_id" + t.integer "hat_id", limit: 4 t.boolean "is_dragon", default: false end @@ -38,100 +38,101 @@ ActiveRecord::Schema.define(version: 20170225201811) do add_index "comments", ["story_id", "short_id"], name: "story_id_short_id", using: :btree add_index "comments", ["thread_id"], name: "thread_id", using: :btree - create_table "hat_requests", force: true do |t| + create_table "hat_requests", force: :cascade do |t| t.datetime "created_at" t.datetime "updated_at" - t.integer "user_id" - t.string "hat" - t.string "link" - t.text "comment" + t.integer "user_id", limit: 4 + t.string "hat", limit: 255 + t.string "link", limit: 255 + t.text "comment", limit: 65535 end - create_table "hats", force: true do |t| + create_table "hats", force: :cascade do |t| t.datetime "created_at" t.datetime "updated_at" - t.integer "user_id" - t.integer "granted_by_user_id" - t.string "hat" - t.string "link" + t.integer "user_id", limit: 4 + t.integer "granted_by_user_id", limit: 4 + t.string "hat", limit: 255 + t.string "link", limit: 255 end - create_table "hidden_stories", force: true do |t| - t.integer "user_id" - t.integer "story_id" + create_table "hidden_stories", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.integer "story_id", limit: 4 end add_index "hidden_stories", ["user_id", "story_id"], name: "index_hidden_stories_on_user_id_and_story_id", unique: true, using: :btree - create_table "invitation_requests", force: true do |t| - t.string "code" - t.boolean "is_verified", default: false - t.string "email" - t.string "name" - t.text "memo" - t.string "ip_address" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + create_table "invitation_requests", force: :cascade do |t| + t.string "code", limit: 255 + t.boolean "is_verified", default: false + t.string "email", limit: 255 + t.string "name", limit: 255 + t.text "memo", limit: 65535 + t.string "ip_address", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "invitations", force: true do |t| - t.integer "user_id" - t.string "email" - t.string "code" + create_table "invitations", force: :cascade do |t| + t.integer "user_id", limit: 4 + t.string "email", limit: 255 + t.string "code", limit: 255 t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "memo", limit: 16777215 end - create_table "keystores", id: false, force: true do |t| + create_table "keystores", id: false, force: :cascade do |t| t.string "key", limit: 50, default: "", null: false t.integer "value", limit: 8 end add_index "keystores", ["key"], name: "key", unique: true, using: :btree - create_table "messages", force: true do |t| + create_table "messages", force: :cascade do |t| t.datetime "created_at" - t.integer "author_user_id" - t.integer "recipient_user_id" + t.integer "author_user_id", limit: 4 + t.integer "recipient_user_id", limit: 4 t.boolean "has_been_read", default: false t.string "subject", limit: 100 t.text "body", limit: 16777215 t.string "short_id", limit: 30 t.boolean "deleted_by_author", default: false t.boolean "deleted_by_recipient", default: false + t.integer "hat_id", limit: 4 end add_index "messages", ["short_id"], name: "random_hash", unique: true, using: :btree - create_table "moderations", force: true do |t| + create_table "moderations", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.integer "moderator_user_id" - t.integer "story_id" - t.integer "comment_id" - t.integer "user_id" + t.integer "moderator_user_id", limit: 4 + t.integer "story_id", limit: 4 + t.integer "comment_id", limit: 4 + t.integer "user_id", limit: 4 t.text "action", limit: 16777215 t.text "reason", limit: 16777215 t.boolean "is_from_suggestions", default: false end - create_table "stories", force: true do |t| + create_table "stories", force: :cascade do |t| t.datetime "created_at" - t.integer "user_id" + t.integer "user_id", limit: 4 t.string "url", limit: 250, default: "" t.string "title", limit: 150, default: "", null: false t.text "description", limit: 16777215 t.string "short_id", limit: 6, default: "", null: false t.boolean "is_expired", default: false, null: false - t.integer "upvotes", default: 0, null: false - t.integer "downvotes", default: 0, null: false + t.integer "upvotes", limit: 4, default: 0, null: false + t.integer "downvotes", limit: 4, default: 0, null: false t.boolean "is_moderated", default: false, null: false t.decimal "hotness", precision: 20, scale: 10, default: 0.0, null: false t.text "markeddown_description", limit: 16777215 t.text "story_cache", limit: 16777215 - t.integer "comments_count", default: 0, null: false - t.integer "merged_story_id" + t.integer "comments_count", limit: 4, default: 0, null: false + t.integer "merged_story_id", limit: 4 t.datetime "unavailable_at" t.string "twitter_id", limit: 20 t.boolean "user_is_author", default: false @@ -144,35 +145,35 @@ ActiveRecord::Schema.define(version: 20170225201811) do add_index "stories", ["twitter_id"], name: "index_stories_on_twitter_id", using: :btree add_index "stories", ["url"], name: "url", length: {"url"=>191}, using: :btree - create_table "suggested_taggings", force: true do |t| - t.integer "story_id" - t.integer "tag_id" - t.integer "user_id" + create_table "suggested_taggings", force: :cascade do |t| + t.integer "story_id", limit: 4 + t.integer "tag_id", limit: 4 + t.integer "user_id", limit: 4 end - create_table "suggested_titles", force: true do |t| - t.integer "story_id" - t.integer "user_id" + create_table "suggested_titles", force: :cascade do |t| + t.integer "story_id", limit: 4 + t.integer "user_id", limit: 4 t.string "title", limit: 150, default: "", null: false end - create_table "tag_filters", force: true do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "user_id" - t.integer "tag_id" + create_table "tag_filters", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "user_id", limit: 4 + t.integer "tag_id", limit: 4 end add_index "tag_filters", ["user_id", "tag_id"], name: "user_tag_idx", using: :btree - create_table "taggings", force: true do |t| - t.integer "story_id", null: false - t.integer "tag_id", null: false + create_table "taggings", force: :cascade do |t| + t.integer "story_id", limit: 4, null: false + t.integer "tag_id", limit: 4, null: false end add_index "taggings", ["story_id", "tag_id"], name: "story_id_tag_id", unique: true, using: :btree - create_table "tags", force: true do |t| + create_table "tags", force: :cascade do |t| t.string "tag", limit: 25, default: "", null: false t.string "description", limit: 100 t.boolean "privileged", default: false @@ -183,7 +184,7 @@ ActiveRecord::Schema.define(version: 20170225201811) do add_index "tags", ["tag"], name: "tag", unique: true, using: :btree - create_table "users", force: true do |t| + create_table "users", force: :cascade do |t| t.string "username", limit: 50 t.string "email", limit: 100 t.string "password_digest", limit: 75 @@ -192,21 +193,21 @@ ActiveRecord::Schema.define(version: 20170225201811) do t.string "password_reset_token", limit: 75 t.string "session_token", limit: 75, default: "", null: false t.text "about", limit: 16777215 - t.integer "invited_by_user_id" + t.integer "invited_by_user_id", limit: 4 t.boolean "is_moderator", default: false t.boolean "pushover_mentions", default: false t.string "rss_token", limit: 75 t.string "mailing_list_token", limit: 75 - t.integer "mailing_list_mode", default: 0 - t.integer "karma", default: 0, null: false + t.integer "mailing_list_mode", limit: 4, default: 0 + t.integer "karma", limit: 4, default: 0, null: false t.datetime "banned_at" - t.integer "banned_by_user_id" + t.integer "banned_by_user_id", limit: 4 t.string "banned_reason", limit: 200 t.datetime "deleted_at" t.datetime "disabled_invite_at" - t.integer "disabled_invite_by_user_id" + t.integer "disabled_invite_by_user_id", limit: 4 t.string "disabled_invite_reason", limit: 200 - t.text "settings" + t.text "settings", limit: 65535 end add_index "users", ["mailing_list_mode"], name: "mailing_list_enabled", using: :btree @@ -216,10 +217,10 @@ ActiveRecord::Schema.define(version: 20170225201811) do add_index "users", ["session_token"], name: "session_hash", unique: true, using: :btree add_index "users", ["username"], name: "username", unique: true, using: :btree - create_table "votes", force: true do |t| - t.integer "user_id", null: false - t.integer "story_id", null: false - t.integer "comment_id" + create_table "votes", force: :cascade do |t| + t.integer "user_id", limit: 4, null: false + t.integer "story_id", limit: 4, null: false + t.integer "comment_id", limit: 4 t.integer "vote", limit: 1, null: false t.string "reason", limit: 1 end