projects_spec.rb 2.42 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Dashboard Projects' do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project, name: 'awesome stuff') }
6
  let(:project2) { create(:project, :public, name: 'Community project') }
7

8
  before do
9
    project.team << [user, :developer]
10 11 12 13 14 15 16
    sign_in(user)
  end

  it_behaves_like "an autodiscoverable RSS feed with current_user's RSS token" do
    before do
      visit dashboard_projects_path
    end
17
  end
18 19 20 21 22 23

  it 'shows the project the user in a member of in the list' do
    visit dashboard_projects_path
    expect(page).to have_content('awesome stuff')
  end

24 25 26 27 28 29 30 31
  it 'shows "New project" button' do
    visit dashboard_projects_path

    page.within '#content-body' do
      expect(page).to have_link('New project')
    end
  end

32 33 34
  context 'when last_repository_updated_at, last_activity_at and update_at are present' do
    it 'shows the last_repository_updated_at attribute as the update date' do
      project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago)
35

36 37 38 39 40
      visit dashboard_projects_path

      expect(page).to have_xpath("//time[@datetime='#{project.last_repository_updated_at.getutc.iso8601}']")
    end
  end
41

42 43 44 45 46 47 48 49 50
  context 'when last_repository_updated_at and last_activity_at are missing' do
    it 'shows the updated_at attribute as the update date' do
      project.update_attributes!(last_repository_updated_at: nil, last_activity_at: nil)
      project.touch

      visit dashboard_projects_path

      expect(page).to have_xpath("//time[@datetime='#{project.updated_at.getutc.iso8601}']")
    end
51 52
  end

53 54 55 56 57 58 59 60 61 62 63
  context 'when on Starred projects tab' do
    it 'shows only starred projects' do
      user.toggle_star(project2)

      visit(starred_dashboard_projects_path)

      expect(page).not_to have_content(project.name)
      expect(page).to have_content(project2.name)
    end
  end

64
  describe "with a pipeline", clean_gitlab_redis_shared_state: true do
65
    let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) }
66 67

    before do
68 69 70 71
      # Since the cache isn't updated when a new pipeline is created
      # we need the pipeline to advance in the pipeline since the cache was created
      # by visiting the login page.
      pipeline.succeed
72 73 74 75
    end

    it 'shows that the last pipeline passed' do
      visit dashboard_projects_path
76

77
      expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit)}']")
78 79
    end
  end
80
end