request notification emails -> started sharing notification emails
This commit is contained in:
parent
847f4fd260
commit
2e5b5e1efe
31 changed files with 76 additions and 177 deletions
|
|
@ -78,7 +78,7 @@ class PeopleController < ApplicationController
|
||||||
@contacts_of_contact = []
|
@contacts_of_contact = []
|
||||||
end
|
end
|
||||||
|
|
||||||
if (@person != current_user.person) && (!@contact || @contact.mutual)
|
if (@person != current_user.person) && !@contact
|
||||||
@commenting_disabled = true
|
@commenting_disabled = true
|
||||||
else
|
else
|
||||||
@commenting_disabled = false
|
@commenting_disabled = false
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,12 @@ class PostVisibilitiesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def update
|
def update
|
||||||
#note :id is garbage
|
#note :id references a postvisibility
|
||||||
|
|
||||||
@post = Post.where(:id => params[:post_id]).select("id, author_id").first
|
@post = Post.where(:id => params[:post_id]).select("id, author_id").first
|
||||||
@contact = current_user.contact_for(@post.author)
|
@contact = current_user.contact_for(@post.author)
|
||||||
if @vis = PostVisibility.unscoped.where(:contact_id => @contact.id,
|
|
||||||
|
if @vis = PostVisibility.where(:contact_id => @contact.id,
|
||||||
:post_id => params[:post_id]).first
|
:post_id => params[:post_id]).first
|
||||||
@vis.hidden = !@vis.hidden
|
@vis.hidden = !@vis.hidden
|
||||||
if @vis.save
|
if @vis.save
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,7 @@ module NotificationsHelper
|
||||||
else
|
else
|
||||||
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
||||||
end
|
end
|
||||||
elsif note.instance_of?(Notifications::RequestAccepted)
|
elsif note.instance_of?(Notifications::StartedSharing)
|
||||||
translation(target_type)
|
|
||||||
elsif note.instance_of?(Notifications::NewRequest)
|
|
||||||
translation(target_type)
|
translation(target_type)
|
||||||
elsif note.instance_of?(Notifications::CommentOnPost)
|
elsif note.instance_of?(Notifications::CommentOnPost)
|
||||||
post = Post.where(:id => note.target_id).first
|
post = Post.where(:id => note.target_id).first
|
||||||
|
|
|
||||||
|
|
@ -21,31 +21,17 @@ class Notifier < ActionMailer::Base
|
||||||
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_request(recipient_id, sender_id)
|
def started_sharing(recipient_id, sender_id)
|
||||||
@receiver = User.find_by_id(recipient_id)
|
@receiver = User.find_by_id(recipient_id)
|
||||||
@sender = Person.find_by_id(sender_id)
|
@sender = Person.find_by_id(sender_id)
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'new_request')
|
log_mail(recipient_id, sender_id, 'started_sharing')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
:subject => I18n.t('notifier.new_request.subject', :from => @sender.name), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def request_accepted(recipient_id, sender_id)
|
|
||||||
@receiver = User.find_by_id(recipient_id)
|
|
||||||
@sender = Person.find_by_id(sender_id)
|
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'request_accepted')
|
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
|
||||||
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
|
|
||||||
module Job
|
|
||||||
class MailRequestAcceptance < Base
|
|
||||||
@queue = :mail
|
|
||||||
def self.perform_delegate(recipient_id, sender_id, target_id)
|
|
||||||
Notifier.request_accepted(recipient_id, sender_id).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
|
|
||||||
module Job
|
module Job
|
||||||
class MailRequestReceived < Base
|
class MailStartedSharing < Base
|
||||||
@queue = :mail
|
@queue = :mail
|
||||||
def self.perform_delegate(recipient_id, sender_id, target_id)
|
def self.perform_delegate(recipient_id, sender_id, target_id)
|
||||||
Notifier.new_request(recipient_id, sender_id).deliver
|
Notifier.started_sharing(recipient_id, sender_id).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
class Notifications::NewRequest < Notification
|
|
||||||
def mail_job
|
|
||||||
Job::MailRequestReceived
|
|
||||||
end
|
|
||||||
def translation_key
|
|
||||||
'new_request'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
8
app/models/notifications/started_sharing.rb
Normal file
8
app/models/notifications/started_sharing.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
class Notifications::StartedSharing < Notification
|
||||||
|
def mail_job
|
||||||
|
Job::MailStartedSharing
|
||||||
|
end
|
||||||
|
def translation_key
|
||||||
|
'started_sharing'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -53,11 +53,7 @@ class Request < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def notification_type(user, person)
|
def notification_type(user, person)
|
||||||
if Contact.unscoped.where(:user_id => user.id, :person_id => person.id).first
|
Notifications::StartedSharing
|
||||||
Notifications::RequestAccepted
|
|
||||||
else
|
|
||||||
Notifications::NewRequest
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscribers(user)
|
def subscribers(user)
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,11 @@ class UserPreference < ActiveRecord::Base
|
||||||
|
|
||||||
validate :must_be_valid_email_type
|
validate :must_be_valid_email_type
|
||||||
|
|
||||||
|
|
||||||
VALID_EMAIL_TYPES =
|
VALID_EMAIL_TYPES =
|
||||||
["mentioned",
|
["mentioned",
|
||||||
"comment_on_post",
|
"comment_on_post",
|
||||||
"private_message",
|
"private_message",
|
||||||
"request_acceptance",
|
"started_sharing",
|
||||||
"request_received",
|
|
||||||
"also_commented"]
|
"also_commented"]
|
||||||
|
|
||||||
def must_be_valid_email_type
|
def must_be_valid_email_type
|
||||||
|
|
|
||||||
|
|
@ -48,5 +48,5 @@
|
||||||
= notification_people_link(note)
|
= notification_people_link(note)
|
||||||
= object_link(note)
|
= object_link(note)
|
||||||
|
|
||||||
%span.time= timeago(note.created_at)
|
.time= timeago(note.created_at)
|
||||||
= will_paginate @notifications
|
= will_paginate @notifications
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
%p
|
|
||||||
= t('notifier.hello', :name => @receiver.email)
|
|
||||||
%p
|
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
= t('notifier.new_request.just_sent_you')
|
|
||||||
= t('.try_it_out')
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), new_user_session_url
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.new_request.just_sent_you')
|
|
||||||
!= t('notifier.new_request.try_it_out')
|
|
||||||
|
|
||||||
!= "#{t('notifier.new_request.sign_in')}: #{new_user_session_url}"
|
|
||||||
|
|
||||||
!= t('notifier.love')
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||||
%p
|
%p
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||||
= t('.accepted')
|
= t('.sharing')
|
||||||
|
|
||||||
%br
|
%br
|
||||||
= link_to t('.sign_in'), new_user_session_url
|
= link_to t('.sign_in'), new_user_session_url
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||||
!= t('notifier.request_accepted.accepted')
|
!= t('notifier.started_sharing.sharing')
|
||||||
|
|
||||||
!= t('.sign_in')
|
!= t('.sign_in')
|
||||||
!= new_user_session_url
|
!= new_user_session_url
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
.span-15.last
|
.span-15.last
|
||||||
#author_info
|
#author_info
|
||||||
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
|
- if user_signed_in? && !((@contact.persisted? && @contact.mutual) || current_user.person == @person)
|
||||||
.right
|
.right
|
||||||
= link_to t('.start_sharing'),
|
= link_to t('.start_sharing'),
|
||||||
{:controller => "contacts",
|
{:controller => "contacts",
|
||||||
|
|
|
||||||
|
|
@ -90,11 +90,6 @@
|
||||||
= type.label t('.comment_on_post')
|
= type.label t('.comment_on_post')
|
||||||
= type.check_box :comment_on_post, {:checked => @email_prefs['comment_on_post']}, false, true
|
= type.check_box :comment_on_post, {:checked => @email_prefs['comment_on_post']}, false, true
|
||||||
|
|
||||||
%br
|
|
||||||
%p.checkbox_select
|
|
||||||
= type.label t('.request_received')
|
|
||||||
= type.check_box :request_received, {:checked => @email_prefs['request_received']}, false, true
|
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%p.checkbox_select
|
%p.checkbox_select
|
||||||
= type.label t('.private_message')
|
= type.label t('.private_message')
|
||||||
|
|
@ -102,8 +97,8 @@
|
||||||
|
|
||||||
%br
|
%br
|
||||||
%p.checkbox_select
|
%p.checkbox_select
|
||||||
= type.label t('.request_acceptence')
|
= type.label t('.started_sharing')
|
||||||
= type.check_box :request_acceptance, {:checked => @email_prefs['request_acceptance']}, false, true
|
= type.check_box :started_sharing, {:checked => @email_prefs['started_sharing']}, false, true
|
||||||
|
|
||||||
%br
|
%br
|
||||||
= f.submit t('.change')
|
= f.submit t('.change')
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ en:
|
||||||
other: "%{count} people disliked this"
|
other: "%{count} people disliked this"
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
request_accepted: "accepted your share request."
|
started_sharing: "started sharing with you."
|
||||||
new_request: "offered to share with you."
|
new_request: "offered to share with you."
|
||||||
private_message: "sent you a message."
|
private_message: "sent you a message."
|
||||||
comment_on_post: "commented on your"
|
comment_on_post: "commented on your"
|
||||||
|
|
@ -313,14 +313,9 @@ en:
|
||||||
single_admin:
|
single_admin:
|
||||||
subject: "A message about your Diaspora account:"
|
subject: "A message about your Diaspora account:"
|
||||||
admin: "Your Diaspora administrator"
|
admin: "Your Diaspora administrator"
|
||||||
new_request:
|
started_sharing:
|
||||||
subject: "new Diaspora* contact request from %{from}"
|
subject: "%{name} has started sharing with you on Diaspora*"
|
||||||
just_sent_you: "just sent you a contact request on Diaspora*"
|
sharing: "has started sharing with you!"
|
||||||
try_it_out: "You should really think about checking it out."
|
|
||||||
sign_in: "Sign in here"
|
|
||||||
request_accepted:
|
|
||||||
subject: "%{name} has accepted your contact request on Diaspora*"
|
|
||||||
accepted: "has accepted your contact request!"
|
|
||||||
sign_in: "Sign in here"
|
sign_in: "Sign in here"
|
||||||
comment_on_post:
|
comment_on_post:
|
||||||
subject: "%{name} has commented on your post."
|
subject: "%{name} has commented on your post."
|
||||||
|
|
@ -614,8 +609,7 @@ en:
|
||||||
also_commented: "...someone also comments on your contact's post?"
|
also_commented: "...someone also comments on your contact's post?"
|
||||||
comment_on_post: "...someone comments on your post?"
|
comment_on_post: "...someone comments on your post?"
|
||||||
mentioned: "...you are mentioned in a post?"
|
mentioned: "...you are mentioned in a post?"
|
||||||
request_received: "...you receive a new share request?"
|
started_sharing: "...someone starts sharing with you?"
|
||||||
request_acceptence: "...your share request is accepted?"
|
|
||||||
private_message: "...you receive a private message?"
|
private_message: "...you receive a private message?"
|
||||||
change: "Change"
|
change: "Change"
|
||||||
destroy: "Account successfully closed."
|
destroy: "Account successfully closed."
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ class ContactRemovePendingAddMutual < ActiveRecord::Migration
|
||||||
SET contacts.mutual = true
|
SET contacts.mutual = true
|
||||||
WHERE contacts.pending = false
|
WHERE contacts.pending = false
|
||||||
SQL
|
SQL
|
||||||
|
)
|
||||||
|
|
||||||
|
execute( <<SQL
|
||||||
|
DELETE user_preferences.* FROM user_preferences
|
||||||
|
WHERE user_preferences.email_type = 'request_acceptance'
|
||||||
|
OR user_preferences.email_type = 'request_received'
|
||||||
|
SQL
|
||||||
)
|
)
|
||||||
|
|
||||||
remove_foreign_key "contacts", "people"
|
remove_foreign_key "contacts", "people"
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,14 @@ Feature: disconnecting users
|
||||||
| confirm | no contacts |
|
| confirm | no contacts |
|
||||||
| reject | 1 contact |
|
| reject | 1 contact |
|
||||||
|
|
||||||
Scenario Outline: remove last contact from the contact show page
|
Scenario Outline: remove the contact from the last aspect on the contact show page
|
||||||
When I am on "alice@alice.alice"'s page
|
When I am on "alice@alice.alice"'s page
|
||||||
And I follow "edit aspect membership"
|
And I follow "edit aspect membership"
|
||||||
And I preemptively <accept> the alert
|
|
||||||
And I press the first ".added" within "#facebox #aspects_list ul > li:first-child"
|
And I press the first ".added" within "#facebox #aspects_list ul > li:first-child"
|
||||||
|
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
And I am on the manage aspects page
|
And I am on the manage aspects page
|
||||||
Then I should see <contacts> in "Besties"
|
Then I should see no contacts in "Besties"
|
||||||
|
|
||||||
Examples:
|
|
||||||
| accept | contacts |
|
|
||||||
| confirm | no contacts |
|
|
||||||
| reject | 1 contact |
|
|
||||||
|
|
||||||
Scenario: remove contact from the aspect edit page
|
Scenario: remove contact from the aspect edit page
|
||||||
When I go to the home page
|
When I go to the home page
|
||||||
|
|
@ -55,15 +49,3 @@ Feature: disconnecting users
|
||||||
And I am on the manage aspects page
|
And I am on the manage aspects page
|
||||||
Then I should see no contacts in "Besties"
|
Then I should see no contacts in "Besties"
|
||||||
|
|
||||||
Scenario: cancel removing contact from the contact show page
|
|
||||||
When I go to the home page
|
|
||||||
And I press the first ".contact-count" within "#aspect_listings"
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
|
|
||||||
And I preemptively reject the alert
|
|
||||||
And I press the first ".added" within "#facebox .contact_list ul > li:first-child"
|
|
||||||
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
And I am on the manage aspects page
|
|
||||||
Then I should see 1 contact in "Besties"
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ Feature: managing contact requests
|
||||||
Background:
|
Background:
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
And I have an aspect called "Family"
|
And I have an aspect called "Family"
|
||||||
And I have one contact request
|
And I have one follower
|
||||||
|
|
||||||
Scenario: seeing contact request notifications
|
Scenario: seeing contact request notifications
|
||||||
When I am on the home page
|
When I am on the home page
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ Feature: Notifications
|
||||||
|
|
||||||
Scenario: someone offers to share with me
|
Scenario: someone offers to share with me
|
||||||
Given I am signed in
|
Given I am signed in
|
||||||
And I have one contact request
|
And I have one follower
|
||||||
And I follow "notifications" in the header
|
And I follow "notifications" in the header
|
||||||
Then I should see "offered to share with you"
|
Then I should see "started sharing with you"
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,10 @@ When /^I have user with username "([^"]*)" in an aspect called "([^"]*)"$/ do |u
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Given /^I have one contact request$/ do
|
Given /^I have one follower$/ do
|
||||||
other_user = Factory(:user)
|
other_user = Factory(:user)
|
||||||
other_aspect = other_user.aspects.create!(:name => "meh")
|
other_aspect = other_user.aspects.create!(:name => "meh")
|
||||||
other_user.send_contact_request_to(@me.person, other_aspect)
|
other_user.share_with(@me.person, other_aspect)
|
||||||
|
|
||||||
other_user.reload
|
other_user.reload
|
||||||
other_aspect.reload
|
other_aspect.reload
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ module Diaspora
|
||||||
p = Post.arel_table
|
p = Post.arel_table
|
||||||
post_ids = []
|
post_ids = []
|
||||||
if contact = self.contact_for(person)
|
if contact = self.contact_for(person)
|
||||||
post_ids = Post.connection.execute(contact.post_visibilities.select('post_visibilities.post_id').to_sql).map{|r| r.first}
|
post_ids = Post.connection.execute(contact.post_visibilities.where(:hidden => false).select('post_visibilities.post_id').to_sql).map{|r| r.first}
|
||||||
end
|
end
|
||||||
post_ids += Post.connection.execute(person.posts.where(:public => true).select('posts.id').to_sql).map{|r| r.first}
|
post_ids += Post.connection.execute(person.posts.where(:public => true).select('posts.id').to_sql).map{|r| r.first}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,18 @@ describe PostVisibilitiesController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user1 = alice
|
|
||||||
@bob = bob
|
|
||||||
sign_in :user, @user1
|
|
||||||
|
|
||||||
a2 = bob.aspects.create(:name => "two")
|
a2 = bob.aspects.create(:name => "two")
|
||||||
a2.contacts << bob.contact_for(alice.person)
|
bob.contacts.create(:person => alice.person, :aspects => [a2])
|
||||||
a2.save
|
|
||||||
|
|
||||||
|
|
||||||
@status = bob.post(:status_message, :text => "hello", :public => true, :to => a2)
|
@status = bob.post(:status_message, :text => "hello", :public => true, :to => a2)
|
||||||
@vis = @status.post_visibilities.first
|
@vis = @status.post_visibilities.first
|
||||||
@vis.reload.hidden.should == false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
|
before do
|
||||||
|
sign_in :user, alice
|
||||||
|
end
|
||||||
|
|
||||||
context "on a post you can see" do
|
context "on a post you can see" do
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
put :update, :format => :js, :id => 42, :post_id => @status.id
|
put :update, :format => :js, :id => 42, :post_id => @status.id
|
||||||
|
|
@ -31,27 +28,28 @@ describe PostVisibilitiesController do
|
||||||
|
|
||||||
it 'marks hidden if visible' do
|
it 'marks hidden if visible' do
|
||||||
put :update, :format => :js, :id => 42, :post_id => @status.id
|
put :update, :format => :js, :id => 42, :post_id => @status.id
|
||||||
@vis.reload.hidden.should == true
|
@vis.reload.hidden.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'marks visible if hidden' do
|
it 'marks visible if hidden' do
|
||||||
@vis.hidden = true
|
@vis.update_attributes(:hidden => true)
|
||||||
@vis.save!
|
|
||||||
put :update, :format => :js, :id => 42, :post_id => @status.id
|
put :update, :format => :js, :id => 42, :post_id => @status.id
|
||||||
@vis.reload.hidden.should == false
|
@vis.reload.hidden.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "post you do not see" do
|
context "post you do not see" do
|
||||||
before do
|
before do
|
||||||
user2 = eve
|
sign_in :user, eve
|
||||||
sign_in :user, user2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not let a user destroy a visibility that is not theirs' do
|
it 'does not let a user destroy a visibility that is not theirs' do
|
||||||
lambda {
|
lambda {
|
||||||
put :update, :format => :js, :id => 42, :post_id => @status.id
|
put :update, :format => :js, :id => 42, :post_id => @status.id
|
||||||
}.should_not change(@vis.reload, :hidden).to(true)
|
}.should_not change(@vis.reload, :hidden).to(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not succceed' do
|
it 'does not succceed' do
|
||||||
put :update, :format => :js, :id => 42, :post_id => @status.id
|
put :update, :format => :js, :id => 42, :post_id => @status.id
|
||||||
response.should_not be_success
|
response.should_not be_success
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ describe Notifier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".new_request" do
|
describe ".started_sharing" do
|
||||||
let!(:request_mail) {Notifier.new_request(user.id, person.id)}
|
let!(:request_mail) {Notifier.started_sharing(user.id, person.id)}
|
||||||
it 'goes to the right person' do
|
it 'goes to the right person' do
|
||||||
request_mail.to.should == [user.email]
|
request_mail.to.should == [user.email]
|
||||||
end
|
end
|
||||||
|
|
@ -61,7 +61,6 @@ describe Notifier do
|
||||||
request_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
request_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'has the name of person sending the request' do
|
it 'has the name of person sending the request' do
|
||||||
request_mail.body.encoded.include?(person.name).should be true
|
request_mail.body.encoded.include?(person.name).should be true
|
||||||
end
|
end
|
||||||
|
|
@ -71,22 +70,6 @@ describe Notifier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".request_accepted" do
|
|
||||||
let!(:request_accepted_mail) {Notifier.request_accepted(user.id, person.id)}
|
|
||||||
it 'goes to the right person' do
|
|
||||||
request_accepted_mail.to.should == [user.email]
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
|
||||||
request_accepted_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the name of person sending the request' do
|
|
||||||
request_accepted_mail.body.encoded.include?(person.name).should be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
describe ".mentioned" do
|
describe ".mentioned" do
|
||||||
before do
|
before do
|
||||||
@user = alice
|
@user = alice
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ describe Notification do
|
||||||
:actors => [@person],
|
:actors => [@person],
|
||||||
:recipient_id => @user.id}
|
:recipient_id => @user.id}
|
||||||
|
|
||||||
n = Notifications::NewRequest.new(opts)
|
n = Notifications::StartedSharing.new(opts)
|
||||||
n.stub!(:recipient).and_return @user
|
n.stub!(:recipient).and_return @user
|
||||||
|
|
||||||
@user.should_receive(:mail)
|
@user.should_receive(:mail)
|
||||||
|
|
|
||||||
|
|
@ -51,18 +51,11 @@ describe Request do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notification_type' do
|
describe '#notification_type' do
|
||||||
before do
|
|
||||||
@request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns request_accepted' do
|
it 'returns request_accepted' do
|
||||||
pending 'TODO(*) take out request accepted'
|
request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect)
|
||||||
@user.contacts.create(:person_id => @person.id)
|
@user.contacts.create(:person_id => @person.id)
|
||||||
@request.notification_type(@user, @person).should == Notifications::RequestAccepted
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns new_request' do
|
request.notification_type(@user, @person).should == Notifications::StartedSharing
|
||||||
@request.notification_type(@user, @person).should == Notifications::NewRequest
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,6 @@ describe Diaspora::UserModules::Connecting do
|
||||||
}.from(true).to(false)
|
}.from(true).to(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "deletes the disconnected user's posts from visible_posts" do
|
it "deletes the disconnected user's posts from visible_posts" do
|
||||||
StatusMessage.delete_all
|
StatusMessage.delete_all
|
||||||
message = alice.post(:status_message, :text => "hi", :to => alice.aspects.first.id)
|
message = alice.post(:status_message, :text => "hi", :to => alice.aspects.first.id)
|
||||||
|
|
|
||||||
|
|
@ -236,18 +236,22 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'update_user_preferences' do
|
describe 'update_user_preferences' do
|
||||||
|
before do
|
||||||
|
@pref_count = UserPreference::VALID_EMAIL_TYPES.count
|
||||||
|
end
|
||||||
|
|
||||||
it 'unsets disable mail and makes the right amount of prefs' do
|
it 'unsets disable mail and makes the right amount of prefs' do
|
||||||
alice.disable_mail = true
|
alice.disable_mail = true
|
||||||
proc {
|
proc {
|
||||||
alice.update_user_preferences({})
|
alice.update_user_preferences({})
|
||||||
}.should change(alice.user_preferences, :count).by(6)
|
}.should change(alice.user_preferences, :count).by(@pref_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'still sets new prefs to false on update' do
|
it 'still sets new prefs to false on update' do
|
||||||
alice.disable_mail = true
|
alice.disable_mail = true
|
||||||
proc {
|
proc {
|
||||||
alice.update_user_preferences({'mentioned' => false})
|
alice.update_user_preferences({'mentioned' => false})
|
||||||
}.should change(alice.user_preferences, :count).by(5)
|
}.should change(alice.user_preferences, :count).by(@pref_count-1)
|
||||||
alice.reload.disable_mail.should be_false
|
alice.reload.disable_mail.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -488,14 +492,14 @@ describe User do
|
||||||
alice.disable_mail = false
|
alice.disable_mail = false
|
||||||
alice.save
|
alice.save
|
||||||
|
|
||||||
Resque.should_receive(:enqueue).with(Job::MailRequestReceived, alice.id, 'contactrequestid').once
|
Resque.should_receive(:enqueue).with(Job::MailStartedSharing, alice.id, 'contactrequestid').once
|
||||||
alice.mail(Job::MailRequestReceived, alice.id, 'contactrequestid')
|
alice.mail(Job::MailStartedSharing, alice.id, 'contactrequestid')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not enqueue a mail job if the correct corresponding job has a prefrence entry' do
|
it 'does not enqueue a mail job if the correct corresponding job has a prefrence entry' do
|
||||||
alice.user_preferences.create(:email_type => 'request_received')
|
alice.user_preferences.create(:email_type => 'started_sharing')
|
||||||
Resque.should_not_receive(:enqueue)
|
Resque.should_not_receive(:enqueue)
|
||||||
alice.mail(Job::MailRequestReceived, alice.id, 'contactrequestid')
|
alice.mail(Job::MailStartedSharing, alice.id, 'contactrequestid')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue