Defect #44768 » 0003-keep-private-flag-when-copying-issues_r25469.patch
| app/models/issue.rb | ||
|---|---|---|
|
self.status = statuses_allowed.first || default_status
|
||
|
end
|
||
|
@is_private_specified = true if attrs.key?('is_private')
|
||
|
# Use the selected tracker's private default when no value has been specified.
|
||
|
if new_record? && tracker&.private_by_default? &&
|
||
|
# Use the selected tracker's private default when no value has been specified, except for copies.
|
||
|
if new_record? && !copy? && tracker&.private_by_default? &&
|
||
|
!@is_private_specified && safe_attribute?('is_private', user)
|
||
|
attrs['is_private'] = '1'
|
||
|
end
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
assert_select 'input[name=?][checked=checked]', 'issue[is_private]'
|
||
|
end
|
||
|
def test_new_copy_should_keep_public_flag_of_source_issue_if_tracker_is_private_by_default
|
||
|
Tracker.find(1).update! :private_by_default => true
|
||
|
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :is_private => false)
|
||
|
@request.session[:user_id] = 2
|
||
|
get(:new, :params => {:project_id => 1, :copy_from => issue.id})
|
||
|
assert_response :success
|
||
|
assert_select 'input[type=checkbox][name=?]', 'issue[is_private]'
|
||
|
assert_select 'input[name=?][checked=checked]', 'issue[is_private]', 0
|
||
|
end
|
||
|
def test_update_form_for_new_issue_should_apply_private_by_default_when_submitted_private_is_unchecked
|
||
|
Tracker.find(2).update! :private_by_default => true
|
||
|
@request.session[:user_id] = 2
|
||
| ... | ... | |
|
assert_response :forbidden
|
||
|
end
|
||
|
def test_bulk_copy_should_keep_public_flag_if_tracker_is_private_by_default
|
||
|
Tracker.find(1).update! :private_by_default => true
|
||
|
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :is_private => false)
|
||
|
@request.session[:user_id] = 2
|
||
|
assert_difference 'Issue.count', 1 do
|
||
|
post(
|
||
|
:bulk_update,
|
||
|
:params => {
|
||
|
:ids => [issue.id],
|
||
|
:copy => '1',
|
||
|
:issue => {:project_id => '', :tracker_id => '', :is_private => ''}
|
||
|
}
|
||
|
)
|
||
|
end
|
||
|
assert_equal false, Issue.order(:id => :desc).first.is_private
|
||
|
end
|
||
|
def test_bulk_copy_should_allow_not_changing_the_issue_attributes
|
||
|
@request.session[:user_id] = 2
|
||
|
issues = [
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert_equal "125", issue.custom_value_for(2).value
|
||
|
end
|
||
|
def test_copy_should_keep_is_private_if_tracker_is_private_by_default
|
||
|
Tracker.find(1).update! :private_by_default => true
|
||
|
Role.find(1).add_permission! :set_issues_private
|
||
|
orig = Issue.generate!(:project_id => 1, :tracker_id => 1, :is_private => false)
|
||
|
issue = Issue.new.copy_from(orig)
|
||
|
User.current = User.find(2)
|
||
|
issue.safe_attributes = {'subject' => 'Copy'}
|
||
|
assert_equal false, issue.is_private
|
||
|
end
|
||
|
def test_copy_to_another_project_should_clear_assignee_if_not_valid
|
||
|
issue = Issue.generate!(:project_id => 1, :assigned_to_id => 2)
|
||
|
project = Project.generate!
|
||
- « Previous
- 1
- 2
- 3
- Next »