[#4604] Add a method and rake task to clear and update all TimeEntry cost caches
This commit is contained in:
@@ -301,4 +301,33 @@ class RateTest < ActiveSupport::TestCase
|
||||
assert Time.parse(Setting.plugin_redmine_rate['last_caching_run']), "Last run timestamp not parseable"
|
||||
end
|
||||
end
|
||||
|
||||
context "#update_all_time_entries_to_refresh_cache" do
|
||||
setup do
|
||||
@user = User.generate!
|
||||
@project = Project.generate!
|
||||
@date = Date.today.to_s
|
||||
@rate = Rate.generate!(:user => @user, :project => @project, :date_in_effect => @date, :amount => 200.0)
|
||||
@time_entry1 = TimeEntry.generate!({:user => @user, :project => @project, :spent_on => @date, :hours => 10.0, :activity => TimeEntryActivity.generate!})
|
||||
@time_entry2 = TimeEntry.generate!({:user => @user, :project => @project, :spent_on => @date, :hours => 20.0, :activity => TimeEntryActivity.generate!})
|
||||
end
|
||||
|
||||
should "update the caches of all Time Entries" do
|
||||
assert_equal "0", ActiveRecord::Base.connection.select_all('select count(*) as count from time_entries where cost IS NULL').first["count"]
|
||||
|
||||
Rate.update_all_time_entries_to_refresh_cache
|
||||
|
||||
assert_equal "0", ActiveRecord::Base.connection.select_all('select count(*) as count from time_entries where cost IS NULL').first["count"]
|
||||
|
||||
end
|
||||
|
||||
should "timestamp a successful run" do
|
||||
assert_equal nil, Setting.plugin_redmine_rate['last_cache_clearing_run']
|
||||
|
||||
Rate.update_all_time_entries_to_refresh_cache
|
||||
|
||||
assert Setting.plugin_redmine_rate['last_cache_clearing_run'], "Last run not timestamped"
|
||||
assert Time.parse(Setting.plugin_redmine_rate['last_cache_clearing_run']), "Last run timestamp not parseable"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user