[#4604] Add an admin panel for the rate caches

This commit is contained in:
Eric Davis
2010-10-13 11:32:32 -07:00
parent fb3b0a41ae
commit 073dfe1177
8 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
class RateCachesController < ApplicationController
unloadable
layout 'admin'
before_filter :require_admin
def index
end
end

View File

@@ -0,0 +1 @@
<h2><%= l(:text_rate_caches_panel) %></h2>

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

View File

@@ -8,3 +8,5 @@ en:
rate_label_set_rate: Set Rate
rate_label_default: Default Rate
rate_cost: Cost
text_rate_caches_panel: "Rate Caches"

View File

@@ -36,6 +36,8 @@ Redmine::Plugin.register :redmine_rate do
})
permission :view_rate, { }
menu :admin_menu, :rate_caches, { :controller => 'rate_caches', :action => 'index'}, :caption => :text_rate_caches_panel
end
require 'redmine_rate/hooks/timesheet_hook_helper'
@@ -44,3 +46,4 @@ require 'redmine_rate/hooks/plugin_timesheet_views_timesheet_group_header_hook'
require 'redmine_rate/hooks/plugin_timesheet_views_timesheet_time_entry_hook'
require 'redmine_rate/hooks/plugin_timesheet_views_timesheet_time_entry_sum_hook'
require 'redmine_rate/hooks/plugin_timesheet_view_timesheets_report_header_tags_hook'
require 'redmine_rate/hooks/view_layouts_base_html_head_hook'

View File

@@ -0,0 +1,9 @@
module RedmineRate
module Hooks
class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return content_tag(:style, "#admin-menu a.rate-caches { background-image: url('#{image_path('database_refresh.png', :plugin => 'redmine_rate')}'); }", :type => 'text/css')
end
end
end
end

View File

@@ -0,0 +1,26 @@
require 'test_helper'
class AdminPanelTest < ActionController::IntegrationTest
def setup
@user = User.generate!(:admin => true, :password => 'rates', :password_confirmation => 'rates')
login_as(@user.login, 'rates')
end
context "Rate Caches admin panel" do
should "be listed in the main Admin section" do
click_link "Administration"
assert_response :success
assert_select "#admin-menu" do
assert_select "a.rate-caches"
end
end
should "show the last run timestamp for the last caching run"
should "show the last run timestamp for the last cache clearing run"
should "have a button to force a caching run"
should "have a button to force a cache clearing run"
end
end

View File

@@ -3,3 +3,41 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper
# Ensure that we are using the temporary fixture path
Engines::Testing.set_fixture_path
require "webrat"
Webrat.configure do |config|
config.mode = :rails
end
module IntegrationTestHelper
def login_as(user="existing", password="existing")
visit "/login"
fill_in 'Login', :with => user
fill_in 'Password', :with => password
click_button 'login'
assert_response :success
assert User.current.logged?
end
def logout
visit '/logout'
assert_response :success
assert !User.current.logged?
end
def assert_forbidden
assert_response :forbidden
assert_template 'common/403'
end
def assert_requires_login
assert_response :success
assert_template 'account/login'
end
end
class ActionController::IntegrationTest
include IntegrationTestHelper
end