BigW Consortium Gitlab

root_controller_spec.rb 2.11 KB
Newer Older
Robert Speicher committed
1 2 3
require 'spec_helper'

describe RootController do
4
  describe 'GET index' do
Robert Speicher committed
5 6 7 8 9 10 11 12
    context 'with a user' do
      let(:user) { create(:user) }

      before do
        sign_in(user)
        allow(subject).to receive(:current_user).and_return(user)
      end

13
      context 'who has customized their dashboard setting for starred projects' do
Robert Speicher committed
14 15 16 17 18
        before do
          user.update_attribute(:dashboard, 'stars')
        end

        it 'redirects to their specified dashboard' do
19
          get :index
Robert Speicher committed
20 21 22 23
          expect(response).to redirect_to starred_dashboard_projects_path
        end
      end

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
      context 'who has customized their dashboard setting for project activities' do
        before do
          user.update_attribute(:dashboard, 'project_activity')
        end

        it 'redirects to the activity list' do
          get :index
          expect(response).to redirect_to activity_dashboard_path
        end
      end

      context 'who has customized their dashboard setting for starred project activities' do
        before do
          user.update_attribute(:dashboard, 'starred_project_activity')
        end

        it 'redirects to the activity list' do
          get :index
          expect(response).to redirect_to activity_dashboard_path(filter: 'starred')
        end
      end

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
      context 'who has customized their dashboard setting for groups' do
        before do
          user.update_attribute(:dashboard, 'groups')
        end

        it 'redirects to their group list' do
          get :index
          expect(response).to redirect_to dashboard_groups_path
        end
      end

      context 'who has customized their dashboard setting for todos' do
        before do
          user.update_attribute(:dashboard, 'todos')
        end

        it 'redirects to their todo list' do
          get :index
          expect(response).to redirect_to dashboard_todos_path
        end
      end

Robert Speicher committed
68 69
      context 'who uses the default dashboard setting' do
        it 'renders the default dashboard' do
70 71
          get :index
          expect(response).to render_template 'dashboard/projects/index'
Robert Speicher committed
72 73 74 75 76
        end
      end
    end
  end
end