better abstraction for system infos
This commit is contained in:
parent
c190c504b6
commit
bc9054b615
@ -3,10 +3,12 @@
|
||||
class AdditionalsInfo
|
||||
include Redmine::I18n
|
||||
|
||||
class << self
|
||||
def system_infos
|
||||
{ system_info: { label: l(:label_system_info), value: system_info },
|
||||
system_uptime: { label: l(:label_uptime), value: system_uptime } }
|
||||
{ system_info: { label: l(:label_system_info),
|
||||
value: system_info },
|
||||
system_uptime: { label: l(:label_uptime),
|
||||
value: system_uptime,
|
||||
api_value: system_uptime(format: :datetime) } }
|
||||
end
|
||||
|
||||
def system_info
|
||||
@ -71,5 +73,4 @@ class AdditionalsInfo
|
||||
def windows_platform?
|
||||
/cygwin|mswin|mingw|bccwin|wince|emx/.match? RUBY_PLATFORM
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,13 @@
|
||||
table.list
|
||||
- AdditionalsInfo.system_infos.each_value do |system_info|
|
||||
tr
|
||||
- AdditionalsInfo.new.system_infos.each do |type, system_info|
|
||||
tr class=type
|
||||
td.name
|
||||
= "#{system_info[:label]}:"
|
||||
td.name = system_info[:value]
|
||||
= "#{system_info[:label].presence || type}:"
|
||||
td.name
|
||||
- case system_info[:value]
|
||||
- when true
|
||||
= image_tag 'true.png'
|
||||
- when false
|
||||
= image_tag 'exclamation.png'
|
||||
- else
|
||||
= system_info[:value]
|
||||
|
@ -4,12 +4,12 @@ require File.expand_path '../../test_helper', __FILE__
|
||||
|
||||
class AdditionalsInfoTest < Additionals::TestCase
|
||||
def test_system_info
|
||||
text = AdditionalsInfo.system_info
|
||||
text = AdditionalsInfo.new.system_info
|
||||
assert_not_equal '', text
|
||||
assert_not_equal 'unknown', text
|
||||
end
|
||||
|
||||
def test_windows_platform
|
||||
assert_not AdditionalsInfo.windows_platform?
|
||||
assert_not AdditionalsInfo.new.windows_platform?
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user