Changes delete conversation button tooltip to 'hide' or 'delete'

This commit is contained in:
margori 2014-12-15 16:46:01 -03:00
parent 5d44fa771a
commit 27a1886834
4 changed files with 39 additions and 12 deletions

View file

@ -10,8 +10,13 @@ class ConversationVisibilitiesController < ApplicationController
@vis = ConversationVisibility.where(:person_id => current_user.person.id,
:conversation_id => params[:conversation_id]).first
if @vis
participants = @vis.conversation.participants.count
if @vis.destroy
flash[:notice] = I18n.t('conversations.destroy.success')
if participants == 1
flash[:notice] = I18n.t('conversations.destroy.delete_success')
else
flash[:notice] = I18n.t('conversations.destroy.hide_success')
end
end
end
redirect_to conversations_path

View file

@ -3,12 +3,20 @@
-# the COPYRIGHT file.
.conversation_participants
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
conversation_visibility_path(conversation),
:method => 'delete',
:data => { :confirm => "#{t('.delete')}?" },
:title => t('.delete'),
:class => 'close_conversation')
- if conversation.participants.count > 1
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
conversation_visibility_path(conversation),
:method => 'delete',
:data => { :confirm => "#{t('.hide')}?" },
:title => t('.hide'),
:class => 'close_conversation')
- else
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
conversation_visibility_path(conversation),
:method => 'delete',
:data => { :confirm => "#{t('.delete')}?" },
:title => t('.delete'),
:class => 'close_conversation')
%h3{ :class => direction_for(conversation.subject) }
= conversation.subject

View file

@ -358,7 +358,8 @@ en:
show:
reply: "reply"
replying: "Replying..."
delete: "delete and block conversation"
hide: "hide and mute conversation"
delete: "delete conversation"
new:
to: "to"
subject: "subject"
@ -377,8 +378,8 @@ en:
new_conversation:
fail: "Invalid message"
destroy:
success: "Conversation successfully removed"
delete_success: "Conversation successfully deleted"
hide_success: "Conversation successfully hidden"
date:
formats:
fullmonth_day: "%B %d"

View file

@ -33,5 +33,18 @@ describe ConversationVisibilitiesController, :type => :controller do
delete :destroy, :conversation_id => @conversation.id
}.not_to change(ConversationVisibility, :count)
end
it 'returns "hidden"' do
get :destroy, :conversation_id => @conversation.id
expect(flash.notice).to include("hidden")
end
it 'returns "deleted" when last participant' do
get :destroy, :conversation_id => @conversation.id
sign_out :user
sign_in :user, bob
get :destroy, :conversation_id => @conversation.id
expect(flash.notice).to include("deleted")
end
end
end