diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-05-07 15:00:58 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-05-07 15:00:58 +0100 |
commit | 842918602dbe622dc20593c0abea5293e304ac62 (patch) | |
tree | c748164aab8cfa43fe3332640c60e3308b4e9c29 /spec/models/user_spec.rb | |
parent | 214d7880c3d651b367eb73651a6e0e3046868287 (diff) | |
parent | 6ad3814e1b31bfacfae7a2aabb4e4607b12ca66f (diff) | |
download | gitlab-ce-remove-old-isobject.tar.gz |
Merge branch 'master' into remove-old-isobjectremove-old-isobject
* master: (226 commits)
Real time pipeline show action
Fix `Routable.find_by_full_path` on MySQL
add CHANGELOG.md entry for !11138
add tooltips to user contrib graph key
Use an absolute path for locale path in FastGettext config
Colorize labels in issue search field
Fix Karma failures for jQuery deferreds
Reduce risk of deadlocks
Fix failing spec and eslint
Resolve discussions
Resolve discussions
Dry up routable lookups. Fixes #30317
Add “project moved” flash message on redirect
Resolve discussions
Fix Rubocop failures
Index redirect_routes path for LIKE
Add index for source association and for path
Fix or workaround spec failure
Refactor
Delete conflicting redirects
...
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 401eaac07a1..63e71f5ff2f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -849,6 +849,65 @@ describe User, models: true do end end + describe '.find_by_full_path' do + let!(:user) { create(:user) } + + context 'with a route matching the given path' do + let!(:route) { user.namespace.route } + + it 'returns the user' do + expect(User.find_by_full_path(route.path)).to eq(user) + end + + it 'is case-insensitive' do + expect(User.find_by_full_path(route.path.upcase)).to eq(user) + expect(User.find_by_full_path(route.path.downcase)).to eq(user) + end + end + + context 'with a redirect route matching the given path' do + let!(:redirect_route) { user.namespace.redirect_routes.create(path: 'foo') } + + context 'without the follow_redirects option' do + it 'returns nil' do + expect(User.find_by_full_path(redirect_route.path)).to eq(nil) + end + end + + context 'with the follow_redirects option set to true' do + it 'returns the user' do + expect(User.find_by_full_path(redirect_route.path, follow_redirects: true)).to eq(user) + end + + it 'is case-insensitive' do + expect(User.find_by_full_path(redirect_route.path.upcase, follow_redirects: true)).to eq(user) + expect(User.find_by_full_path(redirect_route.path.downcase, follow_redirects: true)).to eq(user) + end + end + end + + context 'without a route or a redirect route matching the given path' do + context 'without the follow_redirects option' do + it 'returns nil' do + expect(User.find_by_full_path('unknown')).to eq(nil) + end + end + context 'with the follow_redirects option set to true' do + it 'returns nil' do + expect(User.find_by_full_path('unknown', follow_redirects: true)).to eq(nil) + end + end + end + + context 'with a group route matching the given path' do + let!(:group) { create(:group, path: 'group_path') } + + it 'returns nil' do + expect(User.find_by_full_path('group_path')).to eq(nil) + end + end + end + describe 'all_ssh_keys' do it { is_expected.to have_many(:keys).dependent(:destroy) } |