Fix deprecation warnings for rails 6.1
This commit is contained in:
parent
fe84d3e101
commit
3bb9b9a18d
9 changed files with 23 additions and 27 deletions
|
|
@ -11,9 +11,9 @@ class Block < ApplicationRecord
|
||||||
validate :not_blocking_yourself
|
validate :not_blocking_yourself
|
||||||
|
|
||||||
def not_blocking_yourself
|
def not_blocking_yourself
|
||||||
if self.user.person.id == self.person_id
|
return unless user.person.id == person_id
|
||||||
errors[:person_id] << "stop blocking yourself!"
|
|
||||||
end
|
errors.add(:person_id, "stop blocking yourself!")
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Array<Person>] The recipient of the block
|
# @return [Array<Person>] The recipient of the block
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,8 @@ class Message < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def participant_of_parent_conversation
|
def participant_of_parent_conversation
|
||||||
if conversation && !conversation.participants.include?(author)
|
return unless conversation&.participants&.exclude?(author)
|
||||||
errors[:base] << "Author is not participating in the conversation"
|
|
||||||
else
|
errors.add(:base, "Author is not participating in the conversation")
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@ class Report < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry_does_not_exist
|
def entry_does_not_exist
|
||||||
if Report.where(item_id: item_id, item_type: item_type).exists?(user_id: user_id)
|
return unless 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
|
errors.add(:base, "You cannot report the same post twice.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_or_comment_does_exist
|
def post_or_comment_does_exist
|
||||||
if Post.find_by_id(item_id).nil? && Comment.find_by_id(item_id).nil?
|
return unless 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
|
errors.add(:base, "Post or comment was already deleted or doesn't exists.")
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_reported_item
|
def destroy_reported_item
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,6 @@ class Reshare < Post
|
||||||
private
|
private
|
||||||
|
|
||||||
def root_must_be_public
|
def root_must_be_public
|
||||||
if self.root && !self.root.public
|
errors.add(:base, "Only posts which are public may be reshared.") if root && !root.public
|
||||||
errors[:base] << "Only posts which are public may be reshared."
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class StatusMessage < Post
|
||||||
private
|
private
|
||||||
|
|
||||||
def presence_of_content
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -535,10 +535,10 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def no_person_with_same_username
|
def no_person_with_same_username
|
||||||
diaspora_id = "#{self.username}#{User.diaspora_id_host}"
|
diaspora_id = "#{username}#{User.diaspora_id_host}"
|
||||||
if self.username_changed? && Person.exists?(:diaspora_handle => diaspora_id)
|
return unless username_changed? && Person.exists?(diaspora_handle: diaspora_id)
|
||||||
errors[:base] << 'That username has already been taken'
|
|
||||||
end
|
errors.add(:base, "That username has already been taken")
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_account!
|
def close_account!
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%h3= t(".change_password")
|
%h3= t(".change_password")
|
||||||
= form_for @user, url: edit_user_path, html: {method: :put, class: "form-horizontal"} do |f|
|
= 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
|
= f.error_messages
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :current_password, t(".current_password"), class: "col-sm-6 control-label"
|
= f.label :current_password, t(".current_password"), class: "col-sm-6 control-label"
|
||||||
|
|
|
||||||
|
|
@ -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
|
# 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
|
def tag_name_max_length
|
||||||
self.tag_list.each do |tag|
|
tag_list.each do |tag|
|
||||||
errors[:tags] << I18n.t('tags.name_too_long', :count => 255, :current_length => tag.length) if tag.length > 255
|
errors.add(:tags, I18n.t("tags.name_too_long", count: 255, current_length: tag.length)) if tag.length > 255
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
protected :tag_name_max_length
|
protected :tag_name_max_length
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ describe "status_messages/_status_message.mobile.haml" do
|
||||||
)
|
)
|
||||||
post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache)
|
post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache)
|
||||||
|
|
||||||
render template: "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_not include("<script>")
|
||||||
|
expect(rendered).to include("<script>alert(0);</script>")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue