mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 05:34:55 +08:00
Add last_time_changed_at columnd to SystemNotifications
This commit is contained in:
parent
863e3873c2
commit
8ebb7561d9
5 changed files with 9 additions and 1 deletions
|
@ -5,6 +5,6 @@ class SystemNotification < ApplicationRecord
|
|||
has_many :users, through: :user_system_notifications
|
||||
|
||||
validates :title, :modal_title, :modal_body, :description,
|
||||
:source_created_at, :source_id,
|
||||
:source_created_at, :source_id, :last_time_changed_at,
|
||||
presence: true
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ class CreateSystemNotifications < ActiveRecord::Migration[5.1]
|
|||
t.boolean :show_on_login, default: false
|
||||
t.datetime :source_created_at, index: true
|
||||
t.bigint :source_id, index: true, unique: true
|
||||
t.datetime :last_time_changed_at, index: true, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
|
|
@ -668,8 +668,10 @@ ActiveRecord::Schema.define(version: 20190125123107) do
|
|||
t.boolean "show_on_login", default: false
|
||||
t.datetime "source_created_at"
|
||||
t.bigint "source_id"
|
||||
t.datetime "last_time_changed_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["last_time_changed_at"], name: "index_system_notifications_on_last_time_changed_at"
|
||||
t.index ["source_created_at"], name: "index_system_notifications_on_source_created_at"
|
||||
t.index ["source_id"], name: "index_system_notifications_on_source_id"
|
||||
end
|
||||
|
|
|
@ -8,6 +8,7 @@ FactoryBot.define do
|
|||
modal_body { Faker::Lorem.paragraphs(4).map { |pr| "<p>#{pr}</p>" }.join }
|
||||
source_created_at { Faker::Time.between(3.days.ago, Date.today) }
|
||||
source_id { Faker::Number.between(1, 1000) }
|
||||
last_time_changed_at { Time.now }
|
||||
trait :show_on_login do
|
||||
show_on_login { true }
|
||||
end
|
||||
|
|
|
@ -33,6 +33,10 @@ describe SystemNotification do
|
|||
describe '#source_created_at' do
|
||||
it { is_expected.to validate_presence_of(:source_created_at) }
|
||||
end
|
||||
|
||||
describe '#last_time_changed_at' do
|
||||
it { is_expected.to validate_presence_of(:last_time_changed_at) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Associations' do
|
||||
|
|
Loading…
Add table
Reference in a new issue