summaryrefslogtreecommitdiff
path: root/spec/features/atom/builds_spec.rb
blob: 72764b1629d2a71f5e36b482f59213097d8d3d81 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'spec_helper'

describe "Admin Builds" do
  let(:commit) { FactoryGirl.create :ci_commit }
  let(:build) { FactoryGirl.create :ci_build, commit: commit }

  before do
    login_as :admin
  end

  describe "GET /admin/builds" do
    before do
      build
      visit admin_builds_path
    end

    it { expect(page).to have_content "Running" }
    it { expect(page).to have_content build.short_sha }
  end

  describe "Tabs" do
    it "shows all builds" do
      FactoryGirl.create :ci_build, commit: commit, status: "pending"
      FactoryGirl.create :ci_build, commit: commit, status: "running"
      FactoryGirl.create :ci_build, commit: commit, status: "success"
      FactoryGirl.create :ci_build, commit: commit, status: "failed"

      visit admin_builds_path

      within ".center-top-menu" do
        click_on "All"
      end

      expect(page.all(".build-link").size).to eq(4)
    end

    it "shows finished builds" do
      build = FactoryGirl.create :ci_build, commit: commit, status: "pending"
      build1 = FactoryGirl.create :ci_build, commit: commit, status: "running"
      build2 = FactoryGirl.create :ci_build, commit: commit, status: "success"

      visit admin_builds_path

      within ".center-top-menu" do
        click_on "Finished"
      end

      expect(page.find(".build-link")).not_to have_content(build.id)
      expect(page.find(".build-link")).not_to have_content(build1.id)
      expect(page.find(".build-link")).to have_content(build2.id)
    end

    it "shows running builds" do
      build = FactoryGirl.create :ci_build, commit: commit, status: "pending"
      build2 = FactoryGirl.create :ci_build, commit: commit, status: "success"
      build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed"

      visit admin_builds_path

      within ".center-top-menu" do
        click_on "Running"
      end

      expect(page.find(".build-link")).to have_content(build.id)
      expect(page.find(".build-link")).not_to have_content(build2.id)
      expect(page.find(".build-link")).not_to have_content(build3.id)
    end
  end
end