
https://svn.lrde.epita.fr/svn/ranch/trunk Index: ChangeLog from Nicolas Despr�s <nicolas.despres@gmail.com> Update the system table. * web/ranch/test/unit/system_test.rb: Test the validation rule set. * web/ranch/test/fixtures/systems.yml: Add a second system fixture. * web/ranch/app/models/system.rb: Update the validations rule set. * web/ranch/db/schema.rb: Add cpu and memory information. app/models/system.rb | 22 +++++++++++++++--- db/schema.rb | 19 +++++++++------ test/fixtures/systems.yml | 55 +++++++++++++++++++++++++++++++++++++++++++--- test/unit/system_test.rb | 19 +++++++++++++++ 4 files changed, 100 insertions(+), 15 deletions(-) Index: web/ranch/test/unit/system_test.rb --- web/ranch/test/unit/system_test.rb (revision 51) +++ web/ranch/test/unit/system_test.rb (working copy) @@ -3,6 +3,23 @@ class SystemTest < Test::Unit::TestCase fixtures :systems - def test_truth + def test_save_default + assert ! System.new.save end + + def test_save_fixtures + System.find_all.each do |system| + assert(system.save, + "cannot save #{system.hostname}: " + + system.errors.full_messages.inspect) + end + end + + def test_save_mem_size_positive + system = systems("ouagadougou") + system.mem_size = -42 + assert ! system.save + assert 1, system.errors.count + end + end Index: web/ranch/test/fixtures/systems.yml --- web/ranch/test/fixtures/systems.yml (revision 51) +++ web/ranch/test/fixtures/systems.yml (working copy) @@ -1,14 +1,63 @@ +<% id = 0 %> + ouagadougou: - id: 1 + id: <%= id += 1 %> hostname: ouagadougou.lrde.epita.fr kernel_name: Linux - kernel_version: "2.4.27-2-k7 #1 Tue Aug 16 17:30:14" + kernel_revision: "2.4.27-2-k7" + kernel_version: "#1 Tue Aug 16 17:30:14" host_type: i686 os_name: GNU/Linux - os_version: comp_name: g++ comp_version: 4.0.3 comp_flags: -02 -W -Wall + mem_size: 256664 + cpu_name: "AMD Athlon(tm) XP 2000+" + cpu_frequency: 1661.957 + info: | + Running action system + SYSTEM UNAME: CYGWIN_NT-5.1 pau 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin + BUILD DATE: Mon Nov 14 10:13:51 2005 + BUILD SHORTDATE: 14/11 10:13 + HIGHEST SVN REVISION: 26 + BUILD REVISION: 6 + PKG_CONFIG_PATH: + PATH: /cygdrive/d/build_farm/prefix/monoburg/bin:/usr/local/bin:/bin:/cygdrive/c/ghc/ghc-6.4/bin:/cygdrive/c/program files/imagemagick-6.2.5-q16:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/Intel/DMIX:/bin + BF_DEPS: + + CFLAGS: + CXXFLAGS: + CC: ccache gcc + CXX: ccache g++ + CONFIGURE OPTIONS: --prefix=/cygdrive/d/build_farm/prefix/ranch + DISTCHECK_CONFIGURE_FLAGS: + + --- gcc (/bin/gcc) --- + gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) + Copyright (C) 2004 Free Software Foundation, Inc. + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + --- g++ (/bin/g++) --- + g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) + Copyright (C) 2004 Free Software Foundation, Inc. + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +vaucanson: + id: <%= id += 1 %> + hostname: vaucanson + kernel_name: Linux + kernel_revision: 2.6.10-1.760_FC3smp + kernel_version: "#1 SMP Wed Feb 2 00:29:03 EST 2005" + host_type: i686 + os_name: GNU/Linux + comp_name: g++ + comp_version: 4.0.1 + comp_flags: -02 -W -Wall + mem_size: 4151600 + cpu_name: "Intel(R) Xeon(TM) CPU 3.20GHz" + cpu_frequency: 3194.224 info: | Running action system SYSTEM UNAME: CYGWIN_NT-5.1 pau 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin Index: web/ranch/app/models/system.rb --- web/ranch/app/models/system.rb (revision 51) +++ web/ranch/app/models/system.rb (working copy) @@ -2,15 +2,31 @@ has_many :output - validates_presence_of :hostname + validates_presence_of(:hostname, + :kernel_name, :kernel_revision, :kernel_version, + :host_type, + :os_name, + :comp_name, :comp_version, :comp_flags, + :mem_size, + :cpu_name, :cpu_frequency) validates_length_of :hostname, :maximum => 128 validates_length_of :kernel_name, :maximum => 128 + validates_length_of :kernel_revision, :maximum => 128 validates_length_of :kernel_version, :maximum => 128 validates_length_of :host_type, :maximum => 128 validates_length_of :os_name, :maximum => 128 - validates_length_of :os_version, :maximum => 128 validates_length_of :comp_name, :maximum => 128 validates_length_of :comp_version, :maximum => 128 - validates_length_of :comp_flags, :maximum => 128 + validates_length_of :comp_flags, :maximum => 255 + validates_numericality_of :mem_size, :only_integer => true + validates_length_of :mem_size, :maximum => 255 + validates_length_of :cpu_name, :maximum => 128 + validates_numericality_of :cpu_frequency + + protected + + def validate + errors.add("mem_size", "is not positive") unless mem_size.to_i > 0 + end end Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 51) +++ web/ranch/db/schema.rb (working copy) @@ -40,14 +40,17 @@ create_table "systems", :force => true do |t| t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false - t.column "kernel_name", :string, :limit => 64 - t.column "kernel_version", :string, :limit => 64 - t.column "host_type", :string, :limit => 64 - t.column "os_name", :string, :limit => 64 - t.column "os_version", :string, :limit => 64 - t.column "comp_name", :string, :limit => 64 - t.column "comp_version", :string, :limit => 64 - t.column "comp_flags", :string, :limit => 64 + t.column "kernel_name", :string, :limit => 128, :default => "", :null => false + t.column "kernel_revision", :string, :limit => 128, :default => "", :null => false + t.column "kernel_version", :string, :limit => 128, :default => "", :null => false + t.column "host_type", :string, :limit => 128, :default => "", :null => false + t.column "os_name", :string, :limit => 128, :default => "", :null => false + t.column "comp_name", :string, :limit => 128, :default => "", :null => false + t.column "comp_version", :string, :limit => 128, :default => "", :null => false + t.column "comp_flags", :string, :default => "", :null => false + t.column "mem_size", :integer, :default => 0, :null => false + t.column "cpu_name", :string, :limit => 128, :default => "", :null => false + t.column "cpu_frequency", :float, :default => 0.0, :null => false t.column "info", :text end