summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2024-07-08 21:32:15 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2024-07-08 21:32:15 +0000
commit57743c4145eadc4d702b7bd21eafbb30a15b48ca (patch)
tree641aec6c4e11e6949d095249d1b3a47e03e5ac0b /test/functional
parentf9f486bdd091fcfdc351b188981688dccffed210 (diff)
downloadredmine-57743c4145eadc4d702b7bd21eafbb30a15b48ca.tar.gz
redmine-57743c4145eadc4d702b7bd21eafbb30a15b48ca.zip
Permission check based on the type of @watchables@ (#40946).
Patch by Jens Krämer (@jkraemer). git-svn-id: https://svn.redmine.org/redmine/trunk@22915 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/watchers_controller_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/watchers_controller_test.rb b/test/functional/watchers_controller_test.rb
index 65aad4e1f..ed3c25770 100644
--- a/test/functional/watchers_controller_test.rb
+++ b/test/functional/watchers_controller_test.rb
@@ -578,6 +578,41 @@ class WatchersControllerTest < Redmine::ControllerTest
assert !wiki_page.watched_by?(user)
end
+ def test_destroy_without_permission
+ @request.session[:user_id] = 2
+ wiki_page = WikiPage.find(1)
+ user = User.find(1)
+ Role.find(1).remove_permission! :delete_wiki_page_watchers
+
+ assert wiki_page.watched_by?(user)
+ assert_no_difference('Watcher.count') do
+ delete :destroy, :params => {
+ :object_type => 'wiki_page', :object_id => '1', :user_id => '1'
+ }, :xhr => true
+ assert_response 403
+ end
+ wiki_page.reload
+ assert wiki_page.watched_by?(user)
+ end
+
+ def test_create_without_permission
+ @request.session[:user_id] = 2
+ wiki_page = WikiPage.find(1)
+ user = User.find(1)
+ Role.find(1).remove_permission! :add_wiki_page_watchers
+ Watcher.delete_all
+
+ assert_not wiki_page.watched_by?(user)
+ assert_no_difference('Watcher.count') do
+ post :create, :params => {
+ :object_type => 'wiki_page', :object_id => '1', :user_id => '1'
+ }, :xhr => true
+ assert_response 403
+ end
+ wiki_page.reload
+ assert_not wiki_page.watched_by?(user)
+ end
+
def test_destroy_locked_user
user = User.find(3)
user.lock!