download_buttons_spec.rb 1.24 KB
Newer Older
1 2
require 'spec_helper'

3 4 5 6 7
describe 'Projects > Show > Download buttons' do
  let(:user) { create(:user) }
  let(:role) { :developer }
  let(:status) { 'success' }
  let(:project) { create(:project, :repository) }
Lin Jen-Shin's avatar
Lin Jen-Shin committed
8

9
  let(:pipeline) do
Lin Jen-Shin's avatar
Lin Jen-Shin committed
10 11 12 13 14
    create(:ci_pipeline,
           project: project,
           sha: project.commit.sha,
           ref: project.default_branch,
           status: status)
15
  end
Lin Jen-Shin's avatar
Lin Jen-Shin committed
16

17
  let!(:build) do
18 19 20 21 22 23
    create(:ci_build, :success, :artifacts,
           pipeline: pipeline,
           status: pipeline.status,
           name: 'build')
  end

24
  before do
25
    sign_in(user)
26
    project.add_role(user, role)
27 28 29 30 31
  end

  describe 'when checking project main page' do
    context 'with artifacts' do
      before do
32
        visit project_path(project)
33 34
      end

35
      it 'shows download artifacts button' do
36
        href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
37 38

        expect(page).to have_link "Download '#{build.name}'", href: href
39
      end
40

41
      it 'download links have download attribute' do
42 43 44 45 46
        expect(page).to have_selector('a', text: 'Download')
        page.all('a', text: 'Download').each do |link|
          expect(link[:download]).to eq ''
        end
      end
47 48 49
    end
  end
end