https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Desprès <nicolas.despres(a)gmail.com>
First draft of the graph form.
* web/ranch/test/functional/graph_form_controller_test.rb: New. Test
the controller.
* web/ranch/app/helpers/graph_form_helper.rb: New.
* web/ranch/app/controllers/graph_form_controller.rb: New. Control
the form.
* web/ranch/app/views/graph_form: New.
* web/ranch/app/views/graph_form/index.rhtml: New. View of the
form.
* web/ranch/app/views/benches/list.rhtml: Link to graph_form instead
of graph.
* web/ranch/db/schema.rb: Add the revision field.
app/controllers/graph_form_controller.rb | 10 ++++++++++
app/helpers/graph_form_helper.rb | 2 ++
app/views/benches/list.rhtml | 2 +-
app/views/graph_form/index.rhtml | 24 ++++++++++++++++++++++++
db/schema.rb | 1 +
test/functional/graph_form_controller_test.rb | 25 +++++++++++++++++++++++++
6 files changed, 63 insertions(+), 1 deletion(-)
Index: web/ranch/test/functional/graph_form_controller_test.rb
--- web/ranch/test/functional/graph_form_controller_test.rb (revision 0)
+++ web/ranch/test/functional/graph_form_controller_test.rb (revision 0)
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'graph_form_controller'
+
+# Re-raise errors caught by the controller.
+class GraphFormController; def rescue_action(e) raise e end; end
+
+class GraphFormControllerTest < Test::Unit::TestCase
+ fixtures :projects, :benches
+
+ def setup
+ @controller = GraphFormController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ # Replace this with your real tests.
+ def test_truth
+ get :index, { :project_id => 1, :bench_name => 'determinize' }
+ assert_response :success
+ assert_template 'index'
+
+ assert_not_nil assigns(:project)
+ assert_not_nil assigns(:bench_name)
+ end
+end
Index: web/ranch/app/helpers/graph_form_helper.rb
--- web/ranch/app/helpers/graph_form_helper.rb (revision 0)
+++ web/ranch/app/helpers/graph_form_helper.rb (revision 0)
@@ -0,0 +1,2 @@
+module GraphFormHelper
+end
Index: web/ranch/app/controllers/graph_form_controller.rb
--- web/ranch/app/controllers/graph_form_controller.rb (revision 0)
+++ web/ranch/app/controllers/graph_form_controller.rb (revision 0)
@@ -0,0 +1,10 @@
+class GraphFormController < ApplicationController
+
+ layout 'ranch'
+
+ def index
+ @bench_name = params[:bench_name]
+ @project = Project.find params[:project_id]
+ end
+
+end
Index: web/ranch/app/views/graph_form/index.rhtml
--- web/ranch/app/views/graph_form/index.rhtml (revision 0)
+++ web/ranch/app/views/graph_form/index.rhtml (revision 0)
@@ -0,0 +1,24 @@
+ <!-- -*- html -*- -->
+<div style="text-align: center;">
+<%= content_tag "h2", "#{(a)project.name}name}: #{@bench_name}" %>
+<%= start_form_tag :action => "draw",
+ :project_id => @project.id,
+ :bench_name => @bench_name %>
+<%= content_tag "p", "Choose a range of revision:" %>
+<p>
+<center>
+<table>
+ <tr>
+ <td>Start</td>
+ <td>Stop</td>
+ </tr>
+ <tr>
+ <td><%= text_field "revision", "start", "size"
=> 8, "value" => 0 %></td>
+ <td><%= text_field "revision", "stop", "size"
=> 8, "value" => 10 %></td>
+ </tr>
+</table>
+</center>
+</p>
+<%= submit_tag "Draw" %>
+<%= end_form_tag %>
+</div>
Index: web/ranch/app/views/benches/list.rhtml
--- web/ranch/app/views/benches/list.rhtml (revision 11)
+++ web/ranch/app/views/benches/list.rhtml (working copy)
@@ -10,7 +10,7 @@
<% for bench_name in @benches_name %>
<tr>
<td>
- <%= link_to bench_name, :controller => "graph",
+ <%= link_to bench_name, :controller => "graph_form",
:action => "index",
:project_id => @project.id,
:bench_name => bench_name %>
Index: web/ranch/db/schema.rb
--- web/ranch/db/schema.rb (revision 11)
+++ web/ranch/db/schema.rb (working copy)
@@ -7,6 +7,7 @@
create_table "benches", :force => true do |t|
t.column "name", :string, :limit => 128, :default =>
"noname", :null => false
t.column "project_id", :integer, :limit => 10, :default => 0, :null
=> false
+ t.column "revision", :integer, :limit => 10, :default => 0, :null
=> false
end
add_index "benches", ["project_id"], :name =>
"project_id"