Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #46 from Princetambar/group_messages

# Feature to get people involve into conversation added with specs
  • Loading branch information...
commit 6b41ab43cd8d0c97c8dac3bf0bfd8eb3cf1269d2 2 parents 5b1ff24 + 59541bf
Piotr Niełacny authored
21 README.md
View
@@ -304,4 +304,25 @@ end
@alice.restore_message(@message) # @alice restore message from trash
```
+Group message
+=============
+
+## How to join other users's conversation
+
+```ruby
+@message = @alice.send_message(@bob, :topic => "Helou bob!", :body => "What's up?")
+@reply_message = @sukhi.reply_to(@message, "Hi there!", "I would like to join to this conversation!")
+@sec_reply_message = @bob.reply_to(@message, "Hi!", "Fine!")
+@third_reply_message = @alice.reply_to(@reply_message, "hi!", "no problem")
+```
+
+## Know the people involved in conversation
+
+```ruby
+@message.people #will give you participants users object
+
+@message.people #=> [@alice,@bob,@sukhi]
+```
+
+
Copyright © 2011 Piotr Niełacny (http://ruby-blog.pl), released under the MIT license
4 lib/acts-as-messageable/message.rb
View
@@ -91,5 +91,9 @@ def restore
def reply(*args)
to.reply_to(self, *args)
end
+
+ def people
+ conversation.map{|x| x.from}.uniq!
+ end
end
end
11 spec/group-messages_spec.rb
View
@@ -6,7 +6,7 @@
let(:pat) { User.find_by_email("pat@example.com") }
before do
- User.acts_as_messageable :class_name => "CustomMessage",
+ User.acts_as_messageable :class_name => "ActsAsMessageable::Message",
:group_messages => true
@message = alice.send_message(bob, :topic => "Helou bob!", :body => "What's up?")
end
@@ -15,8 +15,15 @@
@reply_message = pat.reply_to(@message, "Hi there!", "I would like to join to this conversation!")
@sec_reply_message = bob.reply_to(@message, "Hi!", "Fine!")
@third_reply_message = alice.reply_to(@reply_message, "hi!", "no problem")
- puts @message.conversation.inspect
@message.conversation.should == [@reply_message, @message]
end
+
+ it "alice,bob and pat should be involve into conversation" do
+ @reply_message = pat.reply_to(@message, "Hi there!", "I would like to join to this conversation!")
+ @sec_reply_message = bob.reply_to(@message, "Hi!", "Fine!")
+ @third_reply_message = alice.reply_to(@reply_message, "hi!", "no problem")
+ @message.people.should == [alice,bob,pat]
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.