summaryrefslogtreecommitdiff
path: root/spec/controllers/users_controller_spec.rb
blob: d47a37914df78f8135fe66c08d92d61667e3587e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'spec_helper'

describe UsersController do
  let(:user)    { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') }

  before do
    sign_in(user)
  end

  describe 'GET #show' do
    render_views

    it 'renders the show template' do
      get :show, username: user.username
      expect(response.status).to eq(200)
      expect(response).to render_template('show')
    end
  end

  describe 'GET #calendar' do
    it 'renders calendar' do
      get :calendar, username: user.username
      expect(response).to render_template('calendar')
    end
  end

  describe 'GET #calendar_activities' do
    let!(:project) { create(:project) }
    let!(:user) { create(:user) }

    before do
      allow_any_instance_of(User).to receive(:contributed_projects_ids).and_return([project.id])
      project.team << [user, :developer]
    end

    it 'assigns @calendar_date' do
      get :calendar_activities, username: user.username, date: '2014-07-31'
      expect(assigns(:calendar_date)).to eq(Date.parse('2014-07-31'))
    end

    it 'renders calendar_activities' do
      get :calendar_activities, username: user.username
      expect(response).to render_template('calendar_activities')
    end
  end
end