diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 5b86413b46..3914ec322a 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -261,10 +261,8 @@ module QueriesHelper link_to value, issue_path(item) when :parent, :'issue.parent' value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : '' - when :description - item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : '' - when :last_notes - item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : '' + when :description, :last_notes, :comments + item.send(column.name).present? ? content_tag('div', textilizable(item, column.name), :class => 'wiki') : '' when :done_ratio progress_bar(value) when :relations diff --git a/app/views/issues/tabs/_time_entries.html.erb b/app/views/issues/tabs/_time_entries.html.erb index 86a23d0c55..f828f38f18 100644 --- a/app/views/issues/tabs/_time_entries.html.erb +++ b/app/views/issues/tabs/_time_entries.html.erb @@ -25,9 +25,11 @@ <%= l_hours_short time_entry.hours %> -
<%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %>
<%= f.hours_field :hours, :size => 6, :required => true %>
-<%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %>
++ <%= f.textarea :comments, :cols => 60, + :rows => [[3, @time_entry.comments.to_s.length / 50].max, 10].min, + :maxlength => 1024, + :class => 'wiki-edit', + :data => wiki_textarea_stimulus_attributes, + :required => Setting.timelog_required_fields.include?('comments') %> +
+ <%= wikitoolbar_for 'time_entry_comments', (@project ? preview_issue_path(:project_id => @project) : preview_text_path) %><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %>
<% @time_entry.editable_custom_field_values.each do |value| %><%= custom_field_tag_with_label :time_entry, value %>
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 28374a90ee..8a6f4e978b 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -3427,6 +3427,20 @@ class IssuesControllerTest < Redmine::ControllerTest end end + def test_show_spent_time_tab_should_textilize_time_entry_comments + @request.session[:user_id] = 1 + TimeEntry.find(3).update!(:comments => '*formatted comment*') + + with_settings :text_formatting => 'textile' do + get(:issue_tab, :params => {:id => 3, :name => 'time_entries'}, :xhr => true) + end + assert_response :success + + assert_select 'div[id=?]', 'time-entry-3' do + assert_select 'div.wiki.journal-note strong', :text => 'formatted comment' + end + end + def test_show_should_display_open_badge_for_open_issue get :show, params: {id: 1} diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 8ceaf65336..bf796f73f8 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -41,6 +41,18 @@ class TimelogControllerTest < Redmine::ControllerTest end assert_select 'label[for=?]', 'time_entry_user_id', 0 assert_select 'select[name=?]', 'time_entry[user_id]', 0 + assert_select 'textarea.wiki-edit[name=?][maxlength=?]', 'time_entry[comments]', '1024' + assert_select 'script', :text => /new jsToolBar\(document\.getElementById\('time_entry_comments'\)\)/ + assert_select 'script', :text => %r{preview/text} + end + + def test_new_should_mark_comments_as_required_if_setting_requires_it + @request.session[:user_id] = 3 + with_settings :timelog_required_fields => ['comments'] do + get :new + end + assert_response :success + assert_select 'label[for=?] span.required', 'time_entry_comments' end def test_new_with_project_id @@ -51,6 +63,7 @@ class TimelogControllerTest < Redmine::ControllerTest assert_select 'input[name=?][type=hidden]', 'project_id' assert_select 'input[name=?][type=hidden]', 'issue_id', 0 assert_select 'select[name=?]', 'time_entry[project_id]', 0 + assert_select 'script', :text => %r{issues/preview} end def test_new_with_issue_id diff --git a/test/helpers/queries_helper_test.rb b/test/helpers/queries_helper_test.rb index b22bfcb270..e98b66ae47 100644 --- a/test/helpers/queries_helper_test.rb +++ b/test/helpers/queries_helper_test.rb @@ -109,4 +109,21 @@ class QueriesHelperTest < Redmine::HelperTest assert_select_in options, 'option[value=?]', "cf_#{i_cf.id}.cf_#{u_cf.id}", text: "User's Phone number" assert_select_in options, 'optgroup[label=?]', 'User', 1 end + + def test_column_value_should_textilize_item + with_settings :text_formatting => 'textile' do + column = QueryColumn.new(:description) + item = Issue.generate!(:description => '*issue description*') + value = column.value_object(item) + assert_select_in column_value(column, item, value), 'div.wiki>p>strong', :text => 'issue description' + column = QueryColumn.new(:last_notes) + Journal.generate!(journalized: item, notes: '*last note*') + value = column.value_object(item) + assert_select_in column_value(column, item, value), 'div.wiki>p>strong', :text => 'last note' + column = QueryColumn.new(:comments) + item = TimeEntry.generate!(:comments => '*time entry comments*') + value = column.value_object(item) + assert_select_in column_value(column, item, value), 'div.wiki>p>strong', :text => 'time entry comments' + end + end end