class ConversationSummarizer
  include ActionView::Helpers::TextHelper

  LENGTH = 200

  attr_accessor :conversation

  def self.summary(conversation)
    new(conversation).summary
  end

  def initialize(conversation)
    self.conversation = conversation
  end

  def summary
    if subject.present?
      subject
    elsif first_sentence.size <= LENGTH
      first_sentence
    else
      truncated_message
    end
  end

  def subject
    conversation.subject
  end

  def first_sentence
    sentence = first_message && first_message.partition(/\.|\?|\!|\s\-\s/)[0..1].join
    sentence.to_s.strip.chomp('-').strip
  end

  def truncated_message
    first_message && truncate(first_message, length: LENGTH, separator: ' ').html_safe
  end

  def first_message
    conversation.first_message && conversation.first_message.content
  end
end

class ConversationSummarizer
  include ActionView::Helpers::TextHelper

  LENGTH = 200

  attr_accessor :conversation

  def self.summary(conversation)
    new(conversation).summary
  end

  def initialize(conversation)
    self.conversation = conversation
  end

  def summary
    if subject
      subject
    elsif first_sentence.size <= LENGTH
      first_sentence
    else
      truncated_message
    end
  end

  def subject
    conversation.subject
  end

  def first_sentence
    sentence = first_message && first_message.partition(/\.|\?|\!|\s\-\s/)[0..1].join
    sentence.strip.chomp('-').strip
  end

  def truncated_message
    first_message && truncate(first_message, length: LENGTH, separator: ' ').html_safe
  end

  def first_message
    conversation.first_message && conversation.first_message.content
  end
end

--- 
+++ 
@@ -14,7 +14,7 @@
   end
 
   def summary
-    if subject
+    if subject.present?
       subject
     elsif first_sentence.size <= LENGTH
       first_sentence
@@ -29,7 +29,7 @@
 
   def first_sentence
     sentence = first_message && first_message.partition(/\.|\?|\!|\s\-\s/)[0..1].join
-    sentence.strip.chomp('-').strip
+    sentence.to_s.strip.chomp('-').strip
   end
 
   def truncated_message
Fix weird failing test case
