0
0
Fork 0

Adding a bunch of tests

This commit is contained in:
Eugen Rochko 2016-02-26 15:28:08 +01:00
parent 44c5958203
commit f16b31f077
22 changed files with 439 additions and 105 deletions

View file

@ -59,4 +59,12 @@ class Account < ActiveRecord::Base
def subscription(webhook_url)
@subscription ||= OStatus2::Subscription.new(self.remote_url, secret: self.secret, token: self.verify_token, webhook: webhook_url, hub: self.hub_url)
end
before_create do
if local?
keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 48 : 2048)
self.private_key = keypair.to_pem
self.public_key = keypair.public_key.to_pem
end
end
end

View file

@ -54,10 +54,9 @@ class Status < ActiveRecord::Base
unless reblog?
self.text.scan(Account::MENTION_RE).each do |match|
uri = match.first
username = uri.split('@').first
domain = uri.split('@').size == 2 ? uri.split('@').last : nil
account = Account.find_by(username: username, domain: domain)
uri = match.first
username, domain = uri.split('@')
account = Account.find_by(username: username, domain: domain)
m << account unless account.nil?
end

View file

@ -29,7 +29,7 @@ class StreamEntry < ActiveRecord::Base
end
def threaded?
[:favorite, :comment].include? verb
verb == :favorite || object_type == :comment
end
def thread