messageable_users: it's ok to message yourself
fixes #9829 users without any enrollments weren't included in User.messageable_users, but messaging yourself should always be allowed. Test plan: * log in as a user without any enrollments - Go to your inbox. You should be able to message yourself by searching for your name. OR - Go to your profile page on an account with profiles enabled. You should be able to see your profile. Change-Id: If5182d807fe2f3150999d442d30202c22dffa4d1 Reviewed-on: https://gerrit.instructure.com/12819 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
bace9ae25a
commit
3a19b07882
|
@ -2301,6 +2301,12 @@ class User < ActiveRecord::Base
|
|||
AND user_account_associations.user_id = users.id
|
||||
#{user_condition_sql}
|
||||
SQL
|
||||
user_sql << <<-SQL unless options[:context]
|
||||
SELECT #{MESSAGEABLE_USER_COLUMN_SQL}, NULL AS course_id, NULL AS group_id, NULL AS roles
|
||||
FROM users
|
||||
WHERE id = #{self.id}
|
||||
#{user_condition_sql}
|
||||
SQL
|
||||
|
||||
if options[:ids]
|
||||
# provides a way for this user to start a conversation with someone
|
||||
|
|
|
@ -791,6 +791,10 @@ describe User do
|
|||
@deleted_user.destroy
|
||||
end
|
||||
|
||||
it "should include yourself even when not enrolled in courses" do
|
||||
@student.messageable_users(:ids => [@student.id]).should eql [@student]
|
||||
end
|
||||
|
||||
it "should only return users from the specified context and type" do
|
||||
set_up_course_with_users
|
||||
@course.enroll_user(@student, 'StudentEnrollment', :enrollment_state => 'active')
|
||||
|
|
Loading…
Reference in New Issue