mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 14:15:22 +00:00
Add urgent
scope to SoftwareUpdate
model
This commit is contained in:
parent
766358e52b
commit
c24cbc60e3
|
@ -56,7 +56,7 @@ class AdminMailer < ApplicationMailer
|
|||
end
|
||||
|
||||
def new_critical_software_updates
|
||||
@software_updates = SoftwareUpdate.where(urgent: true).to_a.sort_by(&:gem_version)
|
||||
@software_updates = SoftwareUpdate.urgent.to_a.sort_by(&:gem_version)
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail subject: default_i18n_subject(instance: @instance)
|
||||
|
|
|
@ -18,6 +18,8 @@ class SoftwareUpdate < ApplicationRecord
|
|||
|
||||
enum :type, { patch: 0, minor: 1, major: 2 }, suffix: :type
|
||||
|
||||
scope :urgent, -> { where(urgent: true) }
|
||||
|
||||
def gem_version
|
||||
Gem::Version.new(version)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SoftwareUpdate do
|
||||
describe 'Scopes' do
|
||||
describe '.urgent' do
|
||||
let!(:urgent_update) { Fabricate :software_update, urgent: true }
|
||||
let!(:non_urgent_update) { Fabricate :software_update, urgent: false }
|
||||
|
||||
it 'returns records that are urgent' do
|
||||
expect(described_class.urgent)
|
||||
.to include(urgent_update)
|
||||
.and not_include(non_urgent_update)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pending?' do
|
||||
subject { described_class.new(version: update_version) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue