Browse Source

Added rails fortune test

Patrick Falls 12 years ago
parent
commit
eb9e2367fa

+ 6 - 0
rails/app/controllers/hello_world_controller.rb

@@ -14,4 +14,10 @@ class HelloWorldController < ApplicationController
     end
     end
     render :json => results
     render :json => results
   end
   end
+  
+  def fortune
+    @fortunes = Fortune.all
+    @fortunes << Fortune.new(:message => "Additional fortune added at request time.")
+    @fortunes = @fortunes.sort { |x, y| x.message <=> y.message }
+  end
 end
 end

+ 4 - 0
rails/app/models/fortune.rb

@@ -0,0 +1,4 @@
+class Fortune < ActiveRecord::Base
+  self.table_name = "Fortune"
+  attr_accessible :message
+end

+ 12 - 0
rails/app/views/hello_world/fortune.html.erb

@@ -0,0 +1,12 @@
+<table>
+<tr>
+<th>id</th>
+<th>message</th>
+</tr>
+<% @fortunes.each do |fortune| %>
+<tr>
+<td><%= fortune.id %></td>
+<td><%= fortune.message %></td>
+</tr>
+<% end %>
+</table>

+ 1 - 3
rails/app/views/layouts/application.html.erb

@@ -1,11 +1,9 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
 <head>
 <head>
-  <title>Hello World</title>
+<title>Fortunes</title>
 </head>
 </head>
 <body>
 <body>
-
 <%= yield %>
 <%= yield %>
-
 </body>
 </body>
 </html>
 </html>

+ 2 - 0
rails/benchmark_config

@@ -6,6 +6,7 @@
       "json_url": "/hello_world/json",
       "json_url": "/hello_world/json",
       "db_url": "/hello_world/db",
       "db_url": "/hello_world/db",
       "query_url": "/hello_world/db?queries=",
       "query_url": "/hello_world/db?queries=",
+      "fortune_url": "/fortune",
       "port": 8080,
       "port": 8080,
       "sort": 16
       "sort": 16
     },
     },
@@ -14,6 +15,7 @@
       "json_url": "/rails/hello_world/json",
       "json_url": "/rails/hello_world/json",
       "db_url": "/rails/hello_world/db",
       "db_url": "/rails/hello_world/db",
       "query_url": "/rails/hello_world/db?queries=",
       "query_url": "/rails/hello_world/db?queries=",
+      "fortune_url": "/fortune",
       "port": 8080,
       "port": 8080,
       "sort": 17
       "sort": 17
     }
     }

+ 1 - 0
rails/config/routes.rb

@@ -1,6 +1,7 @@
 Hello::Application.routes.draw do
 Hello::Application.routes.draw do
   get "hello_world/json"
   get "hello_world/json"
   get "hello_world/db"
   get "hello_world/db"
+  get "fortune" => "hello_world#fortune"
 
 
 
 
   # The priority is based upon order of creation:
   # The priority is based upon order of creation: