BigW Consortium Gitlab

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

8
  step 'I see project commits' do
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 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 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 37 38 39 40 41 42
  step 'I fill compare fields with branches' do
    fill_in 'from', with: 'feature'
    fill_in 'to',   with: 'master'

    click_button 'Compare'
  end

43
  step 'I fill compare fields with refs' do
44 45
    fill_in "from", with: sample_commit.parent_id
    fill_in "to",   with: sample_commit.id
46 47 48
    click_button "Compare"
  end

49 50 51 52 53 54 55
  step 'I unfold diff' do
    @diff = first('.js-unfold')
    @diff.click
    sleep 2
  end

  step 'I should see additional file lines' do
56
    page.within @diff.parent do
57
      expect(first('.new_line').text).not_to have_content "..."
58 59 60
    end
  end

61
  step 'I see compared refs' do
62 63
    expect(page).to have_content "Commits (1)"
    expect(page).to have_content "Showing 2 changed files"
64
  end
65

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  step 'I visit commits list page for feature branch' do
    visit namespace_project_commits_path(@project.namespace, @project, 'feature', { limit: 5 })
  end

  step 'I see feature branch commits' do
    commit = @project.repository.commit('0b4bc9a')
    expect(page).to have_content(@project.name)
    expect(page).to have_content(commit.message[0..12])
    expect(page).to have_content(commit.short_id)
  end

  step 'project have an open merge request' do
    create(:merge_request,
           title: 'Feature',
           source_project: @project,
           source_branch: 'feature',
           target_branch: 'master',
           author: @project.users.first
          )
  end

  step 'I click the "Compare" tab' do
    click_link('Compare')
  end

  step 'I fill compare fields with branches' do
    fill_in 'from', with: 'master'
    fill_in 'to',   with: 'feature'

    click_button 'Compare'
  end

  step 'I see compared branches' do
    expect(page).to have_content 'Commits (1)'
    expect(page).to have_content 'Showing 1 changed file with 5 additions and 0 deletions'
  end

  step 'I see button to create a new merge request' do
    expect(page).to have_link 'Create Merge Request'
  end

  step 'I should not see button to create a new merge request' do
108
    expect(page).not_to have_link 'Create Merge Request'
109 110 111 112
  end

  step 'I should see button to the merge request' do
    merge_request = MergeRequest.find_by(title: 'Feature')
113
    expect(page).to have_link "View Open Merge Request", href: namespace_project_merge_request_path(@project.namespace, @project, merge_request)
114 115
  end

116
  step 'I see breadcrumb links' do
117 118
    expect(page).to have_selector('ul.breadcrumb')
    expect(page).to have_selector('ul.breadcrumb a', count: 4)
119
  end
randx committed
120

121
  step 'I see commits stats' do
122 123 124 125
    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 committed
126
  end
127

128
  step 'I visit a commit with an image that changed' do
Vinnie Okada committed
129
    visit namespace_project_commit_path(@project.namespace, @project, sample_image_commit.id)
130 131
  end

132
  step 'The diff links to both the previous and current image' do
133
    links = page.all('.two-up span div a')
134 135
    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}}
136
  end
137

138
  step 'I see inline diff button' do
139
    expect(page).to have_content "Inline"
140
  end
141 142 143 144

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

  step 'commit has ci status' do
147
    @project.enable_ci
148 149
    pipeline = create :ci_pipeline, project: @project, sha: sample_commit.id
    create :ci_build, pipeline: pipeline
150 151
  end

152
  step 'repository contains ".gitlab-ci.yml" file' do
153
    allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(String.new)
154 155
  end

156
  step 'I see commit ci info' do
Kamil Trzcinski committed
157
    expect(page).to have_content "Builds for 1 pipeline pending"
158 159 160
  end

  step 'I click status link' do
Kamil Trzcinski committed
161
    find('.commit-ci-menu').click_link "Builds"
162 163 164
  end

  step 'I see builds list' do
Kamil Trzcinski committed
165
    expect(page).to have_content "Builds for 1 pipeline pending"
Douwe Maan committed
166
    expect(page).to have_content "1 build"
167
  end
168 169 170 171 172 173 174 175 176

  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
177
end