Show error and flash-notice when sending messages to non contacts
This commit is contained in:
parent
dd8660b12e
commit
597ab20715
4 changed files with 54 additions and 1 deletions
|
|
@ -19,6 +19,7 @@
|
|||
* Add flash warning to conversation mobile, unification of flash warning with login and register mobile, and add support for flash warning to Opera browser. [#3686](https://github.com/diaspora/diaspora/pull/3686)
|
||||
* Add progress percentage to upload images. [#3740](https://github.com/diaspora/diaspora/pull/3740)
|
||||
* Mark all unread post-related notifications as read, if one of this gets opened. [#3787](https://github.com/diaspora/diaspora/pull/3787)
|
||||
* Add flash-notice when sending messages to non-contacts. [#3723](https://github.com/diaspora/diaspora/pull/3723)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,14 @@ class ConversationsController < ApplicationController
|
|||
params[:conversation][:messages_attributes] = [ {:author => current_user.person, :text => message_text }]
|
||||
|
||||
@conversation = Conversation.new(params[:conversation])
|
||||
if @conversation.save
|
||||
if person_ids.present? && @conversation.save
|
||||
Postzord::Dispatcher.build(current_user, @conversation).post
|
||||
flash[:notice] = I18n.t('conversations.create.sent')
|
||||
else
|
||||
flash[:error] = I18n.t('conversations.create.fail')
|
||||
if person_ids.blank?
|
||||
flash[:error] = I18n.t('conversations.create.no_contact')
|
||||
end
|
||||
end
|
||||
if params[:profile]
|
||||
redirect_to person_path(params[:profile])
|
||||
|
|
|
|||
|
|
@ -345,6 +345,7 @@ en:
|
|||
create:
|
||||
sent: "Message sent"
|
||||
fail: "Invalid message"
|
||||
no_contact: "Hey, you need to add the contact first!"
|
||||
new_message:
|
||||
fail: "Invalid message"
|
||||
destroy:
|
||||
|
|
|
|||
|
|
@ -113,6 +113,30 @@ describe ConversationsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with empty subject' do
|
||||
before do
|
||||
@hash = {
|
||||
:conversation => {
|
||||
:subject => ' ',
|
||||
:text => 'text debug'
|
||||
},
|
||||
:contact_ids => [alice.contacts.first.id]
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a conversation' do
|
||||
lambda {
|
||||
post :create, @hash
|
||||
}.should change(Conversation, :count).by(1)
|
||||
end
|
||||
|
||||
it 'creates a message' do
|
||||
lambda {
|
||||
post :create, @hash
|
||||
}.should change(Message, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with empty text' do
|
||||
before do
|
||||
@hash = {
|
||||
|
|
@ -136,6 +160,30 @@ describe ConversationsController do
|
|||
}.should_not change(Message, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with empty contact' do
|
||||
before do
|
||||
@hash = {
|
||||
:conversation => {
|
||||
:subject => 'secret stuff',
|
||||
:text => 'text debug'
|
||||
},
|
||||
:contact_ids => ' '
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not create a conversation' do
|
||||
lambda {
|
||||
post :create, @hash
|
||||
}.should_not change(Conversation, :count).by(1)
|
||||
end
|
||||
|
||||
it 'does not create a message' do
|
||||
lambda {
|
||||
post :create, @hash
|
||||
}.should_not change(Message, :count).by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue