commits.rb 3.47 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
Kamil Trzcinski's avatar
Kamil Trzcinski committed
107
    create :ci_commit, gl_project: @project, sha: sample_commit.id
108
109
110
111
112
  end

  step 'I see commit ci info' do
    expect(page).to have_content "build: skipped"
  end
113
end