From 13eb095e83b2db6248b32a14e2e5a4345e50b310 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 3 Jul 2022 17:26:05 +0200 Subject: [PATCH 01/18] Bump js_image_paths to support rails 6 and sprockets 4 --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 1bb1bf142..7ac950de9 100644 --- a/Gemfile +++ b/Gemfile @@ -89,8 +89,8 @@ gem "uuid", "2.3.9" gem "handlebars_assets", "0.23.9" gem "jquery-rails", "4.5.0" +gem "js_image_paths", "0.2.0" gem "js-routes", "2.2.4" -gem "js_image_paths", "0.1.1" source "https://gems.diasporafoundation.org" do gem "rails-assets-jquery", "3.6.0" # Should be kept in sync with jquery-rails diff --git a/Gemfile.lock b/Gemfile.lock index 01a31fd76..d4d582486 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -342,8 +342,8 @@ GEM thor (>= 0.14, < 2.0) js-routes (2.2.4) railties (>= 4) - js_image_paths (0.1.1) - rails (>= 4.0, < 6.0) + js_image_paths (0.2.0) + rails (>= 4.0, < 8.0) sprockets (>= 3.0.0) json (2.6.2) json-jwt (1.13.0) @@ -480,7 +480,7 @@ GEM public_suffix (4.0.7) raabro (1.4.0) racc (1.6.0) - rack (2.2.3.1) + rack (2.2.4) rack-cors (1.1.1) rack (>= 2.0.0) rack-google-analytics (1.2.0) @@ -500,7 +500,7 @@ GEM rack-rewrite (1.5.1) rack-ssl (1.4.1) rack - rack-test (2.0.0) + rack-test (2.0.2) rack (>= 1.3) rails (5.2.8) actioncable (= 5.2.8) @@ -817,7 +817,7 @@ DEPENDENCIES jasmine-jquery-rails (= 2.0.3) jquery-rails (= 4.5.0) js-routes (= 2.2.4) - js_image_paths (= 0.1.1) + js_image_paths (= 0.2.0) json (= 2.6.2) json-schema (= 3.0.0) leaflet-rails (= 1.7.0) From 0382cb48c15e48ea74397b5082541b1a4fbf1cc8 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 3 Jul 2022 17:29:31 +0200 Subject: [PATCH 02/18] Bump diaspora_federation to support rails 6 --- Gemfile | 6 +++--- Gemfile.lock | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index 7ac950de9..1cd81b9ca 100644 --- a/Gemfile +++ b/Gemfile @@ -15,8 +15,8 @@ gem "unicorn-worker-killer", "0.4.5" # Federation -gem "diaspora_federation-json_schema", "0.2.7" -gem "diaspora_federation-rails", "0.2.7" +gem "diaspora_federation-json_schema", "0.2.8" +gem "diaspora_federation-rails", "0.2.8" # API and JSON @@ -278,7 +278,7 @@ group :test do gem "timecop", "0.9.5" gem "webmock", "3.14.0", require: false - gem "diaspora_federation-test", "0.2.7" + gem "diaspora_federation-test", "0.2.8" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index d4d582486..b8e0077a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,18 +190,18 @@ GEM devise rails (>= 3.0.4) diaspora-prosody-config (0.0.7) - diaspora_federation (0.2.7) + diaspora_federation (0.2.8) faraday (>= 0.9.0, < 1.0) faraday_middleware (>= 0.10.0, < 1.0) nokogiri (~> 1.6, >= 1.6.8) typhoeus (~> 1.0) valid (~> 1.0) - diaspora_federation-json_schema (0.2.7) - diaspora_federation-rails (0.2.7) - actionpack (>= 4.2, < 6) - diaspora_federation (= 0.2.7) - diaspora_federation-test (0.2.7) - diaspora_federation (= 0.2.7) + diaspora_federation-json_schema (0.2.8) + diaspora_federation-rails (0.2.8) + actionpack (>= 4.2, < 7) + diaspora_federation (= 0.2.8) + diaspora_federation-test (0.2.8) + diaspora_federation (= 0.2.8) fabrication (~> 2.16) uuid (~> 2.3, >= 2.3.8) diff-lcs (1.5.0) @@ -796,9 +796,9 @@ DEPENDENCIES devise-two-factor (= 4.0.2) devise_lastseenable (= 0.0.6) diaspora-prosody-config (= 0.0.7) - diaspora_federation-json_schema (= 0.2.7) - diaspora_federation-rails (= 0.2.7) - diaspora_federation-test (= 0.2.7) + diaspora_federation-json_schema (= 0.2.8) + diaspora_federation-rails (= 0.2.8) + diaspora_federation-test (= 0.2.8) eye (= 0.10.0) factory_girl_rails (= 4.9.0) faraday (= 0.17.5) From 429aa8f374f33cffac07ece1a79cfe771a570c02 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 10 Jul 2022 00:13:31 +0200 Subject: [PATCH 03/18] Upgrade to sprockets 4 --- Gemfile.lock | 2 +- app/assets/config/manifest.js | 9 ++++++--- config/application.rb | 8 -------- config/environments/test.rb | 1 - config/initializers/color_themes.rb | 7 +++++++ lib/bookmarklet_renderer.rb | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b8e0077a0..3a6990d88 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -680,7 +680,7 @@ GEM simplecov_json_formatter (0.1.4) sinon-rails (1.15.0) railties (>= 3.1) - sprockets (3.7.2) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index fc75a31f6..3b8db2b12 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,11 +1,14 @@ +//= link_tree ../images + +//= link main.js +//= link mobile/mobile.js //= link contact-list.js //= link jquery3.js //= link jquery_ujs.js -//= link main.js //= link jsxc.js //= link bookmarklet.js //= link mobile/bookmarklet.js -//= link mobile/mobile.js -//= link error_pages.css + //= link admin.css +//= link error_pages.css //= link rtl.css diff --git a/config/application.rb b/config/application.rb index 50524a735..83c82284d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -74,14 +74,6 @@ module Diaspora # Speed up precompile by not loading the environment config.assets.initialize_on_precompile = false - # Precompile additional assets. - # (application.js, application.css, and all non-JS/CSS in the app/assets are already added) - config.assets.precompile = %w[ - color_themes/*/desktop.css - color_themes/*/mobile.css - manifest.js - ] - # See lib/tasks/assets.rake: non_digest_assets config.assets.non_digest_assets = %w(branding/logos/asterisk.png) diff --git a/config/environments/test.rb b/config/environments/test.rb index 26db9c226..4f56e4017 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -27,7 +27,6 @@ Rails.application.configure do config.assets.precompile += %w[poltergeist_disable_transition.css] # Don't precompile all themes for tests - config.assets.precompile -= %w[color_themes/*/desktop.css color_themes/*/mobile.css] config.assets.precompile += %w[ color_themes/original/desktop.css color_themes/dark_green/desktop.css diff --git a/config/initializers/color_themes.rb b/config/initializers/color_themes.rb index 7cabdba64..8231c73ac 100644 --- a/config/initializers/color_themes.rb +++ b/config/initializers/color_themes.rb @@ -17,3 +17,10 @@ if color_themes_file.exist? else AVAILABLE_COLOR_THEMES = ["original"].freeze end + +unless Rails.env.test? + AVAILABLE_COLOR_THEMES.each do |theme_code| + Rails.application.config.assets.precompile += + %W[color_themes/#{theme_code}/desktop.css color_themes/#{theme_code}/mobile.css] + end +end diff --git a/lib/bookmarklet_renderer.rb b/lib/bookmarklet_renderer.rb index a8e998a73..d15fb7261 100644 --- a/lib/bookmarklet_renderer.rb +++ b/lib/bookmarklet_renderer.rb @@ -16,7 +16,7 @@ class BookmarkletRenderer end def source - @source ||= Rails.application.assets["bookmarklet.js"].pathname.to_s + @source ||= Rails.application.assets["bookmarklet.js"].filename end def body From 14e27a65aeb39a5295542923f087fb966f3f58b1 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 10 Jul 2022 02:57:56 +0200 Subject: [PATCH 04/18] Move ActsAsTaggableOn::Tag overrides to initializer This is to prepare for zeitwerk autoloader, and the old file couldn't be autoloaded anyway, so the easiest is to just move it out of the models folder. --- .../javascripts/app/helpers/text_formatter.js | 2 +- .../app/views/tag_following_list_view.js | 2 +- app/models/acts_as_taggable_on-tag.rb | 25 ------------------- config/initializers/acts_as_taggable_on.rb | 24 +++++++++++++++++- 4 files changed, 25 insertions(+), 28 deletions(-) delete mode 100644 app/models/acts_as_taggable_on-tag.rb diff --git a/app/assets/javascripts/app/helpers/text_formatter.js b/app/assets/javascripts/app/helpers/text_formatter.js index c9a302fe9..814665959 100644 --- a/app/assets/javascripts/app/helpers/text_formatter.js +++ b/app/assets/javascripts/app/helpers/text_formatter.js @@ -43,7 +43,7 @@ var hashtagPlugin = window.markdownitHashtag; md.use(hashtagPlugin, { - // compare tag_text_regexp in app/models/acts_as_taggable_on-tag.rb + // compare tag_text_regexp in config/initializers/acts_as_taggable_on.rb hashtagRegExp: "[" + PosixBracketExpressions.word + "\\u055b" + // Armenian emphasis mark "\\u055c" + // Armenian exclamation mark diff --git a/app/assets/javascripts/app/views/tag_following_list_view.js b/app/assets/javascripts/app/views/tag_following_list_view.js index d284f137c..41af8e7e5 100644 --- a/app/assets/javascripts/app/views/tag_following_list_view.js +++ b/app/assets/javascripts/app/views/tag_following_list_view.js @@ -48,7 +48,7 @@ app.views.TagFollowingList = app.views.Base.extend({ if(evt){ evt.preventDefault(); } var name = this.$(".tag_input").val(); - // compare tag_text_regexp in app/models/acts_as_taggable_on-tag.rb + // compare tag_text_regexp in config/initializers/acts_as_taggable_on.rb var normalizedName = (name === "<3" ? name : name.replace( new RegExp("[^" + PosixBracketExpressions.alnum + "_\\-]+", "gi"), "").toLowerCase()); diff --git a/app/models/acts_as_taggable_on-tag.rb b/app/models/acts_as_taggable_on-tag.rb deleted file mode 100644 index dc5ece4cc..000000000 --- a/app/models/acts_as_taggable_on-tag.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -module ActsAsTaggableOn - class Tag - - self.include_root_in_json = false - - def self.tag_text_regexp - @tag_text_regexp ||= "[[:word:]]\u055b\u055c\u055e\u058a_-" - end - - def self.autocomplete(name) - where("name LIKE ?", "#{name.downcase}%").order("name ASC") - end - - def self.normalize(name) - if name =~ /^#?<3/ - # Special case for love, because the world needs more love. - '<3' - elsif name - name.gsub(/[^#{self.tag_text_regexp}]/, '').downcase - end - end - end -end diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb index de8bfc5aa..743fdfa63 100644 --- a/config/initializers/acts_as_taggable_on.rb +++ b/config/initializers/acts_as_taggable_on.rb @@ -1,4 +1,26 @@ # frozen_string_literal: true -require 'models/acts_as_taggable_on-tag' +module ActsAsTaggableOn + class Tag + self.include_root_in_json = false + + def self.tag_text_regexp + @tag_text_regexp ||= "[[:word:]]\u055b\u055c\u055e\u058a_-" + end + + def self.autocomplete(name) + where("name LIKE ?", "#{name.downcase}%").order("name ASC") + end + + def self.normalize(name) + if name =~ /^#?<3/ + # Special case for love, because the world needs more love. + "<3" + elsif name + name.gsub(/[^#{tag_text_regexp}]/, "").downcase + end + end + end +end + ActsAsTaggableOn.force_lowercase = true From 2f30b42d93821aa1fe0c52229433b3d6176c29c9 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 10 Jul 2022 03:01:15 +0200 Subject: [PATCH 05/18] Don't load sidekiq workers during initialization This is to prevent the warning about zeitwerk autoloader --- config/initializers/sidekiq_scheduled.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/sidekiq_scheduled.rb b/config/initializers/sidekiq_scheduled.rb index 46fc92adb..7385651ee 100644 --- a/config/initializers/sidekiq_scheduled.rb +++ b/config/initializers/sidekiq_scheduled.rb @@ -79,5 +79,7 @@ if Sidekiq.server? schedule_file_path = Rails.root.join("config", "schedule.yml") regenerate_config(schedule_file_path) unless valid_config?(schedule_file_path) - Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file_path) + Rails.application.reloader.to_prepare do + Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file_path) + end end From 2d38a24a8688b3db5e8cba90e81a0eccd8086474 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 16 Jul 2022 16:46:18 +0200 Subject: [PATCH 06/18] Upgrade to rails 6.0 --- .rubocop.yml | 6 + Gemfile | 4 +- Gemfile.lock | 110 ++++++++++-------- app/mailers/notifier.rb | 2 +- bin/setup | 33 ++++++ config/application.rb | 36 ++---- config/boot.rb | 2 +- config/environments/development.rb | 17 ++- config/environments/production.rb | 43 ++++++- config/environments/test.rb | 18 ++- .../application_controller_renderer.rb | 10 +- .../initializers/filter_parameter_logging.rb | 3 +- config/routes.rb | 2 +- spec/controllers/node_info_controller_spec.rb | 2 +- 14 files changed, 188 insertions(+), 100 deletions(-) create mode 100755 bin/setup diff --git a/.rubocop.yml b/.rubocop.yml index e1a7219a2..fa0c9d76c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,6 +57,12 @@ Layout/SpaceAroundEqualsInParameterDefault: # are needed. Style/StringLiterals: EnforcedStyle: double_quotes + Exclude: + # These files are generated by rails, so it's best to keep them close to the original for smaller diffs + - "config/application.rb" + - "config/boot.rb" + - "config/environment.rb" + - "config/environments/*.rb" # We do not need to support Ruby 1.9, so this is good to use. Style/SymbolArray: diff --git a/Gemfile b/Gemfile index 1cd81b9ca..06aa176ca 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "rails", "5.2.8" +gem "rails", "6.0.5.1" # Legacy Rails features, remove me! # responders (class level) @@ -128,7 +128,7 @@ gem "markdown-it-html5-embed", "1.0.0" gem "http_accept_language", "2.1.1" gem "i18n-inflector-rails", "1.0.7" -gem "rails-i18n", "5.1.3" +gem "rails-i18n", "6.0.0" # Map gem "leaflet-rails", "1.7.0" diff --git a/Gemfile.lock b/Gemfile.lock index 3a6990d88..fe1f5cc44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,52 +2,66 @@ GEM remote: https://rubygems.org/ remote: https://gems.diasporafoundation.org/ specs: - actioncable (5.2.8) - actionpack (= 5.2.8) + actioncable (6.0.5.1) + actionpack (= 6.0.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.8) - actionpack (= 5.2.8) - actionview (= 5.2.8) - activejob (= 5.2.8) + actionmailbox (6.0.5.1) + actionpack (= 6.0.5.1) + activejob (= 6.0.5.1) + activerecord (= 6.0.5.1) + activestorage (= 6.0.5.1) + activesupport (= 6.0.5.1) + mail (>= 2.7.1) + actionmailer (6.0.5.1) + actionpack (= 6.0.5.1) + actionview (= 6.0.5.1) + activejob (= 6.0.5.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.8) - actionview (= 5.2.8) - activesupport (= 5.2.8) + actionpack (6.0.5.1) + actionview (= 6.0.5.1) + activesupport (= 6.0.5.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.8) - activesupport (= 5.2.8) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.5.1) + actionpack (= 6.0.5.1) + activerecord (= 6.0.5.1) + activestorage (= 6.0.5.1) + activesupport (= 6.0.5.1) + nokogiri (>= 1.8.5) + actionview (6.0.5.1) + activesupport (= 6.0.5.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) + rails-html-sanitizer (~> 1.1, >= 1.2.0) active_model_serializers (0.9.8) activemodel (>= 3.2) concurrent-ruby (~> 1.0) - activejob (5.2.8) - activesupport (= 5.2.8) + activejob (6.0.5.1) + activesupport (= 6.0.5.1) globalid (>= 0.3.6) - activemodel (5.2.8) - activesupport (= 5.2.8) - activerecord (5.2.8) - activemodel (= 5.2.8) - activesupport (= 5.2.8) - arel (>= 9.0) + activemodel (6.0.5.1) + activesupport (= 6.0.5.1) + activerecord (6.0.5.1) + activemodel (= 6.0.5.1) + activesupport (= 6.0.5.1) activerecord-import (1.4.0) activerecord (>= 4.2) - activestorage (5.2.8) - actionpack (= 5.2.8) - activerecord (= 5.2.8) - marcel (~> 1.0.0) - activesupport (5.2.8) + activestorage (6.0.5.1) + actionpack (= 6.0.5.1) + activejob (= 6.0.5.1) + activerecord (= 6.0.5.1) + marcel (~> 1.0) + activesupport (6.0.5.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) acts-as-taggable-on (8.1.0) activerecord (>= 5.0, < 6.2) acts_as_api (1.0.1) @@ -60,7 +74,6 @@ GEM apparition (0.6.0) capybara (~> 3.13, < 4) websocket-driver (>= 0.6.5) - arel (9.0.0) asset_sync (2.15.2) activemodel (>= 4.1.0) fog-core @@ -317,7 +330,7 @@ GEM mime-types (~> 3.0) multi_xml (>= 0.5.2) httpclient (2.8.3) - i18n (1.10.0) + i18n (1.12.0) concurrent-ruby (~> 1.0) i18n-inflector (2.6.7) i18n (>= 0.4.1) @@ -502,18 +515,20 @@ GEM rack rack-test (2.0.2) rack (>= 1.3) - rails (5.2.8) - actioncable (= 5.2.8) - actionmailer (= 5.2.8) - actionpack (= 5.2.8) - actionview (= 5.2.8) - activejob (= 5.2.8) - activemodel (= 5.2.8) - activerecord (= 5.2.8) - activestorage (= 5.2.8) - activesupport (= 5.2.8) + rails (6.0.5.1) + actioncable (= 6.0.5.1) + actionmailbox (= 6.0.5.1) + actionmailer (= 6.0.5.1) + actionpack (= 6.0.5.1) + actiontext (= 6.0.5.1) + actionview (= 6.0.5.1) + activejob (= 6.0.5.1) + activemodel (= 6.0.5.1) + activerecord (= 6.0.5.1) + activestorage (= 6.0.5.1) + activesupport (= 6.0.5.1) bundler (>= 1.3.0) - railties (= 5.2.8) + railties (= 6.0.5.1) sprockets-rails (>= 2.0.0) rails-assets-autosize (4.0.2) rails-assets-backbone (1.3.3) @@ -571,18 +586,18 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) - rails-i18n (5.1.3) + rails-i18n (6.0.0) i18n (>= 0.7, < 2) - railties (>= 5.0, < 6) + railties (>= 6.0.0, < 7) rails-timeago (2.20.0) actionpack (>= 5.2) activesupport (>= 5.2) - railties (5.2.8) - actionpack (= 5.2.8) - activesupport (= 5.2.8) + railties (6.0.5.1) + actionpack (= 6.0.5.1) + activesupport (= 6.0.5.1) method_source rake (>= 0.8.7) - thor (>= 0.19.0, < 2.0) + thor (>= 0.20.3, < 2.0) rainbow (3.1.1) raindrops (0.20.0) rake (12.3.3) @@ -770,6 +785,7 @@ GEM nokogiri (~> 1.8) yard (0.9.28) webrick (~> 1.7.0) + zeitwerk (2.6.0) PLATFORMS ruby @@ -849,7 +865,7 @@ DEPENDENCIES rack-piwik (= 0.3.0) rack-rewrite (= 1.5.1) rack-ssl (= 1.4.1) - rails (= 5.2.8) + rails (= 6.0.5.1) rails-assets-autosize (= 4.0.2)! rails-assets-backbone (= 1.3.3)! rails-assets-blueimp-gallery (= 2.33.0)! @@ -875,7 +891,7 @@ DEPENDENCIES rails-assets-markdown-it-sup (= 1.0.0)! rails-assets-utatti-perfect-scrollbar (= 1.4.0)! rails-controller-testing (= 1.0.5) - rails-i18n (= 5.1.3) + rails-i18n (= 6.0.0) rails-timeago (= 2.20.0) redcarpet (= 3.5.1) redis (= 4.7.0) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 977883985..35b3f9f69 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -54,8 +54,8 @@ class Notifier < ApplicationMailer @notification = NotificationMailers.const_get(type.to_s.camelize).new(*args) with_recipient_locale do + self.action_name = type mail(@notification.headers) do |format| - self.action_name = type format.text format.html end diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000..0e39e8cb1 --- /dev/null +++ b/bin/setup @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require 'fileutils' + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:prepare' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config/application.rb b/config/application.rb index 83c82284d..36b801b9d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -32,42 +32,26 @@ require_relative 'asset_sync' module Diaspora class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.1 + config.load_defaults 6.0 # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + + # Use classic autoloader for now + config.autoloader = :classic # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W[#{config.root}/app] config.autoload_once_paths += %W[#{config.root}/lib] - # 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)' - - # 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" + # Allow to decode Time from serialized columns + config.active_record.yaml_column_permitted_classes = [Time] # 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 - # Enable the asset pipeline config.assets.enabled = true @@ -75,7 +59,7 @@ module Diaspora config.assets.initialize_on_precompile = false # See lib/tasks/assets.rake: non_digest_assets - config.assets.non_digest_assets = %w(branding/logos/asterisk.png) + config.assets.non_digest_assets = %w[branding/logos/asterisk.png] # Configure generators values. Many other options are available, be sure to check the documentation. config.generators do |g| diff --git a/config/boot.rb b/config/boot.rb index dcd2d28d5..4fe16d4e8 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/config/environments/development.rb b/config/environments/development.rb index ea9b17981..8358d6b51 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -15,12 +15,14 @@ Rails.application.configure do config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. - if Rails.root.join("tmp", "caching-dev.txt").exist? + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.seconds.to_i}" + 'Cache-Control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -28,6 +30,9 @@ Rails.application.configure do config.cache_store = :null_store end + # Store uploaded files on the local file system (see config/storage.yml for options). + # config.active_storage.service = :local + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -39,6 +44,9 @@ Rails.application.configure do # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. @@ -53,13 +61,16 @@ Rails.application.configure do # Show the logging configuration on STDOUT config.show_log_configuration = true - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Allow the host configured in the diaspora.toml to access the development server + config.hosts << AppConfig.pod_uri.host + # Speed up asset serving config.middleware.insert 0, TurboDevAssets end diff --git a/config/environments/production.rb b/config/environments/production.rb index 13a91a017..60b0ba0f3 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -17,14 +17,13 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Attempt to read encrypted secrets from `config/secrets.yml.enc`. - # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or - # `config/secrets.yml.key`. - config.read_encrypted_secrets = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :terser @@ -45,7 +44,10 @@ Rails.application.configure do # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Mount Action Cable outside main process or domain + # Store uploaded files on the local file system (see config/storage.yml for options). + # config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] @@ -68,12 +70,20 @@ Rails.application.configure do # Use a different cache store in production. # config.cache_store = :mem_cache_store + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "diaspora_production" + config.action_mailer.perform_caching = false # 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 = false + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify @@ -92,4 +102,25 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 4f56e4017..0762db9fd 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # 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 - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application @@ -17,7 +18,7 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.seconds.to_i}" + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" } # Suppress logger output for asset requests. @@ -38,12 +39,17 @@ Rails.application.configure do # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # 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 + + # Store uploaded files on the local file system in a temporary directory. + # config.active_storage.service = :test + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -57,7 +63,7 @@ Rails.application.configure do # Set the logging destination(s) config.log_to = %w[file] - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true # for fixture_builder diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index 315ac48a9..f4556db39 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true # Be sure to restart your server when you modify this file. -# ApplicationController.renderer.defaults.merge!( -# http_host: 'example.org', -# https: false -# ) +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 791647716..dde581019 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -3,5 +3,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 += %i[password message text bio] -Rails.application.config.filter_parameters += [:otp_attempt] +Rails.application.config.filter_parameters += %i[password otp_attempt message text bio] diff --git a/config/routes.rb b/config/routes.rb index 88c1d5fde..5c0d4f19c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ require "sidekiq/web" require "sidekiq/cron/web" Rails.application.routes.draw do - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :report, except: %i(edit new show) diff --git a/spec/controllers/node_info_controller_spec.rb b/spec/controllers/node_info_controller_spec.rb index ba3c10738..fcad4bc31 100644 --- a/spec/controllers/node_info_controller_spec.rb +++ b/spec/controllers/node_info_controller_spec.rb @@ -52,7 +52,7 @@ describe NodeInfoController do get :document, params: {version: version}, format: :json expect(response.content_type) - .to eq("application/json; profile=http://nodeinfo.diaspora.software/ns/schema/#{version}#") + .to eq("application/json; profile=http://nodeinfo.diaspora.software/ns/schema/#{version}#; charset=utf-8") end end end From b5a46cf7bbd5e9a857e26443a40b5b1a6b696cb1 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 16 Jul 2022 18:17:06 +0200 Subject: [PATCH 07/18] Fix deprecation warnings for rails 6.0 --- app/controllers/people_controller.rb | 3 +-- app/controllers/users_controller.rb | 6 +++--- app/models/invitation_code.rb | 9 +++++---- app/models/user.rb | 6 +++--- app/models/user/connecting.rb | 2 +- config/logging.rb | 2 +- ...813160104_cleanup_aspects_and_add_unique_index.rb | 2 +- features/support/integration_sessions_controller.rb | 5 ++++- lib/account_deleter.rb | 2 +- lib/diaspora/federation/receive.rb | 4 ++-- spec/controllers/aspects_controller_spec.rb | 4 ++-- spec/controllers/contacts_controller_spec.rb | 4 ++-- spec/controllers/invitations_controller_spec.rb | 4 ++-- spec/controllers/registrations_controller_spec.rb | 4 ++-- spec/controllers/users_controller_spec.rb | 12 ++++++------ spec/helpers/notifications_helper_spec.rb | 4 ++-- spec/mailers/notifier_spec.rb | 4 ++-- spec/models/user/querying_spec.rb | 2 +- .../_status_message.mobile.haml_spec.rb | 2 +- spec/workers/check_birthday_spec.rb | 10 +++++----- 20 files changed, 47 insertions(+), 44 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index f03036e10..f7d4a49a4 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -15,8 +15,7 @@ class PeopleController < ApplicationController respond_to :json, :only => [:index, :show] rescue_from ActiveRecord::RecordNotFound do - render :file => Rails.root.join('public', '404').to_s, - :format => :html, :layout => false, :status => 404 + render file: Rails.root.join("public/404.html").to_s, format: :html, layout: false, status: :not_found end rescue_from Diaspora::AccountClosed do diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 99a0297a0..f129ecb05 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -34,7 +34,7 @@ class UsersController < ApplicationController def update_privacy_settings privacy_params = params.fetch(:user).permit(:strip_exif) - if current_user.update_attributes(strip_exif: privacy_params[:strip_exif]) + if current_user.update(strip_exif: privacy_params[:strip_exif]) flash[:notice] = t("users.update.settings_updated") else flash[:error] = t("users.update.settings_not_updated") @@ -199,7 +199,7 @@ class UsersController < ApplicationController end def change_language(user_data) - if @user.update_attributes(user_data) + if @user.update(user_data) I18n.locale = @user.language flash.now[:notice] = t("users.update.language_changed") else @@ -229,7 +229,7 @@ class UsersController < ApplicationController end def change_settings(user_data, successful="users.update.settings_updated", error="users.update.settings_not_updated") - if @user.update_attributes(user_data) + if @user.update(user_data) flash.now[:notice] = t(successful) else flash.now[:error] = t(error) diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb index 428096756..1f941c818 100644 --- a/app/models/invitation_code.rb +++ b/app/models/invitation_code.rb @@ -16,17 +16,18 @@ class InvitationCode < ApplicationRecord end def add_invites! - self.update_attributes(:count => self.count+100) + update(count: count + 100) end def use! - self.update_attributes(:count => self.count-1) + update(count: count - 1) end def generate_token - begin + loop do self.token = SecureRandom.hex(6) - end while InvitationCode.exists?(:token => self[:token]) + break unless InvitationCode.default_scoped.exists?(token: token) + end end def self.default_inviter_or(user) diff --git a/app/models/user.rb b/app/models/user.rb index 788fe6aba..131fbcf68 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -250,7 +250,7 @@ class User < ApplicationRecord def update_post(post, post_hash={}) if self.owns? post - post.update_attributes(post_hash) + post.update(post_hash) self.dispatch_post(post) end end @@ -375,7 +375,7 @@ class User < ApplicationRecord ########### Profile ###################### def update_profile(params) if photo = params.delete(:photo) - photo.update_attributes(:pending => false) if photo.pending + photo.update(pending: false) if photo.pending params[:image_url] = photo.url(:thumb_large) params[:image_url_medium] = photo.url(:thumb_medium) params[:image_url_small] = photo.url(:thumb_small) @@ -383,7 +383,7 @@ class User < ApplicationRecord params.stringify_keys! params.slice!(*(Profile.column_names+['tag_string', 'date'])) - if self.profile.update_attributes(params) + if profile.update(params) deliver_profile_update true else diff --git a/app/models/user/connecting.rb b/app/models/user/connecting.rb index 232dba405..62a3a4a02 100644 --- a/app/models/user/connecting.rb +++ b/app/models/user/connecting.rb @@ -58,7 +58,7 @@ class User if destroy contact.destroy else - contact.update_attributes(direction => false) + contact.update(direction => false) end end end diff --git a/config/logging.rb b/config/logging.rb index 06d57f041..38faf0f5c 100644 --- a/config/logging.rb +++ b/config/logging.rb @@ -112,4 +112,4 @@ end # the logging gem is no-op. See: https://github.com/TwP/logging/issues/11 Logging::Logger.send :alias_method, :local_level, :level Logging::Logger.send :alias_method, :local_level=, :level= -Logging::Logger.send :include, LoggerSilence +Logging::Logger.include ActiveSupport::LoggerSilence diff --git a/db/migrate/20170813160104_cleanup_aspects_and_add_unique_index.rb b/db/migrate/20170813160104_cleanup_aspects_and_add_unique_index.rb index 1d8c7325a..7741d5b08 100644 --- a/db/migrate/20170813160104_cleanup_aspects_and_add_unique_index.rb +++ b/db/migrate/20170813160104_cleanup_aspects_and_add_unique_index.rb @@ -17,7 +17,7 @@ class CleanupAspectsAndAddUniqueIndex < ActiveRecord::Migration[5.1] Aspect.where(user_id: 0).delete_all Aspect.joins("INNER JOIN aspects as a2 ON aspects.user_id = a2.user_id AND aspects.name = a2.name") .where("aspects.id > a2.id").each do |aspect| - aspect.update_attributes(name: "#{aspect.name}_#{UUID.generate(:compact)}") + aspect.update(name: "#{aspect.name}_#{UUID.generate(:compact)}") end end end diff --git a/features/support/integration_sessions_controller.rb b/features/support/integration_sessions_controller.rb index 1d6bccbe8..357d1cc86 100644 --- a/features/support/integration_sessions_controller.rb +++ b/features/support/integration_sessions_controller.rb @@ -1,10 +1,13 @@ # frozen_string_literal: true class IntegrationSessionsController < ActionController::Base + prepend_view_path(Rails.root.join("features/support")) + def new @user_id = params[:user_id] - render file: 'features/support/integration_sessions_form', layout: false + render template: "integration_sessions_form", layout: false end + def create sign_in_and_redirect User.find(params[:user_id]) end diff --git a/lib/account_deleter.rb b/lib/account_deleter.rb index 302669bc4..d7f976c1a 100644 --- a/lib/account_deleter.rb +++ b/lib/account_deleter.rb @@ -97,6 +97,6 @@ class AccountDeleter end def mark_account_deletion_complete - AccountDeletion.find_by(person: person)&.update_attributes(completed_at: Time.now.utc) + AccountDeletion.find_by(person: person)&.update(completed_at: Time.now.utc) end end diff --git a/lib/diaspora/federation/receive.rb b/lib/diaspora/federation/receive.rb index dd136ac42..adc3a9c82 100644 --- a/lib/diaspora/federation/receive.rb +++ b/lib/diaspora/federation/receive.rb @@ -116,7 +116,7 @@ module Diaspora if persisted_photo persisted_photo.tap do |photo| - photo.update_attributes( + photo.update( text: entity.text, public: entity.public, created_at: entity.created_at, @@ -145,7 +145,7 @@ module Diaspora def self.profile(entity) author_of(entity).profile.tap do |profile| - profile.update_attributes( + profile.update( first_name: entity.first_name, last_name: entity.last_name, image_url: entity.image_url, diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index a243cfaf8..9e35896d6 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -98,8 +98,8 @@ describe AspectsController, :type => :controller do describe "update_order" do it "updates the aspect order" do - @alices_aspect_1.update_attributes(order_id: 10) - @alices_aspect_2.update_attributes(order_id: 20) + @alices_aspect_1.update(order_id: 10) + @alices_aspect_2.update(order_id: 20) ordered_aspect_ids = [@alices_aspect_2.id, @alices_aspect_1.id] put :update_order, params: {ordered_aspect_ids: ordered_aspect_ids} diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 10cdc3ab5..2e32ec52e 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -76,7 +76,7 @@ describe ContactsController, :type => :controller do it "returns only contacts which are receiving (the user is sharing with them)" do contact = bob.contacts.first - contact.update_attributes(receiving: false) + contact.update(receiving: false) get :index, params: {params: {page: "1"}}, format: :json contact_ids = JSON.parse(response.body).map {|c| c["id"] } @@ -88,7 +88,7 @@ describe ContactsController, :type => :controller do context "set: all" do before do contact = bob.contacts.first - contact.update_attributes(receiving: false) + contact.update(receiving: false) end it "returns all contacts (sharing and receiving)" do diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index 7919b6a8b..87232f401 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -117,7 +117,7 @@ describe InvitationsController, type: :controller do end it "displays an error when no invitations are left" do - alice.invitation_code.update_attributes(count: 0) + alice.invitation_code.update(count: 0) post :create, params: invite_params @@ -127,7 +127,7 @@ describe InvitationsController, type: :controller do it "does not display an error when registration is open" do AppConfig.settings.invitations.open = false - alice.invitation_code.update_attributes(count: 0) + alice.invitation_code.update(count: 0) post :create, params: invite_params diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 7bb94bcaa..8c43191a5 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -49,7 +49,7 @@ describe RegistrationsController, type: :controller do it "does redirect if there are no invites available with this code" do code = InvitationCode.create(user: bob) - code.update_attributes(count: 0) + code.update(count: 0) get :new, params: {invite: {token: code.token}} expect(response).to redirect_to registrations_closed_path @@ -67,7 +67,7 @@ describe RegistrationsController, type: :controller do AppConfig.settings.enable_registrations = true code = InvitationCode.create(user: bob) - code.update_attributes(count: 0) + code.update(count: 0) get :new, params: {invite: {token: code.token}} expect(response).not_to be_redirect diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index ac3e79727..9c4e29adf 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -138,22 +138,22 @@ describe UsersController, :type => :controller do before do allow(@controller).to receive(:current_user).and_return(@user) allow(@user).to receive(:update_with_password) - allow(@user).to receive(:update_attributes) + allow(@user).to receive(:update) end it "uses devise's update with password" do put :update, params: params expect(@user).to have_received(:update_with_password).with(hash_including(password_params)) - expect(@user).not_to have_received(:update_attributes).with(hash_including(password_params)) + expect(@user).not_to have_received(:update).with(hash_including(password_params)) end it "does not update the password without the change_password param" do put :update, params: params.except(:change_password).deep_merge(user: {language: "de"}) expect(@user).not_to have_received(:update_with_password).with(hash_including(password_params)) - expect(@user).not_to have_received(:update_attributes).with(hash_including(password_params)) - expect(@user).to have_received(:update_attributes).with(hash_including(language: "de")) + expect(@user).not_to have_received(:update).with(hash_including(password_params)) + expect(@user).to have_received(:update).with(hash_including(language: "de")) end end @@ -163,13 +163,13 @@ describe UsersController, :type => :controller do before do allow(@controller).to receive(:current_user).and_return(@user) - allow(@user).to receive(:update_attributes) + allow(@user).to receive(:update) end it "does not accept the params" do put :update, params: params - expect(@user).not_to have_received(:update_attributes) + expect(@user).not_to have_received(:update) .with(hash_including(:otp_required_for_login, :otp_secret)) end end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index dea069ef6..bfffc8f1a 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -128,13 +128,13 @@ describe NotificationsHelper, type: :helper do let(:notification) { Notifications::ContactsBirthday.create(recipient: alice, target: bob.person) } it "contains the date" do - bob.profile.update_attributes(birthday: Time.zone.today) + bob.profile.update(birthday: Time.zone.today) link = object_link(notification, notification_people_link(notification)) expect(link).to include(I18n.l(Time.zone.today, format: I18n.t("date.formats.fullmonth_day"))) end it "doesn't break, when the person removes the birthday date" do - bob.profile.update_attributes(birthday: nil) + bob.profile.update(birthday: nil) link = object_link(notification, notification_people_link(notification)) expect(link).to include(I18n.l(Time.zone.today, format: I18n.t("date.formats.fullmonth_day"))) end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 4cdc3c319..872530e9b 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -516,7 +516,7 @@ describe Notifier, type: :mailer do end it "has the inviter id if the name is nil" do - bob.person.profile.update_attributes(first_name: "", last_name: "") + bob.person.profile.update(first_name: "", last_name: "") mail = Notifier.invite(alice.email, bob, "1234", "en") expect(email.body.encoded).to_not include("#{bob.name} (#{bob.diaspora_handle})") expect(mail.body.encoded).to include(bob.person.diaspora_handle) @@ -573,7 +573,7 @@ describe Notifier, type: :mailer do end it "FROM: header should be 'pod_name (username)' when there is no first and last name" do - bob.person.profile.update_attributes(first_name: "", last_name: "") + bob.person.profile.update(first_name: "", last_name: "") mail = Notifier.send_notification("started_sharing", alice.id, bob.person.id) expect(mail["From"].to_s).to eq("\"#{pod_name} (#{bob.person.username})\" <#{AppConfig.mail.sender_address}>") end diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 53843a7bc..27ad42d44 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -74,7 +74,7 @@ describe User::Querying, :type => :model do end it "does not pull back hidden posts" do - @status.share_visibilities.where(user_id: alice.id).first.update_attributes(hidden: true) + @status.share_visibilities.where(user_id: alice.id).first.update(hidden: true) expect(alice.visible_shareable_ids(Post).include?(@status.id)).to be false end end diff --git a/spec/views/status_messages/_status_message.mobile.haml_spec.rb b/spec/views/status_messages/_status_message.mobile.haml_spec.rb index 5487d6a55..e5ad542f7 100644 --- a/spec/views/status_messages/_status_message.mobile.haml_spec.rb +++ b/spec/views/status_messages/_status_message.mobile.haml_spec.rb @@ -10,7 +10,7 @@ describe "status_messages/_status_message.mobile.haml" do ) post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache) - render file: "status_messages/_status_message.mobile.haml", locals: {post: post, photos: post.photos} + render template: "status_messages/_status_message.mobile.haml", locals: {post: post, photos: post.photos} expect(rendered).to_not include("