Skip to content
Browse files

always set conversation tags, even if empty, fixes #7178

because the new filter only shows up if all conversations have tags, if
you start a conversation with someone that you share no contexts with,
the conversation filter disappears. this change ensures all conversations
and conversation_participants have initial empty tags (which then get
added to as messages are added)

test plan:
* start a conversation with someone you share no courses with
* reload the page
* ensure the filter dropdown is still there

Change-Id: I535615897fc630a70baceb645d75f20d2f17a5b9
Reviewed-on: https://gerrit.instructure.com/8529
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
  • Loading branch information...
1 parent 32057f2 commit f84f7146a875af6395c782a16780ba30cc8dc962 @jenseng jenseng committed with zwily Feb 6, 2012
Showing with 15 additions and 1 deletion.
  1. +3 −1 app/models/conversation.rb
  2. +12 −0 spec/models/conversation_spec.rb
View
4 app/models/conversation.rb
@@ -57,14 +57,16 @@ def self.initiate(user_ids, private)
conversation.private_hash = private_hash
conversation.has_attachments = false
conversation.has_media_objects = false
+ conversation.tags = []
conversation.save!
connection.bulk_insert('conversation_participants', user_ids.map{ |user_id|
{
:conversation_id => conversation.id,
:user_id => user_id,
:workflow_state => 'read',
:has_attachments => false,
- :has_media_objects => false
+ :has_media_objects => false,
+ :tags => ''
}
})
end
View
12 spec/models/conversation_spec.rb
@@ -383,6 +383,18 @@
conversation.tags.should eql [@course.asset_string]
end
+ it "should set initial empty tags on the conversation and conversation_participant" do
+ u1 = student_in_course.user
+ u2 = student_in_course(:course => @course).user
+ conversation = Conversation.initiate([u1.id, u2.id], true)
+ conversation.read_attribute(:tags).should_not be_nil
+ conversation.tags.should eql []
+ u1.all_conversations.first.read_attribute(:tags).should_not be_nil
+ u1.all_conversations.first.tags.should eql []
+ u2.all_conversations.first.read_attribute(:tags).should_not be_nil
+ u2.all_conversations.first.tags.should eql []
+ end
+
it "should save all visible tags on the conversation_participant" do
u1 = student_in_course(:active_all => true).user
u2 = student_in_course(:active_all => true, :course => @course).user

0 comments on commit f84f714

Please sign in to comment.
Something went wrong with that request. Please try again.