]> source.dussan.org Git - redmine.git/commitdiff
Merged r15879 (#23969).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Oct 2016 07:05:15 +0000 (07:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 8 Oct 2016 07:05:15 +0000 (07:05 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@15889 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/functional/issues_controller_test.rb
test/unit/issue_test.rb

index 1b9f216316ecdd8f49c6bbcdc3aac46e9e5c542b..58d51e1390325df93518efdd3a20727a6e1de6f9 100644 (file)
@@ -1428,6 +1428,11 @@ class Issue < ActiveRecord::Base
   private
 
   def user_tracker_permission?(user, permission)
+    if project && !project.active?
+      perm = Redmine::AccessControl.permission(permission)
+      return false unless perm && perm.read?
+    end
+
     if user.admin?
       true
     else
index deed445ef07bd9083af375abfc6716f88c9f6114..f3812a936efd198f13116a98d783271abb31cc59 100644 (file)
@@ -1755,6 +1755,25 @@ class IssuesControllerTest < ActionController::TestCase
     assert_response 404
   end
 
+  def test_show_on_active_project_should_display_edit_links
+    @request.session[:user_id] = 1
+
+    get :show, :id => 1
+    assert_response :success
+    assert_select 'a', :text => 'Edit'
+    assert_select 'a', :text => 'Delete'
+  end
+
+  def test_show_on_closed_project_should_not_display_edit_links
+    Issue.find(1).project.close
+    @request.session[:user_id] = 1
+
+    get :show, :id => 1
+    assert_response :success
+    assert_select 'a', :text => 'Edit', :count => 0
+    assert_select 'a', :text => 'Delete', :count => 0
+  end
+
   def test_get_new
     @request.session[:user_id] = 2
     get :new, :project_id => 1, :tracker_id => 1
index d7efda784e3bb287f67df8296c1d09515480200d..f41368a4822f6e2deda4c941cd7a3d1b1005e5b6 100644 (file)
@@ -519,6 +519,22 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal [issue], Issue.assigned_to(user).to_a
   end
 
+  def test_issue_should_be_readonly_on_closed_project
+    issue = Issue.find(1)
+    user = User.find(1)
+
+    assert_equal true, issue.visible?(user)
+    assert_equal true, issue.editable?(user)
+    assert_equal true, issue.deletable?(user)
+
+    issue.project.close
+    issue.reload
+
+    assert_equal true, issue.visible?(user)
+    assert_equal false, issue.editable?(user)
+    assert_equal false, issue.deletable?(user)
+  end
+
   def test_errors_full_messages_should_include_custom_fields_errors
     field = IssueCustomField.find_by_name('Database')