[#4604] Add an admin panel for the rate caches
This commit is contained in:
10
app/controllers/rate_caches_controller.rb
Normal file
10
app/controllers/rate_caches_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class RateCachesController < ApplicationController
|
||||
unloadable
|
||||
|
||||
layout 'admin'
|
||||
|
||||
before_filter :require_admin
|
||||
|
||||
def index
|
||||
end
|
||||
end
|
||||
1
app/views/rate_caches/index.html.erb
Normal file
1
app/views/rate_caches/index.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<h2><%= l(:text_rate_caches_panel) %></h2>
|
||||
BIN
assets/images/database_refresh.png
Normal file
BIN
assets/images/database_refresh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 770 B |
@@ -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"
|
||||
|
||||
|
||||
3
init.rb
3
init.rb
@@ -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'
|
||||
|
||||
@@ -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
|
||||
26
test/integration/admin_panel_test.rb
Normal file
26
test/integration/admin_panel_test.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user