Restream/redmine_non_member_watcher

View on GitHub
lib/redmine_non_member_watcher/patches/watchers_controller_patch.rb

Summary

Maintainability
A
0 mins
Test Coverage
require_dependency 'watchers_controller'

module RedmineNonMemberWatcher::Patches
  module WatchersControllerPatch
    extend ActiveSupport::Concern

    private

    # allow to self-unwatch
    def check_project_privacy
      allowed_to_unwatch? ? true : super
    end

    def allowed_to_unwatch?
      action_name == 'unwatch' &&
        User.current.allowed_to?(:view_watched_issues, @project) &&
        @watched.watched_by?(User.current)
    end
  end
end