Actualiza a Redmine 3.4.13
This commit is contained in:
parent
807ff3308d
commit
ecddcaf1d3
224 changed files with 2222 additions and 1000 deletions
8
test/fixtures/configuration/default.yml.example
vendored
Normal file
8
test/fixtures/configuration/default.yml.example
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
default:
|
||||
somesetting: foo
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
7
test/fixtures/configuration/empty.yml.example
vendored
Normal file
7
test/fixtures/configuration/empty.yml.example
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
default:
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
8
test/fixtures/configuration/no_default.yml.example
vendored
Normal file
8
test/fixtures/configuration/no_default.yml.example
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
default:
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
||||
somesetting: foo
|
9
test/fixtures/configuration/overrides.yml.example
vendored
Normal file
9
test/fixtures/configuration/overrides.yml.example
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
default:
|
||||
somesetting: foo
|
||||
|
||||
production:
|
||||
|
||||
development:
|
||||
|
||||
test:
|
||||
somesetting: bar
|
|
@ -1,13 +1,13 @@
|
|||
Index: trunk/app/controllers/issues_controller.rb
|
||||
===================================================================
|
||||
--- trunk/app/controllers/issues_controller.rb (révision 1483)
|
||||
+++ trunk/app/controllers/issues_controller.rb (révision 1484)
|
||||
@@ -149,7 +149,7 @@
|
||||
attach_files(@issue, params[:attachments])
|
||||
flash[:notice] = 'Demande créée avec succès'
|
||||
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
|
||||
- redirect_to :controller => 'issues', :action => 'show', :id => @issue, :project_id => @project
|
||||
+ redirect_to :controller => 'issues', :action => 'show', :id => @issue
|
||||
return
|
||||
end
|
||||
end
|
||||
Index: trunk/app/controllers/issues_controller.rb
|
||||
===================================================================
|
||||
--- trunk/app/controllers/issues_controller.rb (révision 1483)
|
||||
+++ trunk/app/controllers/issues_controller.rb (révision 1484)
|
||||
@@ -149,7 +149,7 @@
|
||||
attach_files(@issue, params[:attachments])
|
||||
flash[:notice] = 'Demande créée avec succès'
|
||||
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
|
||||
- redirect_to :controller => 'issues', :action => 'show', :id => @issue, :project_id => @project
|
||||
+ redirect_to :controller => 'issues', :action => 'show', :id => @issue
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
4
test/fixtures/files/import_issues_utf8_with_bom.csv
vendored
Normal file
4
test/fixtures/files/import_issues_utf8_with_bom.csv
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
"priority";subject;description;start_date;due_date;parent;private;progress;custom;version;category;user;estimated_hours;tracker;status
|
||||
High;First;First description;2015-07-08;2015-08-25;;no;;PostgreSQL;;New category;dlopper;1;bug;new
|
||||
Normal;Child 1;Child description;;;1;yes;10;MySQL;2.0;New category;;2;feature request;new
|
||||
Normal;Child of existing issue;Child description;;;#2;no;20;;2.1;Printing;;3;bug;assigned
|
|
4
test/fixtures/files/testfile.txt
vendored
4
test/fixtures/files/testfile.txt
vendored
|
@ -1,2 +1,2 @@
|
|||
this is a text file for upload tests
|
||||
with multiple lines
|
||||
this is a text file for upload tests
|
||||
with multiple lines
|
||||
|
|
|
@ -138,4 +138,14 @@ class AutoCompletesControllerTest < Redmine::ControllerTest
|
|||
assert_include "issue", response.body
|
||||
assert_not_include "Bug #12: Closed issue on a locked version", response.body
|
||||
end
|
||||
|
||||
def test_auto_complete_should_return_json_content_type_response
|
||||
get :issues, :params => {
|
||||
:project_id => 'subproject1',
|
||||
:q => '#13'
|
||||
}
|
||||
|
||||
assert_response :success
|
||||
assert_include 'application/json', response.headers['Content-Type']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,21 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||
assert_not_nil e
|
||||
end
|
||||
|
||||
def test_create_with_custom_field_values
|
||||
custom_field = TimeEntryActivityCustomField.generate!
|
||||
assert_difference 'TimeEntryActivity.count' do
|
||||
post :create, :params => {
|
||||
:enumeration => {
|
||||
:type => 'TimeEntryActivity',
|
||||
:name => 'Sample',
|
||||
:custom_field_values => {custom_field.id.to_s => "sample"}
|
||||
}
|
||||
}
|
||||
end
|
||||
assert_redirected_to '/enumerations'
|
||||
assert_equal "sample", Enumeration.find_by(:name => 'Sample').custom_field_values.last.value
|
||||
end
|
||||
|
||||
def test_create_with_failure
|
||||
assert_no_difference 'IssuePriority.count' do
|
||||
post :create, :params => {
|
||||
|
@ -136,6 +151,20 @@ class EnumerationsControllerTest < Redmine::ControllerTest
|
|||
assert_equal 1, Enumeration.find(2).position
|
||||
end
|
||||
|
||||
def test_update_custom_field_values
|
||||
custom_field = TimeEntryActivityCustomField.generate!
|
||||
enumeration = Enumeration.find(9)
|
||||
assert_nil enumeration.custom_field_values.last.value
|
||||
put :update, :params => {
|
||||
:id => enumeration.id,
|
||||
:enumeration => {
|
||||
:custom_field_values => {custom_field.id.to_s => "sample"}
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
assert_equal "sample", enumeration.reload.custom_field_values.last.value
|
||||
end
|
||||
|
||||
def test_destroy_enumeration_not_in_use
|
||||
assert_difference 'IssuePriority.count', -1 do
|
||||
delete :destroy, :params => {
|
||||
|
|
|
@ -773,6 +773,25 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_index_csv_should_not_change_selected_columns
|
||||
get :index, :params => {
|
||||
:set_filter => 1,
|
||||
:c => ["subject", "due_date"],
|
||||
:project_id => "ecookbook"
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal [:subject, :due_date], session[:issue_query][:column_names]
|
||||
|
||||
get :index, :params => {
|
||||
:set_filter => 1,
|
||||
:c =>["all_inline"],
|
||||
:project_id => "ecookbook",
|
||||
:format => 'csv'
|
||||
}
|
||||
assert_response :success
|
||||
assert_equal [:subject, :due_date], session[:issue_query][:column_names]
|
||||
end
|
||||
|
||||
def test_index_pdf
|
||||
["en", "zh", "zh-TW", "ja", "ko"].each do |lang|
|
||||
with_settings :default_language => lang do
|
||||
|
@ -1754,6 +1773,21 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_show_should_format_related_issues_dates
|
||||
with_settings :date_format => '%d/%m/%Y' do
|
||||
issue = Issue.generate!(:start_date => '2018-11-29', :due_date => '2018-12-01')
|
||||
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => issue, :relation_type => 'relates')
|
||||
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select '#relations td.start_date', :text => '29/11/2018'
|
||||
assert_select '#relations td.due_date', :text => '01/12/2018'
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_should_not_disclose_relations_to_invisible_issues
|
||||
Setting.cross_project_issue_relations = '1'
|
||||
IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => 'relates')
|
||||
|
@ -2093,6 +2127,25 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
assert_select "div.description ~ div.attribute.cf_#{field.id} div.value", :text => 'This is a long text'
|
||||
end
|
||||
|
||||
def test_show_custom_fields_with_full_text_formatting_should_be_rendered_using_wiki_class
|
||||
half_field = IssueCustomField.create!(:name => 'Half width field', :field_format => 'text', :tracker_ids => [1],
|
||||
:is_for_all => true, :text_formatting => 'full')
|
||||
full_field = IssueCustomField.create!(:name => 'Full width field', :field_format => 'text', :full_width_layout => '1',
|
||||
:tracker_ids => [1], :is_for_all => true, :text_formatting => 'full')
|
||||
|
||||
issue = Issue.find(1)
|
||||
issue.custom_field_values = {full_field.id => 'This is a long text', half_field.id => 'This is a short text'}
|
||||
issue.save!
|
||||
|
||||
get :show, :params => {
|
||||
:id => 1
|
||||
}
|
||||
assert_response :success
|
||||
|
||||
assert_select "div.attribute.cf_#{half_field.id} div.value div.wiki", 1
|
||||
assert_select "div.attribute.cf_#{full_field.id} div.value div.wiki", 1
|
||||
end
|
||||
|
||||
def test_show_with_multi_user_custom_field
|
||||
field = IssueCustomField.create!(:name => 'Multi user', :field_format => 'user', :multiple => true,
|
||||
:tracker_ids => [1], :is_for_all => true)
|
||||
|
@ -3863,6 +3916,29 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
|
||||
end
|
||||
|
||||
def test_new_as_copy_should_not_propose_locked_watchers
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
issue = Issue.find(1)
|
||||
user = User.generate!
|
||||
user2 = User.generate!
|
||||
|
||||
Watcher.create!(:watchable => issue, :user => user)
|
||||
Watcher.create!(:watchable => issue, :user => user2)
|
||||
|
||||
user2.status = User::STATUS_LOCKED
|
||||
user2.save!
|
||||
get :new, :params => {
|
||||
:project_id => 1,
|
||||
:copy_from => 1
|
||||
}
|
||||
|
||||
assert_select 'input[type=checkbox][name=?][checked=checked]', 'issue[watcher_user_ids][]', 1
|
||||
assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user.id.to_s
|
||||
assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user2.id.to_s, 0
|
||||
assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
|
||||
end
|
||||
|
||||
def test_new_as_copy_with_invalid_issue_should_respond_with_404
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :params => {
|
||||
|
@ -6110,7 +6186,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_bulk_copy_should_allow_copying_the_subtasks
|
||||
test "bulk copy should allow copying the subtasks" do
|
||||
issue = Issue.generate_with_descendants!
|
||||
count = issue.descendants.count
|
||||
@request.session[:user_id] = 2
|
||||
|
@ -6130,10 +6206,9 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
assert_equal count, copy.descendants.count
|
||||
end
|
||||
|
||||
def test_bulk_copy_should_allow_copying_the_subtasks
|
||||
test "issue bulk copy copy watcher" do
|
||||
Watcher.create!(:watchable => Issue.find(1), :user => User.find(3))
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Issue.count' do
|
||||
post :bulk_update, :params => {
|
||||
:ids => [1],
|
||||
|
@ -6141,7 +6216,6 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
:copy_watchers => '1',
|
||||
:issue => {
|
||||
:project_id => ''
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -6212,6 +6286,27 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
def test_destroy_issues_with_time_entries_should_show_the_reassign_form
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :timelog_required_fields => [] do
|
||||
assert_no_difference 'Issue.count' do
|
||||
delete :destroy, :params => {
|
||||
:ids => [1, 3]
|
||||
}
|
||||
end
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
assert_select 'form' do
|
||||
assert_select 'input[name=_method][value=delete]'
|
||||
assert_select 'input[name=todo][value=destroy]'
|
||||
assert_select 'input[name=todo][value=nullify]'
|
||||
assert_select 'input[name=todo][value=reassign]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_issues_with_time_entries_should_not_show_the_nullify_option_when_issue_is_required_for_time_entries
|
||||
with_settings :timelog_required_fields => ['issue_id'] do
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Issue.count' do
|
||||
delete :destroy, :params => {
|
||||
:ids => [1, 3]
|
||||
|
@ -6221,6 +6316,10 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
|
||||
assert_select 'form' do
|
||||
assert_select 'input[name=_method][value=delete]'
|
||||
assert_select 'input[name=todo][value=destroy]'
|
||||
assert_select 'input[name=todo][value=nullify]', 0
|
||||
assert_select 'input[name=todo][value=reassign]'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6259,6 +6358,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
def test_destroy_issues_and_assign_time_entries_to_project
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :timelog_required_fields => [] do
|
||||
assert_difference 'Issue.count', -2 do
|
||||
assert_no_difference 'TimeEntry.count' do
|
||||
delete :destroy, :params => {
|
||||
|
@ -6267,6 +6367,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
||||
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
||||
assert_nil TimeEntry.find(1).issue_id
|
||||
|
@ -6345,6 +6446,23 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||
assert_select '#flash_error', :text => I18n.t(:error_cannot_reassign_time_entries_to_an_issue_about_to_be_deleted)
|
||||
end
|
||||
|
||||
def test_destroy_issues_and_nullify_time_entries_should_fail_when_issue_is_required_for_time_entries
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :timelog_required_fields => ['issue_id'] do
|
||||
assert_no_difference 'Issue.count' do
|
||||
assert_no_difference 'TimeEntry.count' do
|
||||
delete :destroy, :params => {
|
||||
:ids => [1, 3],
|
||||
:todo => 'nullify'
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_response :success
|
||||
assert_select '#flash_error', :text => 'Issue cannot be blank'
|
||||
end
|
||||
|
||||
def test_destroy_issues_from_different_projects
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
# All TimeEntries using project activity
|
||||
project_specific_activity = TimeEntryActivity.find_by_parent_id_and_project_id(9, 1)
|
||||
assert_equal 3, TimeEntry.where(:activity_id => project_specific_activity.id,
|
||||
:project_id => 1).count
|
||||
:project_id => 1).count,
|
||||
"No Time Entries assigned to the project activity"
|
||||
end
|
||||
|
||||
|
@ -185,11 +185,11 @@ class ProjectEnumerationsControllerTest < Redmine::ControllerTest
|
|||
|
||||
# TimeEntries shouldn't have been reassigned on the failed record
|
||||
assert_equal 3, TimeEntry.where(:activity_id => 9,
|
||||
:project_id => 1).count
|
||||
:project_id => 1).count,
|
||||
"Time Entries are not assigned to system activities"
|
||||
# TimeEntries shouldn't have been reassigned on the saved record either
|
||||
assert_equal 1, TimeEntry.where(:activity_id => 10,
|
||||
:project_id => 1).count
|
||||
:project_id => 1).count,
|
||||
"Time Entries are not assigned to system activities"
|
||||
end
|
||||
|
||||
|
|
|
@ -661,6 +661,29 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
assert_select "tr#member-#{member.id}"
|
||||
end
|
||||
|
||||
def test_settings_should_show_tabs_depending_on_permission
|
||||
@request.session[:user_id] = 3
|
||||
project = Project.find(1)
|
||||
role = User.find(3).roles_for_project(project).first
|
||||
|
||||
role.permissions = []
|
||||
role.save
|
||||
get :settings, :params => {
|
||||
:id => project.id
|
||||
}
|
||||
assert_response 403
|
||||
|
||||
role.add_permission! :manage_repository, :manage_boards, :manage_project_activities
|
||||
get :settings, :params => {
|
||||
:id => project.id
|
||||
}
|
||||
assert_response :success
|
||||
assert_select 'a[id^=tab-]', 3
|
||||
assert_select 'a#tab-repositories'
|
||||
assert_select 'a#tab-boards'
|
||||
assert_select 'a#tab-activities'
|
||||
end
|
||||
|
||||
def test_update
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :update, :params => {
|
||||
|
@ -979,4 +1002,35 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||
}
|
||||
assert_select 'body.project-ecookbook'
|
||||
end
|
||||
|
||||
def test_default_search_scope_in_global_page
|
||||
get :index
|
||||
|
||||
assert_select 'div#quick-search form' do
|
||||
assert_select 'input[name=scope][type=hidden]'
|
||||
assert_select 'a[href=?]', '/search'
|
||||
end
|
||||
end
|
||||
|
||||
def test_default_search_scope_for_project_without_subprojects
|
||||
get :show, :params => {
|
||||
:id => 4,
|
||||
}
|
||||
|
||||
assert_select 'div#quick-search form' do
|
||||
assert_select 'input[name=scope][type=hidden]'
|
||||
assert_select 'a[href=?]', '/projects/subproject2/search'
|
||||
end
|
||||
end
|
||||
|
||||
def test_default_search_scope_for_project_with_subprojects
|
||||
get :show, :params => {
|
||||
:id => 1,
|
||||
}
|
||||
|
||||
assert_select 'div#quick-search form' do
|
||||
assert_select 'input[name=scope][type=hidden][value=subprojects]'
|
||||
assert_select 'a[href=?]', '/projects/ecookbook/search?scope=subprojects'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -338,6 +338,46 @@ class SearchControllerTest < Redmine::ControllerTest
|
|||
assert_response 404
|
||||
end
|
||||
|
||||
def test_search_should_include_closed_projects
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
project = Project.find(5)
|
||||
project.close
|
||||
project.save
|
||||
|
||||
# scope all
|
||||
get :index, :params => {:q => 'Issue of a private subproject', :scope => 'all'}
|
||||
assert_response :success
|
||||
|
||||
assert_select '#search-results' do
|
||||
assert_select 'dt.issue', :text => /Bug #6/
|
||||
end
|
||||
|
||||
# scope my_projects
|
||||
get :index, :params => {:q => 'Issue of a private subproject', :scope => 'my_projects'}
|
||||
assert_response :success
|
||||
|
||||
assert_select '#search-results' do
|
||||
assert_select 'dt.issue', :text => /Bug #6/
|
||||
end
|
||||
|
||||
# scope subprojects
|
||||
get :index, :params => {:id => 1, :q => 'Issue of a private subproject', :scope => 'subprojects'}
|
||||
assert_response :success
|
||||
|
||||
assert_select '#search-results' do
|
||||
assert_select 'dt.issue', :text => /Bug #6/
|
||||
end
|
||||
|
||||
# scope project
|
||||
get :index, :params => {:id => 5, :q => 'Issue of a private subproject'}
|
||||
assert_response :success
|
||||
|
||||
assert_select '#search-results' do
|
||||
assert_select 'dt.issue', :text => /Bug #6/
|
||||
end
|
||||
end
|
||||
|
||||
def test_quick_jump_to_issue
|
||||
# issue of a public project
|
||||
get :index, :params => {:q => "3"}
|
||||
|
|
|
@ -276,7 +276,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
},
|
||||
:continue => '1'
|
||||
}
|
||||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=1'
|
||||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=1&time_entry%5Bspent_on%5D=2008-03-14'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -293,7 +293,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
},
|
||||
:continue => '1'
|
||||
}
|
||||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D='
|
||||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=&time_entry%5Bspent_on%5D=2008-03-14'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -310,7 +310,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
},
|
||||
:continue => '1'
|
||||
}
|
||||
assert_redirected_to '/projects/ecookbook/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D='
|
||||
assert_redirected_to '/projects/ecookbook/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=&time_entry%5Bspent_on%5D=2008-03-14'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -327,7 +327,7 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||
},
|
||||
:continue => '1'
|
||||
}
|
||||
assert_redirected_to '/issues/1/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D='
|
||||
assert_redirected_to '/issues/1/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=&time_entry%5Bspent_on%5D=2008-03-14'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -89,4 +89,9 @@ class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
|
|||
assert_equal 4, json['limit']
|
||||
assert_equal issue[8..10], json['results'].map {|r| r['id']}
|
||||
end
|
||||
|
||||
test "GET /search.xml should not quick jump to the issue with given id" do
|
||||
get '/search.xml', :params => {:q => '3'}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
|
56
test/integration/wiki_test.rb
Normal file
56
test/integration/wiki_test.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class WikiIntegrationTest < Redmine::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users, :email_addresses,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:wikis,
|
||||
:wiki_pages,
|
||||
:wiki_contents
|
||||
|
||||
def test_updating_a_renamed_page
|
||||
log_user('jsmith', 'jsmith')
|
||||
|
||||
get '/projects/ecookbook/wiki'
|
||||
assert_response :success
|
||||
|
||||
get '/projects/ecookbook/wiki/Wiki/edit'
|
||||
assert_response :success
|
||||
|
||||
# this update should not end up with a loss of content
|
||||
put '/projects/ecookbook/wiki/Wiki', params: {
|
||||
content: {
|
||||
text: "# Wiki\r\n\r\ncontent", comments:""
|
||||
},
|
||||
wiki_page: { parent_id: "" }
|
||||
}
|
||||
assert_redirected_to "/projects/ecookbook/wiki/Wiki"
|
||||
follow_redirect!
|
||||
assert_select 'div', /content/
|
||||
assert content = WikiContent.last
|
||||
|
||||
# Let's assume somebody else, or the same user in another tab, renames the
|
||||
# page while it is being edited.
|
||||
post '/projects/ecookbook/wiki/Wiki/rename', params: { wiki_page: { title: "NewTitle" } }
|
||||
assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
|
||||
|
||||
# this update should not end up with a loss of content
|
||||
put '/projects/ecookbook/wiki/Wiki', params: {
|
||||
content: {
|
||||
version: content.version, text: "# Wiki\r\n\r\nnew content", comments:""
|
||||
},
|
||||
wiki_page: { parent_id: "" }
|
||||
}
|
||||
|
||||
assert_redirected_to "/projects/ecookbook/wiki/NewTitle"
|
||||
follow_redirect!
|
||||
assert_select 'div', /new content/
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -33,7 +33,7 @@ require File.expand_path(File.dirname(__FILE__) + '/object_helpers')
|
|||
include ObjectHelpers
|
||||
|
||||
require 'net/ldap'
|
||||
require 'mocha/setup'
|
||||
require 'mocha/minitest'
|
||||
require 'fileutils'
|
||||
|
||||
Redmine::SudoMode.disable!
|
||||
|
|
|
@ -23,6 +23,7 @@ class ActivityTest < ActiveSupport::TestCase
|
|||
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(1)
|
||||
end
|
||||
|
||||
|
|
|
@ -262,6 +262,7 @@ class AttachmentTest < ActiveSupport::TestCase
|
|||
|
||||
a = Attachment.new(:filename => "test.png", :description => "Cool image")
|
||||
assert_equal "test.png (Cool image)", a.title
|
||||
assert_equal "test.png", a.filename
|
||||
end
|
||||
|
||||
def test_new_attachment_should_be_editable_by_author
|
||||
|
|
|
@ -26,6 +26,7 @@ class AttachmentTest < ActiveSupport::TestCase
|
|||
self.use_transactional_fixtures = false
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
|
|||
fixtures :auth_sources
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_initialize
|
||||
|
|
|
@ -25,6 +25,7 @@ class BoardTest < ActiveSupport::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(1)
|
||||
end
|
||||
|
||||
|
|
|
@ -32,6 +32,10 @@ class ChangesetTest < ActiveSupport::TestCase
|
|||
:trackers, :projects_trackers,
|
||||
:enabled_modules, :roles
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_ref_keywords_any
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.commit_ref_keywords = '*'
|
||||
|
|
|
@ -21,6 +21,7 @@ class CommentTest < ActiveSupport::TestCase
|
|||
fixtures :users, :email_addresses, :news, :comments, :projects, :enabled_modules
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@jsmith = User.find(2)
|
||||
@news = News.find(1)
|
||||
end
|
||||
|
|
|
@ -206,6 +206,7 @@ class CustomFieldTest < ActiveSupport::TestCase
|
|||
assert f.valid_field_value?('')
|
||||
assert !f.valid_field_value?(' ')
|
||||
assert f.valid_field_value?('123')
|
||||
assert f.valid_field_value?(' 123 ')
|
||||
assert f.valid_field_value?('+123')
|
||||
assert f.valid_field_value?('-123')
|
||||
assert !f.valid_field_value?('6abc')
|
||||
|
@ -219,6 +220,7 @@ class CustomFieldTest < ActiveSupport::TestCase
|
|||
assert f.valid_field_value?('')
|
||||
assert !f.valid_field_value?(' ')
|
||||
assert f.valid_field_value?('11.2')
|
||||
assert f.valid_field_value?(' 11.2 ')
|
||||
assert f.valid_field_value?('-6.250')
|
||||
assert f.valid_field_value?('5')
|
||||
assert !f.valid_field_value?('6abc')
|
||||
|
|
|
@ -21,6 +21,7 @@ class CustomFieldUserFormatTest < ActiveSupport::TestCase
|
|||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user')
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class CustomFieldVersionFormatTest < ActiveSupport::TestCase
|
|||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues, :versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'version')
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class CustomValueTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :custom_values, :users
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_new_without_value_should_set_default_value
|
||||
field = CustomField.generate!(:default_value => 'Default string')
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@ class DefaultDataTest < ActiveSupport::TestCase
|
|||
include Redmine::I18n
|
||||
fixtures :roles
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_no_data
|
||||
assert !Redmine::DefaultData::Loader::no_data?
|
||||
clear_data
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class DocumentCategoryTest < ActiveSupport::TestCase
|
||||
fixtures :enumerations, :documents, :issues
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_should_be_an_enumeration
|
||||
assert DocumentCategory.ancestors.include?(Enumeration)
|
||||
end
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class EnabledModuleTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :trackers, :issue_statuses, :wikis
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_enabling_wiki_should_create_a_wiki
|
||||
CustomField.delete_all
|
||||
project = Project.create!(:name => 'Project with wiki', :identifier => 'wikiproject', :enabled_module_names => [])
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class EnumerationTest < ActiveSupport::TestCase
|
||||
fixtures :enumerations, :issues, :custom_fields, :custom_values
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_objects_count
|
||||
# low priority
|
||||
assert_equal 6, Enumeration.find(4).objects_count
|
||||
|
|
|
@ -28,6 +28,10 @@ class GroupTest < ActiveSupport::TestCase
|
|||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
g = Group.new(:name => 'New group')
|
||||
assert g.save
|
||||
|
|
|
@ -1328,7 +1328,6 @@ RAW
|
|||
end
|
||||
|
||||
def test_avatar_enabled
|
||||
tag_for_anonymous_re = %r{src="/images/anonymous.png(\?\d+)?"}
|
||||
with_settings :gravatar_enabled => '1' do
|
||||
assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
||||
assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
|
||||
|
@ -1340,10 +1339,13 @@ RAW
|
|||
# The default class of the img tag should be gravatar
|
||||
assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"')
|
||||
assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"')
|
||||
assert_match tag_for_anonymous_re, avatar('jsmith')
|
||||
assert_match tag_for_anonymous_re, avatar(nil)
|
||||
assert_nil avatar('jsmith')
|
||||
assert_nil avatar(nil)
|
||||
# Avatar for anonymous user
|
||||
assert_match tag_for_anonymous_re, avatar(User.anonymous)
|
||||
assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
|
||||
# No avatar for groups
|
||||
assert_nil avatar(Group.first)
|
||||
assert avatar(User.anonymous, :size => 24).include?('width="24" height="24"')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class IssueCategoryTest < ActiveSupport::TestCase
|
|||
fixtures :issue_categories, :issues, :users, :groups_users
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@category = IssueCategory.find(1)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@ class IssueCustomFieldTest < ActiveSupport::TestCase
|
|||
|
||||
fixtures :roles
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@category = IssueCategory.find(1)
|
||||
end
|
||||
|
||||
def test_custom_field_with_visible_set_to_false_should_validate_roles
|
||||
set_language_if_valid 'en'
|
||||
field = IssueCustomField.new(:name => 'Field', :field_format => 'string', :visible => false)
|
||||
|
|
|
@ -35,6 +35,7 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
@ -115,6 +116,15 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||
assert_equal 2, issues[2].parent_id
|
||||
end
|
||||
|
||||
def test_import_utf8_with_bom
|
||||
import = generate_import_with_mapping('import_issues_utf8_with_bom.csv')
|
||||
import.settings.merge!('encoding' => 'UTF-8')
|
||||
import.save
|
||||
|
||||
issues = new_records(Issue,3) { import.run }
|
||||
assert_equal 3, issues.count
|
||||
end
|
||||
|
||||
def test_backward_and_forward_reference_to_parent_should_work
|
||||
import = generate_import('import_subtasks.csv')
|
||||
import.settings = {
|
||||
|
@ -188,4 +198,16 @@ class IssueImportTest < ActiveSupport::TestCase
|
|||
import.run
|
||||
assert !File.exists?(file_path)
|
||||
end
|
||||
|
||||
def test_run_should_consider_project_shared_versions
|
||||
system_version = Version.generate!(:project_id => 2, :sharing => 'system', :name => '2.1')
|
||||
system_version.save!
|
||||
|
||||
import = generate_import_with_mapping
|
||||
import.mapping.merge!('fixed_version' => '9')
|
||||
import.save!
|
||||
|
||||
issues = new_records(Issue, 3) { import.run }
|
||||
assert [nil, 3, system_version.id], issues.map(&:fixed_version_id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase
|
|||
|
||||
def setup
|
||||
skip if sqlite? || mysql?
|
||||
User.current = nil
|
||||
CustomField.delete_all
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class IssuePriorityTest < ActiveSupport::TestCase
|
||||
fixtures :enumerations, :issues
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_named_scope
|
||||
assert_equal Enumeration.find_by_name('Normal'), Enumeration.named('normal').first
|
||||
end
|
||||
|
|
|
@ -33,6 +33,10 @@ class IssueRelationTest < ActiveSupport::TestCase
|
|||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
from = Issue.find(1)
|
||||
to = Issue.find(2)
|
||||
|
|
|
@ -26,6 +26,10 @@ class IssueScopesTest < ActiveSupport::TestCase
|
|||
:issues,
|
||||
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_cross_project_scope_without_project_should_return_all_issues
|
||||
ids = Issue.cross_project_scope(nil).pluck(:id).sort
|
||||
assert_equal Issue.pluck(:id).sort, ids
|
||||
|
|
|
@ -28,6 +28,10 @@ class IssueStatusTest < ActiveSupport::TestCase
|
|||
:issues, :journals, :journal_details,
|
||||
:custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
status = IssueStatus.new :name => "Assigned"
|
||||
assert !status.save
|
||||
|
|
|
@ -25,6 +25,10 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
|
|||
:enabled_modules,
|
||||
:workflows
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_leaf_planning_fields_should_be_editable
|
||||
issue = Issue.generate!
|
||||
user = User.find(1)
|
||||
|
@ -321,7 +325,7 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_parent_total_estimated_hours_should_be_sum_of_descendants
|
||||
def test_parent_total_estimated_hours_should_be_sum_of_visible_descendants
|
||||
parent = Issue.generate!
|
||||
parent.generate_child!(:estimated_hours => nil)
|
||||
assert_equal 0, parent.reload.total_estimated_hours
|
||||
|
@ -329,6 +333,9 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
|
|||
assert_equal 5, parent.reload.total_estimated_hours
|
||||
parent.generate_child!(:estimated_hours => 7)
|
||||
assert_equal 12, parent.reload.total_estimated_hours
|
||||
|
||||
parent.generate_child!(:estimated_hours => 9, :is_private => true)
|
||||
assert_equal 12, parent.reload.total_estimated_hours
|
||||
end
|
||||
|
||||
def test_open_issue_with_closed_parent_should_not_validate
|
||||
|
|
|
@ -1375,6 +1375,63 @@ class IssueTest < ActiveSupport::TestCase
|
|||
assert_not_nil copied_closed.closed_on
|
||||
end
|
||||
|
||||
def test_copy_should_not_copy_locked_watchers
|
||||
user = User.find(2)
|
||||
user2 = User.find(3)
|
||||
issue = Issue.find(8)
|
||||
|
||||
Watcher.create!(:user => user, :watchable => issue)
|
||||
Watcher.create!(:user => user2, :watchable => issue)
|
||||
|
||||
user2.status = User::STATUS_LOCKED
|
||||
user2.save!
|
||||
|
||||
issue = Issue.new.copy_from(8)
|
||||
|
||||
assert issue.save
|
||||
assert issue.watched_by?(user)
|
||||
assert !issue.watched_by?(user2)
|
||||
end
|
||||
|
||||
def test_copy_should_clear_subtasks_target_version_if_locked_or_closed
|
||||
version = Version.new(:project => Project.find(1), :name => '2.1',)
|
||||
version.save!
|
||||
|
||||
parent = Issue.generate!
|
||||
child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1', :fixed_version_id => 3)
|
||||
child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2', :fixed_version_id => version.id)
|
||||
|
||||
version.status = 'locked'
|
||||
version.save!
|
||||
|
||||
copy = parent.reload.copy
|
||||
|
||||
assert_difference 'Issue.count', 3 do
|
||||
assert copy.save
|
||||
end
|
||||
|
||||
assert_equal [3, nil], copy.children.map(&:fixed_version_id)
|
||||
end
|
||||
|
||||
def test_copy_should_clear_subtasks_assignee_if_is_locked
|
||||
user = User.find(2)
|
||||
|
||||
parent = Issue.generate!
|
||||
child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1', :assigned_to_id => 3)
|
||||
child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2', :assigned_to_id => user.id)
|
||||
|
||||
user.status = User::STATUS_LOCKED
|
||||
user.save!
|
||||
|
||||
copy = parent.reload.copy
|
||||
|
||||
assert_difference 'Issue.count', 3 do
|
||||
assert copy.save
|
||||
end
|
||||
|
||||
assert_equal [3, nil], copy.children.map(&:assigned_to_id)
|
||||
end
|
||||
|
||||
def test_should_not_call_after_project_change_on_creation
|
||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
|
||||
:subject => 'Test', :author_id => 1)
|
||||
|
@ -2089,6 +2146,32 @@ class IssueTest < ActiveSupport::TestCase
|
|||
assert_equal Date.parse('2012-09-21'), issue2.due_date
|
||||
end
|
||||
|
||||
def test_rescheduling_an_issue_to_a_different_due_date_should_add_journal_to_following_issue
|
||||
with_settings :non_working_week_days => [] do
|
||||
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||
issue2 = Issue.generate!(:start_date => '2012-10-18', :due_date => '2012-10-20')
|
||||
IssueRelation.create!(:issue_from => issue1, :issue_to => issue2,
|
||||
:relation_type => IssueRelation::TYPE_PRECEDES)
|
||||
|
||||
assert_difference 'issue2.journals.count' do
|
||||
issue1.reload
|
||||
issue1.init_journal(User.find(3))
|
||||
issue1.due_date = '2012-10-23'
|
||||
issue1.save!
|
||||
end
|
||||
journal = issue2.journals.order(:id).last
|
||||
|
||||
start_date_detail = journal.details.find_by(:prop_key => 'start_date')
|
||||
assert_equal '2012-10-18', start_date_detail.old_value
|
||||
assert_equal '2012-10-24', start_date_detail.value
|
||||
|
||||
due_date_detail = journal.details.find_by(:prop_key => 'due_date')
|
||||
assert_equal '2012-10-20', due_date_detail.old_value
|
||||
assert_equal '2012-10-26', due_date_detail.value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_rescheduling_reschedule_following_issue_earlier_should_consider_other_preceding_issues
|
||||
issue1 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||
issue2 = Issue.generate!(:start_date => '2012-10-15', :due_date => '2012-10-17')
|
||||
|
|
|
@ -29,6 +29,10 @@ class IssueTransactionTest < ActiveSupport::TestCase
|
|||
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_invalid_move_to_another_project
|
||||
lft1 = new_issue_lft
|
||||
parent1 = Issue.generate!
|
||||
|
|
|
@ -23,6 +23,7 @@ class JournalObserverTest < ActiveSupport::TestCase
|
|||
:users, :email_addresses, :roles
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@journal = Journal.find 1
|
||||
end
|
||||
|
|
|
@ -21,8 +21,9 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
|
|||
|
||||
def test_password_should_be_encrypted
|
||||
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
|
||||
r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn')
|
||||
assert_equal 'foo', r.password
|
||||
plaintext_password = "THIS_IS_A_32_BYTES_LONG_PASSWORD"
|
||||
r = Repository::Subversion.create!(:password => plaintext_password, :url => 'file:///tmp', :identifier => 'svn')
|
||||
assert_equal plaintext_password, r.password
|
||||
assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,26 +23,26 @@ class Redmine::ConfigurationTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_empty
|
||||
assert_kind_of Hash, load_conf('empty.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('empty.yml.example', 'test')
|
||||
end
|
||||
|
||||
def test_default
|
||||
assert_kind_of Hash, load_conf('default.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_no_default
|
||||
assert_kind_of Hash, load_conf('no_default.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('no_default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_overrides
|
||||
assert_kind_of Hash, load_conf('overrides.yml', 'test')
|
||||
assert_kind_of Hash, load_conf('overrides.yml.example', 'test')
|
||||
assert_equal 'bar', @conf['somesetting']
|
||||
end
|
||||
|
||||
def test_with
|
||||
load_conf('default.yml', 'test')
|
||||
load_conf('default.yml.example', 'test')
|
||||
assert_equal 'foo', @conf['somesetting']
|
||||
@conf.with 'somesetting' => 'bar' do
|
||||
assert_equal 'bar', @conf['somesetting']
|
||||
|
|
|
@ -26,6 +26,7 @@ class AttachmentFormatVisibilityTest < ActionView::TestCase
|
|||
:versions, :issues
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_tmp_attachments_directory
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class Redmine::BoolFieldFormatTest < ActionView::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class Redmine::EnumerationFieldFormatTest < ActionView::TestCase
|
|||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
@field = IssueCustomField.create!(:name => 'List', :field_format => 'enumeration', :is_required => false)
|
||||
@foo = CustomFieldEnumeration.new(:name => 'Foo')
|
||||
|
|
|
@ -21,6 +21,7 @@ class Redmine::FieldFormatTest < ActionView::TestCase
|
|||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ require File.expand_path('../../../../../test_helper', __FILE__)
|
|||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::LinkFieldFormatTest < ActionView::TestCase
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_link_field_should_substitute_value
|
||||
field = IssueCustomField.new(:field_format => 'link', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "bar")
|
||||
|
|
|
@ -23,6 +23,7 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
set_language_if_valid 'en'
|
||||
end
|
||||
|
||||
|
@ -37,6 +38,16 @@ class Redmine::ListFieldFormatTest < ActionView::TestCase
|
|||
assert group.valid?
|
||||
end
|
||||
|
||||
def test_non_existing_value_should_be_invalid
|
||||
field = GroupCustomField.create!(:name => 'List', :field_format => 'list', :possible_values => ['Foo', 'Bar'])
|
||||
group = Group.new(:name => 'Group')
|
||||
group.custom_field_values = {field.id => 'Baz'}
|
||||
|
||||
assert_not_include 'Baz', field.possible_custom_value_options(group.custom_value_for(field))
|
||||
assert_equal false, group.valid?
|
||||
assert_include "List #{::I18n.t('activerecord.errors.messages.inclusion')}", group.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_edit_tag_should_have_id_and_name
|
||||
field = IssueCustomField.new(:field_format => 'list', :possible_values => ['Foo', 'Bar'], :is_required => false)
|
||||
value = CustomFieldValue.new(:custom_field => field, :customized => Issue.new)
|
||||
|
|
|
@ -1,31 +1,35 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::NumericFieldFormatTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
|
||||
def test_integer_field_with_url_pattern_should_format_as_link
|
||||
field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3")
|
||||
|
||||
assert_equal 3, field.format.formatted_custom_value(self, custom_value, false)
|
||||
assert_equal '<a href="http://foo/3">3</a>', field.format.formatted_custom_value(self, custom_value, true)
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
require 'redmine/field_format'
|
||||
|
||||
class Redmine::NumericFieldFormatTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_integer_field_with_url_pattern_should_format_as_link
|
||||
field = IssueCustomField.new(:field_format => 'int', :url_pattern => 'http://foo/%value%')
|
||||
custom_value = CustomValue.new(:custom_field => field, :customized => Issue.new, :value => "3")
|
||||
|
||||
assert_equal 3, field.format.formatted_custom_value(self, custom_value, false)
|
||||
assert_equal '<a href="http://foo/3">3</a>', field.format.formatted_custom_value(self, custom_value, true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,10 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
|
|||
:issue_statuses, :issue_categories, :issue_relations, :workflows,
|
||||
:enumerations
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_user_role_should_reject_blank_values
|
||||
field = IssueCustomField.new(:name => 'Foo', :field_format => 'user', :user_role => ["1", ""])
|
||||
field.save!
|
||||
|
@ -45,6 +49,21 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
|
|||
assert issue.valid?
|
||||
end
|
||||
|
||||
def test_non_existing_values_should_be_invalid
|
||||
field = IssueCustomField.create!(:name => 'Foo', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
|
||||
project = Project.generate!
|
||||
user = User.generate!
|
||||
User.add_to_project(user, project, Role.find_by_name('Developer'))
|
||||
|
||||
field.user_role = [Role.find_by_name('Manager').id]
|
||||
field.save!
|
||||
|
||||
issue = Issue.new(:project_id => project.id, :tracker_id => 1, :custom_field_values => {field.id => user.id})
|
||||
assert_not_include [user.name, user.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field))
|
||||
assert_equal false, issue.valid?
|
||||
assert_include "Foo #{::I18n.t('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_possible_values_options_should_return_project_members
|
||||
field = IssueCustomField.new(:field_format => 'user')
|
||||
project = Project.find(1)
|
||||
|
|
|
@ -49,6 +49,20 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase
|
|||
assert issue.valid?
|
||||
end
|
||||
|
||||
def test_not_existing_values_should_be_invalid
|
||||
field = IssueCustomField.create!(:name => 'Foo', :field_format => 'version', :is_for_all => true, :trackers => Tracker.all)
|
||||
project = Project.generate!
|
||||
version = Version.generate!(:project => project, :status => 'closed')
|
||||
|
||||
field.version_status = ["open"]
|
||||
field.save!
|
||||
|
||||
issue = Issue.new(:project_id => project.id, :tracker_id => 1, :custom_field_values => {field.id => version.id})
|
||||
assert_not_include [version.name, version.id.to_s], field.possible_custom_value_options(issue.custom_value_for(field))
|
||||
assert_equal false, issue.valid?
|
||||
assert_include "Foo #{::I18n.t('activerecord.errors.messages.inclusion')}", issue.errors.full_messages.first
|
||||
end
|
||||
|
||||
def test_possible_values_options_should_return_project_versions
|
||||
field = IssueCustomField.new(:field_format => 'version')
|
||||
project = Project.find(1)
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
|
||||
class DiffTest < ActiveSupport::TestCase
|
||||
def test_diff
|
||||
diff = Redmine::Helpers::Diff.new("foo", "bar")
|
||||
assert_not_nil diff
|
||||
end
|
||||
|
||||
def test_dont_double_escape
|
||||
# 3 cases to test in the before: first word, last word, everything inbetween
|
||||
before = "<stuff> with html & special chars</danger>"
|
||||
# all words in after are treated equal
|
||||
after = "other stuff <script>alert('foo');</alert>"
|
||||
|
||||
computed_diff = Redmine::Helpers::Diff.new(before, after).to_html
|
||||
expected_diff = '<span class="diff_in"><stuff> with html & special chars</danger></span> <span class="diff_out">other stuff <script>alert('foo');</alert></span>'
|
||||
|
||||
assert_equal computed_diff, expected_diff
|
||||
end
|
||||
end
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../../../../test_helper', __FILE__)
|
||||
|
||||
class DiffTest < ActiveSupport::TestCase
|
||||
def test_diff
|
||||
diff = Redmine::Helpers::Diff.new("foo", "bar")
|
||||
assert_not_nil diff
|
||||
end
|
||||
|
||||
def test_dont_double_escape
|
||||
# 3 cases to test in the before: first word, last word, everything inbetween
|
||||
before = "<stuff> with html & special chars</danger>"
|
||||
# all words in after are treated equal
|
||||
after = "other stuff <script>alert('foo');</alert>"
|
||||
|
||||
computed_diff = Redmine::Helpers::Diff.new(before, after).to_html
|
||||
expected_diff = '<span class="diff_in"><stuff> with html & special chars</danger></span> <span class="diff_out">other stuff <script>alert('foo');</alert></span>'
|
||||
|
||||
assert_equal computed_diff, expected_diff
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,15 @@
|
|||
require File.expand_path('../../../../../../test_helper', __FILE__)
|
||||
|
||||
class Redmine::Views::Builders::JsonTest < ActiveSupport::TestCase
|
||||
def test_nil_and_false
|
||||
assert_json_output({'value' => nil}) do |b|
|
||||
b.value nil
|
||||
end
|
||||
|
||||
assert_json_output({'value' => false}) do |b|
|
||||
b.value false
|
||||
end
|
||||
end
|
||||
|
||||
def test_hash
|
||||
assert_json_output({'person' => {'name' => 'Ryan', 'age' => 32}}) do |b|
|
||||
|
|
|
@ -401,4 +401,9 @@ EXPECTED
|
|||
|
||||
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(text).gsub(%r{[\r\n\t]}, '')
|
||||
end
|
||||
|
||||
def test_macro_should_support_phrase_modifiers
|
||||
text = "*{{hello_world}}*"
|
||||
assert_match %r|\A<p><strong>Hello world!.*</strong></p>\z|, textilizable(text)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,5 +89,70 @@ STR
|
|||
assert_equal '<p>This is a <a href="/issues">link</a></p>', @formatter.new(text).to_html.strip
|
||||
end
|
||||
|
||||
def test_markdown_should_not_require_surrounded_empty_line
|
||||
text = <<-STR
|
||||
This is a list:
|
||||
* One
|
||||
* Two
|
||||
STR
|
||||
assert_equal "<p>This is a list:</p>\n\n<ul>\n<li>One</li>\n<li>Two</li>\n</ul>", @formatter.new(text).to_html.strip
|
||||
end
|
||||
|
||||
STR_WITH_PRE = [
|
||||
# 0
|
||||
"# Title
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.",
|
||||
# 1
|
||||
"## Heading 2
|
||||
|
||||
~~~ruby
|
||||
def foo
|
||||
end
|
||||
>>>>>>> .merge-right.r17266
|
||||
~~~
|
||||
|
||||
Morbi facilisis accumsan orci non pharetra.
|
||||
|
||||
```
|
||||
Pre Content:
|
||||
|
||||
## Inside pre
|
||||
|
||||
<tag> inside pre block
|
||||
|
||||
Morbi facilisis accumsan orci non pharetra.
|
||||
```",
|
||||
# 2
|
||||
"### Heading 3
|
||||
|
||||
Nulla nunc nisi, egestas in ornare vel, posuere ac libero."]
|
||||
|
||||
def test_get_section_should_ignore_pre_content
|
||||
text = STR_WITH_PRE.join("\n\n")
|
||||
|
||||
assert_section_with_hash STR_WITH_PRE[1..2].join("\n\n"), text, 2
|
||||
assert_section_with_hash STR_WITH_PRE[2], text, 3
|
||||
end
|
||||
|
||||
def test_update_section_should_not_escape_pre_content_outside_section
|
||||
text = STR_WITH_PRE.join("\n\n")
|
||||
replacement = "New text"
|
||||
|
||||
assert_equal [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
|
||||
@formatter.new(text).update_section(3, replacement)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_section_with_hash(expected, text, index)
|
||||
result = @formatter.new(text).get_section(index)
|
||||
|
||||
assert_kind_of Array, result
|
||||
assert_equal 2, result.size
|
||||
assert_equal expected, result.first, "section content did not match"
|
||||
assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -536,13 +536,24 @@ STR
|
|||
def test_should_not_allow_arbitrary_class_attribute_on_offtags
|
||||
%w(code pre kbd).each do |tag|
|
||||
assert_html_output({"<#{tag} class=\"foo\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class='foo'>test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class=\"ruby foo\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class='ruby foo'>test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
assert_html_output({"<#{tag} class=\"ruby \"foo\" bar\">test</#{tag}>" => "<#{tag}>test</#{tag}>"}, false)
|
||||
end
|
||||
|
||||
assert_html_output({"<notextile class=\"foo\">test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class='foo'>test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class=\"ruby foo\">test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class='ruby foo'>test</notextile>" => "test"}, false)
|
||||
assert_html_output({"<notextile class=\"ruby \"foo\" bar\">test</notextile>" => "test"}, false)
|
||||
end
|
||||
|
||||
def test_should_allow_valid_language_class_attribute_on_code_tags
|
||||
# language name is double-quoted
|
||||
assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
||||
# language name is single-quoted
|
||||
assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
|
||||
end
|
||||
|
||||
def test_should_not_allow_valid_language_class_attribute_on_non_code_offtags
|
||||
|
@ -577,6 +588,28 @@ STR
|
|||
}, false)
|
||||
end
|
||||
|
||||
# TODO: Remove this test after migrating to RedCloth 4
|
||||
def test_should_not_crash_with_special_input
|
||||
assert_nothing_raised { to_html(" \f") }
|
||||
assert_nothing_raised { to_html(" \v") }
|
||||
end
|
||||
|
||||
def test_should_not_handle_as_preformatted_text_tags_that_starts_with_pre
|
||||
text = <<-STR
|
||||
<pree>
|
||||
This is some text
|
||||
</pree>
|
||||
STR
|
||||
|
||||
expected = <<-EXPECTED
|
||||
<p><pree><br />
|
||||
This is some text<br />
|
||||
</pree></p>
|
||||
EXPECTED
|
||||
|
||||
assert_equal expected.gsub(%r{[\r\n\t]}, ''), to_html(text).gsub(%r{[\r\n\t]}, '')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_html_output(to_test, expect_paragraph = true)
|
||||
|
|
|
@ -866,6 +866,21 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_equal 'Paella.jpg', detail.value
|
||||
end
|
||||
|
||||
def test_update_issue_should_discard_all_changes_on_validation_failure
|
||||
Issue.any_instance.stubs(:valid?).returns(false)
|
||||
assert_no_difference 'Journal.count' do
|
||||
assert_no_difference 'JournalDetail.count' do
|
||||
assert_no_difference 'Attachment.count' do
|
||||
assert_no_difference 'Issue.count' do
|
||||
journal = submit_email('ticket_with_attachment.eml') do |raw|
|
||||
raw.gsub! /^Subject: .*$/, 'Subject: Re: [Cookbook - Feature #2] (New) Add ingredients categories'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_update_issue_should_send_email_notification
|
||||
journal = submit_email('ticket_reply.eml')
|
||||
assert journal.is_a?(Journal)
|
||||
|
@ -940,6 +955,17 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
assert_equal Message.find(1), m.parent
|
||||
end
|
||||
|
||||
def test_reply_to_a_locked_topic
|
||||
# Lock the topic
|
||||
topic = Message.find(2).parent
|
||||
topic.update_attribute :locked, true
|
||||
|
||||
assert_no_difference('topic.replies_count') do
|
||||
m = submit_email('message_reply_by_subject.eml')
|
||||
assert_not_kind_of Message, m
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_convert_tags_of_html_only_emails
|
||||
with_settings :text_formatting => 'textile' do
|
||||
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})
|
||||
|
@ -1128,12 +1154,13 @@ class MailHandlerTest < ActiveSupport::TestCase
|
|||
options = MailHandler.extract_options_from_env({
|
||||
'tracker' => 'defect',
|
||||
'project' => 'foo',
|
||||
'unknown_user' => 'create'
|
||||
'unknown_user' => 'create',
|
||||
'no_notification' => '1'
|
||||
})
|
||||
|
||||
assert_equal({
|
||||
:issue => {:tracker => 'defect', :project => 'foo'},
|
||||
:unknown_user => 'create'
|
||||
:unknown_user => 'create', :no_notification => '1'
|
||||
}, options)
|
||||
end
|
||||
|
||||
|
|
|
@ -713,6 +713,23 @@ class MailerTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_security_notification_with_overridden_originator_and_remote_ip
|
||||
set_language_if_valid User.find(1).language
|
||||
with_settings :emails_footer => "footer without link" do
|
||||
User.current.remote_ip = '192.168.1.1'
|
||||
assert Mailer.security_notification(User.find(1), message: :notice_account_password_updated, originator: User.find(2), remote_ip: '10.0.0.42').deliver
|
||||
mail = last_email
|
||||
assert_not_nil mail
|
||||
assert_mail_body_match User.find(2).login, mail
|
||||
assert_mail_body_match '10.0.0.42', mail
|
||||
assert_mail_body_match I18n.t(:notice_account_password_updated), mail
|
||||
assert_select_email do
|
||||
assert_select "h1", false
|
||||
assert_select "a", false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_security_notification_should_include_title
|
||||
set_language_if_valid User.find(2).language
|
||||
with_settings :emails_footer => "footer without link" do
|
||||
|
|
|
@ -35,6 +35,7 @@ class MemberTest < ActiveSupport::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@jsmith = Member.find(1)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class MessageTest < ActiveSupport::TestCase
|
|||
:users, :watchers, :enabled_modules
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@board = Board.find(1)
|
||||
@user = User.find(1)
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ class NewsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create_should_send_email_notification
|
||||
|
|
|
@ -22,6 +22,7 @@ class ProjectMembersInheritanceTest < ActiveSupport::TestCase
|
|||
:projects, :trackers, :issue_statuses
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@parent = Project.generate!
|
||||
@member = Member.create!(:principal => User.find(2), :project => @parent, :role_ids => [1, 2])
|
||||
assert_equal 2, @member.reload.roles.size
|
||||
|
|
|
@ -21,6 +21,7 @@ class ProjectNestedSetConcurrencyTest < ActiveSupport::TestCase
|
|||
self.use_transactional_fixtures = false
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
CustomField.delete_all
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class ProjectNestedSetTest < ActiveSupport::TestCase
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
Project.delete_all
|
||||
Tracker.delete_all
|
||||
|
||||
|
|
|
@ -876,6 +876,38 @@ class QueryTest < ActiveSupport::TestCase
|
|||
User.current = nil
|
||||
end
|
||||
|
||||
def test_filter_on_watched_issues_with_view_issue_watchers_permission
|
||||
User.current = User.find(1)
|
||||
User.current.admin = true
|
||||
assert User.current.allowed_to?(:view_issue_watchers, Project.find(1))
|
||||
|
||||
Issue.find(1).add_watcher User.current
|
||||
Issue.find(3).add_watcher User.find(3)
|
||||
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me', '3']}})
|
||||
result = find_issues_with_query(query)
|
||||
assert_includes result, Issue.find(1)
|
||||
assert_includes result, Issue.find(3)
|
||||
ensure
|
||||
User.current.reload
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_filter_on_watched_issues_without_view_issue_watchers_permission
|
||||
User.current = User.find(1)
|
||||
User.current.admin = false
|
||||
assert !User.current.allowed_to?(:view_issue_watchers, Project.find(1))
|
||||
|
||||
Issue.find(1).add_watcher User.current
|
||||
Issue.find(3).add_watcher User.find(3)
|
||||
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me', '3']}})
|
||||
result = find_issues_with_query(query)
|
||||
assert_includes result, Issue.find(1)
|
||||
assert_not_includes result, Issue.find(3)
|
||||
ensure
|
||||
User.current.reload
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_filter_on_custom_field_should_ignore_projects_with_field_disabled
|
||||
field = IssueCustomField.generate!(:trackers => Tracker.all, :project_ids => [1, 3, 4], :is_for_all => false, :is_filter => true)
|
||||
Issue.generate!(:project_id => 3, :tracker_id => 2, :custom_field_values => {field.id.to_s => 'Foo'})
|
||||
|
@ -1458,6 +1490,12 @@ class QueryTest < ActiveSupport::TestCase
|
|||
assert_equal [['id', 'desc']], q.sort_criteria
|
||||
end
|
||||
|
||||
def test_sort_criteria_should_remove_blank_keys
|
||||
q = IssueQuery.new
|
||||
q.sort_criteria = [['priority', 'desc'], [nil, 'desc'], ['', 'asc'], ['project', 'asc']]
|
||||
assert_equal [['priority', 'desc'], ['project', 'asc']], q.sort_criteria
|
||||
end
|
||||
|
||||
def test_set_sort_criteria_with_hash
|
||||
q = IssueQuery.new
|
||||
q.sort_criteria = {'0' => ['priority', 'desc'], '2' => ['tracker']}
|
||||
|
@ -1511,6 +1549,39 @@ class QueryTest < ActiveSupport::TestCase
|
|||
assert_equal values.sort, values
|
||||
end
|
||||
|
||||
def test_sort_by_total_for_estimated_hours
|
||||
# Prepare issues
|
||||
parent = issues(:issues_001)
|
||||
child = issues(:issues_002)
|
||||
private_child = issues(:issues_003)
|
||||
other = issues(:issues_007)
|
||||
|
||||
User.current = users(:users_001)
|
||||
|
||||
parent.safe_attributes = {:estimated_hours => 1}
|
||||
child.safe_attributes = {:estimated_hours => 2, :parent_issue_id => 1}
|
||||
private_child.safe_attributes = {:estimated_hours => 4, :parent_issue_id => 1, :is_private => true}
|
||||
other.safe_attributes = {:estimated_hours => 5}
|
||||
|
||||
[parent, child, private_child, other].each(&:save!)
|
||||
|
||||
|
||||
q = IssueQuery.new(
|
||||
:name => '_',
|
||||
:filters => { 'issue_id' => {:operator => '=', :values => ['1,7']} },
|
||||
:sort_criteria => [['total_estimated_hours', 'asc']]
|
||||
)
|
||||
|
||||
# With private_child, `parent' is "bigger" than `other'
|
||||
ids = q.issue_ids
|
||||
assert_equal [7, 1], ids, "Private issue was not used to calculate sort order"
|
||||
|
||||
# Without the invisible private_child, `other' is "bigger" than `parent'
|
||||
User.current = User.anonymous
|
||||
ids = q.issue_ids
|
||||
assert_equal [1, 7], ids, "Private issue was used to calculate sort order"
|
||||
end
|
||||
|
||||
def test_set_totalable_names
|
||||
q = IssueQuery.new
|
||||
q.totalable_names = ['estimated_hours', :spent_hours, '']
|
||||
|
@ -1790,6 +1861,11 @@ class QueryTest < ActiveSupport::TestCase
|
|||
|
||||
assert q.visible?(User.find(1))
|
||||
assert IssueQuery.visible(User.find(1)).find_by_id(q.id)
|
||||
|
||||
# Should ignore archived project memberships
|
||||
Project.find(1).archive
|
||||
assert !q.visible?(User.find(3))
|
||||
assert_nil IssueQuery.visible(User.find(3)).find_by_id(q.id)
|
||||
end
|
||||
|
||||
def test_query_with_private_visibility_should_be_visible_to_owner
|
||||
|
@ -1876,6 +1952,25 @@ class QueryTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_available_columns_should_not_include_total_estimated_hours_when_trackers_disabled_estimated_hours
|
||||
Tracker.visible.each do |tracker|
|
||||
tracker.core_fields = tracker.core_fields.reject{|field| field == 'estimated_hours'}
|
||||
tracker.save!
|
||||
end
|
||||
query = IssueQuery.new
|
||||
available_columns = query.available_columns.map(&:name)
|
||||
assert_not_include :estimated_hours, available_columns
|
||||
assert_not_include :total_estimated_hours, available_columns
|
||||
|
||||
tracker = Tracker.visible.first
|
||||
tracker.core_fields = ['estimated_hours']
|
||||
tracker.save!
|
||||
query = IssueQuery.new
|
||||
available_columns = query.available_columns.map(&:name)
|
||||
assert_include :estimated_hours, available_columns
|
||||
assert_include :total_estimated_hours, available_columns
|
||||
end
|
||||
|
||||
def setup_member_of_group
|
||||
Group.destroy_all # No fixtures
|
||||
@user_in_group = User.generate!
|
||||
|
@ -2119,4 +2214,19 @@ class QueryTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal ['1','2','3','4','5','6'], query.available_filters['status_id'][:values].map(&:second)
|
||||
end
|
||||
|
||||
def test_as_params_should_serialize_query
|
||||
query = IssueQuery.new(name: "_")
|
||||
query.add_filter('subject', '!~', ['asdf'])
|
||||
query.group_by = 'tracker'
|
||||
query.totalable_names = %w(estimated_hours)
|
||||
query.column_names = %w(id subject estimated_hours)
|
||||
assert hsh = query.as_params
|
||||
|
||||
new_query = IssueQuery.build_from_params(hsh)
|
||||
assert_equal query.filters, new_query.filters
|
||||
assert_equal query.group_by, new_query.group_by
|
||||
assert_equal query.column_names, new_query.column_names
|
||||
assert_equal query.totalable_names, new_query.totalable_names
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,6 +48,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase
|
|||
CHAR_1_LATIN1_HEX = "\xdc".force_encoding('ASCII-8BIT')
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
@repository = Repository::Bazaar.create(
|
||||
:project => @project, :url => REPOSITORY_PATH_TRUNK,
|
||||
|
|
|
@ -29,6 +29,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
|
|||
CHANGESETS_NUM = 7
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
@repository = Repository::Cvs.create(:project => @project,
|
||||
:root_url => REPOSITORY_PATH,
|
||||
|
|
|
@ -25,6 +25,7 @@ class RepositoryFilesystemTest < ActiveSupport::TestCase
|
|||
REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
|
||||
@repository = Repository::Filesystem.create(
|
||||
|
|
|
@ -40,6 +40,7 @@ class RepositoryGitTest < ActiveSupport::TestCase
|
|||
JRUBY_SKIP_STR = "TODO: This test fails in JRuby"
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
@repository = Repository::Git.create(
|
||||
:project => @project,
|
||||
|
|
|
@ -29,6 +29,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase
|
|||
BRANCH_CHAR_1 = "branch-#{CHAR_1_HEX}-01".force_encoding('UTF-8')
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
@repository = Repository::Mercurial.create(
|
||||
:project => @project,
|
||||
|
|
|
@ -25,6 +25,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase
|
|||
NUM_REV = 11
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(3)
|
||||
@repository = Repository::Subversion.create(:project => @project,
|
||||
:url => self.class.subversion_repository_url)
|
||||
|
|
|
@ -38,6 +38,7 @@ class RepositoryTest < ActiveSupport::TestCase
|
|||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@repository = Project.find(1).repository
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class RoleTest < ActiveSupport::TestCase
|
||||
fixtures :roles, :workflows, :trackers
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_sorted_scope
|
||||
assert_equal Role.all.sort, Role.sorted.to_a
|
||||
end
|
||||
|
|
|
@ -37,6 +37,7 @@ class SearchTest < ActiveSupport::TestCase
|
|||
:changesets
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@project = Project.find(1)
|
||||
@issue_keyword = '%unable to print recipes%'
|
||||
@issue = Issue.find(1)
|
||||
|
|
|
@ -21,6 +21,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
|
||||
class SettingTest < ActiveSupport::TestCase
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def teardown
|
||||
Setting.delete_all
|
||||
Setting.clear_cache
|
||||
|
|
|
@ -29,6 +29,10 @@ class TimeEntryActivityTest < ActiveSupport::TestCase
|
|||
|
||||
include Redmine::I18n
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_should_be_an_enumeration
|
||||
assert TimeEntryActivity.ancestors.include?(Enumeration)
|
||||
end
|
||||
|
|
|
@ -27,6 +27,10 @@ class TimeEntryQueryTest < ActiveSupport::TestCase
|
|||
:groups_users,
|
||||
:enabled_modules
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_filter_values_without_project_should_be_arrays
|
||||
q = TimeEntryQuery.new
|
||||
assert_nil q.project
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class TokenTest < ActiveSupport::TestCase
|
||||
fixtures :tokens, :users, :email_addresses
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
token = Token.new
|
||||
token.save
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class TrackerTest < ActiveSupport::TestCase
|
||||
fixtures :trackers, :workflows, :issue_statuses, :roles, :issues, :projects, :projects_trackers
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_sorted_scope
|
||||
assert_equal Tracker.all.sort, Tracker.sorted.to_a
|
||||
end
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class UserPreferenceTest < ActiveSupport::TestCase
|
||||
fixtures :users, :user_preferences
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_hide_mail_should_default_to_true
|
||||
preference = UserPreference.new
|
||||
assert_equal true, preference.hide_mail
|
||||
|
|
|
@ -21,6 +21,10 @@ class VersionTest < ActiveSupport::TestCase
|
|||
fixtures :projects, :users, :issues, :issue_statuses, :trackers,
|
||||
:enumerations, :versions, :projects_trackers
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
v = Version.new(:project => Project.find(1), :name => '1.1',
|
||||
:effective_date => '2011-03-25')
|
||||
|
@ -277,6 +281,21 @@ class VersionTest < ActiveSupport::TestCase
|
|||
assert_equal false, version.deletable?
|
||||
end
|
||||
|
||||
def test_deletable_should_return_false_when_referenced_by_an_attachment
|
||||
version = Version.generate!
|
||||
Attachment.generate!(:container => version, :filename => 'test.txt')
|
||||
|
||||
assert_equal false, version.deletable?
|
||||
end
|
||||
|
||||
def test_like_scope
|
||||
version = Version.create!(:project => Project.find(1), :name => 'Version for like scope test')
|
||||
|
||||
assert_includes Version.like('VERSION FOR LIKE SCOPE TEST'), version
|
||||
assert_includes Version.like('version for like scope test'), version
|
||||
assert_includes Version.like('like scope'), version
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_issue(version, attributes={})
|
||||
|
|
|
@ -25,6 +25,7 @@ class WatcherTest < ActiveSupport::TestCase
|
|||
:watchers
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@user = User.find(1)
|
||||
@issue = Issue.find(1)
|
||||
end
|
||||
|
|
|
@ -24,6 +24,7 @@ class WikiContentTest < ActiveSupport::TestCase
|
|||
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@wiki = Wiki.find(1)
|
||||
@page = @wiki.pages.first
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ class WikiContentVersionTest < ActiveSupport::TestCase
|
|||
fixtures :projects, :users, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_should_respond_to_attachments
|
||||
|
|
|
@ -21,6 +21,7 @@ class WikiPageTest < ActiveSupport::TestCase
|
|||
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@wiki = Wiki.find(1)
|
||||
@page = @wiki.pages.first
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ class WikiRedirectTest < ActiveSupport::TestCase
|
|||
fixtures :projects, :wikis, :wiki_pages
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
@wiki = Wiki.find(1)
|
||||
@original = WikiPage.create(:wiki => @wiki, :title => 'Original title')
|
||||
end
|
||||
|
|
|
@ -22,6 +22,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class WikiTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
wiki = Wiki.new(:project => Project.find(3))
|
||||
assert !wiki.save
|
||||
|
|
|
@ -20,6 +20,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|||
class WorkflowTest < ActiveSupport::TestCase
|
||||
fixtures :roles, :trackers, :issue_statuses
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_copy
|
||||
WorkflowTransition.delete_all
|
||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :new_status_id => 2)
|
||||
|
|
|
@ -21,6 +21,7 @@ class WorkflowTransitionTest < ActiveSupport::TestCase
|
|||
fixtures :roles, :trackers, :issue_statuses
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
WorkflowTransition.delete_all
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue