
https://svn.lrde.epita.fr/svn/ranch/trunk Index: ChangeLog from Nicolas Desprès <nicolas.despres@lrde.epita.fr> Move the revision field from benches to outputs. * web/ranch/db/schema.rb: Move the revision field from the benches table to the outputs table. * web/ranch/test/unit/bench_test.rb, * web/ranch/test/unit/output_test.rb, * web/ranch/test/fixtures/outputs.yml, * web/ranch/test/fixtures/benches.yml, * web/ranch/app/models/bench.rb, * web/ranch/app/models/output.rb: Update. app/models/bench.rb | 11 +---------- app/models/output.rb | 6 +++++- db/schema.rb | 9 ++------- test/fixtures/benches.yml | 4 ---- test/fixtures/outputs.yml | 1 + test/unit/bench_test.rb | 5 ----- test/unit/output_test.rb | 5 +++++ 7 files changed, 14 insertions(+), 27 deletions(-) Index: web/ranch/test/unit/bench_test.rb --- web/ranch/test/unit/bench_test.rb (revision 38) +++ web/ranch/test/unit/bench_test.rb (working copy) @@ -12,11 +12,6 @@ assert !bench.save end - def test_save_presence_of_revision - bench = Bench.new(:name => 'foo', :revision => 0) - assert !bench.save - end - def test_save_maximum_lenght_of_name bench = Bench.new(:name => '' * 256) assert !bench.save Index: web/ranch/test/unit/output_test.rb --- web/ranch/test/unit/output_test.rb (revision 38) +++ web/ranch/test/unit/output_test.rb (working copy) @@ -17,4 +17,9 @@ assert !output.save end + def test_save_presence_of_revision + output = Output.new(:name => 'foo', :revision => 0) + assert !output.save + end + end Index: web/ranch/test/fixtures/outputs.yml --- web/ranch/test/fixtures/outputs.yml (revision 38) +++ web/ranch/test/fixtures/outputs.yml (working copy) @@ -22,6 +22,7 @@ arg_num: <%= arg_num += 1 %> set_num: <%= set_num %> system_id: 0 + revision: <%= rev %> <% end %> <% set_num += 1 Index: web/ranch/test/fixtures/benches.yml --- web/ranch/test/fixtures/benches.yml (revision 38) +++ web/ranch/test/fixtures/benches.yml (working copy) @@ -5,24 +5,20 @@ id: <%= id += 1 %> project_id: 1 name: determinize - revision: <%= rev %> <% end %> quotient: id: <%= id += 1 %> project_id: 1 name: quotient - revision: 1 open: id: <%= id += 1 %> project_id: 2 name: open - revision: 1 close: id: <%= id += 1 %> project_id: 2 name: close - revision: 1 Index: web/ranch/app/models/bench.rb --- web/ranch/app/models/bench.rb (revision 38) +++ web/ranch/app/models/bench.rb (working copy) @@ -3,16 +3,7 @@ belongs_to :project has_many :output - validates_presence_of :name, :revision - validates_numericality_of :revision, :only_integer => true + validates_presence_of :name validates_length_of :name, :maximum => 255 - protected - - def validate - unless revision.to_i > 0 - errors.add("revision", "is not positive") - end - end - end Index: web/ranch/app/models/output.rb --- web/ranch/app/models/output.rb (revision 38) +++ web/ranch/app/models/output.rb (working copy) @@ -3,9 +3,10 @@ belongs_to :bench belongs_to :system - validates_presence_of :name, :value, :arg_num, :set_num + validates_presence_of :name, :value, :arg_num, :set_num, :revision validates_numericality_of :value validates_numericality_of :arg_num, :set_num, :only_integer => true + validates_numericality_of :revision, :only_integer => true validates_length_of :name, :unit, :maximum => 128 protected @@ -13,6 +14,9 @@ def validate errors.add("arg_num", "is not positive") unless arg_num.to_i >= 0 errors.add("set_num", "is not positive") unless set_num.to_i >= 0 + unless revision.to_i > 0 + errors.add("revision", "is not positive") + end end end Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 38) +++ web/ranch/db/schema.rb (working copy) @@ -5,9 +5,8 @@ ActiveRecord::Schema.define() do create_table "benches", :force => true do |t| - t.column "name", :string, :limit => 255, :default => "noname", :null => false + t.column "name", :string, :default => "noname", :null => false t.column "project_id", :integer, :default => 1, :null => false - t.column "revision", :integer, :default => 1, :null => false end add_index "benches", ["project_id"], :name => "project_id" @@ -29,6 +28,7 @@ t.column "arg_num", :integer, :limit => 8, :default => 1, :null => false t.column "set_num", :integer, :default => 0, :null => false t.column "system_id", :integer, :default => 1, :null => false + t.column "revision", :integer, :default => 1, :null => false end add_index "outputs", ["bench_id"], :name => "bench_id" @@ -40,11 +40,6 @@ create_table "systems", :force => true do |t| t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false - t.column "info", :text, :default => "", :null => false - end - - 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