Commit e9af8769 authored by azul's avatar azul
Browse files

remove page_observer - use dependent: delete for PageNotices

parent 1091dd6a
......@@ -7,7 +7,6 @@ class PageNotice < Notice
attr_accessor :from
class << self
alias_method :destroy_all_by_page, :destroy_all_by_noticable
alias_method :for_page, :for_noticable
#
......
class PageObserver < ActiveRecord::Observer
def after_destroy(page)
PageNotice.destroy_all_by_page(page)
end
end
......@@ -75,6 +75,10 @@ class Page < ActiveRecord::Base
include PageExtension::Tracking # page tracking views, edits and stars
include PageExtension::PageHistory
has_many :page_notices, as: :noticable, dependent: :delete_all
# disable timestamps, we set the updated_at field through certain PageHistory subclasses
self.record_timestamps = false
before_save :save_timestamps
......
......@@ -50,7 +50,7 @@ module Crabgrass
config.active_record.observers = :user_observer,
:relationship_observer, :request_to_destroy_our_group_observer,
:request_observer, :page_observer, "tracking/page_observer",
:request_observer, "tracking/page_observer",
"tracking/post_observer", "tracking/wiki_observer",
"tracking/user_participation_observer", "tracking/group_participation_observer"
......
......@@ -210,6 +210,19 @@ class PageSharingTest < ActiveSupport::TestCase
end
end
def test_cleanup_notify_message_on_page_delete
creator = users(:blue)
additional_user = users(:kangaroo)
page = Page.create!(title: 'title', user: creator, access: 'admin')
creator.share_page_with!(page, additional_user, send_notice: true, send_message: 'hi')
page.save!
assert_difference 'PageNotice.count', -1 do
page.destroy
end
end
# share with a committee you are a member of, but you are not a member of the parent group.
# share with a committee you are a member of, but you are not a member of the parent group.
def test_share_with_committee
owner = users(:penguin)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment