don't reference conversations table when not needed

and not necessarily there

Change-Id: I8895cefd2343d98384a666584c9c872bf6281bd9
Reviewed-on: https://gerrit.instructure.com/21132
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Cody Cutrer 2013-06-01 07:36:00 -06:00 committed by Brian Palmer
parent 7b8fe27e82
commit 7716f4129e
2 changed files with 17 additions and 2 deletions

View File

@ -115,7 +115,7 @@ class ConversationParticipant < ActiveRecord::Base
EXISTS (
SELECT *
FROM conversation_participants cp
WHERE cp.conversation_id = conversations.id
WHERE cp.conversation_id = conversation_participants.conversation_id
AND user_id IN (?)
)
SQL
@ -124,7 +124,7 @@ class ConversationParticipant < ActiveRecord::Base
(
SELECT COUNT(*)
FROM conversation_participants cp
WHERE cp.conversation_id = conversations.id
WHERE cp.conversation_id = conversation_participants.conversation_id
AND user_id IN (?)
) = ?
SQL

View File

@ -107,6 +107,21 @@ describe ConversationsController do
assigns[:conversations_json][0][:id].should == @c2.conversation_id
end
it "should return conversations matching a user filter" do
course_with_student_logged_in(:active_all => true)
@c1 = conversation
@other_course = course(:active_all => true)
enrollment = @other_course.enroll_student(@user)
enrollment.workflow_state = 'active'
enrollment.save!
@user.reload
@c2 = conversation(:num_other_users => 1, :course => @other_course)
get 'index', :filter => @user.asset_string, :format => 'json', :include_all_conversation_ids => 1
response.should be_success
assigns[:conversations_json].size.should eql 2
end
it "should not allow student view student to load inbox" do
course_with_teacher_logged_in(:active_all => true)
@fake_student = @course.student_view_student