BigW Consortium Gitlab

commits.rb 5.86 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
16
    click_link "Commits feed"
17 18
  end

19
  step 'I see commits atom feed' do
20
    commit = @project.repository.commit
21 22 23
    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)
24
    expect(body).to have_selector("entry summary", text: commit.description[0..10].delete("\r\n"))
25 26
  end

27 28 29 30 31 32 33 34
  step 'I click on tag link' do
    click_link "Tag"
  end

  step 'I see commit SHA pre-filled' do
    expect(page).to have_selector("input[value='#{sample_commit.id}']")
  end

35
  step 'I click on commit link' do
Vinnie Okada committed
36
    visit namespace_project_commit_path(@project.namespace, @project, sample_commit.id)
37 38
  end

39
  step 'I see commit info' do
40 41
    expect(page).to have_content sample_commit.message
    expect(page).to have_content "Showing #{sample_commit.files_changed_count} changed files"
42 43
  end

44
  step 'I fill compare fields with branches' do
45 46
    select_using_dropdown('from', 'feature')
    select_using_dropdown('to', 'master')
47 48 49 50

    click_button 'Compare'
  end

51
  step 'I fill compare fields with refs' do
52 53
    select_using_dropdown('from', sample_commit.parent_id, true)
    select_using_dropdown('to', sample_commit.id, true)
54

55 56 57
    click_button "Compare"
  end

58 59 60 61 62 63 64
  step 'I unfold diff' do
    @diff = first('.js-unfold')
    @diff.click
    sleep 2
  end

  step 'I should see additional file lines' do
65
    page.within @diff.parent do
66
      expect(first('.new_line').text).not_to have_content "..."
67 68 69
    end
  end

70
  step 'I see compared refs' do
71 72
    expect(page).to have_content "Commits (1)"
    expect(page).to have_content "Showing 2 changed files"
73
  end
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
  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
101 102
    select_using_dropdown('from', 'master')
    select_using_dropdown('to', 'feature')
103 104 105 106 107 108 109 110 111 112

    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
113
    expect(page).to have_link 'Create merge request'
114 115 116
  end

  step 'I should not see button to create a new merge request' do
117
    expect(page).not_to have_link 'Create merge request'
118 119 120 121
  end

  step 'I should see button to the merge request' do
    merge_request = MergeRequest.find_by(title: 'Feature')
122
    expect(page).to have_link "View open merge request", href: namespace_project_merge_request_path(@project.namespace, @project, merge_request)
123 124
  end

125
  step 'I see breadcrumb links' do
126 127
    expect(page).to have_selector('ul.breadcrumb')
    expect(page).to have_selector('ul.breadcrumb a', count: 4)
128
  end
randx committed
129

130
  step 'I see commits stats' do
131 132 133 134
    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
135
  end
136

137
  step 'I visit a commit with an image that changed' do
Vinnie Okada committed
138
    visit namespace_project_commit_path(@project.namespace, @project, sample_image_commit.id)
139 140
  end

141
  step 'The diff links to both the previous and current image' do
142
    links = page.all('.two-up span div a')
143 144
    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}}
145
  end
146

147
  step 'I see inline diff button' do
148
    expect(page).to have_content "Inline"
149
  end
150 151 152 153

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

  step 'commit has ci status' do
156
    @project.enable_ci
157 158
    pipeline = create :ci_pipeline, project: @project, sha: sample_commit.id
    create :ci_build, pipeline: pipeline
159 160
  end

161
  step 'repository contains ".gitlab-ci.yml" file' do
162
    allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(String.new)
163 164
  end

165
  step 'I see commit ci info' do
166
    expect(page).to have_content "Pipeline #1 pending"
167 168
  end

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

178
  def select_using_dropdown(dropdown_type, selection, is_commit = false)
179 180
    dropdown = find(".js-compare-#{dropdown_type}-dropdown")
    dropdown.find(".compare-dropdown-toggle").click
181
    dropdown.find('.dropdown-menu', visible: true)
182 183 184 185 186 187
    dropdown.fill_in("Filter by Git revision", with: selection)
    if is_commit
      dropdown.find('input[type="search"]').send_keys(:return)
    else
      find_link(selection, visible: true).click
    end
188
    dropdown.find('.dropdown-menu', visible: false)
189
  end
190
end