Commit 9a259ef0 authored by Sean McGivern's avatar Sean McGivern

Merge branch...

Merge branch '36870-fix-tests-that-rely-on-the-number-of-tags-or-their-ordering-in-gitlab-test' into 'master'

Fix tests that rely on the number of tags or their ordering in `gitlab-test`

Closes #36870

See merge request gitlab-org/gitlab!20475
parents 4a557819 2be136b6
......@@ -13,7 +13,7 @@ describe Projects::TagsController do
end
it 'returns the tags for the page' do
expect(assigns(:tags).map(&:name)).to eq(['v1.1.0', 'v1.0.0'])
expect(assigns(:tags).map(&:name)).to include('v1.1.0', 'v1.0.0')
end
it 'returns releases matching those tags' do
......
......@@ -837,8 +837,7 @@ describe ProjectsController do
get :refs, params: { namespace_id: project.namespace, id: project, sort: 'updated_desc' }
expect(json_response['Branches']).to include('master')
expect(json_response['Tags'].first).to eq('v1.1.0')
expect(json_response['Tags'].last).to eq('v1.0.0')
expect(json_response['Tags']).to include('v1.0.0')
expect(json_response['Commits']).to be_nil
end
......
......@@ -21,23 +21,21 @@ describe 'Project > Tags', :js do
context 'page with tags list' do
it 'shows tag name' do
page.within first('.tags > .content-list > li') do
expect(page.find('.row-main-content')).to have_content 'v1.1.0 Version 1.1.0'
end
expect(page).to have_content 'v1.1.0 Version 1.1.0'
end
it 'shows tag edit button' do
page.within first('.tags > .content-list > li') do
edit_btn = page.find('.row-fixed-content.controls a.btn-edit')
page.within '.tags > .content-list' do
edit_btn = page.find("li > .row-fixed-content.controls a.btn-edit[href='/#{project.full_path}/-/tags/v1.1.0/release/edit']")
expect(edit_btn['href']).to have_content '/tags/v1.1.0/release/edit'
expect(edit_btn['href']).to end_with("/#{project.full_path}/-/tags/v1.1.0/release/edit")
end
end
end
context 'edit tag release notes' do
before do
find('.tags > .content-list > li:first-child .row-fixed-content.controls a.btn-edit').click
page.find("li > .row-fixed-content.controls a.btn-edit[href='/#{project.full_path}/-/tags/v1.1.0/release/edit']").click
end
it 'shows tag name header' do
......
......@@ -17,7 +17,7 @@ describe 'Developer deletes tag' do
it 'deletes the tag' do
expect(page).to have_content 'v1.1.0'
delete_first_tag
delete_tag 'v1.1.0'
expect(page).not_to have_content 'v1.1.0'
end
......@@ -46,15 +46,15 @@ describe 'Developer deletes tag' do
end
it 'shows the error message' do
delete_first_tag
delete_tag 'v1.1.0'
expect(page).to have_content('Do not delete tags')
end
end
def delete_first_tag
def delete_tag(tag)
page.within('.content') do
accept_confirm { first('.btn-remove').click }
accept_confirm { find("li > .row-fixed-content.controls a.btn-remove[href='/#{project.full_path}/-/tags/#{tag}']").click }
end
end
end
......@@ -15,9 +15,7 @@ describe 'Developer updates tag' do
context 'from the tags list page' do
it 'updates the release notes' do
page.within(first('.content-list .controls')) do
click_link 'Edit release notes'
end
find("li > .row-fixed-content.controls a.btn-edit[href='/#{project.full_path}/-/tags/v1.1.0/release/edit']").click
fill_in 'release_description', with: 'Awesome release notes'
click_button 'Save changes'
......
......@@ -95,24 +95,25 @@ describe TagsFinder do
end
context 'filter and sort' do
it 'filters tags by name and sorts by recently_updated' do
params = { sort: 'updated_desc', search: 'v1' }
tags_finder = described_class.new(repository, params)
let(:tags_to_compare) { %w[v1.0.0 v1.1.0] }
subject { described_class.new(repository, params).execute.select { |tag| tags_to_compare.include?(tag.name) } }
result = tags_finder.execute
context 'when sort by updated_desc' do
let(:params) { { sort: 'updated_desc', search: 'v1' } }
expect(result.first.name).to eq('v1.1.0')
expect(result.count).to eq(2)
it 'filters tags by name' do
expect(subject.first.name).to eq('v1.1.0')
expect(subject.count).to eq(2)
end
end
it 'filters tags by name and sorts by last_updated' do
params = { sort: 'updated_asc', search: 'v1' }
tags_finder = described_class.new(repository, params)
result = tags_finder.execute
context 'when sort by updated_asc' do
let(:params) { { sort: 'updated_asc', search: 'v1' } }
expect(result.first.name).to eq('v1.0.0')
expect(result.count).to eq(2)
it 'filters tags by name' do
expect(subject.first.name).to eq('v1.0.0')
expect(subject.count).to eq(2)
end
end
end
end
......
......@@ -66,14 +66,16 @@ describe Repository do
end
describe 'tags_sorted_by' do
let(:tags_to_compare) { %w[v1.0.0 v1.1.0] }
context 'name_desc' do
subject { repository.tags_sorted_by('name_desc').map(&:name) }
subject { repository.tags_sorted_by('name_desc').map(&:name) & tags_to_compare }
it { is_expected.to eq(['v1.1.0', 'v1.0.0']) }
end
context 'name_asc' do
subject { repository.tags_sorted_by('name_asc').map(&:name) }
subject { repository.tags_sorted_by('name_asc').map(&:name) & tags_to_compare }
it { is_expected.to eq(['v1.0.0', 'v1.1.0']) }
end
......@@ -115,7 +117,7 @@ describe Repository do
context 'annotated tag pointing to a blob' do
let(:annotated_tag_name) { 'annotated-tag' }
subject { repository.tags_sorted_by('updated_asc').map(&:name) }
subject { repository.tags_sorted_by('updated_asc').map(&:name) & (tags_to_compare + [annotated_tag_name]) }
before do
options = { message: 'test tag message\n',
......
......@@ -7,6 +7,7 @@ describe API::Tags do
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
let(:project) { create(:project, :repository, creator: user, path: 'my.project') }
let(:tag_name) { project.repository.find_tag('v1.1.0').name }
let(:tag_message) { project.repository.find_tag('v1.1.0').message }
let(:project_id) { project.id }
let(:current_user) { nil }
......@@ -75,7 +76,7 @@ describe API::Tags do
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers
expect(json_response.first['name']).to eq(tag_name)
expect(json_response.map { |r| r['name'] }).to include(tag_name)
end
context 'when repository is disabled' do
......@@ -135,9 +136,10 @@ describe API::Tags do
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers
expect(json_response.first['name']).to eq(tag_name)
expect(json_response.first['message']).to eq('Version 1.1.0')
expect(json_response.first['release']['description']).to eq(description)
expected_tag = json_response.find { |r| r['name'] == tag_name }
expect(expected_tag['message']).to eq(tag_message)
expect(expected_tag['release']['description']).to eq(description)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment