mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 07:05:20 +00:00
Add by_version
method to SoftwareUpdate
model
This commit is contained in:
parent
c24cbc60e3
commit
2bfa58aa1a
|
@ -6,7 +6,7 @@ module Admin
|
|||
|
||||
def index
|
||||
authorize :software_update, :index?
|
||||
@software_updates = SoftwareUpdate.all.sort_by(&:gem_version)
|
||||
@software_updates = SoftwareUpdate.by_version
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -48,7 +48,7 @@ class AdminMailer < ApplicationMailer
|
|||
end
|
||||
|
||||
def new_software_updates
|
||||
@software_updates = SoftwareUpdate.all.to_a.sort_by(&:gem_version)
|
||||
@software_updates = SoftwareUpdate.by_version
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail subject: default_i18n_subject(instance: @instance)
|
||||
|
@ -56,7 +56,7 @@ class AdminMailer < ApplicationMailer
|
|||
end
|
||||
|
||||
def new_critical_software_updates
|
||||
@software_updates = SoftwareUpdate.urgent.to_a.sort_by(&:gem_version)
|
||||
@software_updates = SoftwareUpdate.urgent.by_version
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail subject: default_i18n_subject(instance: @instance)
|
||||
|
|
|
@ -37,6 +37,10 @@ class SoftwareUpdate < ApplicationRecord
|
|||
Rails.configuration.x.mastodon.software_update_url.present?
|
||||
end
|
||||
|
||||
def by_version
|
||||
all.sort_by(&:gem_version)
|
||||
end
|
||||
|
||||
def pending_to_a
|
||||
return [] unless check_enabled?
|
||||
|
||||
|
|
|
@ -16,6 +16,16 @@ RSpec.describe SoftwareUpdate do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.by_version' do
|
||||
let!(:latest_update) { Fabricate :software_update, version: '4.0.0' }
|
||||
let!(:older_update) { Fabricate :software_update, version: '3.0.0' }
|
||||
|
||||
it 'returns record in gem version order' do
|
||||
expect(described_class.by_version)
|
||||
.to eq([older_update, latest_update])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pending?' do
|
||||
subject { described_class.new(version: update_version) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue