[ranch] 9: Add projects list page.

https://svn.lrde.epita.fr/svn/ranch/trunk Index: ChangeLog from Nicolas Despr�s <nicolas.despres@gmail.com> Add projects list page. * web/ranch/test/unit/project_test.rb: New. Test the projet controller. * web/ranch/test/test_helper.rb: Ask to reinitialize the test db for each test in order to avoid conflict between tests. * web/ranch/test/functional/projects_controller_test.rb: New. * web/ranch/test/fixtures/projects.yml: New. Fixtures to test fill the project table with. * web/ranch/app/helpers/projects_helper.rb: New. * web/ranch/app/models/project.rb: New. Model mapped on the projects table. * web/ranch/app/controllers/projects_controller.rb: New. * web/ranch/app/views/layouts/ranch.rhtml: New. Layout of the web application. * web/ranch/app/views/projects: New. View for the project controller. * web/ranch/app/views/projects/list.rhtml: New. View of the list request of the projets controller. * web/ranch/config/routes.rb: Route the front page to the project controller index. * web/ranch/config/database.yml: Add location and access to our databases. * web/ranch/db/schema.rb: New. Structure of our database. * web/ranch/public/index.html: Remove. Drop the default front page. * web/ranch/public/stylesheets/scaffold.css: New. Stylesheet of the application. * web/ranch/log/test.log, web/ranch/log/development.log, * web/ranch/log/production.log, * web/ranch/log/server.log: Remove. We don't versioned log files. app/controllers/projects_controller.rb | 14 +++++ app/helpers/projects_helper.rb | 2 app/models/project.rb | 2 app/views/layouts/ranch.rhtml | 21 +++++++ app/views/projects/list.rhtml | 25 +++++++++ config/database.yml | 12 ++-- config/routes.rb | 2 db/schema.rb | 11 ++++ public/stylesheets/scaffold.css | 74 ++++++++++++++++++++++++++++ test/fixtures/projects.yml | 8 +++ test/functional/projects_controller_test.rb | 31 +++++++++++ test/test_helper.rb | 2 test/unit/project_test.rb | 10 +++ 13 files changed, 206 insertions(+), 8 deletions(-) Index: web/ranch/test/unit/project_test.rb --- web/ranch/test/unit/project_test.rb (revision 0) +++ web/ranch/test/unit/project_test.rb (revision 0) @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ProjectTest < Test::Unit::TestCase + fixtures :projects + + # Replace this with your real tests. + def test_truth + assert_kind_of Project, projects(:first) + end +end Index: web/ranch/test/test_helper.rb --- web/ranch/test/test_helper.rb (revision 8) +++ web/ranch/test/test_helper.rb (working copy) @@ -15,7 +15,7 @@ # in MySQL. Turn off transactional fixtures in this case; however, if you # don't care one way or the other, switching from MyISAM to InnoDB tables # is recommended. - self.use_transactional_fixtures = true + self.use_transactional_fixtures = false # Instantiated fixtures are slow, but give you @david where otherwise you # would need people(:david). If you don't want to migrate your existing Index: web/ranch/test/functional/projects_controller_test.rb --- web/ranch/test/functional/projects_controller_test.rb (revision 0) +++ web/ranch/test/functional/projects_controller_test.rb (revision 0) @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'projects_controller' + +# Re-raise errors caught by the controller. +class ProjectsController; def rescue_action(e) raise e end; end + +class ProjectsControllerTest < Test::Unit::TestCase + fixtures :projects + + def setup + @controller = ProjectsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_index + get :index + assert_response :success + assert_template 'list' + end + + def test_list + get :list + + assert_response :success + assert_template 'list' + + assert_not_nil assigns(:projects) + end + +end Index: web/ranch/test/fixtures/projects.yml --- web/ranch/test/fixtures/projects.yml (revision 0) +++ web/ranch/test/fixtures/projects.yml (revision 0) @@ -0,0 +1,8 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +vaucanson: + id: 1 + name: Vaucanson +olena: + id: 2 + name: Olena + Index: web/ranch/app/helpers/projects_helper.rb --- web/ranch/app/helpers/projects_helper.rb (revision 0) +++ web/ranch/app/helpers/projects_helper.rb (revision 0) @@ -0,0 +1,2 @@ +module ProjectsHelper +end Index: web/ranch/app/models/project.rb --- web/ranch/app/models/project.rb (revision 0) +++ web/ranch/app/models/project.rb (revision 0) @@ -0,0 +1,2 @@ +class Project < ActiveRecord::Base +end Index: web/ranch/app/controllers/projects_controller.rb --- web/ranch/app/controllers/projects_controller.rb (revision 0) +++ web/ranch/app/controllers/projects_controller.rb (revision 0) @@ -0,0 +1,14 @@ +class ProjectsController < ApplicationController + + layout 'ranch' + + def index + list + render :action => 'list' + end + + def list + @projects = Project.find_all + end + +end Index: web/ranch/app/views/layouts/ranch.rhtml --- web/ranch/app/views/layouts/ranch.rhtml (revision 0) +++ web/ranch/app/views/layouts/ranch.rhtml (revision 0) @@ -0,0 +1,21 @@ + <!-- -*- html -*- --> + +<html> + <head> + <title>Ranch: regression benchmark system</title> + <%= stylesheet_link_tag 'scaffold' %> + </head> + <body> + <div style="text-align: center;"> + <h1>Ranch</h1> + <hr> + </div> + + <%= @content_for_layout %> + + <div style="text-align: center;"> + <hr> + Powered by RubyOnRails + </div> + </body> +</html> Index: web/ranch/app/views/projects/list.rhtml --- web/ranch/app/views/projects/list.rhtml (revision 0) +++ web/ranch/app/views/projects/list.rhtml (revision 0) @@ -0,0 +1,25 @@ + <!-- -*- html -*- --> +<div style="text-align: center;"> +<h2>Welcome</h2> +<p> +Ranch is a regression benchmark system. +</p> +<p> +Select a project: +</p> +<p> +<center> +<table> + <% for project in @projects %> + <tr> + <td> + <%= link_to project.name, :controller => "benchmark", + :action => "index", + :id => project.id %> + </td> + </tr> + <% end %> +</table> +</center> +</p> +</div> Index: web/ranch/config/routes.rb --- web/ranch/config/routes.rb (revision 8) +++ web/ranch/config/routes.rb (working copy) @@ -8,7 +8,7 @@ # You can have the root of your site routed by hooking up '' # -- just remember to delete public/index.html. - # map.connect '', :controller => "welcome" + map.connect '', :controller => "projects" # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl' Index: web/ranch/config/database.yml --- web/ranch/config/database.yml (revision 8) +++ web/ranch/config/database.yml (working copy) @@ -8,8 +8,8 @@ development: adapter: mysql database: ranch_development - username: root - password: + username: ranch + password: ranch socket: /var/run/mysqld/mysqld.sock # Connect on a TCP socket. If omitted, the adapter will connect on the @@ -23,15 +23,15 @@ test: adapter: mysql database: ranch_test - username: root - password: + username: ranch + password: ranch socket: /var/run/mysqld/mysqld.sock production: adapter: mysql database: ranch_production - username: root - password: + username: ranch + password: ranch socket: /var/run/mysqld/mysqld.sock Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 0) +++ web/ranch/db/schema.rb (revision 0) @@ -0,0 +1,11 @@ +# This file is autogenerated. Instead of editing this file, please use the +# migrations feature of ActiveRecord to incrementally modify your database, and +# then regenerate this schema definition. + +ActiveRecord::Schema.define() do + + create_table "projects", :force => true do |t| + t.column "name", :string, :default => "noname", :null => false + end + +end Index: web/ranch/public/stylesheets/scaffold.css --- web/ranch/public/stylesheets/scaffold.css (revision 0) +++ web/ranch/public/stylesheets/scaffold.css (revision 0) @@ -0,0 +1,74 @@ +body { background-color: #fff; color: #333; } + +body, p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { color: #000; } +a:visited { color: #666; } +a:hover { color: #fff; background-color:#000; } + +.fieldWithErrors { + padding: 2px; + background-color: red; + display: table; +} + +#ErrorExplanation { + width: 400px; + border: 2px solid red; + padding: 7px; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#ErrorExplanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + background-color: #c00; + color: #fff; +} + +#ErrorExplanation p { + color: #333; + margin-bottom: 0; + padding: 5px; +} + +#ErrorExplanation ul li { + font-size: 12px; + list-style: square; +} + +div.uploadStatus { + margin: 5px; +} + +div.progressBar { + margin: 5px; +} + +div.progressBar div.border { + background-color: #fff; + border: 1px solid grey; + width: 100%; +} + +div.progressBar div.background { + background-color: #333; + height: 18px; + width: 0%; +} +
participants (1)
-
Nicolas Despr�s