From 8fd174298df3fea60a4efe958fca9c1946633e10 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 23 May 2017 09:53:01 +0900 Subject: Cover AccountsController more in spec (#3229) * Introduce recent scope to Status and StreamEntry Introduce recent scope to Status and StreamEntry as Account has. * Cover AccountsController more in AccountsController --- app/models/status.rb | 3 ++- app/models/stream_entry.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/status.rb b/app/models/status.rb index d7304152f..a3dbce9f1 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -55,8 +55,9 @@ class Status < ApplicationRecord validates_with StatusLengthValidator validates :reblog, uniqueness: { scope: :account }, if: :reblog? - default_scope { order(id: :desc) } + default_scope { recent } + scope :recent, -> { reorder(id: :desc) } scope :remote, -> { where.not(uri: nil) } scope :local, -> { where(uri: nil) } diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index fb349f35c..44aac39b3 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -25,6 +25,7 @@ class StreamEntry < ApplicationRecord STATUS_INCLUDES = [:account, :stream_entry, :conversation, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :conversation, :media_attachments, :tags, mentions: :account], thread: [:stream_entry, :account]].freeze default_scope { where(activity_type: 'Status') } + scope :recent, -> { reorder(id: :desc) } scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) } delegate :target, :title, :content, :thread, -- cgit