senders must now own aspects

This commit is contained in:
Maxwell Salzberg 2011-08-17 11:00:14 -07:00
parent eb8c540ac1
commit e039aabeef
2 changed files with 18 additions and 3 deletions

View file

@ -17,6 +17,7 @@ class Invitation < ActiveRecord::Base
validate :ensure_not_inviting_self, :on => :create
validate :valid_identifier?
validate :sender_owns_aspect?
validates_uniqueness_of :sender_id, :scope => [:identifier, :service], :unless => :admin?
after_create :queue_send! #TODO make this after_commit :queue_saved!, :on => :create
@ -121,6 +122,14 @@ class Invitation < ActiveRecord::Base
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
def valid_identifier?
return false unless self.identifier

View file

@ -24,7 +24,8 @@ describe Invitation do
end
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
@ -35,6 +36,7 @@ describe Invitation do
end
describe 'the invite process' do
before do
end
@ -61,13 +63,17 @@ describe Invitation do
invite.send!
}.should_not change(User, :count)
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
pending
end
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