Skip to content

Commit 95df678

Browse files
committed
exclude non-active e-mail address from user search
fixes instructuregh-689 test plan: * see the github ticket Change-Id: I90a29ca9b898c72e4aeb4c0a00ebcb3d91dd1880 Reviewed-on: https://gerrit.instructure.com/62996 Tested-by: Jenkins Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
1 parent 60b57bd commit 95df678

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

lib/user_search.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def self.complex_sql
9696
(EXISTS (SELECT 1 FROM #{Pseudonym.quoted_table_name}
9797
WHERE #{like_condition('pseudonyms.sis_user_id')}
9898
AND pseudonyms.user_id = users.id
99-
AND (pseudonyms.workflow_state IS NULL
100-
OR pseudonyms.workflow_state != 'deleted'))
101-
OR (#{like_condition('users.name')})
102-
OR EXISTS (SELECT 1 FROM #{CommunicationChannel.quoted_table_name}
103-
WHERE communication_channels.user_id = users.id
104-
AND (communication_channels.path_type = ?
105-
AND #{like_condition('communication_channels.path')})))
99+
AND pseudonyms.workflow_state='active')
100+
OR (#{like_condition('users.name')})
101+
OR EXISTS (SELECT 1 FROM #{CommunicationChannel.quoted_table_name}
102+
WHERE communication_channels.user_id = users.id
103+
AND communication_channels.path_type = ?
104+
AND #{like_condition('communication_channels.path')}
105+
AND communication_channels.workflow_state='active'))
106106
SQL
107107
end
108108

spec/lib/user_search_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@
162162
end
163163

164164
describe 'searching on emails' do
165-
before { user.communication_channels.create!(:path => 'the.giver@example.com', :path_type => CommunicationChannel::TYPE_EMAIL) }
165+
let(:cc) { user.communication_channels.create!(path: 'the.giver@example.com') }
166+
167+
before do
168+
cc.confirm!
169+
end
166170

167171
it 'matches against an email' do
168172
expect(UserSearch.for_user_in_context("the.giver", course, user)).to eq [user]
@@ -175,7 +179,12 @@
175179
end
176180

177181
it 'will not match channels where the type is not email' do
178-
user.communication_channels.last.update_attributes!(:path_type => CommunicationChannel::TYPE_TWITTER)
182+
cc.update_attributes!(:path_type => CommunicationChannel::TYPE_TWITTER)
183+
expect(UserSearch.for_user_in_context("the.giver", course, user)).to eq []
184+
end
185+
186+
it "doesn't match retired channels" do
187+
cc.retire!
179188
expect(UserSearch.for_user_in_context("the.giver", course, user)).to eq []
180189
end
181190
end

0 commit comments

Comments
 (0)