2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe RootController do
|
2015-09-25 12:07:36 +05:30
|
|
|
describe 'GET index' do
|
2017-08-17 22:00:37 +05:30
|
|
|
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-09-11 14:41:01 +05:30
|
|
|
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-10-24 18:46:33 +05:30
|
|
|
context 'who has customized their dashboard setting for starred projects' do
|
2015-09-11 14:41:01 +05:30
|
|
|
before do
|
2017-08-17 22:00:37 +05:30
|
|
|
user.dashboard = 'stars'
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
it 'redirects to their starred projects list' do
|
2015-09-25 12:07:36 +05:30
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
expect(response).to redirect_to starred_dashboard_projects_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
context 'who has customized their dashboard setting for their own activities' do
|
2015-10-24 18:46:33 +05:30
|
|
|
before do
|
2023-04-23 21:23:45 +05:30
|
|
|
user.dashboard = 'your_activity'
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the activity list' do
|
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
expect(response).to redirect_to activity_dashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
context 'who has customized their dashboard setting for project activities' do
|
|
|
|
before do
|
|
|
|
user.dashboard = 'project_activity'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to the projects activity list' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(response).to redirect_to activity_dashboard_path(filter: 'projects')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
context 'who has customized their dashboard setting for starred project activities' do
|
|
|
|
before do
|
2017-08-17 22:00:37 +05:30
|
|
|
user.dashboard = 'starred_project_activity'
|
2015-10-24 18:46:33 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
it 'redirects to their starred projects activity list' do
|
2015-10-24 18:46:33 +05:30
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
expect(response).to redirect_to activity_dashboard_path(filter: 'starred')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
context 'who has customized their dashboard setting for followed user activities' do
|
|
|
|
before do
|
|
|
|
user.dashboard = 'followed_user_activity'
|
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
it 'redirects to the followed users activity list' do
|
2021-04-17 20:07:23 +05:30
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(response).to redirect_to activity_dashboard_path(filter: 'followed')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
context 'who has customized their dashboard setting for groups' do
|
|
|
|
before do
|
2017-08-17 22:00:37 +05:30
|
|
|
user.dashboard = 'groups'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their group list' do
|
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(response).to redirect_to dashboard_groups_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'who has customized their dashboard setting for todos' do
|
|
|
|
before do
|
2017-08-17 22:00:37 +05:30
|
|
|
user.dashboard = 'todos'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to their todo list' do
|
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(response).to redirect_to dashboard_todos_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
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
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(response).to redirect_to issues_dashboard_path(assignee_username: user.username)
|
2018-05-09 12:01:36 +05:30
|
|
|
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
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(response).to redirect_to merge_requests_dashboard_path(assignee_username: user.username)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
context 'who uses the default dashboard setting', :aggregate_failures do
|
|
|
|
render_views
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it 'renders the default dashboard' do
|
|
|
|
get :index
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
expect(response).to render_template 'dashboard/projects/index'
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|