Scaffolding in some mashy stuff
This commit is contained in:
parent
fedeefef98
commit
57f63fd62f
@ -4,6 +4,7 @@ gem 'rails', '2.3.2'
|
||||
gem 'active_presenter', '1.2.1'
|
||||
gem 'activesupport', '2.3.2'
|
||||
gem 'awesome_print', '0.2.1', :require => 'ap'
|
||||
gem 'haml'
|
||||
gem 'mc-settings'
|
||||
gem 'mongrel', '1.1.5'
|
||||
gem 'nokogiri', '1.4.3.1'
|
||||
|
@ -44,6 +44,7 @@ GEM
|
||||
em-websocket (>= 0.2.0)
|
||||
guard (>= 0.10.0)
|
||||
multi_json (~> 1.0)
|
||||
haml (3.1.1)
|
||||
kgio (2.7.2)
|
||||
launchy (0.3.7)
|
||||
configuration (>= 0.0.5)
|
||||
@ -167,6 +168,7 @@ DEPENDENCIES
|
||||
foreman
|
||||
guard
|
||||
guard-livereload
|
||||
haml
|
||||
launchy (= 0.3.7)
|
||||
machinist (= 1.0.6)
|
||||
mc-settings
|
||||
|
85
rails/map-mash/app/controllers/mashes_controller.rb
Normal file
85
rails/map-mash/app/controllers/mashes_controller.rb
Normal file
@ -0,0 +1,85 @@
|
||||
class MashesController < ApplicationController
|
||||
# GET /mashes
|
||||
# GET /mashes.xml
|
||||
def index
|
||||
@mashes = Mash.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @mashes }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /mashes/1
|
||||
# GET /mashes/1.xml
|
||||
def show
|
||||
@mash = Mash.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @mash }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /mashes/new
|
||||
# GET /mashes/new.xml
|
||||
def new
|
||||
@mash = Mash.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @mash }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /mashes/1/edit
|
||||
def edit
|
||||
@mash = Mash.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /mashes
|
||||
# POST /mashes.xml
|
||||
def create
|
||||
@mash = Mash.new(params[:mash])
|
||||
|
||||
respond_to do |format|
|
||||
if @mash.save
|
||||
flash[:notice] = 'Mash was successfully created.'
|
||||
format.html { redirect_to(@mash) }
|
||||
format.xml { render :xml => @mash, :status => :created, :location => @mash }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /mashes/1
|
||||
# PUT /mashes/1.xml
|
||||
def update
|
||||
@mash = Mash.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @mash.update_attributes(params[:mash])
|
||||
flash[:notice] = 'Mash was successfully updated.'
|
||||
format.html { redirect_to(@mash) }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
format.xml { render :xml => @mash.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /mashes/1
|
||||
# DELETE /mashes/1.xml
|
||||
def destroy
|
||||
@mash = Mash.find(params[:id])
|
||||
@mash.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(mashes_url) }
|
||||
format.xml { head :ok }
|
||||
end
|
||||
end
|
||||
end
|
2
rails/map-mash/app/helpers/mashes_helper.rb
Normal file
2
rails/map-mash/app/helpers/mashes_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module MashesHelper
|
||||
end
|
2
rails/map-mash/app/models/map.rb
Normal file
2
rails/map-mash/app/models/map.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class Map < ActiveRecord::Base
|
||||
end
|
2
rails/map-mash/app/models/mash.rb
Normal file
2
rails/map-mash/app/models/mash.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class Mash < ActiveRecord::Base
|
||||
end
|
17
rails/map-mash/app/views/layouts/mashes.html.erb
Normal file
17
rails/map-mash/app/views/layouts/mashes.html.erb
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Mashes: <%= controller.action_name %></title>
|
||||
<%= stylesheet_link_tag 'scaffold' %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p style="color: green"><%= flash[:notice] %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
28
rails/map-mash/app/views/mashes/edit.html.erb
Normal file
28
rails/map-mash/app/views/mashes/edit.html.erb
Normal file
@ -0,0 +1,28 @@
|
||||
<h1>Editing mash</h1>
|
||||
|
||||
<% form_for(@mash) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :requester %><br />
|
||||
<%= f.text_field :requester %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_a %><br />
|
||||
<%= f.text_field :map_a %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_b %><br />
|
||||
<%= f.text_field :map_b %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :winner %><br />
|
||||
<%= f.text_field :winner %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Update' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Show', @mash %> |
|
||||
<%= link_to 'Back', mashes_path %>
|
26
rails/map-mash/app/views/mashes/index.html.erb
Normal file
26
rails/map-mash/app/views/mashes/index.html.erb
Normal file
@ -0,0 +1,26 @@
|
||||
<h1>Listing mashes</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Requester</th>
|
||||
<th>Map a</th>
|
||||
<th>Map b</th>
|
||||
<th>Winner</th>
|
||||
</tr>
|
||||
|
||||
<% @mashes.each do |mash| %>
|
||||
<tr>
|
||||
<td><%=h mash.requester %></td>
|
||||
<td><%=h mash.map_a %></td>
|
||||
<td><%=h mash.map_b %></td>
|
||||
<td><%=h mash.winner %></td>
|
||||
<td><%= link_to 'Show', mash %></td>
|
||||
<td><%= link_to 'Edit', edit_mash_path(mash) %></td>
|
||||
<td><%= link_to 'Destroy', mash, :confirm => 'Are you sure?', :method => :delete %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New mash', new_mash_path %>
|
27
rails/map-mash/app/views/mashes/new.html.erb
Normal file
27
rails/map-mash/app/views/mashes/new.html.erb
Normal file
@ -0,0 +1,27 @@
|
||||
<h1>New mash</h1>
|
||||
|
||||
<% form_for(@mash) do |f| %>
|
||||
<%= f.error_messages %>
|
||||
|
||||
<p>
|
||||
<%= f.label :requester %><br />
|
||||
<%= f.text_field :requester %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_a %><br />
|
||||
<%= f.text_field :map_a %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :map_b %><br />
|
||||
<%= f.text_field :map_b %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :winner %><br />
|
||||
<%= f.text_field :winner %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.submit 'Create' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Back', mashes_path %>
|
23
rails/map-mash/app/views/mashes/show.html.erb
Normal file
23
rails/map-mash/app/views/mashes/show.html.erb
Normal file
@ -0,0 +1,23 @@
|
||||
<p>
|
||||
<b>Requester:</b>
|
||||
<%=h @mash.requester %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Map a:</b>
|
||||
<%=h @mash.map_a %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Map b:</b>
|
||||
<%=h @mash.map_b %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Winner:</b>
|
||||
<%=h @mash.winner %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_mash_path(@mash) %> |
|
||||
<%= link_to 'Back', mashes_path %>
|
@ -1,43 +1,4 @@
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
|
||||
# Sample of regular route:
|
||||
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
||||
# Keep in mind you can assign values other than :controller and :action
|
||||
|
||||
# Sample of named route:
|
||||
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
||||
# This route can be invoked with purchase_url(:id => product.id)
|
||||
|
||||
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
||||
# map.resources :products
|
||||
|
||||
# Sample resource route with options:
|
||||
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
||||
|
||||
# Sample resource route with sub-resources:
|
||||
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
||||
|
||||
# Sample resource route with more complex sub-resources
|
||||
# map.resources :products do |products|
|
||||
# products.resources :comments
|
||||
# products.resources :sales, :collection => { :recent => :get }
|
||||
# end
|
||||
|
||||
# Sample resource route within a namespace:
|
||||
# map.namespace :admin do |admin|
|
||||
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
||||
# admin.resources :products
|
||||
# end
|
||||
|
||||
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
||||
# map.root :controller => "welcome"
|
||||
|
||||
# See how all your routes lay out with "rake routes"
|
||||
|
||||
# Install the default routes as the lowest priority.
|
||||
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
||||
# consider removing the them or commenting them out if you're using named routes and resources.
|
||||
map.connect ':controller/:action/:id'
|
||||
map.connect ':controller/:action/:id.:format'
|
||||
map.root :controller => 'mashes', :action => 'index'
|
||||
map.resources :mashes
|
||||
end
|
||||
|
13
rails/map-mash/db/migrate/20120304151123_create_maps.rb
Normal file
13
rails/map-mash/db/migrate/20120304151123_create_maps.rb
Normal file
@ -0,0 +1,13 @@
|
||||
class CreateMaps < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :maps do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :maps
|
||||
end
|
||||
end
|
16
rails/map-mash/db/migrate/20120304164625_create_mashes.rb
Normal file
16
rails/map-mash/db/migrate/20120304164625_create_mashes.rb
Normal file
@ -0,0 +1,16 @@
|
||||
class CreateMashes < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :mashes do |t|
|
||||
t.string :requester
|
||||
t.integer :map_a
|
||||
t.integer :map_b
|
||||
t.integer :winner
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :mashes
|
||||
end
|
||||
end
|
@ -9,6 +9,21 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 0) do
|
||||
ActiveRecord::Schema.define(:version => 20120304164625) do
|
||||
|
||||
create_table "maps", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "mashes", :force => true do |t|
|
||||
t.string "requester"
|
||||
t.integer "map_a"
|
||||
t.integer "map_b"
|
||||
t.integer "winner"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
end
|
||||
|
0
rails/map-mash/log/.gitkeep
Normal file
0
rails/map-mash/log/.gitkeep
Normal file
@ -1,275 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<title>Ruby on Rails: Welcome aboard</title>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
margin: 0;
|
||||
margin-bottom: 25px;
|
||||
padding: 0;
|
||||
background-color: #f0f0f0;
|
||||
font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
a {color: #03c}
|
||||
a:hover {
|
||||
background-color: #03c;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
#page {
|
||||
background-color: #f0f0f0;
|
||||
width: 750px;
|
||||
margin: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#content {
|
||||
float: left;
|
||||
background-color: white;
|
||||
border: 3px solid #aaa;
|
||||
border-top: none;
|
||||
padding: 25px;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
float: right;
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
|
||||
#header, #about, #getting-started {
|
||||
padding-left: 75px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
|
||||
#header {
|
||||
background-image: url("images/rails.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: top left;
|
||||
height: 64px;
|
||||
}
|
||||
#header h1, #header h2 {margin: 0}
|
||||
#header h2 {
|
||||
color: #888;
|
||||
font-weight: normal;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
|
||||
#about h3 {
|
||||
margin: 0;
|
||||
margin-bottom: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#about-content {
|
||||
background-color: #ffd;
|
||||
border: 1px solid #fc0;
|
||||
margin-left: -11px;
|
||||
}
|
||||
#about-content table {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 11px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
#about-content td {
|
||||
padding: 10px;
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
#about-content td.name {color: #555}
|
||||
#about-content td.value {color: #000}
|
||||
|
||||
#about-content.failure {
|
||||
background-color: #fcc;
|
||||
border: 1px solid #f00;
|
||||
}
|
||||
#about-content.failure p {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
||||
#getting-started {
|
||||
border-top: 1px solid #ccc;
|
||||
margin-top: 25px;
|
||||
padding-top: 15px;
|
||||
}
|
||||
#getting-started h1 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
#getting-started h2 {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
color: #333;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
#getting-started ol {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
#getting-started li {
|
||||
font-size: 18px;
|
||||
color: #888;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
#getting-started li h2 {
|
||||
margin: 0;
|
||||
font-weight: normal;
|
||||
font-size: 18px;
|
||||
color: #333;
|
||||
}
|
||||
#getting-started li p {
|
||||
color: #555;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
#search {
|
||||
margin: 0;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
#search input {
|
||||
font-size: 11px;
|
||||
margin: 2px;
|
||||
}
|
||||
#search-text {width: 170px}
|
||||
|
||||
|
||||
#sidebar ul {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
#sidebar ul h3 {
|
||||
margin-top: 25px;
|
||||
font-size: 16px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
#sidebar li {
|
||||
list-style-type: none;
|
||||
}
|
||||
#sidebar ul.links li {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script type="text/javascript" src="javascripts/prototype.js"></script>
|
||||
<script type="text/javascript" src="javascripts/effects.js"></script>
|
||||
<script type="text/javascript">
|
||||
function about() {
|
||||
if (Element.empty('about-content')) {
|
||||
new Ajax.Updater('about-content', 'rails/info/properties', {
|
||||
method: 'get',
|
||||
onFailure: function() {Element.classNames('about-content').add('failure')},
|
||||
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
|
||||
});
|
||||
} else {
|
||||
new Effect[Element.visible('about-content') ?
|
||||
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
$('search-text').value = '';
|
||||
$('search').onsubmit = function() {
|
||||
$('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="page">
|
||||
<div id="sidebar">
|
||||
<ul id="sidebar-items">
|
||||
<li>
|
||||
<form id="search" action="http://www.google.com/search" method="get">
|
||||
<input type="hidden" name="hl" value="en" />
|
||||
<input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
|
||||
<input type="submit" value="Search" /> the Rails site
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<h3>Join the community</h3>
|
||||
<ul class="links">
|
||||
<li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
|
||||
<li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
|
||||
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<h3>Browse the documentation</h3>
|
||||
<ul class="links">
|
||||
<li><a href="http://api.rubyonrails.org/">Rails API</a></li>
|
||||
<li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
|
||||
<li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
|
||||
<li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<div id="header">
|
||||
<h1>Welcome aboard</h1>
|
||||
<h2>You’re riding Ruby on Rails!</h2>
|
||||
</div>
|
||||
|
||||
<div id="about">
|
||||
<h3><a href="rails/info/properties" onclick="about(); return false">About your application’s environment</a></h3>
|
||||
<div id="about-content" style="display: none"></div>
|
||||
</div>
|
||||
|
||||
<div id="getting-started">
|
||||
<h1>Getting started</h1>
|
||||
<h2>Here’s how to get rolling:</h2>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
|
||||
<p>To see all available options, run it without parameters.</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<h2>Set up a default route and remove or rename this file</h2>
|
||||
<p>Routes are set up in config/routes.rb.</p>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<h2>Create your database</h2>
|
||||
<p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer"> </div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,5 +1,2 @@
|
||||
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
||||
#
|
||||
# To ban all spiders from the entire site uncomment the next two lines:
|
||||
# User-Agent: *
|
||||
# Disallow: /
|
||||
User-Agent: *
|
||||
Disallow: /
|
||||
|
54
rails/map-mash/public/stylesheets/scaffold.css
Normal file
54
rails/map-mash/public/stylesheets/scaffold.css
Normal file
@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
|
131
rails/map-mash/spec/controllers/mashes_controller_spec.rb
Normal file
131
rails/map-mash/spec/controllers/mashes_controller_spec.rb
Normal file
@ -0,0 +1,131 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesController do
|
||||
|
||||
def mock_mash(stubs={})
|
||||
@mock_mash ||= mock_model(Mash, stubs)
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all mashes as @mashes" do
|
||||
Mash.stub(:find).with(:all).and_return([mock_mash])
|
||||
get :index
|
||||
assigns[:mashes].should == [mock_mash]
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested mash as @mash" do
|
||||
Mash.stub(:find).with("37").and_return(mock_mash)
|
||||
get :show, :id => "37"
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new mash as @mash" do
|
||||
Mash.stub(:new).and_return(mock_mash)
|
||||
get :new
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested mash as @mash" do
|
||||
Mash.stub(:find).with("37").and_return(mock_mash)
|
||||
get :edit, :id => "37"
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
|
||||
describe "with valid params" do
|
||||
it "assigns a newly created mash as @mash" do
|
||||
Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => true))
|
||||
post :create, :mash => {:these => 'params'}
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
|
||||
it "redirects to the created mash" do
|
||||
Mash.stub(:new).and_return(mock_mash(:save => true))
|
||||
post :create, :mash => {}
|
||||
response.should redirect_to(mash_url(mock_mash))
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns a newly created but unsaved mash as @mash" do
|
||||
Mash.stub(:new).with({'these' => 'params'}).and_return(mock_mash(:save => false))
|
||||
post :create, :mash => {:these => 'params'}
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
Mash.stub(:new).and_return(mock_mash(:save => false))
|
||||
post :create, :mash => {}
|
||||
response.should render_template('new')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
|
||||
describe "with valid params" do
|
||||
it "updates the requested mash" do
|
||||
Mash.should_receive(:find).with("37").and_return(mock_mash)
|
||||
mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
|
||||
put :update, :id => "37", :mash => {:these => 'params'}
|
||||
end
|
||||
|
||||
it "assigns the requested mash as @mash" do
|
||||
Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
|
||||
put :update, :id => "1"
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
|
||||
it "redirects to the mash" do
|
||||
Mash.stub(:find).and_return(mock_mash(:update_attributes => true))
|
||||
put :update, :id => "1"
|
||||
response.should redirect_to(mash_url(mock_mash))
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "updates the requested mash" do
|
||||
Mash.should_receive(:find).with("37").and_return(mock_mash)
|
||||
mock_mash.should_receive(:update_attributes).with({'these' => 'params'})
|
||||
put :update, :id => "37", :mash => {:these => 'params'}
|
||||
end
|
||||
|
||||
it "assigns the mash as @mash" do
|
||||
Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
|
||||
put :update, :id => "1"
|
||||
assigns[:mash].should equal(mock_mash)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
Mash.stub(:find).and_return(mock_mash(:update_attributes => false))
|
||||
put :update, :id => "1"
|
||||
response.should render_template('edit')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
it "destroys the requested mash" do
|
||||
Mash.should_receive(:find).with("37").and_return(mock_mash)
|
||||
mock_mash.should_receive(:destroy)
|
||||
delete :destroy, :id => "37"
|
||||
end
|
||||
|
||||
it "redirects to the mashes list" do
|
||||
Mash.stub(:find).and_return(mock_mash(:destroy => true))
|
||||
delete :destroy, :id => "1"
|
||||
response.should redirect_to(mashes_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
13
rails/map-mash/spec/fixtures/mashes.yml
vendored
Normal file
13
rails/map-mash/spec/fixtures/mashes.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
requester: MyString
|
||||
map_a: 1
|
||||
map_b: 1
|
||||
winner: 1
|
||||
|
||||
two:
|
||||
requester: MyString
|
||||
map_a: 1
|
||||
map_b: 1
|
||||
winner: 1
|
11
rails/map-mash/spec/helpers/mashes_helper_spec.rb
Normal file
11
rails/map-mash/spec/helpers/mashes_helper_spec.rb
Normal file
@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesHelper do
|
||||
|
||||
#Delete this example and add some real ones or delete this file
|
||||
it "is included in the helper object" do
|
||||
included_modules = (class << helper; self; end).send :included_modules
|
||||
included_modules.should include(MashesHelper)
|
||||
end
|
||||
|
||||
end
|
4
rails/map-mash/spec/integration/mashes_spec.rb
Normal file
4
rails/map-mash/spec/integration/mashes_spec.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Mashes" do
|
||||
end
|
13
rails/map-mash/spec/models/map_spec.rb
Normal file
13
rails/map-mash/spec/models/map_spec.rb
Normal file
@ -0,0 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Map do
|
||||
before(:each) do
|
||||
@valid_attributes = {
|
||||
:name => "value for name"
|
||||
}
|
||||
end
|
||||
|
||||
it "should create a new instance given valid attributes" do
|
||||
Map.create!(@valid_attributes)
|
||||
end
|
||||
end
|
33
rails/map-mash/spec/routing/mashes_routing_spec.rb
Normal file
33
rails/map-mash/spec/routing/mashes_routing_spec.rb
Normal file
@ -0,0 +1,33 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MashesController do
|
||||
describe "routing" do
|
||||
it "recognizes and generates #index" do
|
||||
{ :get => "/mashes" }.should route_to(:controller => "mashes", :action => "index")
|
||||
end
|
||||
|
||||
it "recognizes and generates #new" do
|
||||
{ :get => "/mashes/new" }.should route_to(:controller => "mashes", :action => "new")
|
||||
end
|
||||
|
||||
it "recognizes and generates #show" do
|
||||
{ :get => "/mashes/1" }.should route_to(:controller => "mashes", :action => "show", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #edit" do
|
||||
{ :get => "/mashes/1/edit" }.should route_to(:controller => "mashes", :action => "edit", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #create" do
|
||||
{ :post => "/mashes" }.should route_to(:controller => "mashes", :action => "create")
|
||||
end
|
||||
|
||||
it "recognizes and generates #update" do
|
||||
{ :put => "/mashes/1" }.should route_to(:controller => "mashes", :action => "update", :id => "1")
|
||||
end
|
||||
|
||||
it "recognizes and generates #destroy" do
|
||||
{ :delete => "/mashes/1" }.should route_to(:controller => "mashes", :action => "destroy", :id => "1")
|
||||
end
|
||||
end
|
||||
end
|
26
rails/map-mash/spec/views/mashes/edit.html.erb_spec.rb
Normal file
26
rails/map-mash/spec/views/mashes/edit.html.erb_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mashes/edit.html.erb" do
|
||||
include MashesHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mash] = @mash = stub_model(Mash,
|
||||
:new_record? => false,
|
||||
:requester => "value for requester",
|
||||
:map_a => 1,
|
||||
:map_b => 1,
|
||||
:winner => 1
|
||||
)
|
||||
end
|
||||
|
||||
it "renders the edit mash form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=#{mash_path(@mash)}][method=post]") do
|
||||
with_tag('input#mash_requester[name=?]', "mash[requester]")
|
||||
with_tag('input#mash_map_a[name=?]', "mash[map_a]")
|
||||
with_tag('input#mash_map_b[name=?]', "mash[map_b]")
|
||||
with_tag('input#mash_winner[name=?]', "mash[winner]")
|
||||
end
|
||||
end
|
||||
end
|
30
rails/map-mash/spec/views/mashes/index.html.erb_spec.rb
Normal file
30
rails/map-mash/spec/views/mashes/index.html.erb_spec.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mashes/index.html.erb" do
|
||||
include MashesHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mashes] = [
|
||||
stub_model(Mash,
|
||||
:requester => "value for requester",
|
||||
:map_a => 1,
|
||||
:map_b => 1,
|
||||
:winner => 1
|
||||
),
|
||||
stub_model(Mash,
|
||||
:requester => "value for requester",
|
||||
:map_a => 1,
|
||||
:map_b => 1,
|
||||
:winner => 1
|
||||
)
|
||||
]
|
||||
end
|
||||
|
||||
it "renders a list of mashes" do
|
||||
render
|
||||
response.should have_tag("tr>td", "value for requester".to_s, 2)
|
||||
response.should have_tag("tr>td", 1.to_s, 2)
|
||||
response.should have_tag("tr>td", 1.to_s, 2)
|
||||
response.should have_tag("tr>td", 1.to_s, 2)
|
||||
end
|
||||
end
|
26
rails/map-mash/spec/views/mashes/new.html.erb_spec.rb
Normal file
26
rails/map-mash/spec/views/mashes/new.html.erb_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mashes/new.html.erb" do
|
||||
include MashesHelper
|
||||
|
||||
before(:each) do
|
||||
assigns[:mash] = stub_model(Mash,
|
||||
:new_record? => true,
|
||||
:requester => "value for requester",
|
||||
:map_a => 1,
|
||||
:map_b => 1,
|
||||
:winner => 1
|
||||
)
|
||||
end
|
||||
|
||||
it "renders new mash form" do
|
||||
render
|
||||
|
||||
response.should have_tag("form[action=?][method=post]", mashes_path) do
|
||||
with_tag("input#mash_requester[name=?]", "mash[requester]")
|
||||
with_tag("input#mash_map_a[name=?]", "mash[map_a]")
|
||||
with_tag("input#mash_map_b[name=?]", "mash[map_b]")
|
||||
with_tag("input#mash_winner[name=?]", "mash[winner]")
|
||||
end
|
||||
end
|
||||
end
|
21
rails/map-mash/spec/views/mashes/show.html.erb_spec.rb
Normal file
21
rails/map-mash/spec/views/mashes/show.html.erb_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "/mashes/show.html.erb" do
|
||||
include MashesHelper
|
||||
before(:each) do
|
||||
assigns[:mash] = @mash = stub_model(Mash,
|
||||
:requester => "value for requester",
|
||||
:map_a => 1,
|
||||
:map_b => 1,
|
||||
:winner => 1
|
||||
)
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
response.should have_text(/value\ for\ requester/)
|
||||
response.should have_text(/1/)
|
||||
response.should have_text(/1/)
|
||||
response.should have_text(/1/)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user