]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Private flag ignored when creating an issue with set_own_issues_private permis...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 1 Jun 2011 17:16:38 +0000 (17:16 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 1 Jun 2011 17:16:38 +0000 (17:16 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5991 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/fixtures/roles.yml
test/functional/issues_controller_test.rb

index 8750ca87fef88fa46bd39ae83aa0a4e98ce5cd40..63ee316a301b245fca2c1e3643365c3a259edd31 100644 (file)
@@ -301,6 +301,7 @@ private
     end
 
     @issue.project = @project
+    @issue.author = User.current
     # Tracker must be set before custom field values
     @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
     if @issue.tracker.nil?
@@ -314,7 +315,6 @@ private
         @issue.watcher_user_ids = params[:issue]['watcher_user_ids']
       end
     end
-    @issue.author = User.current
     @priorities = IssuePriority.all
     @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
   end
index 903df8cb114f3dc8122c1733b1fc05ebbafa1008..57f5e6be01e0102704d4fe590ceec2ca206edd03 100644 (file)
@@ -22,6 +22,7 @@ roles_001:
     - :delete_issues
     - :view_issue_watchers
     - :add_issue_watchers
+    - :set_issues_private
     - :delete_issue_watchers
     - :manage_public_queries
     - :save_queries
index a0edab1bdd130efed24e325588edd3b6a0def7df..d97043014c0403cdbf19a0d9930908e97a1bea4f 100644 (file)
@@ -606,6 +606,36 @@ class IssuesControllerTest < ActionController::TestCase
     assert_not_nil issue
     assert_nil issue.parent
   end
+  
+  def test_post_create_private
+    @request.session[:user_id] = 2
+
+    assert_difference 'Issue.count' do
+      post :create, :project_id => 1,
+                 :issue => {:tracker_id => 1,
+                            :subject => 'This is a private issue',
+                            :is_private => '1'}
+    end
+    issue = Issue.first(:order => 'id DESC')
+    assert issue.is_private?
+  end
+  
+  def test_post_create_private_with_set_own_issues_private_permission
+    role = Role.find(1)
+    role.remove_permission! :set_issues_private
+    role.add_permission! :set_own_issues_private
+    
+    @request.session[:user_id] = 2
+
+    assert_difference 'Issue.count' do
+      post :create, :project_id => 1,
+                 :issue => {:tracker_id => 1,
+                            :subject => 'This is a private issue',
+                            :is_private => '1'}
+    end
+    issue = Issue.first(:order => 'id DESC')
+    assert issue.is_private?
+  end
 
   def test_post_create_should_send_a_notification
     ActionMailer::Base.deliveries.clear