commits.rb 4.14 KB
Newer Older
1
class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
Nihad Abbasov's avatar
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedProject
  include SharedPaths
5
  include SharedDiffNote
6
  include RepoHelpers
Nihad Abbasov's avatar
Nihad Abbasov committed
7

8
  step 'I see project commits' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
9
    commit = @project.repository.commit
10 11 12
    expect(page).to have_content(@project.name)
    expect(page).to have_content(commit.message[0..20])
    expect(page).to have_content(commit.short_id)
13 14
  end

15
  step 'I click atom feed link' do
Douwe Maan's avatar
Douwe Maan committed
16
    click_link "Commits Feed"
17 18
  end

19
  step 'I see commits atom feed' do
20
    commit = @project.repository.commit
21 22 23 24
    expect(response_headers['Content-Type']).to have_content("application/atom+xml")
    expect(body).to have_selector("title", text: "#{@project.name}:master commits")
    expect(body).to have_selector("author email", text: commit.author_email)
    expect(body).to have_selector("entry summary", text: commit.description[0..10])
25 26
  end

27
  step 'I click on commit link' do
Vinnie Okada's avatar
Vinnie Okada committed
28
    visit namespace_project_commit_path(@project.namespace, @project, sample_commit.id)
29 30
  end

31
  step 'I see commit info' do
32 33
    expect(page).to have_content sample_commit.message
    expect(page).to have_content "Showing #{sample_commit.files_changed_count} changed files"
34 35
  end

36
  step 'I fill compare fields with refs' do
37 38
    fill_in "from", with: sample_commit.parent_id
    fill_in "to",   with: sample_commit.id
39 40 41
    click_button "Compare"
  end

42 43 44 45 46 47 48
  step 'I unfold diff' do
    @diff = first('.js-unfold')
    @diff.click
    sleep 2
  end

  step 'I should see additional file lines' do
49
    page.within @diff.parent do
50
      expect(first('.new_line').text).not_to have_content "..."
51 52 53
    end
  end

54
  step 'I see compared refs' do
55 56
    expect(page).to have_content "Commits (1)"
    expect(page).to have_content "Showing 2 changed files"
57
  end
58

59
  step 'I see breadcrumb links' do
60 61
    expect(page).to have_selector('ul.breadcrumb')
    expect(page).to have_selector('ul.breadcrumb a', count: 4)
62
  end
randx's avatar
randx committed
63

64
  step 'I see commits stats' do
65 66 67 68
    expect(page).to have_content 'Top 50 Committers'
    expect(page).to have_content 'Committers'
    expect(page).to have_content 'Total commits'
    expect(page).to have_content 'Authors'
randx's avatar
randx committed
69
  end
70

71
  step 'I visit big commit page' do
72
    stub_const('Commit::DIFF_SAFE_FILES', 20)
Vinnie Okada's avatar
Vinnie Okada committed
73
    visit namespace_project_commit_path(@project.namespace, @project, sample_big_commit.id)
74 75
  end

76
  step 'I see big commit warning' do
77 78
    expect(page).to have_content sample_big_commit.message
    expect(page).to have_content "Too many changes"
79
  end
80

81 82 83 84 85 86
  step 'I see "Reload with full diff" link' do
    link = find_link('Reload with full diff')
    expect(link[:href]).to end_with('?force_show_diff=true')
    expect(link[:href]).not_to include('.html')
  end

87
  step 'I visit a commit with an image that changed' do
Vinnie Okada's avatar
Vinnie Okada committed
88
    visit namespace_project_commit_path(@project.namespace, @project, sample_image_commit.id)
89 90
  end

91
  step 'The diff links to both the previous and current image' do
92
    links = page.all('.two-up span div a')
93 94
    expect(links[0]['href']).to match %r{blob/#{sample_image_commit.old_blob_id}}
    expect(links[1]['href']).to match %r{blob/#{sample_image_commit.new_blob_id}}
95
  end
96

97
  step 'I see inline diff button' do
98
    expect(page).to have_content "Inline"
99
  end
100 101 102 103

  step 'I click side-by-side diff button' do
    find('#parallel-diff-btn').click
  end
104 105

  step 'commit has ci status' do
106
    @project.enable_ci
107
    ci_commit = create :ci_commit, project: @project, sha: sample_commit.id
108
    create :ci_build, commit: ci_commit
109 110
  end

111 112 113 114
  step 'repository contains ".gitlab-ci.yml" file' do
    allow_any_instance_of(Ci::Commit).to receive(:ci_yaml_file).and_return(String.new)
  end

115
  step 'I see commit ci info' do
116 117 118 119
    expect(page).to have_content "build: pending"
  end

  step 'I click status link' do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
120
    find('.commit-ci-menu').click_link "Builds"
121 122 123 124
  end

  step 'I see builds list' do
    expect(page).to have_content "build: pending"
Douwe Maan's avatar
Douwe Maan committed
125
    expect(page).to have_content "1 build"
126
  end
127 128 129 130 131 132 133 134 135

  step 'I search "submodules" commits' do
    fill_in 'commits-search', with: 'submodules'
  end

  step 'I should see only "submodules" commits' do
    expect(page).to have_content "More submodules"
    expect(page).not_to have_content "Change some files"
  end
136
end