parent
41df9a4c54
commit
e3913e61e4
@ -1,42 +0,0 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2021 the OpenProject GmbH |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
|
||||
# Return mail notifications that are unread (have read_mail: false) |
||||
module Notifications::Scopes |
||||
module UnreadMail |
||||
extend ActiveSupport::Concern |
||||
|
||||
class_methods do |
||||
def unread_mail |
||||
where(read_mail: false) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,17 @@ |
||||
class CleanupNotifications < ActiveRecord::Migration[6.1] |
||||
def up |
||||
change_table :notifications, bulk: true do |t| |
||||
t.remove :read_mail, :reason_mail, :reason_mail_digest |
||||
t.rename :reason_ian, :reason |
||||
end |
||||
end |
||||
|
||||
def down |
||||
change_table :notifications, bulk: true do |t| |
||||
t.boolean :read_email, default: false, index: true |
||||
t.integer :reason_mail, limit: 1 |
||||
t.integer :reason_mail_digest, limit: 1 |
||||
t.rename :reason, :reason_ian |
||||
end |
||||
end |
||||
end |
@ -1,50 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2021 the OpenProject GmbH |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe Notifications::Scopes::UnreadMail, type: :model do |
||||
describe '.unread_mail' do |
||||
subject(:scope) { ::Notification.unread_mail } |
||||
|
||||
let(:no_mail_notification) { FactoryBot.create(:notification, read_mail: nil) } |
||||
let(:unread_mail_notification) { FactoryBot.create(:notification, read_mail: false) } |
||||
let(:read_mail_notification) { FactoryBot.create(:notification, read_mail: true) } |
||||
|
||||
before do |
||||
no_mail_notification |
||||
unread_mail_notification |
||||
read_mail_notification |
||||
end |
||||
|
||||
it 'contains the notifications with read_mail: false' do |
||||
expect(scope) |
||||
.to match_array([unread_mail_notification]) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue