From 91d10c63f02c6116c6215d66fa8ff7b17cddf527 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 5 Mar 2017 07:58:07 +0000 Subject: Show Last Comment in Issue list (#1474). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@16367 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/issues_controller_test.rb | 37 +++++++++++++++++++++++++++++++ test/unit/query_test.rb | 11 +++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 6aa6a0623..63ac34fdd 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -971,6 +971,43 @@ class IssuesControllerTest < Redmine::ControllerTest assert_equal 'application/pdf', response.content_type end + def test_index_with_last_notes_column + get :index, :set_filter => 1, :c => %w(subject last_notes) + + assert_response :success + assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject + + assert_select 'td.last_notes[colspan="3"]', :text => 'Some notes with Redmine links: #2, r2.' + assert_select 'td.last_notes[colspan="3"]', :text => 'A comment with inline image: and a reference to #1 and r2.' + + get :index, :set_filter => 1, :c => %w(subject last_notes), :format => 'pdf' + assert_response :success + assert_equal 'application/pdf', response.content_type + end + + def test_index_with_last_notes_column_should_display_private_notes_with_permission_only + journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1) + @request.session[:user_id] = 2 + + get :index, :set_filter => 1, :c => %w(subject last_notes) + assert_response :success + assert_select 'td.last_notes[colspan="3"]', :text => 'Privates notes' + + Role.find(1).remove_permission! :view_private_notes + + get :index, :set_filter => 1, :c => %w(subject last_notes) + assert_response :success + assert_select 'td.last_notes[colspan="3"]', :text => 'A comment with inline image: and a reference to #1 and r2.' + end + + def test_index_with_description_and_last_notes_columns_should_display_column_name + get :index, :set_filter => 1, :c => %w(subject last_notes description) + assert_response :success + + assert_select 'td.last_notes[colspan="3"] span', :text => 'Last notes' + assert_select 'td.description[colspan="3"] span', :text => 'Description' + end + def test_index_with_parent_column Issue.delete_all parent = Issue.generate! diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 77340e1ca..5a3283900 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -1302,10 +1302,10 @@ class QueryTest < ActiveSupport::TestCase def test_inline_and_block_columns q = IssueQuery.new - q.column_names = ['subject', 'description', 'tracker'] + q.column_names = ['subject', 'description', 'tracker', 'last_notes'] assert_equal [:id, :subject, :tracker], q.inline_columns.map(&:name) - assert_equal [:description], q.block_columns.map(&:name) + assert_equal [:description, :last_notes], q.block_columns.map(&:name) end def test_custom_field_columns_should_be_inline @@ -1335,6 +1335,13 @@ class QueryTest < ActiveSupport::TestCase end end + def test_query_should_preload_last_notes + q = IssueQuery.new(:name => '_', :column_names => [:subject, :last_notes]) + assert q.has_column?(:last_notes) + issues = q.issues + assert_not_nil issues.first.instance_variable_get("@last_notes") + end + def test_groupable_columns_should_include_custom_fields q = IssueQuery.new column = q.groupable_columns.detect {|c| c.name == :cf_1} -- cgit v1.2.3