git-svn-id: https://svn.redmine.org/redmine/trunk@22340 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/5.1.0
assert_select "input[type=checkbox][name=?][value=#{tracker_id}][checked=checked]", 'custom_field[tracker_ids][]' | assert_select "input[type=checkbox][name=?][value=#{tracker_id}][checked=checked]", 'custom_field[tracker_ids][]' | ||||
end | end | ||||
# tracker not checked | # tracker not checked | ||||
(Tracker.all.pluck(:id) - tracker_ids).each do |tracker_id| | |||||
(Tracker.pluck(:id) - tracker_ids).each do |tracker_id| | |||||
assert_select "input[type=checkbox][name=?][value=#{tracker_id}]", 'custom_field[tracker_ids][]' | assert_select "input[type=checkbox][name=?][value=#{tracker_id}]", 'custom_field[tracker_ids][]' | ||||
end | end | ||||
# project checked | # project checked | ||||
assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'custom_field[project_ids][]' | assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'custom_field[project_ids][]' | ||||
end | end | ||||
# project not checked | # project not checked | ||||
(Project.all.pluck(:id) - project_ids).each do |project_id| | |||||
(Project.pluck(:id) - project_ids).each do |project_id| | |||||
assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'custom_field[project_ids][]' | assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'custom_field[project_ids][]' | ||||
end | end | ||||
end | end |
assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'tracker[project_ids][]' | assert_select "input[type=checkbox][name=?][value=#{project_id}][checked=checked]", 'tracker[project_ids][]' | ||||
end | end | ||||
# project not checked | # project not checked | ||||
(Project.all.pluck(:id) - project_ids).each do |project_id| | |||||
(Project.pluck(:id) - project_ids).each do |project_id| | |||||
assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'tracker[project_ids][]' | assert_select "input[type=checkbox][name=?][value=#{project_id}]", 'tracker[project_ids][]' | ||||
end | end | ||||
# workflow copy selected | # workflow copy selected |
user = User.find_by_login 'jsmith' | user = User.find_by_login 'jsmith' | ||||
assert_not user.must_activate_twofa? | assert_not user.must_activate_twofa? | ||||
group = Group.all.first | |||||
group = Group.first | |||||
group.update_column :twofa_required, true | group.update_column :twofa_required, true | ||||
group.users << user | group.users << user | ||||
user.reload | user.reload |
def IssueCustomField.generate!(attributes={}) | def IssueCustomField.generate!(attributes={}) | ||||
super do |field| | super do |field| | ||||
field.is_for_all = true unless attributes.key?(:is_for_all) | field.is_for_all = true unless attributes.key?(:is_for_all) | ||||
field.tracker_ids = Tracker.all.ids unless attributes.key?(:tracker_ids) || attributes.key?(:trackers) | |||||
field.tracker_ids = Tracker.ids unless attributes.key?(:tracker_ids) || attributes.key?(:trackers) | |||||
yield field if block_given? | yield field if block_given? | ||||
end | end | ||||
end | end |
def test_list_custom_field_should_be_set | def test_list_custom_field_should_be_set | ||||
field = CustomField.find(1) | field = CustomField.find(1) | ||||
field.tracker_ids = Tracker.all.ids | |||||
field.tracker_ids = Tracker.ids | |||||
field.save! | field.save! | ||||
import = generate_import_with_mapping | import = generate_import_with_mapping | ||||
import.mapping["cf_1"] = '8' | import.mapping["cf_1"] = '8' | ||||
def test_multiple_list_custom_field_should_be_set | def test_multiple_list_custom_field_should_be_set | ||||
field = CustomField.find(1) | field = CustomField.find(1) | ||||
field.tracker_ids = Tracker.all.ids | |||||
field.tracker_ids = Tracker.ids | |||||
field.multiple = true | field.multiple = true | ||||
field.save! | field.save! | ||||
import = generate_import_with_mapping | import = generate_import_with_mapping |
def test_create | def test_create | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, | ||||
:status_id => 1, :priority => IssuePriority.all.first, | |||||
:status_id => 1, :priority => IssuePriority.first, | |||||
:subject => 'test_create', | :subject => 'test_create', | ||||
:description => 'IssueTest#test_create', :estimated_hours => '1:30') | :description => 'IssueTest#test_create', :estimated_hours => '1:30') | ||||
assert issue.save | assert issue.save | ||||
with_settings :issue_group_assignment => '1' do | with_settings :issue_group_assignment => '1' do | ||||
issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3, | issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3, | ||||
:status_id => 1, :priority => IssuePriority.all.first, | |||||
:status_id => 1, :priority => IssuePriority.first, | |||||
:subject => 'Assignment test', | :subject => 'Assignment test', | ||||
:assigned_to => group, | :assigned_to => group, | ||||
:is_private => true) | :is_private => true) | ||||
def test_category_based_assignment | def test_category_based_assignment | ||||
issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, | issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, | ||||
:status_id => 1, :priority => IssuePriority.all.first, | |||||
:status_id => 1, :priority => IssuePriority.first, | |||||
:subject => 'Assignment test', | :subject => 'Assignment test', | ||||
:description => 'Assignment test', :category_id => 1) | :description => 'Assignment test', :category_id => 1) | ||||
assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to | assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to | ||||
ActionMailer::Base.deliveries.clear | ActionMailer::Base.deliveries.clear | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, | issue = Issue.new(:project_id => 1, :tracker_id => 1, | ||||
:author_id => 3, :status_id => 1, | :author_id => 3, :status_id => 1, | ||||
:priority => IssuePriority.all.first, | |||||
:priority => IssuePriority.first, | |||||
:subject => 'test_create', :estimated_hours => '1:30') | :subject => 'test_create', :estimated_hours => '1:30') | ||||
with_settings :notified_events => %w(issue_added) do | with_settings :notified_events => %w(issue_added) do | ||||
assert issue.save | assert issue.save | ||||
ActionMailer::Base.deliveries.clear | ActionMailer::Base.deliveries.clear | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, | issue = Issue.new(:project_id => 1, :tracker_id => 1, | ||||
:author_id => 3, :status_id => 1, | :author_id => 3, :status_id => 1, | ||||
:priority => IssuePriority.all.first, | |||||
:priority => IssuePriority.first, | |||||
:subject => 'test_create', :estimated_hours => '1:30') | :subject => 'test_create', :estimated_hours => '1:30') | ||||
with_settings :notified_events => %w(issue_added issue_updated) do | with_settings :notified_events => %w(issue_added issue_updated) do | ||||
assert issue.save | assert issue.save | ||||
ActionMailer::Base.deliveries.clear | ActionMailer::Base.deliveries.clear | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, | issue = Issue.new(:project_id => 1, :tracker_id => 1, | ||||
:author_id => 3, :status_id => 1, | :author_id => 3, :status_id => 1, | ||||
:priority => IssuePriority.all.first, | |||||
:priority => IssuePriority.first, | |||||
:subject => 'test_create', :estimated_hours => '1:30') | :subject => 'test_create', :estimated_hours => '1:30') | ||||
with_settings :notified_events => [] do | with_settings :notified_events => [] do | ||||
assert issue.save | assert issue.save |
} | } | ||||
) | ) | ||||
result = find_issues_with_query(query) | result = find_issues_with_query(query) | ||||
expected = Issue.all.order(:id).ids - [8, 11, 12] | |||||
expected = Issue.order(:id).ids - [8, 11, 12] | |||||
assert_equal expected, result.map(&:id).sort | assert_equal expected, result.map(&:id).sort | ||||
end | end | ||||
def test_activity_id_should_be_set_automatically_if_there_is_only_one_activity_available | def test_activity_id_should_be_set_automatically_if_there_is_only_one_activity_available | ||||
project = Project.find(1) | project = Project.find(1) | ||||
TimeEntry.all.destroy_all | |||||
TimeEntry.destroy_all | |||||
TimeEntryActivity.destroy_all | TimeEntryActivity.destroy_all | ||||
only_one_activity = TimeEntryActivity.create!( | only_one_activity = TimeEntryActivity.create!( | ||||
name: 'Development', | name: 'Development', | ||||
anon = User.anonymous | anon = User.anonymous | ||||
project = Project.find(1) | project = Project.find(1) | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1, | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1, | ||||
:priority => IssuePriority.all.first, :subject => 'test_create', | |||||
:priority => IssuePriority.first, :subject => 'test_create', | |||||
:description => 'IssueTest#test_create', :estimated_hours => '1:30') | :description => 'IssueTest#test_create', :estimated_hours => '1:30') | ||||
assert issue.save | assert issue.save | ||||
activity = TimeEntryActivity.find_by_name('Design') | activity = TimeEntryActivity.find_by_name('Design') | ||||
anon = User.anonymous | anon = User.anonymous | ||||
project = Project.find(1) | project = Project.find(1) | ||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1, | issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => anon.id, :status_id => 1, | ||||
:priority => IssuePriority.all.first, :subject => 'test_create', | |||||
:priority => IssuePriority.first, :subject => 'test_create', | |||||
:description => 'IssueTest#test_create', :estimated_hours => '1:30') | :description => 'IssueTest#test_create', :estimated_hours => '1:30') | ||||
assert issue.save | assert issue.save | ||||
activity = TimeEntryActivity.find_by_name('Design') | activity = TimeEntryActivity.find_by_name('Design') |