Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
- app/controllers/about_controller.rb
- app/controllers/tags_controller.rb
- app/views/about/show.html.haml
- spec/views/about/show.html.haml_spec.rb
This commit is contained in:
Thibaut Girka
2019-03-13 15:16:02 +01:00
97 changed files with 642 additions and 1688 deletions

View File

@ -474,6 +474,7 @@ class Account < ApplicationRecord
before_create :generate_keys
before_validation :prepare_contents, if: :local?
before_validation :prepare_username, on: :create
before_destroy :clean_feed_manager
private
@ -483,6 +484,10 @@ class Account < ApplicationRecord
note&.strip!
end
def prepare_username
username&.squish!
end
def generate_keys
return unless local? && !Rails.env.test?

View File

@ -18,7 +18,11 @@ module Expireable
end
def expired?
!expires_at.nil? && expires_at < Time.now.utc
expires? && expires_at < Time.now.utc
end
def expires?
!expires_at.nil?
end
end
end

View File

@ -72,6 +72,14 @@ class Tag < ApplicationRecord
.limit(limit)
.offset(offset)
end
def find_normalized(name)
find_by(name: name.mb_chars.downcase.to_s)
end
def find_normalized!(name)
find_normalized(name) || raise(ActiveRecord::RecordNotFound)
end
end
private