Commit 61d4410b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge remote-tracking branch 'upstream/master' into fix-download-artifacts-button-link

* upstream/master:
  Reset pushes_since_gc counter before specs run to ensure starting point is 0
  Add missing spec for ProtectedBranches::CreateService
  Refactor boards_spec.rb to avoid code duplication
  Render invalid template for merge requests without source project and open
parents cc51e76e 661c464c
...@@ -428,6 +428,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -428,6 +428,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def validates_merge_request def validates_merge_request
# If source project was removed and merge request for some reason
# wasn't close (Ex. mr from fork to origin)
return invalid_mr if !@merge_request.source_project && @merge_request.open?
# Show git not found page # Show git not found page
# if there is no saved commits between source & target branch # if there is no saved commits between source & target branch
if @merge_request.commits.blank? if @merge_request.commits.blank?
......
...@@ -94,15 +94,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -94,15 +94,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
it 'shows issues in lists' do it 'shows issues in lists' do
page.within(find('.board:nth-child(2)')) do wait_for_board_cards(2, 2)
expect(page.find('.board-header')).to have_content('2') wait_for_board_cards(3, 2)
expect(page).to have_selector('.card', count: 2)
end
page.within(find('.board:nth-child(3)')) do
expect(page.find('.board-header')).to have_content('2')
expect(page).to have_selector('.card', count: 2)
end
end end
it 'shows confidential issues with icon' do it 'shows confidential issues with icon' do
...@@ -203,37 +196,33 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -203,37 +196,33 @@ describe 'Issue Boards', feature: true, js: true do
context 'backlog' do context 'backlog' do
it 'shows issues in backlog with no labels' do it 'shows issues in backlog with no labels' do
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 6)
expect(page.find('.board-header')).to have_content('6')
expect(page).to have_selector('.card', count: 6)
end
end end
it 'moves issue from backlog into list' do it 'moves issue from backlog into list' do
drag_to(list_to_index: 1) drag_to(list_to_index: 1)
page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
end
wait_for_vue_resource wait_for_vue_resource
wait_for_board_cards(1, 5)
page.within(find('.board:nth-child(2)')) do wait_for_board_cards(2, 3)
expect(page.find('.board-header')).to have_content('3')
expect(page).to have_selector('.card', count: 3)
end
end end
end end
context 'done' do context 'done' do
it 'shows list of done issues' do it 'shows list of done issues' do
expect(find('.board:nth-child(4)')).to have_selector('.card', count: 1) wait_for_board_cards(4, 1)
wait_for_ajax
end end
it 'moves issue to done' do it 'moves issue to done' do
drag_to(list_from_index: 0, list_to_index: 3) drag_to(list_from_index: 0, list_to_index: 3)
wait_for_board_cards(1, 5)
wait_for_board_cards(2, 2)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 2)
expect(find('.board:nth-child(1)')).not_to have_content(issue9.title)
expect(find('.board:nth-child(4)')).to have_selector('.card', count: 2) expect(find('.board:nth-child(4)')).to have_selector('.card', count: 2)
expect(find('.board:nth-child(4)')).to have_content(issue9.title) expect(find('.board:nth-child(4)')).to have_content(issue9.title)
expect(find('.board:nth-child(4)')).not_to have_content(planning.title) expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
...@@ -242,8 +231,12 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -242,8 +231,12 @@ describe 'Issue Boards', feature: true, js: true do
it 'removes all of the same issue to done' do it 'removes all of the same issue to done' do
drag_to(list_from_index: 1, list_to_index: 3) drag_to(list_from_index: 1, list_to_index: 3)
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 1) wait_for_board_cards(1, 6)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 1) wait_for_board_cards(2, 1)
wait_for_board_cards(3, 1)
wait_for_board_cards(4, 2)
expect(find('.board:nth-child(2)')).not_to have_content(issue6.title)
expect(find('.board:nth-child(4)')).to have_content(issue6.title) expect(find('.board:nth-child(4)')).to have_content(issue6.title)
expect(find('.board:nth-child(4)')).not_to have_content(planning.title) expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
end end
...@@ -253,6 +246,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -253,6 +246,11 @@ describe 'Issue Boards', feature: true, js: true do
it 'changes position of list' do it 'changes position of list' do
drag_to(list_from_index: 1, list_to_index: 2, selector: '.board-header') drag_to(list_from_index: 1, list_to_index: 2, selector: '.board-header')
wait_for_board_cards(1, 6)
wait_for_board_cards(2, 2)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 1)
expect(find('.board:nth-child(2)')).to have_content(development.title) expect(find('.board:nth-child(2)')).to have_content(development.title)
expect(find('.board:nth-child(2)')).to have_content(planning.title) expect(find('.board:nth-child(2)')).to have_content(planning.title)
end end
...@@ -260,8 +258,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -260,8 +258,11 @@ describe 'Issue Boards', feature: true, js: true do
it 'issue moves between lists' do it 'issue moves between lists' do
drag_to(list_from_index: 1, card_index: 1, list_to_index: 2) drag_to(list_from_index: 1, card_index: 1, list_to_index: 2)
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 1) wait_for_board_cards(1, 6)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 3) wait_for_board_cards(2, 1)
wait_for_board_cards(3, 3)
wait_for_board_cards(4, 1)
expect(find('.board:nth-child(3)')).to have_content(issue6.title) expect(find('.board:nth-child(3)')).to have_content(issue6.title)
expect(find('.board:nth-child(3)').all('.card').last).not_to have_content(development.title) expect(find('.board:nth-child(3)').all('.card').last).not_to have_content(development.title)
end end
...@@ -269,8 +270,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -269,8 +270,11 @@ describe 'Issue Boards', feature: true, js: true do
it 'issue moves between lists' do it 'issue moves between lists' do
drag_to(list_from_index: 2, list_to_index: 1) drag_to(list_from_index: 2, list_to_index: 1)
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 3) wait_for_board_cards(1, 6)
expect(find('.board:nth-child(3)')).to have_selector('.card', count: 1) wait_for_board_cards(2, 3)
wait_for_board_cards(3, 1)
wait_for_board_cards(4, 1)
expect(find('.board:nth-child(2)')).to have_content(issue7.title) expect(find('.board:nth-child(2)')).to have_content(issue7.title)
expect(find('.board:nth-child(2)').all('.card').first).not_to have_content(planning.title) expect(find('.board:nth-child(2)').all('.card').first).not_to have_content(planning.title)
end end
...@@ -278,8 +282,12 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -278,8 +282,12 @@ describe 'Issue Boards', feature: true, js: true do
it 'issue moves from done' do it 'issue moves from done' do
drag_to(list_from_index: 3, list_to_index: 1) drag_to(list_from_index: 3, list_to_index: 1)
expect(find('.board:nth-child(2)')).to have_selector('.card', count: 3)
expect(find('.board:nth-child(2)')).to have_content(issue8.title) expect(find('.board:nth-child(2)')).to have_content(issue8.title)
wait_for_board_cards(1, 6)
wait_for_board_cards(2, 3)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 0)
end end
context 'issue card' do context 'issue card' do
...@@ -342,10 +350,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -342,10 +350,7 @@ describe 'Issue Boards', feature: true, js: true do
end end
it 'moves issues from backlog into new list' do it 'moves issues from backlog into new list' do
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 6)
expect(page.find('.board-header')).to have_content('6')
expect(page).to have_selector('.card', count: 6)
end
click_button 'Create new list' click_button 'Create new list'
wait_for_ajax wait_for_ajax
...@@ -356,10 +361,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -356,10 +361,7 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 5)
expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5)
end
end end
end end
end end
...@@ -379,16 +381,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -379,16 +381,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
wait_for_vue_resource wait_for_vue_resource
wait_for_board_cards(1, 1)
page.within(find('.board', match: :first)) do wait_for_empty_boards((2..4))
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end end
it 'filters by assignee' do it 'filters by assignee' do
...@@ -406,15 +400,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -406,15 +400,8 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 1)
expect(page.find('.board-header')).to have_content('1') wait_for_empty_boards((2..4))
expect(page).to have_selector('.card', count: 1)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end end
it 'filters by milestone' do it 'filters by milestone' do
...@@ -431,16 +418,10 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -431,16 +418,10 @@ describe 'Issue Boards', feature: true, js: true do
end end
wait_for_vue_resource wait_for_vue_resource
wait_for_board_cards(1, 0)
page.within(find('.board', match: :first)) do wait_for_board_cards(2, 1)
expect(page.find('.board-header')).to have_content('0') wait_for_board_cards(3, 0)
expect(page).to have_selector('.card', count: 0) wait_for_board_cards(4, 0)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
end end
it 'filters by label' do it 'filters by label' do
...@@ -456,16 +437,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -456,16 +437,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
wait_for_vue_resource wait_for_vue_resource
wait_for_board_cards(1, 1)
page.within(find('.board', match: :first)) do wait_for_empty_boards((2..4))
expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end end
it 'infinite scrolls list with label filter' do it 'infinite scrolls list with label filter' do
...@@ -519,15 +492,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -519,15 +492,8 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 1)
expect(page.find('.board-header')).to have_content('1') wait_for_empty_boards((2..4))
expect(page).to have_selector('.card', count: 1)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end end
it 'filters by no label' do it 'filters by no label' do
...@@ -544,15 +510,10 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -544,15 +510,10 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 5)
expect(page.find('.board-header')).to have_content('5') wait_for_board_cards(2, 0)
expect(page).to have_selector('.card', count: 5) wait_for_board_cards(3, 0)
end wait_for_board_cards(4, 1)
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
end end
it 'filters by clicking label button on issue' do it 'filters by clicking label button on issue' do
...@@ -565,15 +526,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -565,15 +526,8 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
page.within(find('.board', match: :first)) do wait_for_board_cards(1, 1)
expect(page.find('.board-header')).to have_content('1') wait_for_empty_boards((2..4))
expect(page).to have_selector('.card', count: 1)
end
page.within(find('.board:nth-child(2)')) do
expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0)
end
page.within('.labels-filter') do page.within('.labels-filter') do
expect(find('.dropdown-toggle-text')).to have_content(bug.title) expect(find('.dropdown-toggle-text')).to have_content(bug.title)
...@@ -648,4 +602,17 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -648,4 +602,17 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
end end
def wait_for_board_cards(board_number, expected_cards)
page.within(find(".board:nth-child(#{board_number})")) do
expect(page.find('.board-header')).to have_content(expected_cards.to_s)
expect(page).to have_selector('.card', count: expected_cards)
end
end
def wait_for_empty_boards(board_numbers)
board_numbers.each do |board|
wait_for_board_cards(board, 0)
end
end
end end
...@@ -4,6 +4,10 @@ describe Projects::HousekeepingService do ...@@ -4,6 +4,10 @@ describe Projects::HousekeepingService do
subject { Projects::HousekeepingService.new(project) } subject { Projects::HousekeepingService.new(project) }
let(:project) { create :project } let(:project) { create :project }
before do
project.reset_pushes_since_gc
end
after do after do
project.reset_pushes_since_gc project.reset_pushes_since_gc
end end
......
require 'spec_helper'
describe ProtectedBranches::CreateService, services: true do
let(:project) { create(:empty_project) }
let(:user) { project.owner }
let(:params) do
{
name: 'master',
merge_access_levels_attributes: [ { access_level: Gitlab::Access::MASTER } ],
push_access_levels_attributes: [ { access_level: Gitlab::Access::MASTER } ]
}
end
describe '#execute' do
subject(:service) { described_class.new(project, user, params) }
it 'creates a new protected branch' do
expect { service.execute }.to change(ProtectedBranch, :count).by(1)
expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
expect(project.protected_branches.last.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
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