From 73cb5ea0714386f9e62d68f1e84dbbea03eefefd Mon Sep 17 00:00:00 2001 From: Jason L Perry Date: Fri, 28 Nov 2008 00:32:30 -0500 Subject: [PATCH] Multipart emails are just to much of a pain to handle replying to [#2] --- app/models/notification.rb | 6 +++--- app/views/notification/post.text.html.erb | 7 ------- spec/models/notification_spec.rb | 6 +++--- 3 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 app/views/notification/post.text.html.erb diff --git a/app/models/notification.rb b/app/models/notification.rb index d343640..fdc194a 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -26,10 +26,10 @@ def reply_body(mail) pattern = /^.*Reply above this line.*$/ message = full_body(mail) match = pattern.match(message) - + clean_reply(match ? match.pre_match.strip : message) end - + def full_body(mail) if mail.multipart? plain = mail.parts.select { |part| part.content_type == "text/plain" } @@ -54,7 +54,7 @@ def self.topic_key(address) key = address.scan(/topic-(\d+)@.*/).flatten.first key ? key.to_i : nil end - + def self.topic_reply_to(post) topic = post.respond_to?(:topic) ? post.topic : post "topic-#{topic.id}@#{ActionMailer::Base.default_url_options[:host]}" diff --git a/app/views/notification/post.text.html.erb b/app/views/notification/post.text.html.erb deleted file mode 100644 index 47f2cc3..0000000 --- a/app/views/notification/post.text.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
-Posted by <%=h @post.author.name %>. - -<%= markdown h(@post.body) %> - -
-<%= link_to "View this post online", post_url(@post) %> \ No newline at end of file diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index bfa1e6d..cffe16d 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -7,7 +7,7 @@ it "should find the topic id from the address" do Notification.topic_key("topic-123@example.com").should == 123 end - + it "should not find an id for other addresses" do Notification.topic_key("postmaster@example.com").should be_nil end @@ -20,7 +20,7 @@ @email = File.open(fixture_path + "/emails/simple.email").read @topic = stub_model(Topic) @user = stub_model(User) - + User.stub!(:find_by_email).and_return(@user) Topic.stub!(:find_by_id).and_return(@topic) end @@ -59,7 +59,7 @@ :author => @user, :body => "I am replying." ) - Notification.receive(File.open(fixture_path + "/emails/reply.email").read) + Notification.receive(File.open(fixture_path + "/emails/reply.email").read) end end