diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8750ca87f..63ee316a3 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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 diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index 903df8cb1..57f5e6be0 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -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 diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index a0edab1bd..d97043014 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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