<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/comment.rb</filename>
    </added>
    <added>
      <filename>db/migrate/20080910173454_create_comments.rb</filename>
    </added>
    <added>
      <filename>lib/tasks/rspec.rake</filename>
    </added>
    <added>
      <filename>script/autospec</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -19,12 +19,32 @@ class PicturesController &lt; ApplicationController
   # View only one picture
   def show
     @picture = Picture.find_by_permalink params[:id]
+    prepare_picture
+    @comment = @picture.comments.new
+  rescue ActiveRecord::RecordNotFound
+    render :file =&gt; &quot;#{RAILS_ROOT}/public/404.html&quot;, :status =&gt; 404
+  end
+
+  def create_comment
+    @comment = Comment.create(params[:comment])
+    if @comment.save
+      flash[:notice] = 'You comment is save'
+      redirect_to picture_url(comment.picture) 
+    else
+      flash[:notice] = 'Your comment failed'
+      @picture = Picture.find(params[:comment][:picture_id])
+      prepare_picture
+      render :action =&gt; 'show'
+    end
+  end
+
+  private
+
+  def prepare_picture
     raise ActiveRecord::RecordNotFound if @picture.nil?
     @gallery = @picture.gallery
     @tags = @picture.tag_list
     @breadcrumb = @picture
-  rescue ActiveRecord::RecordNotFound
-    render :file =&gt; &quot;#{RAILS_ROOT}/public/404.html&quot;, :status =&gt; 404
   end
 
 end</diff>
      <filename>app/controllers/pictures_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -81,4 +81,7 @@ module ApplicationHelper
     end
     str
   end
+
+  def add_error_message
+  end
 end</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@ class Picture &lt; ActiveRecord::Base
 
   belongs_to :gallery
   has_many :thumbnails, :foreign_key =&gt; 'parent_id'
+  has_many :comments
   
   has_attachment :content_type =&gt; :image, 
       :storage =&gt; :file_system, </diff>
      <filename>app/models/picture.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,3 +9,31 @@
 &lt;p&gt;
   &lt;%= @picture.description %&gt;
 &lt;/p&gt;
+
+&lt;%= flash_notice %&gt;
+
+&lt;% form_for @comment, :url =&gt; {:action =&gt; 'create_comment'}, :html =&gt; {:id =&gt; 'commentform'} do |f| -%&gt;
+  &lt;h3&gt;Add Comment&lt;/h3&gt;
+  &lt;%= error_messages_for 'comment' %&gt;
+
+  &lt;div id='respond'&gt;
+    &lt;p&gt;
+      &lt;%= f.label :author %&gt;
+      &lt;%= f.text_field :author %&gt;
+    &lt;/p&gt;
+
+    &lt;p&gt;
+      &lt;%= f.label :email %&gt;
+      &lt;%= f.text_field :email %&gt;
+    &lt;/p&gt;
+
+    &lt;p&gt;
+      &lt;%= f.label :body %&gt;
+      &lt;%= f.text_area :body %&gt;
+    &lt;/p&gt;
+    &lt;p class=&quot;button&quot;&gt;
+      &lt;%= f.hidden_field :picture_id %&gt;
+      &lt;%= submit_tag %&gt;
+    &lt;/p&gt;
+  &lt;/div&gt;
+&lt;% end %&gt;</diff>
      <filename>app/views/pictures/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@ ActionController::Routing::Routes.draw do |map|
   map.connect '/galleries/:id/page/:page', :controller =&gt; 'galleries', :action =&gt; 'show', :page =&gt; /\d+/
   map.connect '/galleries/:gallery_id/pictures/:id/page/:page', :controller =&gt; 'pictures', :action =&gt; 'show', :page =&gt; /\d+/
     
-  map.resources :pictures
+  map.resources :pictures, :collection =&gt; {:create_comment =&gt; :post}
   map.resources :tags
 
   # route to the paginate of all galleries</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,19 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version =&gt; 20080824170446) do
+ActiveRecord::Schema.define(:version =&gt; 20080910173454) do
+
+  create_table &quot;comments&quot;, :force =&gt; true do |t|
+    t.string   &quot;title&quot;
+    t.text     &quot;body&quot;
+    t.string   &quot;email&quot;
+    t.string   &quot;author&quot;
+    t.string   &quot;ip&quot;
+    t.boolean  &quot;published&quot;
+    t.integer  &quot;picture_id&quot;
+    t.datetime &quot;created_at&quot;
+    t.datetime &quot;updated_at&quot;
+  end
 
   create_table &quot;galleries&quot;, :force =&gt; true do |t|
     t.string  &quot;name&quot;</diff>
      <filename>db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -141,3 +141,105 @@ a.current_gallery {
   color : #CC6600;
   font-weight: bold;
 }
+
+/*------------------------------------------------------------------
+[4.1.2. Comments]
+*/
+
+#commentform {
+    background:url(../../images/theme/bg_white.png);
+    padding:10px 35px 25px 10px;
+    text-align: left;
+}
+
+    #commentform input {
+        width:180px;
+        padding:3px 3px 3px 23px;
+        margin: 15px;
+    }
+
+    #commentform textarea {
+        padding:3px;
+        margin: 15px 0 15px 15px;
+        font-size:1em;
+        width:480px;
+    }
+
+    #commentform label {
+        float:left;
+        width: 150px;
+        text-align:right;
+        height:30px;
+        padding-top:15px;
+        margin-left: 50px;
+        line-height:0.7em
+    }
+
+    #commentform label small {
+        font-size:0.6em
+    }
+
+    input#comment_author {
+        background:url(../../images/theme/user50.png) no-repeat #FFF 2% 50%;
+    }
+
+    input#comment_author:hover {
+        background:url(../../images/theme/user.png) no-repeat #FFF 2% 50%;
+    }
+    }                                                                                                                                                                                             
+
+    input#comment_email {
+        background:url(../../images/theme/email_open50.png) no-repeat #FFF 2% 50%;
+    }
+
+    input#comment_email:hover {
+        background:url(../../images/theme/email_open.png) no-repeat #FFF 2% 50%;
+    }
+
+    input#comment_url {
+        background:url(../../images/theme/world_link50.png) no-repeat #FFF 2% 50%;
+    }
+
+    input#comment_url:hover {
+        background:url(../../images/theme/world_link.png) no-repeat #FFF 2% 50%;
+    }
+
+    input#form-preview-button {
+        background:url(../../images/theme/page_edit50.png) no-repeat #f6e0c6 2% 50%;
+        width: 110px;
+        margin:0
+    }
+
+    input#form-preview-button:hover {
+        background:url(../../images/theme/page_edit.png) no-repeat #f6e0c6 2% 50%;
+    }
+
+
+    input#form-submit-button {
+        background:url(../../images/theme/accept50.png) no-repeat #f6e0c6 2% 50%;
+        width: 110px;
+        margin:0
+    }
+
+    input#form-submit-button:hover {
+        background:url(../../images/theme/accept.png) no-repeat #f6e0c6 2% 50%;
+    }
+
+ol#commentList {
+    margin-left: 25px;
+}
+
+ol#commentList  li {
+    margin: 10px 0 10px 0
+}                                                                                                                                                                                                 
+                                                                                                                                                                                                  
+div.commentContent {                                                                                                                                                                              
+    padding:10px;                                                                                                                                                                                 
+    background:url(../../images/theme/bg_white.png);                                                                                                                                              
+    margin:5px 0 0 0                                                                                                                                                                              
+                                                                                                                                                                                                  
+}                                                                                                                                                                                                 
+                                                                                                                                                                                                  
+div.author cite {                                                                                                                                                                                 
+    font-style:normal                                                                                                                                                                             
+} </diff>
      <filename>public/stylesheets/pictrails.css</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 #!/usr/bin/env ruby
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
 require 'rubygems'
 require 'drb/drb'
@@ -23,20 +22,29 @@ module Spec
               active_connections.delete(name)
             end
           end
-        end        
+        end
 
         if ActionController.const_defined?(:Dispatcher)
           dispatcher = ::ActionController::Dispatcher.new($stdout)
-          dispatcher.cleanup_application(true)
+          dispatcher.cleanup_application
         elsif ::Dispatcher.respond_to?(:reset_application!)
           ::Dispatcher.reset_application!
         else
           raise &quot;Application reloading failed&quot;
         end
+        if Object.const_defined?(:Fixtures) &amp;&amp; Fixtures.respond_to?(:reset_cache)
+          Fixtures.reset_cache
+        end
+
         ::Dependencies.mechanism = :load
         require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
         load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
 
+        if in_memory_database?
+          load &quot;#{RAILS_ROOT}/db/schema.rb&quot; # use db agnostic schema by default
+          ActiveRecord::Migrator.up('db/migrate') # use migrations
+        end
+
         ::Spec::Runner::CommandLine.run(
           ::Spec::Runner::OptionParser.parse(
             argv,
@@ -45,6 +53,12 @@ module Spec
           )
         )
       end
+
+      def in_memory_database?
+        ENV[&quot;RAILS_ENV&quot;] == &quot;test&quot; and
+        ::ActiveRecord::Base.connection.class.to_s == &quot;ActiveRecord::ConnectionAdapters::SQLite3Adapter&quot; and
+        ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
+      end
     end
   end
 end
@@ -91,7 +105,7 @@ opts.parse!(ARGV)
 puts &quot;Ready&quot;
 exec_server = lambda {
   trap(&quot;USR2&quot;) { restart_test_server } if Signal.list.has_key?(&quot;USR2&quot;)
-  DRb.start_service(&quot;druby://localhost:8989&quot;, Spec::Runner::RailsSpecServer.new)
+  DRb.start_service(&quot;druby://127.0.0.1:8989&quot;, Spec::Runner::RailsSpecServer.new)
   DRb.thread.join
 }
 </diff>
      <filename>script/spec_server</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,10 @@ describe PicturesController do
   controller_name :pictures
 
   before :each do
-    @picture = mock_model(Picture)
-    @picture.stub!(:gallery).and_return([])
-    @picture.stub!(:tag_list).and_return([])
+    @picture = mock_model(Picture,{ :gallery =&gt; mock_model(Gallery),
+                                    :tag_list =&gt; [],
+                                    :comments =&gt; mock(&quot;comments&quot;, { :new =&gt; mock_model(Comment)})
+                                  })
     @gallery = mock_model(Gallery)
   end
 </diff>
      <filename>spec/controllers/pictures_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,4 @@
 --colour
---format
-progress
---loadby
-mtime
+--format progress
+--loadby mtime
 --reverse</diff>
      <filename>spec/spec.opts</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-Subproject commit 7138144bd72b8a28123506fe7892007c85d43659
+Subproject commit 3391c8caacc99af5bc3a0f00dff6908c62dcaf27</diff>
      <filename>vendor/plugins/rspec</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-Subproject commit 08670b640ee8da5bc29a8db751813aa259544036
+Subproject commit 2b25c672537fa3e4ce0341263e890aaa052a8b3e</diff>
      <filename>vendor/plugins/rspec-rails</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9e0b990675746157c229629e3d7180d9bd6d5c10</id>
    </parent>
  </parents>
  <author>
    <name>shingara</name>
    <email>cyril.mougel@gmail.com</email>
  </author>
  <url>http://github.com/shingara/pictrails/commit/d8a9f7f696b461e3f9a8d8f0e09e42440b5f6f27</url>
  <id>d8a9f7f696b461e3f9a8d8f0e09e42440b5f6f27</id>
  <committed-date>2008-09-13T02:27:36-07:00</committed-date>
  <authored-date>2008-09-13T02:27:36-07:00</authored-date>
  <message>start add comment, with a comment model and view of comment in view picture</message>
  <tree>827602f8678d4ffc04c6c2d0faa85ea42f1433f0</tree>
  <committer>
    <name>shingara</name>
    <email>cyril.mougel@gmail.com</email>
  </committer>
</commit>
