Merge branch 'next-minor' into develop

This commit is contained in:
Benjamin Neff 2022-07-20 21:34:39 +02:00
commit d4079070ed
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
68 changed files with 457 additions and 375 deletions

View file

@ -15,8 +15,8 @@ jobs:
fail-fast: false
matrix:
ruby:
- 2.7
- 2.6
- 2.5
db:
- mysql
- postgresql

View file

@ -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:

View file

@ -1 +1 @@
2.6
2.7

View file

@ -51,7 +51,11 @@ We use yarn to install the frontend dependencies now, so you need to have that i
* Fix deprecation warnings for sidekiq 7.0 [#8359](https://github.com/diaspora/diaspora/pull/8359)
* Remove entypo-rails dependency to prepare for rails 6 [#8361](https://github.com/diaspora/diaspora/pull/8361)
* Remove compass-rails dependency which is not supported anymore [#8362](https://github.com/diaspora/diaspora/pull/8362)
* Switch to sassc-rails which speeds up `assets:precompile` a lot [#8362](https://github.com/diaspora/diaspora/pull/8362)
* Remove markerb dependency which doesn't exist anymore [#8365](https://github.com/diaspora/diaspora/pull/8365)
* Upgrade to rails 6.1 [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Update the suggested Ruby version to 2.7. If you run into trouble during the update and you followed our installation guides, run `rvm install 2.7`. [#8366](https://github.com/diaspora/diaspora/pull/8366)
* Upgrade to bundler 2 [#8366](https://github.com/diaspora/diaspora/pull/8366)
## Bug fixes
* Fix that no mails were sent after photo export [#8365](https://github.com/diaspora/diaspora/pull/8365)

20
Gemfile
View file

@ -2,7 +2,7 @@
source "https://rubygems.org"
gem "rails", "5.2.8"
gem "rails", "6.1.6.1"
# Legacy Rails features, remove me!
# responders (class level)
@ -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
@ -39,11 +39,11 @@ gem "simple_captcha2", "0.5.0", require: "simple_captcha"
# Background processing
gem "redis", "4.7.0"
gem "sidekiq", "6.4.2"
gem "sidekiq", "6.5.1"
# Scheduled processing
gem "sidekiq-cron", "1.4.0"
gem "sidekiq-cron", "1.6.0"
# Compression
@ -91,22 +91,22 @@ gem "uuid", "2.3.9"
gem "handlebars_assets", "0.23.9"
gem "jquery-rails", "4.5.0"
gem "jquery-ui-rails", "5.0.5"
gem "js_image_paths", "0.2.0"
gem "js-routes", "2.2.4"
gem "js_image_paths", "0.1.1"
gem "sprockets-es6", "0.9.2"
# Localization
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"
# Parsing
gem "nokogiri", "1.12.5"
gem "nokogiri", "1.13.7"
gem "open_graph_reader", "0.7.2" # also update User-Agent in features/support/webmock.rb and open_graph_cache_spec.rb
gem "redcarpet", "3.5.1"
gem "ruby-oembed", "0.16.1"
@ -138,7 +138,7 @@ gem "active_model_serializers", "0.9.8"
# Tags
gem "acts-as-taggable-on", "8.1.0"
gem "acts-as-taggable-on", "9.0.1"
# URIs and HTTP
@ -245,7 +245,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

View file

@ -1,54 +1,72 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.8)
actionpack (= 5.2.8)
actioncable (6.1.6.1)
actionpack (= 6.1.6.1)
activesupport (= 6.1.6.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.1.6.1)
actionpack (= 6.1.6.1)
activejob (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
mail (>= 2.7.1)
actionmailer (6.1.6.1)
actionpack (= 6.1.6.1)
actionview (= 6.1.6.1)
activejob (= 6.1.6.1)
activesupport (= 6.1.6.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.8)
actionview (= 5.2.8)
activesupport (= 5.2.8)
rack (~> 2.0, >= 2.0.8)
actionpack (6.1.6.1)
actionview (= 6.1.6.1)
activesupport (= 6.1.6.1)
rack (~> 2.0, >= 2.0.9)
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.1.6.1)
actionpack (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
nokogiri (>= 1.8.5)
actionview (6.1.6.1)
activesupport (= 6.1.6.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.1.6.1)
activesupport (= 6.1.6.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.1.6.1)
activesupport (= 6.1.6.1)
activerecord (6.1.6.1)
activemodel (= 6.1.6.1)
activesupport (= 6.1.6.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.1.6.1)
actionpack (= 6.1.6.1)
activejob (= 6.1.6.1)
activerecord (= 6.1.6.1)
activesupport (= 6.1.6.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.6.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
acts-as-taggable-on (8.1.0)
activerecord (>= 5.0, < 6.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts-as-taggable-on (9.0.1)
activerecord (>= 6.0, < 7.1)
acts_as_api (1.0.1)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
@ -59,7 +77,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
@ -192,18 +209,18 @@ GEM
devise_lastseenable (0.0.6)
devise
rails (>= 3.0.4)
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)
@ -319,7 +336,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)
@ -347,8 +364,8 @@ GEM
railties (>= 3.2.16)
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)
@ -389,7 +406,7 @@ GEM
mime-types-data (3.2022.0105)
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
mini_portile2 (2.8.0)
minitest (5.15.0)
mobile-fu (1.4.0)
rack-mobile-detect
@ -401,8 +418,8 @@ GEM
mysql2 (0.5.4)
naught (1.1.0)
nio4r (2.5.8)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
nokogiri (1.13.7)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
oauth (0.5.10)
oauth2 (2.0.2)
@ -484,7 +501,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)
@ -504,20 +521,22 @@ 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)
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)
bundler (>= 1.3.0)
railties (= 5.2.8)
rails (6.1.6.1)
actioncable (= 6.1.6.1)
actionmailbox (= 6.1.6.1)
actionmailer (= 6.1.6.1)
actionpack (= 6.1.6.1)
actiontext (= 6.1.6.1)
actionview (= 6.1.6.1)
activejob (= 6.1.6.1)
activemodel (= 6.1.6.1)
activerecord (= 6.1.6.1)
activestorage (= 6.1.6.1)
activesupport (= 6.1.6.1)
bundler (>= 1.15.0)
railties (= 6.1.6.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
@ -528,18 +547,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.1.6.1)
actionpack (= 6.1.6.1)
activesupport (= 6.1.6.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
raindrops (0.20.0)
rake (12.3.3)
@ -619,11 +638,11 @@ GEM
secure_headers (6.3.3)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sidekiq (6.4.2)
sidekiq (6.5.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-cron (1.4.0)
sidekiq-cron (1.6.0)
fugit (~> 1)
sidekiq (>= 4.2.1)
simple_captcha2 (0.5.0)
@ -637,7 +656,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-es6 (0.9.2)
@ -688,8 +707,8 @@ GEM
unf (~> 0.1.0)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
@ -733,6 +752,7 @@ GEM
yajl-ruby (1.4.1)
yard (0.9.28)
webrick (~> 1.7.0)
zeitwerk (2.6.0)
PLATFORMS
ruby
@ -740,7 +760,7 @@ PLATFORMS
DEPENDENCIES
active_model_serializers (= 0.9.8)
activerecord-import (= 1.4.0)
acts-as-taggable-on (= 8.1.0)
acts-as-taggable-on (= 9.0.1)
acts_as_api (= 1.0.1)
addressable (= 2.8.0)
apparition (= 0.6.0)
@ -758,9 +778,9 @@ DEPENDENCIES
devise (= 4.8.1)
devise-two-factor (= 4.0.2)
devise_lastseenable (= 0.0.6)
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_bot_rails (= 6.1.0)
faraday (= 0.17.5)
@ -780,7 +800,7 @@ DEPENDENCIES
jquery-rails (= 4.5.0)
jquery-ui-rails (= 5.0.5)
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)
@ -790,7 +810,7 @@ DEPENDENCIES
minitest (= 5.15.0)
mobile-fu (= 1.4.0)
mysql2 (= 0.5.4)
nokogiri (= 1.12.5)
nokogiri (= 1.13.7)
omniauth (= 2.1.0)
omniauth-rails_csrf_protection (= 1.0.1)
omniauth-tumblr (= 1.2)
@ -811,9 +831,9 @@ DEPENDENCIES
rack-piwik (= 0.3.0)
rack-rewrite (= 1.5.1)
rack-ssl (= 1.4.1)
rails (= 5.2.8)
rails (= 6.1.6.1)
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)
@ -828,8 +848,8 @@ DEPENDENCIES
sassc-rails (= 2.1.2)
secure_headers (= 6.3.3)
shoulda-matchers (= 4.5.1)
sidekiq (= 6.4.2)
sidekiq-cron (= 1.4.0)
sidekiq (= 6.5.1)
sidekiq-cron (= 1.6.0)
simple_captcha2 (= 0.5.0)
simplecov (= 0.21.2)
sinon-rails (= 1.15.0)
@ -852,4 +872,4 @@ DEPENDENCIES
yajl-ruby (= 1.4.1)
BUNDLED WITH
1.17.3
2.3.18

View file

@ -1,10 +1,13 @@
//= 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 bookmarklet.js
//= link mobile/bookmarklet.js
//= link mobile/mobile.js
//= link error_pages.css
//= link admin.css
//= link error_pages.css
//= link rtl.css

View file

@ -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

View file

@ -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());

View file

@ -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

View file

@ -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")
@ -198,7 +198,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
@ -241,7 +241,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)

View file

@ -39,8 +39,9 @@ module NotificationMailers
from_name += " (#{@sender.profile.full_name.empty? ? @sender.username : @sender.name})" if @sender.present?
{
from: name_and_address(from_name, AppConfig.mail.sender_address),
to: name_and_address(@recipient.name, @recipient.email)
from: name_and_address(from_name, AppConfig.mail.sender_address),
to: name_and_address(@recipient.name, @recipient.email),
template_name: self.class.name.demodulize.underscore
}
end

View file

@ -51,14 +51,10 @@ class Notifier < ApplicationMailer
end
def send_notification(type, *args)
@notification = NotificationMailers.const_get(type.to_s.camelize).new(*args)
@notification = NotificationMailers.const_get(type.camelize).new(*args)
with_recipient_locale do
mail(@notification.headers) do |format|
self.action_name = type
format.text
format.html
end
mail(@notification.headers)
end
end

View file

@ -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

View file

@ -11,9 +11,9 @@ class Block < ApplicationRecord
validate :not_blocking_yourself
def not_blocking_yourself
if self.user.person.id == self.person_id
errors[:person_id] << "stop blocking yourself!"
end
return unless user.person.id == person_id
errors.add(:person_id, "stop blocking yourself!")
end
# @return [Array<Person>] The recipient of the block

View file

@ -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)

View file

@ -37,10 +37,8 @@ class Message < ApplicationRecord
private
def participant_of_parent_conversation
if conversation && !conversation.participants.include?(author)
errors[:base] << "Author is not participating in the conversation"
else
true
end
return unless conversation&.participants&.exclude?(author)
errors.add(:base, "Author is not participating in the conversation")
end
end

View file

@ -22,15 +22,15 @@ class Report < ApplicationRecord
end
def entry_does_not_exist
if Report.where(item_id: item_id, item_type: item_type).exists?(user_id: user_id)
errors[:base] << 'You cannot report the same post twice.'
end
return unless Report.where(item_id: item_id, item_type: item_type).exists?(user_id: user_id)
errors.add(:base, "You cannot report the same post twice.")
end
def post_or_comment_does_exist
if Post.find_by_id(item_id).nil? && Comment.find_by_id(item_id).nil?
errors[:base] << 'Post or comment was already deleted or doesn\'t exists.'
end
return unless Post.find_by(id: item_id).nil? && Comment.find_by(id: item_id).nil?
errors.add(:base, "Post or comment was already deleted or doesn't exists.")
end
def destroy_reported_item

View file

@ -86,9 +86,6 @@ class Reshare < Post
private
def root_must_be_public
if self.root && !self.root.public
errors[:base] << "Only posts which are public may be reshared."
return false
end
errors.add(:base, "Only posts which are public may be reshared.") if root && !root.public
end
end

View file

@ -130,7 +130,7 @@ class StatusMessage < Post
private
def presence_of_content
errors[:base] << "Cannot create a StatusMessage without content" if text_and_photos_blank?
errors.add(:base, "Cannot create a StatusMessage without content") if text_and_photos_blank?
end
end

View file

@ -249,7 +249,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
@ -374,7 +374,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)
@ -382,7 +382,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
@ -541,10 +541,10 @@ class User < ApplicationRecord
end
def no_person_with_same_username
diaspora_id = "#{self.username}#{User.diaspora_id_host}"
if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
errors[:base] << 'That username has already been taken'
end
diaspora_id = "#{username}#{User.diaspora_id_host}"
return unless username_changed? && Person.exists?(diaspora_handle: diaspora_id)
errors.add(:base, "That username has already been taken")
end
def close_account!

View file

@ -58,7 +58,7 @@ class User
if destroy
contact.destroy
else
contact.update_attributes(direction => false)
contact.update(direction => false)
end
end
end

View file

@ -1,10 +1,5 @@
- content_for(:page_title) do
The page you were looking for doesn't exist (404)
.transparent.big-number
404
%h3
These are not the kittens you're looking for. Move along.
%p
%a{href: "javascript:history.back()"}
Go Back?

View file

@ -1,13 +1,7 @@
- content_for(:page_title) do
The change you wanted was rejected (422)
.transparent.big-number
422
%h3
The change you wanted was rejected.
%p
Maybe you tried to change something you didn't have access to.
%p
%a{href: "javascript:history.back()"}
Go Back?

View file

@ -1,8 +1,6 @@
- content_for(:page_title) do
We're sorry, but something went wrong (500)
.transparent.big-number
500
%h3
Internal server error.
Our bad! Sorry about that. :(
@ -10,7 +8,3 @@
- if AppConfig.admins.podmin_email?
%p
Drop us an email to <a href="mailto:#{AppConfig.admins.podmin_email}">#{AppConfig.admins.podmin_email}</a>.
%p
%a{href: "javascript:history.back()"}
Go Back?

View file

@ -11,5 +11,12 @@
= yield(:head)
%body{class: "error-#{@code}", id: "error_#{@code}"}
%body{class: "error-#{local_assigns[:code]}", id: "error_#{local_assigns[:code]}"}
.transparent.big-number
= local_assigns[:code]
= yield
%p
%a{href: "javascript:history.back()"}
Go Back?

View file

@ -34,7 +34,7 @@
.col-md-12
%h3= t(".change_password")
= form_for @user, url: edit_user_path, html: {method: :put, class: "form-horizontal"} do |f|
- if (@user.errors.keys & %i(password password_confirmation current_password)).present?
- if (@user.errors.attribute_names & %i[password password_confirmation current_password]).present?
= f.error_messages
.form-group
= f.label :current_password, t(".current_password"), class: "col-sm-6 control-label"

View file

@ -6,7 +6,7 @@ module Workers
sidekiq_options queue: :low
def perform(*args)
Notifier.send_notification(self.class.name.gsub("Workers::Mail::", "").underscore, *args).deliver_now
Notifier.send_notification(self.class.name.demodulize.underscore, *args).deliver_now
end
end
end

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
require_relative "../config/boot"
require "rails/commands"

View file

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run

33
bin/setup Executable file
View file

@ -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 set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time 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

View file

@ -6,7 +6,7 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path("../config/environment", __FILE__)
require_relative "config/environment"
# Kill unicorn workers really aggressively (at 300mb)
if defined?(Unicorn)
@ -18,4 +18,5 @@ if defined?(Unicorn)
end
use Rack::Deflater
run Diaspora::Application
run Rails.application
Rails.application.load_server

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative 'boot'
require_relative "boot"
require 'rails/all'
require "rails/all"
require_relative "bundler_helper"
@ -10,80 +10,43 @@ require_relative "bundler_helper"
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups(BundlerHelper.database))
# Do not dump the limit of boolean fields on MySQL,
# since that generates a db/schema.rb that's incompatible
# with PostgreSQL
require 'active_record/connection_adapters/abstract_mysql_adapter'
module ActiveRecord
module ConnectionAdapters
class Mysql2Adapter < AbstractMysqlAdapter
def prepare_column_options(column, *_)
super.tap {|spec|
spec.delete(:limit) if column.type == :boolean
}
end
end
end
end
# Load asset_sync early
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.1
# 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.
# Use classic autoloader for now
config.autoloader = :classic
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# 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
# 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)
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|
@ -98,8 +61,6 @@ module Diaspora
}
config.action_mailer.asset_host = AppConfig.pod_uri.to_s
config.action_view.raise_on_missing_translations = true
config.middleware.use Rack::OAuth2::Server::Resource::Bearer, "OpenID Connect" do |req|
Api::OpenidConnect::OAuthAccessToken
.valid(Time.zone.now.utc).find_by(token: req.access_token) || req.invalid_token!

View file

@ -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.

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
# Load the Rails application.
require_relative 'application'
require_relative "application"
# Initialize the Rails application.
Rails.application.initialize!

View file

@ -1,10 +1,12 @@
# frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# 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
# In the development environment your application's code is reloaded any time
# it changes. 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
@ -15,12 +17,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 +32,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
@ -36,9 +43,18 @@ Rails.application.configure do
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# 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 +69,22 @@ Rails.application.configure do
# Show the logging configuration on STDOUT
config.show_log_configuration = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = 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
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
# 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

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@ -17,14 +19,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
@ -33,19 +34,19 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
if AppConfig.environment.assets.host.present?
config.action_controller.asset_host = AppConfig.environment.assets.host.get
config.asset_host = AppConfig.environment.assets.host.get
end
# 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
# 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.*/ ]
@ -53,7 +54,8 @@ Rails.application.configure do
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Log level
# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = :info
# Prepend all log lines with the following tags.
@ -68,20 +70,34 @@ 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
# Log disallowed deprecations.
config.active_support.disallowed_deprecation = :log
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Use default logging formatter so that PID and timestamp are not suppressed.
# config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
# if ENV["RAILS_LOG_TO_STDOUT"].present?
@ -92,4 +108,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

View file

@ -1,12 +1,15 @@
# frozen_string_literal: true
require "active_support/core_ext/integer/time"
# 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 +20,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.
@ -27,7 +30,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
@ -39,12 +41,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.
@ -55,11 +62,20 @@ Rails.application.configure do
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Set the logging destination(s)
config.log_to = %w[file]
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Raises error for missing translations.
config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# for fixture_builder
ENV["FIXTURES_PATH"] = "spec/fixtures"

View file

@ -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

View file

@ -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

View file

@ -10,4 +10,9 @@ Rails.application.config.assets.version = "1.0"
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join("node_modules")
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.public_file_server.enabled = AppConfig.environment.assets.serve?

View file

@ -2,7 +2,8 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code
# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'".
Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"]

View file

@ -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

View file

@ -3,5 +3,6 @@
# 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 passw secret token _key crypt salt certificate otp otp_attempt ssn message text bio
]

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -1,4 +1,4 @@
FROM ruby:2.6-slim-buster
FROM ruby:2.7-slim-buster
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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, _opts)
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,

View file

@ -15,8 +15,8 @@ module Diaspora
# tag's name is limited to 255 charchters according to ActsAsTaggableOn gem, so we check the length of the name for each tag
def tag_name_max_length
self.tag_list.each do |tag|
errors[:tags] << I18n.t('tags.name_too_long', :count => 255, :current_length => tag.length) if tag.length > 255
tag_list.each do |tag|
errors.add(:tags, I18n.t("tags.name_too_long", count: 255, current_length: tag.length)) if tag.length > 255
end
end
protected :tag_name_max_length

View file

@ -6,44 +6,14 @@ class ErrorPageRenderer
def initialize options={}
@codes = options.fetch :codes, [404, 500]
@output = options.fetch :output, "public/%s.html"
@vars = options.fetch :vars, {}
@template = options.fetch :template, "errors/error_%s"
@layout = options.fetch :layout, "layouts/error_page"
end
def render
@codes.each do |code|
view = build_action_view
view.assign @vars.merge(code: code)
path = Rails.root.join(@output % code)
File.write path, view.render(template: @template % code, layout: @layout)
File.write path, ApplicationController.render(@template % code, layout: @layout, locals: {code: code})
end
end
def helpers(&block)
@helpers = block
end
private
def build_action_view
paths = ::ActionController::Base.view_paths
::ActionView::Base.new(paths).tap do |view|
view.class_eval do
include Rails.application.helpers
include Rails.application.routes.url_helpers
end
view.assets_manifest = build_manifest(Rails.application)
view.class_eval(&@helpers) if @helpers
end
end
# Internal API from the sprocket-rails railtie, if somebody finds a way to
# call it, please replace it. Might need to be updated on sprocket-rails
# updates.
def build_manifest(app)
config = app.config
path = File.join(config.paths['public'].first, config.assets.prefix)
Sprockets::Manifest.new(app.assets, path, config.assets.manifest)
end
end

View file

@ -1,38 +1,43 @@
# frozen_string_literal: true
namespace :assets do
# create new assets manifest for tasks which run after assets:precompile
def assets_manifest
return @assets_manifest if @assets_manifest
config = Diaspora::Application.config
path = File.join(config.paths["public"].first, config.assets.prefix)
@assets_manifest = Sprockets::Manifest.new(Diaspora::Application.assets, path, config.assets.manifest)
end
desc "Generate error pages"
task :generate_error_pages => :environment do
task generate_error_pages: :environment do
ApplicationController.view_context_class.assets_manifest = assets_manifest
renderer = ErrorPageRenderer.new codes: [404, 422, 500]
renderer.render
end
desc "Create non digest assets"
task non_digest_assets: :environment do
logger = ::Logging::Logger["assets:non_digest_assets"]
Diaspora::Application.config.assets.non_digest_assets.each do |asset|
digested_path = assets_manifest.assets[asset]
raise Sprockets::Rails::Helper::AssetNotFound, "Precompiled asset for '#{asset}' not found" unless digested_path
non_digest_assets = Diaspora::Application.config.assets.non_digest_assets
Rails.application.assets_manifest.assets.each do |logical_path, digested_path|
logical_pathname = Pathname.new(logical_path)
next unless non_digest_assets.any? {|testpath| logical_pathname.fnmatch?(testpath, File::FNM_PATHNAME) }
full_digested_path = Rails.root.join("public", "assets", digested_path)
full_non_digested_path = Rails.root.join("public", "assets", logical_path)
full_digested_path = File.join(assets_manifest.directory, digested_path)
full_non_digested_path = File.join(assets_manifest.directory, asset)
next unless FileUtils.uptodate?(full_digested_path, [full_non_digested_path])
logger.info "Copying #{full_digested_path} to #{full_non_digested_path}"
puts "Copying #{full_digested_path} to #{full_non_digested_path}"
FileUtils.copy_file(full_digested_path, full_non_digested_path, true)
end
end
# Augment precompile with error page generation
task :precompile do
Rake::Task[:precompile].enhance do
Rake::Task["assets:generate_error_pages"].invoke
Rake::Task["assets:non_digest_assets"].invoke
end
end
Rake::Task["assets:generate_error_pages"].enhance [ "yarn:install" ]
Rake::Task[:generate_error_pages].enhance ["yarn:install"]
end

View file

@ -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}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -142,22 +142,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
@ -167,13 +167,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

View file

@ -48,9 +48,9 @@ describe ApplicationHelper, :type => :helper do
end
it "returns false if the service is already connected" do
@current_user.services << FactoryBot.build(:service, provider: "service")
expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true)
expect(service_unconnected?("service")).to be false
@current_user.services << FactoryBot.build(:service)
expect(AppConfig).to receive(:show_service?).with("twitter", alice).and_return(true)
expect(service_unconnected?("twitter")).to be false
end
it "returns false if the the service shouldn't be shown" do

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -10,8 +10,9 @@ describe "status_messages/_status_message.mobile.haml" do
)
post = FactoryBot.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", locals: {post: post, photos: post.photos}
expect(rendered).to_not include("<script>")
expect(rendered).to include("&lt;script&gt;alert(0);&lt;/script&gt;")
end
end

View file

@ -7,7 +7,7 @@ describe Workers::CheckBirthday do
before do
Timecop.freeze(Time.zone.local(1999, 9, 9))
birthday_profile.update_attributes(birthday: "1990-09-09")
birthday_profile.update(birthday: "1990-09-09")
allow(Notifications::ContactsBirthday).to receive(:notify)
end
@ -22,13 +22,13 @@ describe Workers::CheckBirthday do
end
it "does nothing if the birthday does not exist" do
birthday_profile.update_attributes(birthday: nil)
birthday_profile.update(birthday: nil)
Workers::CheckBirthday.new.perform
expect(Notifications::ContactsBirthday).not_to have_received(:notify)
end
it "does nothing if the person's birthday is not today" do
birthday_profile.update_attributes(birthday: "1988-04-15")
birthday_profile.update(birthday: "1988-04-15")
Workers::CheckBirthday.new.perform
expect(Notifications::ContactsBirthday).not_to have_received(:notify)
end
@ -41,14 +41,14 @@ describe Workers::CheckBirthday do
end
it "does not call notify method if a contact user is not :receiving from the birthday person" do
contact2.update_attributes(receiving: false)
contact2.update(receiving: false)
Workers::CheckBirthday.new.perform
expect(Notifications::ContactsBirthday).to have_received(:notify).with(contact1, [])
expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact2, [])
end
it "does not call notify method if a birthday person is not :sharing with the contact user" do
contact2.update_attributes(sharing: false)
contact2.update(sharing: false)
Workers::CheckBirthday.new.perform
expect(Notifications::ContactsBirthday).to have_received(:notify).with(contact1, [])
expect(Notifications::ContactsBirthday).not_to have_received(:notify).with(contact2, [])