Commit bbee50f4e31870f6036067e310526eb4f9586823

Spacing conforms to Ruby standard now..

Commit diff

LICENSE

 
1Copyright (c) 2008 Social Corp.
2
3Permission is hereby granted, free of charge, to any person obtaining
4a copy of this software and associated documentation files (the
5"Software"), to deal in the Software without restriction, including
6without limitation the rights to use, copy, modify, merge, publish,
7distribute, sublicense, and/or sell copies of the Software, and to
8permit persons to whom the Software is furnished to do so, subject to
9the following conditions:
10
11The above copyright notice and this permission notice shall be
12included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
toggle raw diff

app/controllers/posts.rb

 
11class Posts < Application
22
33 def index
4 @posts = Post.find( :all, :order => "created_at DESC" )
4 @posts = Post.find(:all, :order => "created_at DESC")
55 render
66 end
77
88 def create
9 Post.create!( :body => params[:body] )
10 redirect url( :action => "index" )
9 Post.create!(:body => params[:body])
10 redirect url(:action => "index")
1111 end
1212
1313end
toggle raw diff

app/views/posts/index.html.erb

 
33
44<p>Recent Posts:</p>
55<div id="posts" class="container">
6 <%= partial( "/shared/post", :with => @posts ) %>
6 <%= partial("/shared/post", :with => @posts) %>
77</div>
88
99<p>Post Something:</p>
10<% form_tag( :action => url( :controller => "posts", :action => "create" ) ) do %>
11 <%= text_field( :name => "body", :size => 40 ) %>
12 <%= submit_button( "Post Message!" ) %>
10<% form_tag(:action => url( :controller => "posts", :action => "create") ) do %>
11 <%= text_field(:name => "body", :size => 40) %>
12 <%= submit_button("Post Message!") %>
1313<% end %>
toggle raw diff

app/views/shared/_post.html.erb

 
11<div id="post-<%= post.id %>" class="post">
2 <p class="body"><%= h( post.body ) %></p>
3 <p class="created"><%= relative_date( post.created_at ) %></p>
2 <p class="body"><%= h(post.body) %></p>
3 <p class="created"><%= relative_date(post.created_at) %></p>
44</div>
toggle raw diff

log/merb_test.log

 
13261326 WHERE `id` = 102
13271327
13281328 ~ SQL (0.000365) COMMIT
1329 ~ Loaded TEST Environment...
1330 ~ loading gem 'merb_activerecord' from ...
1331 ~ loading gem 'merb_helpers' from ...
1332 ~ loading gem 'activerecord' from ...
1333 ~ Connecting to database...
1334 ~ Compiling routes...
1335 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
1336 ~ SQL (0.021390) SET NAMES 'utf8'
1337 ~ SQL (0.000537) SET SQL_AUTO_IS_NULL=0
1338 ~ Post Load (0.028270) SELECT * FROM `posts` ORDER BY created_at DESC
1339 ~ {:action_time=>0.346355, :before_filters_time=>3.1e-05, :after_filters_time=>1.0e-05}
1340 ~ Post Columns (0.018802) SHOW FIELDS FROM `posts`
1341 ~ SQL (0.000782) SELECT count(*) AS count_all FROM `posts` 
1342 ~ SQL (0.000237) BEGIN
1343 ~ Post Create (0.001502) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'It was a good game though', '2008-04-17 00:48:57')
1344 ~ SQL (0.000501) COMMIT
1345 ~ Redirecting to: /posts/index
1346 ~ {:action_time=>0.005691, :before_filters_time=>1.4e-05, :after_filters_time=>1.3e-05}
1347 ~ SQL (0.000329) SELECT count(*) AS count_all FROM `posts` 
1348 ~ SQL (0.000117) BEGIN
1349 ~ SQL (0.000080) ROLLBACK
1350 ~ SQL (0.001053) BEGIN
1351 ~ Post Create (0.000465) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Merb Rawks', '2008-04-17 00:48:57')
1352 ~ SQL (0.000979) COMMIT
1353 ~ SQL (0.000177) BEGIN
1354 ~ Post Create (0.001740) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Like the Hawks', '2008-04-17 00:48:57')
1355 ~ SQL (0.000553) COMMIT
1356 ~ Post Load (0.000310) SELECT * FROM `posts` 
1357 ~ SQL (0.000082) BEGIN
1358 ~ Post Destroy (0.001490)  DELETE FROM `posts`
1359 WHERE `id` = 1
1360
1361 ~ SQL (0.000488) COMMIT
1362 ~ SQL (0.000145) BEGIN
1363 ~ Post Destroy (0.000178)  DELETE FROM `posts`
1364 WHERE `id` = 2
1365
1366 ~ SQL (0.000409) COMMIT
1367 ~ SQL (0.000138) BEGIN
1368 ~ Post Destroy (0.000147)  DELETE FROM `posts`
1369 WHERE `id` = 3
1370
1371 ~ SQL (0.000464) COMMIT
1372 ~ SQL (0.000287) BEGIN
1373 ~ Post Create (0.000301) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Merb Rawks', '2008-04-17 00:48:57')
1374 ~ SQL (0.000538) COMMIT
1375 ~ SQL (0.000083) BEGIN
1376 ~ Post Create (0.000220) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Like the Hawks', '2008-04-17 00:48:57')
1377 ~ SQL (0.000525) COMMIT
1378 ~ Post Load (0.000316) SELECT * FROM `posts` 
1379 ~ SQL (0.000083) BEGIN
1380 ~ Post Destroy (0.000205)  DELETE FROM `posts`
1381 WHERE `id` = 4
1382
1383 ~ SQL (0.000424) COMMIT
1384 ~ SQL (0.000133) BEGIN
1385 ~ Post Destroy (0.000156)  DELETE FROM `posts`
1386 WHERE `id` = 5
1387
1388 ~ SQL (0.000427) COMMIT
1389 ~ SQL (0.000101) BEGIN
1390 ~ Post Create (0.000360) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Merb Rawks', '2008-04-17 00:48:57')
1391 ~ SQL (0.000468) COMMIT
1392 ~ SQL (0.000119) BEGIN
1393 ~ Post Create (0.000174) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Like the Hawks', '2008-04-17 00:48:57')
1394 ~ SQL (0.000413) COMMIT
1395 ~ Post Load (0.000253) SELECT * FROM `posts` 
1396 ~ SQL (0.000080) BEGIN
1397 ~ Post Destroy (0.000194)  DELETE FROM `posts`
1398 WHERE `id` = 6
1399
1400 ~ SQL (0.000549) COMMIT
1401 ~ SQL (0.000138) BEGIN
1402 ~ Post Destroy (0.000157)  DELETE FROM `posts`
1403 WHERE `id` = 7
1404
1405 ~ SQL (0.000413) COMMIT
1406 ~ SQL (0.000107) BEGIN
1407 ~ Post Create (0.000315) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Merb Rawks', '2008-04-17 00:48:57')
1408 ~ SQL (0.000413) COMMIT
1409 ~ SQL (0.000112) BEGIN
1410 ~ Post Create (0.000203) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-17 00:48:57', 'Like the Hawks', '2008-04-17 00:48:57')
1411 ~ SQL (0.000389) COMMIT
1412 ~ Post Load (0.000334) SELECT * FROM `posts` 
1413 ~ SQL (0.000083) BEGIN
1414 ~ Post Destroy (0.000207)  DELETE FROM `posts`
1415 WHERE `id` = 8
1416
1417 ~ SQL (0.000544) COMMIT
1418 ~ SQL (0.000139) BEGIN
1419 ~ Post Destroy (0.000265)  DELETE FROM `posts`
1420 WHERE `id` = 9
1421
1422 ~ SQL (0.000464) COMMIT
1423 ~ Loaded TEST Environment...
1424 ~ loading gem 'merb_activerecord' from ...
1425 ~ loading gem 'merb_helpers' from ...
1426 ~ loading gem 'activerecord' from ...
1427 ~ Connecting to database...
1428 ~ Compiling routes...
1429 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
1430 ~ SQL (0.000242) SET NAMES 'utf8'
1431 ~ SQL (0.017911) SET SQL_AUTO_IS_NULL=0
1432 ~ Post Load (0.013901) SELECT * FROM `posts` ORDER BY created_at DESC
1433 ~ {:before_filters_time=>1.4e-05, :after_filters_time=>1.1e-05, :action_time=>0.125603}
1434 ~ Post Columns (0.018951) SHOW FIELDS FROM `posts`
1435 ~ SQL (0.000224) SELECT count(*) AS count_all FROM `posts` 
1436 ~ SQL (0.010148) BEGIN
1437 ~ Post Create (0.000388) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'It was a good game though', '2008-04-24 10:34:58')
1438 ~ SQL (0.000535) COMMIT
1439 ~ Redirecting to: /posts/index
1440 ~ {:before_filters_time=>1.4e-05, :after_filters_time=>2.0e-05, :action_time=>0.014993}
1441 ~ SQL (0.000247) SELECT count(*) AS count_all FROM `posts` 
1442 ~ SQL (0.000144) BEGIN
1443 ~ SQL (0.000089) ROLLBACK
1444 ~ SQL (0.000367) BEGIN
1445 ~ Post Create (0.000250) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Merb Rawks', '2008-04-24 10:34:58')
1446 ~ SQL (0.000511) COMMIT
1447 ~ SQL (0.000199) BEGIN
1448 ~ Post Create (0.000189) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Like the Hawks', '2008-04-24 10:34:58')
1449 ~ SQL (0.000612) COMMIT
1450 ~ Post Load (0.000323) SELECT * FROM `posts` 
1451 ~ SQL (0.000082) BEGIN
1452 ~ Post Destroy (0.000213)  DELETE FROM `posts`
1453 WHERE `id` = 1
1454
1455 ~ SQL (0.000672) COMMIT
1456 ~ SQL (0.000093) BEGIN
1457 ~ Post Destroy (0.000155)  DELETE FROM `posts`
1458 WHERE `id` = 2
1459
1460 ~ SQL (0.000415) COMMIT
1461 ~ SQL (0.000132) BEGIN
1462 ~ Post Destroy (0.000144)  DELETE FROM `posts`
1463 WHERE `id` = 3
1464
1465 ~ SQL (0.000390) COMMIT
1466 ~ SQL (0.000211) BEGIN
1467 ~ Post Create (0.000256) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Merb Rawks', '2008-04-24 10:34:58')
1468 ~ SQL (0.000443) COMMIT
1469 ~ SQL (0.000118) BEGIN
1470 ~ Post Create (0.000188) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Like the Hawks', '2008-04-24 10:34:58')
1471 ~ SQL (0.000415) COMMIT
1472 ~ Post Load (0.000921) SELECT * FROM `posts` 
1473 ~ SQL (0.000129) BEGIN
1474 ~ Post Destroy (0.000352)  DELETE FROM `posts`
1475 WHERE `id` = 4
1476
1477 ~ SQL (0.000509) COMMIT
1478 ~ SQL (0.000104) BEGIN
1479 ~ Post Destroy (0.000276)  DELETE FROM `posts`
1480 WHERE `id` = 5
1481
1482 ~ SQL (0.000529) COMMIT
1483 ~ SQL (0.000106) BEGIN
1484 ~ Post Create (0.000230) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Merb Rawks', '2008-04-24 10:34:58')
1485 ~ SQL (0.000434) COMMIT
1486 ~ SQL (0.000095) BEGIN
1487 ~ Post Create (0.000159) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Like the Hawks', '2008-04-24 10:34:58')
1488 ~ SQL (0.000429) COMMIT
1489 ~ Post Load (0.000258) SELECT * FROM `posts` 
1490 ~ SQL (0.000079) BEGIN
1491 ~ Post Destroy (0.000197)  DELETE FROM `posts`
1492 WHERE `id` = 6
1493
1494 ~ SQL (0.008884) COMMIT
1495 ~ SQL (0.000088) BEGIN
1496 ~ Post Destroy (0.000223)  DELETE FROM `posts`
1497 WHERE `id` = 7
1498
1499 ~ SQL (0.000467) COMMIT
1500 ~ SQL (0.000109) BEGIN
1501 ~ Post Create (0.000244) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Merb Rawks', '2008-04-24 10:34:58')
1502 ~ SQL (0.000463) COMMIT
1503 ~ SQL (0.000081) BEGIN
1504 ~ Post Create (0.000166) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-24 10:34:58', 'Like the Hawks', '2008-04-24 10:34:58')
1505 ~ SQL (0.000465) COMMIT
1506 ~ Post Load (0.000334) SELECT * FROM `posts` 
1507 ~ SQL (0.000082) BEGIN
1508 ~ Post Destroy (0.000204)  DELETE FROM `posts`
1509 WHERE `id` = 8
1510
1511 ~ SQL (0.000428) COMMIT
1512 ~ SQL (0.000132) BEGIN
1513 ~ Post Destroy (0.000183)  DELETE FROM `posts`
1514 WHERE `id` = 9
1515
1516 ~ SQL (0.000382) COMMIT
1517 ~ Loaded TEST Environment...
1518 ~ loading gem 'merb_activerecord' from ...
1519 ~ loading gem 'merb_helpers' from ...
1520 ~ loading gem 'activerecord' from ...
1521 ~ Connecting to database...
1522 ~ Compiling routes...
1523 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
1524 ~ SQL (0.000283) SET NAMES 'utf8'
1525 ~ SQL (0.000092) SET SQL_AUTO_IS_NULL=0
1526 ~ Post Load (0.020983) SELECT * FROM `posts` ORDER BY created_at DESC
1527 ~ {:before_filters_time=>1.4e-05, :after_filters_time=>9.0e-06, :action_time=>0.141346}
1528 ~ Post Columns (0.029512) SHOW FIELDS FROM `posts`
1529 ~ SQL (0.000287) SELECT count(*) AS count_all FROM `posts` 
1530 ~ SQL (0.000231) BEGIN
1531 ~ Post Create (0.000346) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'It was a good game though', '2008-04-26 05:46:15')
1532 ~ SQL (0.000512) COMMIT
1533 ~ Redirecting to: /posts/index
1534 ~ {:before_filters_time=>1.3e-05, :after_filters_time=>2.1e-05, :action_time=>0.004725}
1535 ~ SQL (0.000212) SELECT count(*) AS count_all FROM `posts` 
1536 ~ SQL (0.000114) BEGIN
1537 ~ SQL (0.000075) ROLLBACK
1538 ~ SQL (0.000144) BEGIN
1539 ~ Post Create (0.000235) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Merb Rawks', '2008-04-26 05:46:15')
1540 ~ SQL (0.000434) COMMIT
1541 ~ SQL (0.000103) BEGIN
1542 ~ Post Create (0.000147) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Like the Hawks', '2008-04-26 05:46:15')
1543 ~ SQL (0.000390) COMMIT
1544 ~ Post Load (0.000320) SELECT * FROM `posts` 
1545 ~ SQL (0.000077) BEGIN
1546 ~ Post Destroy (0.000199)  DELETE FROM `posts`
1547 WHERE `id` = 10
1548
1549 ~ SQL (0.020925) COMMIT
1550 ~ SQL (0.000099) BEGIN
1551 ~ Post Destroy (0.000264)  DELETE FROM `posts`
1552 WHERE `id` = 11
1553
1554 ~ SQL (0.000524) COMMIT
1555 ~ SQL (0.000145) BEGIN
1556 ~ Post Destroy (0.000164)  DELETE FROM `posts`
1557 WHERE `id` = 12
1558
1559 ~ SQL (0.000429) COMMIT
1560 ~ SQL (0.000101) BEGIN
1561 ~ Post Create (0.000211) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Merb Rawks', '2008-04-26 05:46:15')
1562 ~ SQL (0.000469) COMMIT
1563 ~ SQL (0.000097) BEGIN
1564 ~ Post Create (0.000180) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Like the Hawks', '2008-04-26 05:46:15')
1565 ~ SQL (0.000437) COMMIT
1566 ~ Post Load (0.000379) SELECT * FROM `posts` 
1567 ~ SQL (0.000091) BEGIN
1568 ~ Post Destroy (0.000240)  DELETE FROM `posts`
1569 WHERE `id` = 13
1570
1571 ~ SQL (0.000430) COMMIT
1572 ~ SQL (0.000080) BEGIN
1573 ~ Post Destroy (0.000185)  DELETE FROM `posts`
1574 WHERE `id` = 14
1575
1576 ~ SQL (0.000412) COMMIT
1577 ~ SQL (0.000128) BEGIN
1578 ~ Post Create (0.000262) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Merb Rawks', '2008-04-26 05:46:15')
1579 ~ SQL (0.000481) COMMIT
1580 ~ SQL (0.000087) BEGIN
1581 ~ Post Create (0.000150) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Like the Hawks', '2008-04-26 05:46:15')
1582 ~ SQL (0.000353) COMMIT
1583 ~ Post Load (0.000249) SELECT * FROM `posts` 
1584 ~ SQL (0.000094) BEGIN
1585 ~ Post Destroy (0.000241)  DELETE FROM `posts`
1586 WHERE `id` = 15
1587
1588 ~ SQL (0.000453) COMMIT
1589 ~ SQL (0.000128) BEGIN
1590 ~ Post Destroy (0.000157)  DELETE FROM `posts`
1591 WHERE `id` = 16
1592
1593 ~ SQL (0.000358) COMMIT
1594 ~ SQL (0.000122) BEGIN
1595 ~ Post Create (0.000238) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Merb Rawks', '2008-04-26 05:46:15')
1596 ~ SQL (0.000436) COMMIT
1597 ~ SQL (0.000105) BEGIN
1598 ~ Post Create (0.000152) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:46:15', 'Like the Hawks', '2008-04-26 05:46:15')
1599 ~ SQL (0.000392) COMMIT
1600 ~ Post Load (0.000326) SELECT * FROM `posts` 
1601 ~ SQL (0.000077) BEGIN
1602 ~ Post Destroy (0.000211)  DELETE FROM `posts`
1603 WHERE `id` = 17
1604
1605 ~ SQL (0.000526) COMMIT
1606 ~ SQL (0.000125) BEGIN
1607 ~ Post Destroy (0.000274)  DELETE FROM `posts`
1608 WHERE `id` = 18
1609
1610 ~ SQL (0.000363) COMMIT
1611 ~ Loaded TEST Environment...
1612 ~ loading gem 'merb_activerecord' from ...
1613 ~ loading gem 'merb_helpers' from ...
1614 ~ loading gem 'activerecord' from ...
1615 ~ Connecting to database...
1616 ~ Compiling routes...
1617 ~ Using 'share-nothing' cookie sessions (4kb limit per client)
1618 ~ SQL (0.000225) SET NAMES 'utf8'
1619 ~ SQL (0.000093) SET SQL_AUTO_IS_NULL=0
1620 ~ Post Load (0.000380) SELECT * FROM `posts` ORDER BY created_at DESC
1621 ~ {:before_filters_time=>1.2e-05, :after_filters_time=>9.0e-06, :action_time=>0.048231}
1622 ~ Post Columns (0.001538) SHOW FIELDS FROM `posts`
1623 ~ SQL (0.000207) SELECT count(*) AS count_all FROM `posts` 
1624 ~ SQL (0.000125) BEGIN
1625 ~ Post Create (0.000268) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'It was a good game though', '2008-04-26 05:50:09')
1626 ~ SQL (0.000503) COMMIT
1627 ~ Redirecting to: /posts/index
1628 ~ {:before_filters_time=>1.2e-05, :after_filters_time=>2.0e-05, :action_time=>0.004249}
1629 ~ SQL (0.000266) SELECT count(*) AS count_all FROM `posts` 
1630 ~ SQL (0.000106) BEGIN
1631 ~ SQL (0.000075) ROLLBACK
1632 ~ SQL (0.000863) BEGIN
1633 ~ Post Create (0.000276) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Merb Rawks', '2008-04-26 05:50:09')
1634 ~ SQL (0.000474) COMMIT
1635 ~ SQL (0.000082) BEGIN
1636 ~ Post Create (0.000182) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Like the Hawks', '2008-04-26 05:50:09')
1637 ~ SQL (0.000416) COMMIT
1638 ~ Post Load (0.000307) SELECT * FROM `posts` 
1639 ~ SQL (0.000077) BEGIN
1640 ~ Post Destroy (0.000199)  DELETE FROM `posts`
1641 WHERE `id` = 19
1642
1643 ~ SQL (0.000465) COMMIT
1644 ~ SQL (0.000124) BEGIN
1645 ~ Post Destroy (0.000145)  DELETE FROM `posts`
1646 WHERE `id` = 20
1647
1648 ~ SQL (0.000379) COMMIT
1649 ~ SQL (0.000123) BEGIN
1650 ~ Post Destroy (0.000691)  DELETE FROM `posts`
1651 WHERE `id` = 21
1652
1653 ~ SQL (0.000449) COMMIT
1654 ~ SQL (0.000101) BEGIN
1655 ~ Post Create (0.000218) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Merb Rawks', '2008-04-26 05:50:09')
1656 ~ SQL (0.000491) COMMIT
1657 ~ SQL (0.000107) BEGIN
1658 ~ Post Create (0.000288) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Like the Hawks', '2008-04-26 05:50:09')
1659 ~ SQL (0.000492) COMMIT
1660 ~ Post Load (0.000316) SELECT * FROM `posts` 
1661 ~ SQL (0.000077) BEGIN
1662 ~ Post Destroy (0.000203)  DELETE FROM `posts`
1663 WHERE `id` = 22
1664
1665 ~ SQL (0.027021) COMMIT
1666 ~ SQL (0.000124) BEGIN
1667 ~ Post Destroy (0.000242)  DELETE FROM `posts`
1668 WHERE `id` = 23
1669
1670 ~ SQL (0.000489) COMMIT
1671 ~ SQL (0.000103) BEGIN
1672 ~ Post Create (0.000213) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Merb Rawks', '2008-04-26 05:50:09')
1673 ~ SQL (0.000500) COMMIT
1674 ~ SQL (0.000077) BEGIN
1675 ~ Post Create (0.000149) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Like the Hawks', '2008-04-26 05:50:09')
1676 ~ SQL (0.000407) COMMIT
1677 ~ Post Load (0.000253) SELECT * FROM `posts` 
1678 ~ SQL (0.000074) BEGIN
1679 ~ Post Destroy (0.000187)  DELETE FROM `posts`
1680 WHERE `id` = 24
1681
1682 ~ SQL (0.000465) COMMIT
1683 ~ SQL (0.000083) BEGIN
1684 ~ Post Destroy (0.000176)  DELETE FROM `posts`
1685 WHERE `id` = 25
1686
1687 ~ SQL (0.000432) COMMIT
1688 ~ SQL (0.000098) BEGIN
1689 ~ Post Create (0.000205) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Merb Rawks', '2008-04-26 05:50:09')
1690 ~ SQL (0.000451) COMMIT
1691 ~ SQL (0.000091) BEGIN
1692 ~ Post Create (0.000149) INSERT INTO `posts` (`updated_at`, `body`, `created_at`) VALUES('2008-04-26 05:50:09', 'Like the Hawks', '2008-04-26 05:50:09')
1693 ~ SQL (0.000441) COMMIT
1694 ~ Post Load (0.000314) SELECT * FROM `posts` 
1695 ~ SQL (0.000077) BEGIN
1696 ~ Post Destroy (0.000198)  DELETE FROM `posts`
1697 WHERE `id` = 26
1698
1699 ~ SQL (0.000468) COMMIT
1700 ~ SQL (0.000131) BEGIN
1701 ~ Post Destroy (0.000186)  DELETE FROM `posts`
1702 WHERE `id` = 27
1703
1704 ~ SQL (0.000384) COMMIT
toggle raw diff

spec/controllers/posts_spec.rb

 
33describe Posts, "#index" do
44
55 it "should respond correctly" do
6 dispatch_to( Posts, :index ).should respond_successfully
6 dispatch_to(Posts, :index).should respond_successfully
77 end
88
99end
1010
1111describe Posts, "#create" do
1212
13 before( :each ) do
13 before(:each) do
1414 @params = { :body => "It was a good game though" }
1515 end
1616
1717 it "should redirect to #index after successfully creating a Post" do
1818 lambda {
19 dispatch_to( Posts, :create, @params ).should redirect_to( "/posts/index" )
20 }.should change( Post, :count )
19 dispatch_to(Posts, :create, @params).should redirect_to("/posts/index")
20 }.should change(Post, :count)
2121 end
2222
2323 it "should raise an exception when insufficient body text is submitted" do
2424 lambda {
25 dispatch_to( Posts, :create ).should redirect_to( "/posts/index" )
26 }.should raise_error( ActiveRecord::RecordInvalid )
25 dispatch_to(Posts, :create).should redirect_to("/posts/index")
26 }.should raise_error(ActiveRecord::RecordInvalid)
2727 end
2828
2929end
toggle raw diff

spec/models/post_spec.rb

 
1require File.join( File.dirname(__FILE__), "..", "spec_helper" )
1require File.join(File.dirname(__FILE__), "..", "spec_helper")
22
33describe Post do
44
1010 it "should require at least two body characters to be valid" do
1111 post = Post.new
1212 post.should_not be_valid
13 post.errors.on( :body ).should include( "is too short (minimum is 2 characters)" )
13 post.errors.on(:body).should include("is too short (minimum is 2 characters)")
1414 end
1515
1616end
toggle raw diff

spec/views/posts/index_spec.rb

 
22
33describe "posts/index" do
44
5 before( :each ) do
6 @controller = Posts.new( fake_request )
7 @posts = [Post.create( :body => "Merb Rawks", :created_at => Time.now ), Post.create( :body => "Like the Hawks", :created_at => Time.now )]
8 @controller.instance_variable_set( :@posts, @posts )
9 @body = @controller.render( :index )
5 before(:each) do
6 @controller = Posts.new(fake_request)
7 @posts = [Post.create(:body => "Merb Rawks", :created_at => Time.now), Post.create(:body => "Like the Hawks", :created_at => Time.now)]
8 @controller.instance_variable_set(:@posts, @posts)
9 @body = @controller.render(:index)
1010 end
1111
1212 it "should have a containing div for the posts" do
13 @body.should have_selector( "div#posts.container" )
13 @body.should have_selector("div#posts.container")
1414 end
1515
1616 it "should have a div for each individual post" do
1717 @posts.each do |post|
18 @body.should have_selector( "div#posts.container div#post-#{ post.id }.post" )
18 @body.should have_selector("div#posts.container div#post-#{ post.id }.post")
1919 end
2020 end
2121
2222 it "should have the contents of each post inside a div with an id and class" do
2323 @posts.each do |post|
24 @body.should match_tag( :div, :id => "post-#{ post.id }", :class => "post", :content => post.body )
24 @body.should match_tag(:div, :id => "post-#{ post.id }", :class => "post", :content => post.body)
2525 end
2626 end
2727
2828 it "should have a form to create new posts with a single input and submit button" do
29 @body.should match_selector( "form[@action=/posts/create]" )
30