Commit 961d87937b55535ff3ffd041dbc78af82d644daa

Authored by Marin Jankovski
1 parent 2e94f0d2

Add the tests for user search.

Showing 1 changed file with 12 additions and 0 deletions   Show diff stats
spec/models/user_spec.rb
... ... @@ -292,6 +292,18 @@ describe User do
292 292 end
293 293 end
294 294  
  295 + describe 'search' do
  296 + let(:user1) { create(:user, username: 'James', email: 'james@testing.com') }
  297 + let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') }
  298 +
  299 + it "should be case insensitive" do
  300 + User.search(user1.username.upcase).to_a.should == [user1]
  301 + User.search(user1.username.downcase).to_a.should == [user1]
  302 + User.search(user2.username.upcase).to_a.should == [user2]
  303 + User.search(user2.username.downcase).to_a.should == [user2]
  304 + end
  305 + end
  306 +
295 307 describe 'by_username_or_id' do
296 308 let(:user1) { create(:user, username: 'foo') }
297 309  
... ...