https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Despr�s <nicolas.despres(a)gmail.com>
Add the created_at field to the system table.
* web/ranch/test/unit/system_test.rb: Make the diff test
deterministic.
* web/ranch/test/fixtures/systems.yml: Add fixtures for the
created_at field.
* web/ranch/app/models/system.rb: Do not include the created_at
field in the diff.
* web/ranch/db/schema.rb: Add the created_at field.
app/models/system.rb | 10 +++++-----
db/schema.rb | 15 ++++++++-------
test/fixtures/systems.yml | 2 ++
test/unit/system_test.rb | 6 ++++--
4 files changed, 19 insertions(+), 14 deletions(-)
Index: web/ranch/test/unit/system_test.rb
--- web/ranch/test/unit/system_test.rb (revision 65)
+++ web/ranch/test/unit/system_test.rb (working copy)
@@ -35,8 +35,10 @@
end
assert ! sys1.diff?(sys2)
sys2 = systems("ouagadougou2")
- require 'pp'
- assert_equal ["cpu_frequency"], sys1.diff(sys2)
+ diff_result = sys1.diff(sys2)
+ %w(cpu_frequency).each do |x|
+ assert diff_result.include?(x), "#{x} is missing in the diff"
+ end
end
end
Index: web/ranch/test/fixtures/systems.yml
--- web/ranch/test/fixtures/systems.yml (revision 65)
+++ web/ranch/test/fixtures/systems.yml (working copy)
@@ -4,6 +4,7 @@
<%= "ouagadougou#{i}:" %>
id: <%= id += 1 %>
+ created_at: <%= "2005-11-0#{i} 18:02:50.550163 +01:00" %>
hostname: ouagadougou
kernel_name: Linux
kernel_revision: "2.4.27-2-k7"
@@ -52,6 +53,7 @@
<%= "vaucanson#{i}:" %>
id: <%= id += 1 %>
+ created_at: <%= "2005-11-1#{i} 18:02:50.550163 +01:00" %>
hostname: vaucanson
kernel_name: Linux
kernel_revision: 2.6.10-1.760_FC3smp
Index: web/ranch/app/models/system.rb
--- web/ranch/app/models/system.rb (revision 65)
+++ web/ranch/app/models/system.rb (working copy)
@@ -3,12 +3,12 @@
has_many :output
validates_presence_of(:hostname,
- :kernel_name, :kernel_revision, :kernel_version,
:host_type,
- :os_name,
- :comp_name, :comp_version, :comp_flags,
+ :cpu_name, :cpu_frequency,
:mem_size,
- :cpu_name, :cpu_frequency)
+ :comp_name, :comp_version, :comp_flags,
+ :os_name,
+ :kernel_name, :kernel_revision, :kernel_version)
validates_length_of :hostname, :maximum => 128
validates_length_of :kernel_name, :maximum => 128
validates_length_of :kernel_revision, :maximum => 128
@@ -32,7 +32,7 @@
end
def diff(other)
- except = %w( info id )
+ except = %w( info id created_at )
ret = []
attributes.each do |k, v|
if not except.include? k and v != other.attributes[k]
Index: web/ranch/db/schema.rb
--- web/ranch/db/schema.rb (revision 65)
+++ web/ranch/db/schema.rb (working copy)
@@ -39,18 +39,19 @@
end
create_table "systems", :force => true do |t|
+ t.column "created_at", :datetime, :null => false
t.column "hostname", :string, :limit => 128, :default =>
"localhost", :null => false
- 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 "cpu_frequency", :float, :default => 0.0, :null => false
+ t.column "cpu_name", :string, :limit => 128, :default =>
"", :null => false
+ t.column "mem_size", :integer, :default => 0, :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 "os_name", :string, :limit => 128, :default => "",
:null => false
+ 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 "info", :text
end