Skip to content
Extraits de code Groupes Projets
Valider e039aabe rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

senders must now own aspects

parent eb8c540a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -17,6 +17,7 @@ class Invitation < ActiveRecord::Base ...@@ -17,6 +17,7 @@ class Invitation < ActiveRecord::Base
validate :ensure_not_inviting_self, :on => :create validate :ensure_not_inviting_self, :on => :create
validate :valid_identifier? validate :valid_identifier?
validate :sender_owns_aspect?
validates_uniqueness_of :sender_id, :scope => [:identifier, :service], :unless => :admin? validates_uniqueness_of :sender_id, :scope => [:identifier, :service], :unless => :admin?
after_create :queue_send! #TODO make this after_commit :queue_saved!, :on => :create after_create :queue_send! #TODO make this after_commit :queue_saved!, :on => :create
...@@ -121,6 +122,14 @@ class Invitation < ActiveRecord::Base ...@@ -121,6 +122,14 @@ class Invitation < ActiveRecord::Base
end end
end end
# @note Validation
def sender_owns_aspect?
unless(self.sender && (self.sender_id == self.aspect.user_id))
errors[:base] << 'You do not own that aspect'
end
end
# @note Validation # @note Validation
def valid_identifier? def valid_identifier?
return false unless self.identifier return false unless self.identifier
......
...@@ -24,7 +24,8 @@ describe Invitation do ...@@ -24,7 +24,8 @@ describe Invitation do
end end
it 'ensures the sender is placing the recipient into one of his aspects' do it 'ensures the sender is placing the recipient into one of his aspects' do
pending @invitation.aspect = Factory(:aspect)
@invitation.should_not be_valid
end end
end end
...@@ -35,6 +36,7 @@ describe Invitation do ...@@ -35,6 +36,7 @@ describe Invitation do
end end
describe 'the invite process' do describe 'the invite process' do
before do before do
end end
...@@ -61,13 +63,17 @@ describe Invitation do ...@@ -61,13 +63,17 @@ describe Invitation do
invite.send! invite.send!
}.should_not change(User, :count) }.should_not change(User, :count)
end end
it 'is able to resend an invite' do
end
it 'handles the case when that user has an invite but not a user' do it 'handles the case when that user has an invite but not a user' do
pending
end end
it 'handles the case where that user has an invite but has not yet accepted' do it 'handles the case where that user has an invite but has not yet accepted' do
pending
end
it 'generate the invitation token and pass it to the user' do
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter