Spec for posting to no group
This commit is contained in:
parent
72c41a5ff8
commit
abafa03e92
2 changed files with 14 additions and 1 deletions
|
|
@ -45,9 +45,11 @@ class User
|
|||
options[:person] = self.person
|
||||
|
||||
group_ids = options[:to]
|
||||
|
||||
raise "You must post to someone." if group_ids.nil? || group_ids.empty?
|
||||
|
||||
group_ids = [group_ids] unless group_ids.is_a? Array
|
||||
|
||||
return nil if group_ids.nil? || group_ids.empty?
|
||||
group_ids.map!{|gid| ensure_bson gid }
|
||||
options.delete(:to)
|
||||
|
||||
|
|
|
|||
11
spec/models/user/posting_spec.rb
Normal file
11
spec/models/user/posting_spec.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe User do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@group = @user.group(:name => 'heroes')
|
||||
end
|
||||
it 'should not be able to post without a group' do
|
||||
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue