[#4604] Add buttons for load and clear the caches
This commit is contained in:
1 parent
7824eadc94
commit
e4f1a623f1
5 files changed
+52
-2
No files matched your search
@@ -19,4 +19,17 @@ class RateCachesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if params[:cache].present?
|
||||||
|
if params[:cache].match(/missing/)
|
||||||
|
Rate.update_all_time_entries_with_missing_cost
|
||||||
|
flash[:notice] = l(:text_caches_loaded_successfully)
|
||||||
|
elsif params[:cache].match(/reload/)
|
||||||
|
Rate.update_all_time_entries_to_refresh_cache
|
||||||
|
flash[:notice] = l(:text_caches_loaded_successfully)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to :action => 'index'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -11,3 +11,8 @@
|
|||||||
<%= l(:text_last_cache_clearing_run) %><%= h(@last_cache_clearing_run) %>
|
<%= l(:text_last_cache_clearing_run) %><%= h(@last_cache_clearing_run) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= button_to(l(:text_load_missing_caches), {:controller => 'rate_caches', :action => 'update', :cache => 'missing'}, :method => :put) %>
|
||||||
|
<%= button_to(l(:text_clear_and_load_all_caches), {:controller => 'rate_caches', :action => 'update', :cache => 'reload'}, :method => :put) %>
|
||||||
|
</p>
|
||||||
@@ -12,3 +12,7 @@ en:
|
|||||||
text_no_cache_run: "no cache run found"
|
text_no_cache_run: "no cache run found"
|
||||||
text_last_caching_run: "Last caching run at: "
|
text_last_caching_run: "Last caching run at: "
|
||||||
text_last_cache_clearing_run: "Last cache clearing run at: "
|
text_last_cache_clearing_run: "Last cache clearing run at: "
|
||||||
|
text_load_missing_caches: "Load Missing Caches"
|
||||||
|
text_clear_and_load_all_caches: "Clear and Load All Caches"
|
||||||
|
text_caches_loaded_successfully: "Caches loaded successfully"
|
||||||
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
ActionController::Routing::Routes.draw do |map|
|
ActionController::Routing::Routes.draw do |map|
|
||||||
map.resources :rates
|
map.resources :rates
|
||||||
|
map.connect 'rate_caches', :conditions => {:method => :put}, :controller => 'rate_caches', :action => 'update'
|
||||||
end
|
end
|
||||||
@@ -48,7 +48,34 @@ class AdminPanelTest < ActionController::IntegrationTest
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have a button to force a caching run"
|
should "have a button to force a caching run" do
|
||||||
should "have a button to force a cache clearing run"
|
click_link "Administration"
|
||||||
|
click_link "Rate Caches"
|
||||||
|
click_button "Load Missing Caches"
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
appx_clear_time = Date.today.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
assert_select '#caching-run' do
|
||||||
|
assert_select 'p', :text => /#{appx_clear_time}/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
should "have a button to force a cache clearing run" do
|
||||||
|
click_link "Administration"
|
||||||
|
click_link "Rate Caches"
|
||||||
|
click_button "Clear and Load All Caches"
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
appx_clear_time = Date.today.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
assert_select '#cache-clearing-run' do
|
||||||
|
assert_select 'p', :text => /#{appx_clear_time}/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user