<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/messages/_full_message.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -5,4 +5,8 @@ module CommunicationsHelper
       edit_connection_path(conn)
     end
   end
+
+  def message_anchor(message)
+    &quot;message_#{message.id}&quot;
+  end
 end</diff>
      <filename>app/helpers/communications_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,6 +51,11 @@ class Message &lt; Communication
   def parent=(message)
     @parent = message
   end
+  
+  # Return the sender/recipient that *isn't* the given person.
+  def other_person(person)
+    person == sender ? recipient : sender
+  end
 
   # Put the message in the trash for the given person.
   def trash(person, time=Time.now)
@@ -85,7 +90,7 @@ class Message &lt; Communication
   
   # Return true if the message is a reply to a previous message.
   def reply?
-    !parent.nil? and correct_sender_recipient_pair?
+    (!parent.nil? or !parent_id.nil?) and correct_sender_recipient_pair?
   end
   
   # Return true if the sender/recipient pair is valid for a given parent.</diff>
      <filename>app/models/message.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,18 @@
 &lt;li&gt;
   &lt;div class=&quot;profile-image&quot;&gt;
     &lt;%= image_link message.sender %&gt;
+    &lt;%- if not message.read? and not current_person?(message.sender) -%&gt;
+      &lt;%= image_tag(&quot;icons/email.gif&quot;, :class =&gt; &quot;icon&quot;) %&gt;
+    &lt;%- elsif message.replied_to? -%&gt;
+      &lt;%= image_tag(&quot;icons/reply.gif&quot;, :class =&gt; &quot;icon&quot; )  %&gt;
+    &lt;%- end -%&gt;    
   &lt;/div&gt;
   &lt;p&gt;&lt;span class=&quot;field&quot;&gt;From:&lt;/span&gt; &lt;%= person_link message.sender %&gt;&lt;/p&gt;
   &lt;p class=&quot;meta published&quot;&gt;
     &lt;%= time_ago_in_words message.created_at %&gt; ago
   &lt;/p&gt;
   &lt;p title=&quot;Subject&quot;&gt;
-    &lt;%= link_to sanitize(truncate(message.subject, 30)), message %&gt;
+    &lt;%= link_to sanitize(truncate(message.subject, 30)),
+                message_path(message, :anchor =&gt; message_anchor(message)) %&gt;
   &lt;/p&gt;
 &lt;/li&gt;
\ No newline at end of file</diff>
      <filename>app/views/home/_message.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,7 @@
 &lt;li class=&quot;message&quot;&gt;
   &lt;div class=&quot;profile-image&quot;&gt;
-    &lt;% other_person = current_person?(message.sender) ?
-                      message.recipient : message.sender %&gt;
-    &lt;%= image_link other_person, :image =&gt; :thumbnail,
+    &lt;%= image_link message.other_person(current_person),
+                   :image =&gt; :thumbnail,
                    :image_options =&gt; { :class =&gt; &quot;photo&quot; } %&gt;
 
     &lt;%- if not message.read? and not current_person?(message.sender) -%&gt;
@@ -23,7 +22,8 @@
   &lt;/p&gt;
   &lt;p&gt;
     &lt;span class=&quot;label&quot;&gt;Subject:&lt;/span&gt;
-    &lt;%= link_to sanitize(message.subject), message %&gt;    
+    &lt;%= link_to sanitize(message.subject),
+                message_path(message, :anchor =&gt; message_anchor(message)) %&gt;
   &lt;/p&gt;
   &lt;p class=&quot;tools meta&quot;&gt;
     &lt;%= link_to &quot;Read&quot;, message %&gt; |
@@ -31,7 +31,7 @@
     &lt;% unless message.trashed?(current_person) -%&gt;
       &lt;%= link_to(&quot;Trash&quot;, message, :method =&gt; :delete) %&gt;
     &lt;% else -%&gt;
-      &lt;%= link_to &quot;Untrash&quot;, undestroy_message_path(message), 
+      &lt;%= link_to &quot;Untrash&quot;, undestroy_message_path(message),
                              :method =&gt; :put %&gt;
     &lt;% end -%&gt;    
   &lt;/p&gt;</diff>
      <filename>app/views/messages/_message.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
   &lt;% form_for(:message,
               :url =&gt; person_messages_path(@recipient)) do |f| %&gt;
     &lt;div class=&quot;form_row full&quot;&gt;
-      &lt;label for=&quot;message_to&quot;&gt;To&lt;/label&gt;
+      &lt;label for=&quot;recipient&quot;&gt;To&lt;/label&gt;
       &lt;%= text_field_tag :recipient, h(@recipient.name) %&gt;
       &lt;!-- TODO: be able to change recipients with this
       &lt;a href=&quot;#&quot; class=&quot;add-recipient&quot;&gt;</diff>
      <filename>app/views/messages/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,19 @@
 &lt;%- column_div :type =&gt; :primary do -%&gt;
   &lt;% if current_person?(@message.sender) %&gt;
-    &lt;% other_person = @message.recipient %&gt;
-    &lt;% heading = &quot;Message sent to #{h other_person.name}&quot; %&gt;
+    &lt;% heading = &quot;Message sent to #{h @message.recipient.name}&quot; %&gt;
   &lt;% else %&gt;
-    &lt;% other_person = @message.sender %&gt;
-    &lt;% heading = &quot;Message from #{h other_person.name}&quot; %&gt;
+    &lt;% heading = &quot;Message from #{h @message.sender.name}&quot; %&gt;
   &lt;% end %&gt;
   
   &lt;h2&gt;&lt;%= heading %&gt;&lt;/h2&gt;
 
   &lt;%= render :partial =&gt; 'message_nav' %&gt;
   
-  &lt;h3 class=&quot;subject&quot;&gt;
-  &lt;%= image_link other_person %&gt;
-  &lt;%= @message.subject %&gt;&lt;/h3&gt;
-  &lt;%= display @message.content %&gt;
-  &lt;p class=&quot;meta tools&quot;&gt;
-    Sent &lt;%= time_ago_in_words @message.created_at %&gt; ago |
-    &lt;%= link_to &quot;Reply&quot;, reply_message_path(@message) %&gt; |
-    &lt;% unless @message.trashed?(current_person) -%&gt;
-      &lt;%= link_to(&quot;Trash&quot;, @message, :method =&gt; :delete) %&gt;
-    &lt;% else -%&gt;
-      &lt;%= link_to &quot;Untrash&quot;, undestroy_message_path(@message), 
-                             :method =&gt; :put %&gt;
-    &lt;% end -%&gt;
-  &lt;/p&gt;
+  &lt;h3 class=&quot;subject&quot;&gt;&lt;%= sanitize @message.subject %&gt;&lt;/h3&gt;
+  &lt;ul class=&quot;list person&quot;&gt;
+    &lt;%= render :partial =&gt; 'full_message',
+               :collection =&gt; @message.conversation.messages %&gt;
+  &lt;/ul&gt;
 
 &lt;%- end -%&gt;
 </diff>
      <filename>app/views/messages/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -39,12 +39,13 @@ describe MessagesController do
     end
     
     it &quot;should have a working reply page&quot; do
-      login_as @message.recipient
-      get :reply, :id =&gt; @message
-      response.should be_success
-      response.should render_template(&quot;new&quot;)
-      assigns(:message).parent.should == @message
-      assigns(:recipient).should == @message.sender
+      proper_reply_behavior(@message.recipient)
+    end
+    
+    it &quot;should have a working reply page for the recipient&quot; do
+      # This spec tests replying to your *own* message, as at
+      # the bottom of a thread.
+      proper_reply_behavior(@message.sender)
     end
 
     it &quot;should reply correctly when logged in as the sender&quot; do
@@ -127,4 +128,19 @@ describe MessagesController do
       assigns(:message).should be_reply
     end.should change(Message, :count).by(1)
   end
+  
+  def proper_reply_behavior(person)
+    login_as person
+    get :reply, :id =&gt; @message
+    response.should be_success
+    # Check that the hidden parent_id tag is there, with the right value.
+    response.should have_tag(&quot;input[id=?][name=?][type=?][value=?]&quot;,
+                             &quot;message_parent_id&quot;,
+                             &quot;message[parent_id]&quot;,
+                             &quot;hidden&quot;,
+                             @message.id)
+    response.should render_template(&quot;new&quot;)
+    assigns(:message).parent.should == @message
+    assigns(:recipient).should == @message.other_person(person)
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/controllers/messages_controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>dd27682a2c32827e9c8749002857663bbde9ea09</id>
    </parent>
    <parent>
      <id>0d3cda76d349fe41f8e38a5eebeb8fea8d6f1b49</id>
    </parent>
  </parents>
  <author>
    <name>Michael Hartl</name>
    <email>michael@michaelhartl.com</email>
  </author>
  <url>http://github.com/insoshi/insoshi/commit/825ca094af08bf123ac19cd1a1c8a95457c97a15</url>
  <id>825ca094af08bf123ac19cd1a1c8a95457c97a15</id>
  <committed-date>2008-07-31T13:59:11-07:00</committed-date>
  <authored-date>2008-07-31T13:59:11-07:00</authored-date>
  <message>Merge branch 'messages' into edge</message>
  <tree>4770b15ad60eec2680ffa634dc78ee2f0144b4b0</tree>
  <committer>
    <name>Michael Hartl</name>
    <email>michael@michaelhartl.com</email>
  </committer>
</commit>
