]> source.dussan.org Git - redmine.git/commitdiff
Merged r5991 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 2 Jul 2011 17:28:00 +0000 (17:28 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 2 Jul 2011 17:28:00 +0000 (17:28 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@6158 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 4758cf92d5e0c41bbb950b748e913334979455bd..eeb3de267bf38d768c984a8bdd6364541d1d1f5d 100644 (file)
@@ -612,6 +612,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