about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-26 15:28:08 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-26 15:28:08 +0100
commitf16b31f0773c2fd1122ff0ad98cb392e762f0d0b (patch)
tree24880b7ee107288e7acb540011281569e8502e96 /app/models
parent44c5958203dd8d0f96f880a8014a3233719077a6 (diff)
Adding a bunch of tests
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb8
-rw-r--r--app/models/status.rb7
-rw-r--r--app/models/stream_entry.rb2
3 files changed, 12 insertions, 5 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 2cbec488b..1b4f4ebdf 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -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
diff --git a/app/models/status.rb b/app/models/status.rb
index d95870393..3ba58cc91 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -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
diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb
index a3ae099a1..e19dcc6c6 100644
--- a/app/models/stream_entry.rb
+++ b/app/models/stream_entry.rb
@@ -29,7 +29,7 @@ class StreamEntry < ActiveRecord::Base
   end
 
   def threaded?
-    [:favorite, :comment].include? verb
+    verb == :favorite || object_type == :comment
   end
 
   def thread