From 53714c4699af540f5edf4a0bfd49528ddd20eed2 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Thu, 19 Feb 2015 06:51:39 +0100 Subject: [PATCH] Fix notification for new conversations --- app/models/conversation.rb | 4 ++-- features/desktop/conversations.feature | 4 +++- features/step_definitions/conversations_steps.rb | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 7ade2b88f..dbf1fb774 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -20,7 +20,7 @@ class Conversation < ActiveRecord::Base def max_participants errors.add(:max_participants, "too many participants") if participants.count > 20 end - + def local_recipients recipients.each do |recipient| if recipient.local? @@ -86,7 +86,7 @@ class Conversation < ActiveRecord::Base end def receive(user, person) - cnv = Conversation.find_or_create_by!(self.attributes) + cnv = Conversation.create_with(self.attributes).find_or_create_by!(guid: guid) self.participants.each do |participant| ConversationVisibility.find_or_create_by(conversation_id: cnv.id, person_id: participant.id) diff --git a/features/desktop/conversations.feature b/features/desktop/conversations.feature index 2c42d4bc7..2737aef71 100644 --- a/features/desktop/conversations.feature +++ b/features/desktop/conversations.feature @@ -20,5 +20,7 @@ Feature: private conversations And "Alice Awesome" should be part of active conversation And I should see "hello, alice!" within ".stream_container" When I sign in as "alice@alice.alice" - And I reply with "hey, how you doing?" + Then I should have 1 unread private message + And I should have 1 email delivery + When I reply with "hey, how you doing?" Then I should see "hey, how you doing?" within ".stream_container" diff --git a/features/step_definitions/conversations_steps.rb b/features/step_definitions/conversations_steps.rb index d087a2541..586f799d5 100644 --- a/features/step_definitions/conversations_steps.rb +++ b/features/step_definitions/conversations_steps.rb @@ -4,6 +4,10 @@ Then /^"([^"]*)" should be part of active conversation$/ do |name| end end +Then /^I should have (\d+) unread private messages?$/ do |n_unread| + find("header #conversations_badge .badge_count").should have_content(n_unread) +end + Then /^I send a message with subject "([^"]*)" and text "([^"]*)" to "([^"]*)"$/ do |subject, text, person| step %(I am on the conversations page) within("#conversation_new", match: :first) do