##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15342:29ddc82a11f3
r15741:f8df935dcada
Show More
time_entry_reports_controller_test.rb
352 lines | 13.1 KiB | text/x-ruby | RubyLexer
/ test / functional / time_entry_reports_controller_test.rb
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 # -*- coding: utf-8 -*-
Jean-Philippe Lang
Functional tests cleanup....
r10709 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Functional tests cleanup....
r10709 #
# 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.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118
Jean-Philippe Lang
Adds our own class for controller tests....
r15279 class TimeEntryReportsControllerTest < Redmine::ControllerTest
Jean-Philippe Lang
Dropped TimeEntryReportsController....
r7907 tests TimelogController
Toshi MARUYAMA
code layout clean up test/functional/time_entry_reports_controller_test.rb...
r7644 fixtures :projects, :enabled_modules, :roles, :members, :member_roles,
Toshi MARUYAMA
add missing fixture to TimeEntryReportsControllerTest...
r13548 :email_addresses,
Toshi MARUYAMA
code layout clean up test/functional/time_entry_reports_controller_test.rb...
r7644 :issues, :time_entries, :users, :trackers, :enumerations,
Toshi MARUYAMA
add missing fixtures to TimeEntryReportsControllerTest...
r12605 :issue_statuses, :custom_fields, :custom_values,
:projects_trackers, :custom_fields_trackers,
:custom_fields_projects
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118
Toshi MARUYAMA
add csv separator check to the test to export time entry csv in Traditional Chinese (#8368)...
r7829 include Redmine::I18n
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 def setup
Setting.default_language = "en"
end
Jean-Philippe Lang
Changed timelogs filters to use non-AJAX requests (#1965)....
r5177 def test_report_at_project_level
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 'ecookbook'}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_all_projects
get :report
assert_response :success
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'form#query_form[action=?]', '/time_entries/report'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_all_projects_denied
r = Role.anonymous
r.permissions.delete(:view_time_entries)
r.permissions_will_change!
r.save
get :report
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Ftime_entries%2Freport'
end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_all_projects_one_criteria
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '8.65'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
def test_report_all_time
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '162.90'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
def test_report_all_time_by_day
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '162.90'
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'th', :text => '2007-03-12'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_one_criteria
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '8.65'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 def test_report_two_criteria
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '162.90'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Jean-Philippe Lang
Exclude custom fields with multiple values from time report criteria (#16519)....
r12780 def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
Jean-Philippe Lang
Fixed that time report raises a SQL error if there are multiple CustomValue for a time entry (#11160)....
r9648 field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2'])
entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today)
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1')
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value2')
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"]}
Jean-Philippe Lang
Fixed that time report raises a SQL error if there are multiple CustomValue for a time entry (#11160)....
r9648 assert_response :success
end
Jean-Philippe Lang
Exclude custom fields with multiple values from time report criteria (#16519)....
r12780 def test_report_multiple_values_custom_fields_should_not_be_proposed
TimeEntryCustomField.create!(:name => 'Single', :field_format => 'list', :possible_values => ['value1', 'value2'])
TimeEntryCustomField.create!(:name => 'Multi', :field_format => 'list', :multiple => true, :possible_values => ['value1', 'value2'])
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1}
Jean-Philippe Lang
Exclude custom fields with multiple values from time report criteria (#16519)....
r12780 assert_response :success
assert_select 'select[name=?]', 'criteria[]' do
assert_select 'option', :text => 'Single'
assert_select 'option', :text => 'Multi', :count => 0
end
end
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_one_day
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342 assert_select 'tr.total td:last', :text => '4.25'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Jean-Philippe Lang
Fixed that time entries report by week breaks on edge cases (#5329)....
r11241 def test_report_by_week_should_use_commercial_year
TimeEntry.delete_all
TimeEntry.generate!(:hours => '2', :spent_on => '2009-12-25') # 2009-52
TimeEntry.generate!(:hours => '4', :spent_on => '2009-12-31') # 2009-53
TimeEntry.generate!(:hours => '8', :spent_on => '2010-01-01') # 2009-53
TimeEntry.generate!(:hours => '16', :spent_on => '2010-01-05') # 2010-1
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"]}
Jean-Philippe Lang
Fixed that time entries report by week breaks on edge cases (#5329)....
r11241 assert_response :success
assert_select '#time-report thead tr' do
assert_select 'th:nth-child(1)', :text => 'Project'
assert_select 'th:nth-child(2)', :text => '2009-52'
assert_select 'th:nth-child(3)', :text => '2009-53'
assert_select 'th:nth-child(4)', :text => '2010-1'
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 assert_select 'th:nth-child(5)', :text => 'Total time'
Jean-Philippe Lang
Fixed that time entries report by week breaks on edge cases (#5329)....
r11241 end
assert_select '#time-report tbody tr' do
assert_select 'td:nth-child(1)', :text => 'eCookbook'
assert_select 'td:nth-child(2)', :text => '2.00'
assert_select 'td:nth-child(3)', :text => '12.00'
assert_select 'td:nth-child(4)', :text => '16.00'
assert_select 'td:nth-child(5)', :text => '30.00' # Total
end
end
Jean-Philippe Lang
Makes project custom fields available on spent time report (#1766)....
r11229 def test_report_should_propose_association_custom_fields
get :report
assert_response :success
assert_select 'select[name=?]', 'criteria[]' do
assert_select 'option[value=cf_1]', {:text => 'Database'}, 'Issue custom field not found'
assert_select 'option[value=cf_3]', {:text => 'Development status'}, 'Project custom field not found'
assert_select 'option[value=cf_7]', {:text => 'Billable'}, 'TimeEntryActivity custom field not found'
end
end
def test_report_with_association_custom_fields
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342
assert_select 'tr.total td:last', :text => '162.90'
Jean-Philippe Lang
Makes project custom fields available on spent time report (#1766)....
r11229
# Custom fields columns
assert_select 'th', :text => 'Database'
assert_select 'th', :text => 'Development status'
assert_select 'th', :text => 'Billable'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 # Custom field row
Jean-Philippe Lang
Makes project custom fields available on spent time report (#1766)....
r11229 assert_select 'tr' do
assert_select 'td', :text => 'MySQL'
assert_select 'td.hours', :text => '1.00'
end
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_one_criteria_no_result
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342
assert_select '.nodata'
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Jean-Philippe Lang
Adds "Status" to the time report criteria (#9985)....
r8523 def test_report_status_criterion
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {:project_id => 1, :criteria => ['status']}
Jean-Philippe Lang
Adds "Status" to the time report criteria (#9985)....
r8523 assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15342
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'th', :text => 'Status'
assert_select 'td', :text => 'New'
Jean-Philippe Lang
Adds "Status" to the time report criteria (#9985)....
r8523 end
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_all_projects_csv_export
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {
:columns => 'month',
:from => "2007-01-01",
:to => "2007-06-30",
:criteria => ["project", "user", "activity"],
:format => "csv"
}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_equal 'text/csv; header=present', @response.content_type
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 lines = @response.body.chomp.split("\n")
# Headers
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 # Total row
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 assert_equal 'Total time,"","",154.25,8.65,162.90', lines.last
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
remove trailing white-spaces from test/functional/time_entry_reports_controller_test.rb....
r6492
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 def test_report_csv_export
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {
:project_id => 1,
:columns => 'month',
:from => "2007-01-01",
:to => "2007-06-30",
:criteria => ["project", "user", "activity"],
:format => "csv"
}
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 assert_response :success
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_equal 'text/csv; header=present', @response.content_type
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 lines = @response.body.chomp.split("\n")
# Headers
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 assert_equal 'Project,User,Activity,2007-3,2007-4,Total time', lines.first
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 # Total row
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 assert_equal 'Total time,"","",154.25,8.65,162.90', lines.last
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691
def test_csv_big_5
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 user = User.find_by_id(3)
user.firstname = str_utf8
user.lastname = "test-lastname"
assert user.save
comments = "test_csv_big_5"
te1 = TimeEntry.create(:spent_on => '2011-11-11',
:hours => 7.3,
:project => Project.find(1),
:user => user,
:activity => TimeEntryActivity.find_by_name('Design'),
:comments => comments)
te2 = TimeEntry.find_by_comments(comments)
assert_not_nil te2
assert_equal 7.3, te2.hours
assert_equal 3, te2.user_id
Jean-Philippe Lang
Don't change Setting.default_language in tests....
r13542 with_settings :default_language => "zh-TW" do
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {
:project_id => 1,
:columns => 'day',
:from => "2011-11-11",
:to => "2011-11-11",
:criteria => ["user"],
:format => "csv"
}
Jean-Philippe Lang
Don't change Setting.default_language in tests....
r13542 end
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 assert_response :success
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_equal 'text/csv; header=present', @response.content_type
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 lines = @response.body.chomp.split("\n")
# Headers
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
s2 = "\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 assert_equal s1, lines.first
# Total row
assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1]
Toshi MARUYAMA
fix time entry csv last line encoding (#8549)...
r7827 assert_equal "#{s2},7.30,7.30", lines[2]
Toshi MARUYAMA
add csv separator check to the test to export time entry csv in Traditional Chinese (#8368)...
r7829
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)".force_encoding('UTF-8')
Toshi MARUYAMA
add csv separator check to the test to export time entry csv in Traditional Chinese (#8368)...
r7829 assert_equal str_tw, l(:general_lang_name)
assert_equal 'Big5', l(:general_csv_encoding)
assert_equal ',', l(:general_csv_separator)
assert_equal '.', l(:general_csv_decimal_separator)
Toshi MARUYAMA
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
r7691 end
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700
def test_csv_cannot_convert_should_be_replaced_big_5
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700 user = User.find_by_id(3)
user.firstname = str_utf8
user.lastname = "test-lastname"
assert user.save
comments = "test_replaced"
te1 = TimeEntry.create(:spent_on => '2011-11-11',
:hours => 7.3,
:project => Project.find(1),
:user => user,
:activity => TimeEntryActivity.find_by_name('Design'),
:comments => comments)
te2 = TimeEntry.find_by_comments(comments)
assert_not_nil te2
assert_equal 7.3, te2.hours
assert_equal 3, te2.user_id
Jean-Philippe Lang
Don't change Setting.default_language in tests....
r13542 with_settings :default_language => "zh-TW" do
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {
:project_id => 1,
:columns => 'day',
:from => "2011-11-11",
:to => "2011-11-11",
:criteria => ["user"],
:format => "csv"
}
Jean-Philippe Lang
Don't change Setting.default_language in tests....
r13542 end
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700 assert_response :success
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_equal 'text/csv; header=present', @response.content_type
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700 lines = @response.body.chomp.split("\n")
# Headers
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 s1 = "\xa5\xce\xa4\xe1,2011-11-11,\xa4u\xae\xc9\xc1`\xadp".force_encoding('Big5')
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700 assert_equal s1, lines.first
# Total row
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 s2 = "\xa5H?".force_encoding('Big5')
Toshi MARUYAMA
fix malformed time entry report csv encoding in case of unable to convert (#8549)...
r7700 assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
end
Toshi MARUYAMA
add tests to export time entry csv in French for csv separator (#8368)...
r7831
def test_csv_fr
with_settings :default_language => "fr" do
str1 = "test_csv_fr"
user = User.find_by_id(3)
te1 = TimeEntry.create(:spent_on => '2011-11-11',
:hours => 7.3,
:project => Project.find(1),
:user => user,
:activity => TimeEntryActivity.find_by_name('Design'),
:comments => str1)
te2 = TimeEntry.find_by_comments(str1)
assert_not_nil te2
assert_equal 7.3, te2.hours
assert_equal 3, te2.user_id
Jean-Philippe Lang
Pass parameters with :params in controller tests....
r15284 get :report, :params => {
:project_id => 1,
:columns => 'day',
:from => "2011-11-11",
:to => "2011-11-11",
:criteria => ["user"],
:format => "csv"
}
Toshi MARUYAMA
add tests to export time entry csv in French for csv separator (#8368)...
r7831 assert_response :success
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_equal 'text/csv; header=present', @response.content_type
Toshi MARUYAMA
add tests to export time entry csv in French for csv separator (#8368)...
r7831 lines = @response.body.chomp.split("\n")
# Headers
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 s1 = "Utilisateur;2011-11-11;Temps total".force_encoding('ISO-8859-1')
s2 = "Temps total".force_encoding('ISO-8859-1')
Toshi MARUYAMA
add tests to export time entry csv in French for csv separator (#8368)...
r7831 assert_equal s1, lines.first
# Total row
assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1]
assert_equal "#{s2};7,30;7,30", lines[2]
Toshi MARUYAMA
fix tests (#13120)...
r13528 str_fr = "French (Fran\xc3\xa7ais)".force_encoding('UTF-8')
Toshi MARUYAMA
add tests to export time entry csv in French for csv separator (#8368)...
r7831 assert_equal str_fr, l(:general_lang_name)
assert_equal 'ISO-8859-1', l(:general_csv_encoding)
assert_equal ';', l(:general_csv_separator)
assert_equal ',', l(:general_csv_decimal_separator)
end
end
Eric Davis
Refactor: extract TimelogController#report to a new controller class...
r4118 end