Skip to content
Snippets Groups Projects

Make getting a user by the username case insensitive

Merged William George requested to merge awgeorge1/gitlab-ce:master into master
All threads resolved!
Compare and Show latest version
1 file
+ 34
0
Compare changes
  • Side-by-side
  • Inline
@@ -6,7+6,7 @@
describe '#execute' do
context 'when the user exists (id)' do
it 'returns the user' do
user = create(:user)
found = described_class.new(user.id).execute
expect(found).to eq(user)
end
end
context 'when the user exists (id as string)' do
it 'returns the user' do
user = create(:user)
found = described_class.new(user.id.to_s).execute
expect(found).to eq(user)
end
end
context 'when the user exists (username)' do
it 'returns the user' do
user = create(:user)
@@ -22,6 +31,14 @@
end
end
context 'when the user does not exist (username)' do
it 'returns nil' do
found = described_class.new("non_existent_username").execute
expect(found).to be_nil
end
end
context 'when the user does not exist' do
it 'returns nil' do
found = described_class.new(1).execute
@@ -41,6 +58,15 @@
end
end
context 'when the user exists (id as string)' do
it 'returns the user' do
user = create(:user)
found = described_class.new(user.id.to_s).execute!
expect(found).to eq(user)
end
end
context 'when the user exists (username)' do
it 'returns the user' do
user = create(:user)
@@ -50,6 +76,14 @@
end
end
context 'when the user does not exist (username)' do
it 'raises ActiveRecord::RecordNotFound' do
finder = described_class.new("non_existent_username")
expect { finder.execute! }.to raise_error(ActiveRecord::RecordNotFound)
end
end
context 'when the user does not exist' do
it 'raises ActiveRecord::RecordNotFound' do
finder = described_class.new(1)
Loading