diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-03-14 11:10:58 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-03-14 11:10:58 +0000 |
commit | 9cd573549fbc1f48e497fe455a1ff8f196840069 (patch) | |
tree | be565600e92f5554231457567afa90c2d5df870c /spec | |
parent | 7e4fcbf9bec34bb4c8e023f3726a99273850f800 (diff) | |
parent | 335736f627c3c4f4a521a59c49ddae1f53eb1434 (diff) | |
download | gitlab-ce-9cd573549fbc1f48e497fe455a1ff8f196840069.tar.gz |
Merge branch 'project-redirects-rspec' into 'master'
Replace project redirects spinach tests with RSpec analog
See merge request gitlab-org/gitlab-ce!17676
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/redirects_spec.rb | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/features/projects/redirects_spec.rb b/spec/features/projects/redirects_spec.rb new file mode 100644 index 00000000000..d1d8ca07035 --- /dev/null +++ b/spec/features/projects/redirects_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' + +describe 'Project redirects' do + let(:user) { create :user } + let(:public_project) { create :project, :public } + let(:private_project) { create :project, :private } + + before do + allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com') + end + + it 'shows public project page' do + visit project_path(public_project) + + page.within '.breadcrumbs .breadcrumb-item-text' do + expect(page).to have_content(public_project.name) + end + end + + it 'redirects to sign in page when project is private' do + visit project_path(private_project) + + expect(current_path).to eq(new_user_session_path) + end + + it 'redirects to sign in page when project does not exist' do + visit project_path(build(:project, :public)) + + expect(current_path).to eq(new_user_session_path) + end + + it 'redirects to public project page after signing in' do + visit project_path(public_project) + + first(:link, 'Sign in').click + + fill_in 'user_login', with: user.email + fill_in 'user_password', with: user.password + click_button 'Sign in' + + expect(status_code).to eq(200) + expect(current_path).to eq("/#{public_project.full_path}") + end + + it 'redirects to private project page after sign in' do + visit project_path(private_project) + + owner = private_project.owner + fill_in 'user_login', with: owner.email + fill_in 'user_password', with: owner.password + click_button 'Sign in' + + expect(status_code).to eq(200) + expect(current_path).to eq("/#{private_project.full_path}") + end + + context 'when signed in' do + before do + sign_in(user) + end + + it 'returns 404 status when project does not exist' do + visit project_path(build(:project, :public)) + + expect(status_code).to eq(404) + end + + it 'returns 404 when project is private' do + visit project_path(private_project) + + expect(status_code).to eq(404) + end + end +end |