diff options
Diffstat (limited to 'test/functional/issues_controller_test.rb')
-rw-r--r-- | test/functional/issues_controller_test.rb | 275 |
1 files changed, 221 insertions, 54 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 2ed9ac9ea..4b9b44537 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -332,7 +332,7 @@ class IssuesControllerTest < Redmine::ControllerTest # assert link properties assert_select( 'a.query.selected[title=?][href=?]', - 'Description for Oepn issues by priority and tracker', + 'Description for Open issues by priority and tracker', '/projects/ecookbook/issues?query_id=5', :text => "Open issues by priority and tracker" ) @@ -1737,7 +1737,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'td.last_notes[colspan="4"]', :text => 'Some notes with Redmine links: #2, r2.' assert_select( 'td.last_notes[colspan="4"]', - :text => 'A comment with inline image: and a reference to #1 and r2.' + :text => 'A comment with inline image: and a reference to #1 and r2.' ) get( :index, @@ -2003,12 +2003,34 @@ class IssuesControllerTest < Redmine::ControllerTest def test_index_with_int_custom_field_total field = IssueCustomField.generate!(:field_format => 'int', :is_for_all => true) - CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '2') - CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '7') - get(:index, :params => {:t => ["cf_#{field.id}"]}) + CustomValue.create!(:customized => Issue.find(1), :custom_field => field, :value => '9800') + CustomValue.create!(:customized => Issue.find(2), :custom_field => field, :value => '10') + + field_with_delimiter = IssueCustomField.generate!(:field_format => 'int', :thousands_delimiter => '1', :is_for_all => true) + CustomValue.create!(:customized => Issue.find(1), :custom_field => field_with_delimiter, :value => '9800') + CustomValue.create!(:customized => Issue.find(2), :custom_field => field_with_delimiter, :value => '10') + + get(:index, :params => {:t => ["cf_#{field.id}", "cf_#{field_with_delimiter.id}"]}) assert_response :success assert_select '.query-totals' - assert_select ".total-for-cf-#{field.id} span.value", :text => '9' + assert_select ".total-for-cf-#{field.id} span.value", :text => '9810' + assert_select ".total-for-cf-#{field_with_delimiter.id} span.value", :text => '9,810' + end + + def test_index_with_float_custom_field_total + field = IssueCustomField.generate!(field_format: 'float', is_for_all: true) + CustomValue.create!(customized: Issue.find(1), custom_field: field, value: '1000000.01') + CustomValue.create!(customized: Issue.find(2), custom_field: field, value: '99.01') + + field_with_delimiter = IssueCustomField.generate!(field_format: 'float', thousands_delimiter: '1', is_for_all: true) + CustomValue.create!(customized: Issue.find(1), custom_field: field_with_delimiter, value: '1000000.01') + CustomValue.create!(customized: Issue.find(2), custom_field: field_with_delimiter, value: '99.01') + + get(:index, params: {t: ["cf_#{field.id}", "cf_#{field_with_delimiter.id}"]}) + assert_response :success + assert_select '.query-totals' + assert_select ".total-for-cf-#{field.id} span.value", text: '1000099.02' + assert_select ".total-for-cf-#{field_with_delimiter.id} span.value", text: '1,000,099.02' end def test_index_with_spent_time_total_should_sum_visible_spent_time_only @@ -2463,7 +2485,7 @@ class IssuesControllerTest < Redmine::ControllerTest end assert_select 'div#tab-content-history' do assert_select 'div[id=?]', "change-#{Issue.find(1).journals.last.id}" do - assert_select 'ul.details', :text => "Subtask ##{issue.id} added" + assert_select 'ul.journal-details', :text => "Subtask ##{issue.id} added" end end end @@ -2642,18 +2664,47 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_show_should_not_display_prev_next_links_for_issue_not_in_query_results - @request.session[:issue_query] = - { - :filters => { - 'status_id' => {:values => [''], :operator => 'c'} - }, - :project_id => 1, - :sort => [['id', 'asc']] + @request.session[:issue_query] = { + filters: { + 'status_id' => {operator: 'o', values: ['']} + }, + project_id: 1, + sort: [['id', 'asc']] + } + get(:show, params: {id: 8}) + + assert_response :success + assert_select 'a', text: /Previous/, count: 0 + assert_select 'a', text: /Next/, count: 0 + end + + def test_show_should_display_prev_next_links_for_issue_not_in_query_when_flash_contains_previous_and_next_issue_ids + @request.session[:issue_query] = { + filters: { + 'status_id' => {operator: 'o', values: ['']} + }, + project_id: 1, + sort: [['id', 'asc']] + } + get( + :show, + params: { id: 8 }, # The issue#8 is closed + flash: { + previous_and_next_issue_ids: { + prev_issue_id: 7, + next_issue_id: 9, + issue_position: 7, + issue_count: 10 + } } - get(:show, :params => {:id => 1}) + ) + assert_response :success - assert_select 'a', :text => /Previous/, :count => 0 - assert_select 'a', :text => /Next/, :count => 0 + assert_select 'div.next-prev-links' do + assert_select 'a[href="/issues/7"]', text: /Previous/ + assert_select 'a[href="/issues/9"]', text: /Next/ + assert_select 'span.position', text: "7 of 10" + end end def test_show_show_should_display_prev_next_links_with_query_sort_by_user_custom_field @@ -2684,25 +2735,6 @@ class IssuesControllerTest < Redmine::ControllerTest end end - def test_show_should_display_prev_next_links_when_request_has_previous_and_next_issue_ids_params - get( - :show, - :params => { - :id => 1, - :prev_issue_id => 1, - :next_issue_id => 3, - :issue_position => 2, - :issue_count => 4 - } - ) - assert_response :success - assert_select 'div.next-prev-links' do - assert_select 'a[href="/issues/1"]', :text => /Previous/ - assert_select 'a[href="/issues/3"]', :text => /Next/ - assert_select 'span.position', :text => "2 of 4" - end - end - def test_show_should_display_category_field_if_categories_are_defined Issue.update_all :category_id => nil get(:show, :params => {:id => 1}) @@ -2784,7 +2816,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'h3', {text: /Watchers \(\d*\)/, count: 0} end - def test_show_should_display_watchers_with_gravatars + def test_show_should_display_watchers_with_avatars @request.session[:user_id] = 2 issue = Issue.find(1) issue.add_watcher User.find(2) @@ -2792,9 +2824,10 @@ class IssuesControllerTest < Redmine::ControllerTest with_settings :gravatar_enabled => '1' do get(:show, :params => {:id => 1}) end + assert_select 'div#watchers ul' do assert_select 'li.user-2' do - assert_select 'img.gravatar[title=?]', 'John Smith' + assert_select '.avatar[title=?]', 'John Smith' assert_select 'a[href="/users/2"]' assert_select 'a[class*=delete]' end @@ -3233,6 +3266,22 @@ class IssuesControllerTest < Redmine::ControllerTest end end + def test_show_render_changeset_comments_in_original_context + issue = Issue.find(9) + issue.changeset_ids = [110] + issue.save! + + @request.session[:user_id] = 2 + get :issue_tab, params: {id: issue.id, name: 'changesets', format: 'js'}, xhr: true + + assert_select 'div#changeset-110' do + # assert_select 'div.tabs a[id=?]', 'tab-changesets', text: 'unicorns' + assert_select 'div.changeset-comments' do + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Wiki', text: 'wiki' + end + end + end + def test_show_should_display_spent_time_tab_for_issue_with_time_entries @request.session[:user_id] = 1 get :show, :params => {:id => 3} @@ -3257,7 +3306,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'a[title=?][href=?]', 'Edit', '/time_entries/3/edit' assert_select 'a[title=?][href=?]', 'Delete', '/time_entries/3' - assert_select 'ul[class=?]', 'details', :text => /1.00 h/ + assert_select 'ul[class=?]', 'journal-details', :text => /1.00 h/ end end @@ -3283,6 +3332,42 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'span.badge.badge-private', text: 'Private' end + def test_show_should_display_reactions + current_user = User.generate! + + User.add_to_project(current_user, projects(:projects_001), + Role.generate!(users_visibility: 'members_of_visible_projects', permissions: [:view_issues])) + + @request.session[:user_id] = current_user.id + + get :show, params: { id: 1 } + + assert_response :success + + assert_select 'span[data-reaction-button-id=reaction_issue_1]' do + # The current_user can only see members who belong to projects that the current_user has access to. + # Since the Redmine Admin user does not belong to any projects visible to the current_user, + # the Redmine Admin user's name is not displayed in the reaction user list. Instead, "1 other" is shown. + assert_select 'a.reaction-button[title=?]', 'Dave Lopper and John Smith' do + assert_select 'span.icon-label', '2' + end + end + + assert_select 'span[data-reaction-button-id=reaction_journal_1]' do + assert_select 'a.reaction-button[title=?]', 'John Smith' + end + assert_select 'span[data-reaction-button-id=reaction_journal_2] a.reaction-button' + end + + def test_should_not_display_reactions_when_reactions_feature_is_disabled + with_settings reactions_enabled: '0' do + get :show, params: { id: 1 } + + assert_response :success + assert_select 'span[data-reaction-button-id]', false + end + end + def test_show_should_not_display_edit_attachment_icon_for_user_without_edit_issue_permission_on_tracker role = Role.find(2) role.set_permission_trackers 'edit_issues', [2, 3] @@ -5885,6 +5970,16 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'input[name=?]', 'time_entry[hours]', 0 end + def test_get_edit_should_not_display_the_time_entry_form_on_closed_issue + with_settings :timelog_accept_closed_issues => '0' do + @request.session[:user_id] = 2 + issue = Issue.find(1) + issue.update :status => IssueStatus.find(5) + get(:edit, :params => {:id => 1}) + assert_select 'input[name=?]', 'time_entry[hours]', 0 + end + end + def test_get_edit_with_params @request.session[:user_id] = 2 get( @@ -5938,6 +6033,16 @@ class IssuesControllerTest < Redmine::ControllerTest end end + def test_get_edit_with_custom_field_progress_bar + cf = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true, :field_format => 'progressbar') + + @request.session[:user_id] = 1 + get(:edit, :params => {:id => 1}) + assert_response :success + + assert_select "select[id=?]", "issue_custom_field_values_#{cf.id}", 1 + end + def test_get_edit_with_me_assigned_to_id @request.session[:user_id] = 2 get( @@ -6341,6 +6446,57 @@ class IssuesControllerTest < Redmine::ControllerTest assert mail.subject.include?("(#{IssueStatus.find(2).name})") end + def test_update_should_accept_time_entry_when_closing_issue + with_settings :timelog_accept_closed_issues => '0' do + issue = Issue.find(1) + assert_equal 1, issue.status_id + @request.session[:user_id] = 2 + assert_difference('TimeEntry.count', 1) do + put( + :update, + :params => { + :id => 1, + :issue => { + :status_id => 5, + }, + :time_entry => { + :hours => '2', + :comments => '', + :activity_id => TimeEntryActivity.first + } + } + ) + end + assert_redirected_to :action => 'show', :id => '1' + issue.reload + assert issue.closed? + end + end + + def test_update_should_not_accept_time_entry_on_closed_issue + with_settings :timelog_accept_closed_issues => '0' do + issue = Issue.find(1) + issue.update :status => IssueStatus.find(5) + @request.session[:user_id] = 2 + assert_no_difference('TimeEntry.count') do + put( + :update, + :params => { + :id => 1, + :issue => { + }, + :time_entry => { + :hours => '2', + :comments => '', + :activity_id => TimeEntryActivity.first + } + } + ) + end + assert_response :success + end + end + def test_put_update_with_note_only notes = 'Note added by IssuesControllerTest#test_update_with_note_only' @@ -6903,7 +7059,11 @@ class IssuesControllerTest < Redmine::ControllerTest :issue_count => 3 } ) - assert_redirected_to '/issues/11?issue_count=3&issue_position=2&next_issue_id=12&prev_issue_id=8' + assert_redirected_to '/issues/11' + assert_equal( + { issue_count: '3', issue_position: '2', next_issue_id: '12', prev_issue_id: '8' }, + flash[:previous_and_next_issue_ids] + ) end def test_update_with_permission_on_tracker_should_be_allowed @@ -8538,7 +8698,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'div#tab-content-history' do assert_select 'div[id=?]', "change-#{parent.journals.last.id}" do - assert_select 'ul.details', :text => "Subtask deleted (##{child.id})" + assert_select 'ul.journal-details', :text => "Subtask deleted (##{child.id})" end end end @@ -8627,31 +8787,27 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'a[href=?][onclick=?]', "/issues/1", "", :text => 'Cancel' end - def test_show_should_display_author_gravatar_only_when_not_assigned + def test_show_should_display_author_avatar_only_when_not_assigned issue = Issue.find(1) assert_nil issue.assigned_to_id @request.session[:user_id] = 1 - with_settings :gravatar_enabled => '1' do - get :show, :params => {:id => issue.id} - assert_select 'div.gravatar-with-child' do - assert_select 'img.gravatar', 1 - end + get :show, :params => {:id => issue.id} + assert_select 'div.avatar-with-child' do + assert_select '.avatar', 1 end end - def test_show_should_display_author_and_assignee_gravatars_when_assigned + def test_show_should_display_author_and_assignee_avatars_when_assigned issue = Issue.find(1) issue.assigned_to_id = 2 issue.save! @request.session[:user_id] = 1 - with_settings :gravatar_enabled => '1' do - get :show, :params => {:id => issue.id} - assert_select 'div.gravatar-with-child' do - assert_select 'img.gravatar', 2 - assert_select 'img.gravatar-child', 1 - end + get :show, :params => {:id => issue.id} + assert_select 'div.avatar-with-child' do + assert_select '.avatar', 2 + assert_select '.avatar-child', 1 end end @@ -8823,4 +8979,15 @@ class IssuesControllerTest < Redmine::ControllerTest end end end + + def test_related_issues_columns_setting + with_settings :related_issues_default_columns => ['status', 'total_estimated_hours'], :display_related_issues_table_headers => 1 do + Issue.find(1).update!(parent_id: 2) + get :show, params: { id: 2 } + assert_response :success + assert_select 'thead.related-issues th', text: 'Subject' + assert_select 'thead.related-issues th', text: 'Status' + assert_select 'thead.related-issues th', text: 'Total estimated time' + end + end end |