2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-06-10 07:59:39 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe RootController do
|
2015-09-08 14:14:14 +00:00
|
|
|
describe 'GET index' do
|
2017-02-24 17:55:32 +00:00
|
|
|
context 'when user is not logged in' do
|
|
|
|
it 'redirects to the sign-in page' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a custom home page URL is defined' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(home_page_url: 'https://gitlab.com')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects the user to the custom home page URL' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(response).to redirect_to('https://gitlab.com')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-10 07:59:39 +00:00
|
|
|
context 'with a user' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
allow(subject).to receive(:current_user).and_return(user)
|
|
|
|
end
|
|
|
|
|
2015-09-26 00:04:20 +00:00
|
|
|
context 'who has customized their dashboard setting for starred projects' do
|
2015-06-10 07:59:39 +00:00
|
|
|
before do
|
2017-02-24 17:55:32 +00:00
|
|
|
user.dashboard = 'stars'
|
2015-06-10 07:59:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their specified dashboard' do
|
2015-09-08 14:14:14 +00:00
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2015-06-10 07:59:39 +00:00
|
|
|
expect(response).to redirect_to starred_dashboard_projects_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-26 00:04:20 +00:00
|
|
|
context 'who has customized their dashboard setting for project activities' do
|
|
|
|
before do
|
2017-02-24 17:55:32 +00:00
|
|
|
user.dashboard = 'project_activity'
|
2015-09-26 00:04:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the activity list' do
|
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2015-09-26 00:04:20 +00:00
|
|
|
expect(response).to redirect_to activity_dashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'who has customized their dashboard setting for starred project activities' do
|
|
|
|
before do
|
2017-02-24 17:55:32 +00:00
|
|
|
user.dashboard = 'starred_project_activity'
|
2015-09-26 00:04:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the activity list' do
|
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2015-09-26 00:04:20 +00:00
|
|
|
expect(response).to redirect_to activity_dashboard_path(filter: 'starred')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-24 10:12:45 +00:00
|
|
|
context 'who has customized their dashboard setting for groups' do
|
|
|
|
before do
|
2017-02-24 17:55:32 +00:00
|
|
|
user.dashboard = 'groups'
|
2016-03-24 10:12:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their group list' do
|
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2016-03-24 10:12:45 +00:00
|
|
|
expect(response).to redirect_to dashboard_groups_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'who has customized their dashboard setting for todos' do
|
|
|
|
before do
|
2017-02-24 17:55:32 +00:00
|
|
|
user.dashboard = 'todos'
|
2016-03-24 10:12:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their todo list' do
|
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2016-03-24 10:12:45 +00:00
|
|
|
expect(response).to redirect_to dashboard_todos_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-27 12:16:12 +00:00
|
|
|
context 'who has customized their dashboard setting for assigned issues' do
|
|
|
|
before do
|
|
|
|
user.dashboard = 'issues'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their assigned issues' do
|
|
|
|
get :index
|
|
|
|
|
2018-10-29 03:03:43 +00:00
|
|
|
expect(response).to redirect_to issues_dashboard_path(assignee_username: user.username)
|
2018-03-27 12:16:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'who has customized their dashboard setting for assigned merge requests' do
|
|
|
|
before do
|
|
|
|
user.dashboard = 'merge_requests'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their assigned merge requests' do
|
|
|
|
get :index
|
|
|
|
|
2018-10-29 03:03:43 +00:00
|
|
|
expect(response).to redirect_to merge_requests_dashboard_path(assignee_username: user.username)
|
2018-03-27 12:16:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-10 07:59:39 +00:00
|
|
|
context 'who uses the default dashboard setting' do
|
|
|
|
it 'renders the default dashboard' do
|
2015-09-08 14:14:14 +00:00
|
|
|
get :index
|
2017-02-24 17:55:32 +00:00
|
|
|
|
2015-09-08 14:14:14 +00:00
|
|
|
expect(response).to render_template 'dashboard/projects/index'
|
2015-06-10 07:59:39 +00:00
|
|
|
end
|
2020-08-18 21:09:57 +00:00
|
|
|
|
|
|
|
context 'when experiment is enabled' do
|
|
|
|
before do
|
|
|
|
stub_experiment_for_user(customize_homepage: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the default dashboard' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(assigns[:customize_homepage]).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when experiment not enabled' do
|
|
|
|
before do
|
|
|
|
stub_experiment(customize_homepage: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the default dashboard' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(assigns[:customize_homepage]).to be false
|
|
|
|
end
|
|
|
|
end
|
2015-06-10 07:59:39 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|