Commit e6a2885c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ce-to-ee-2018-04-11' into 'master'

CE upstream - 2018-04-11 12:26 UTC

See merge request gitlab-org/gitlab-ee!5326
parents 5d9b5118 6fdc6ee7
......@@ -27,20 +27,22 @@
$(document).off('markdown-preview:hide.vue', this.writeMarkdownTab);
},
methods: {
isMarkdownForm(form) {
return form && !form.find('.js-vue-markdown-field').length;
isValid(form) {
return !form ||
form.find('.js-vue-markdown-field').length ||
$(this.$el).closest('form') === form[0];
},
previewMarkdownTab(event, form) {
if (event.target.blur) event.target.blur();
if (this.isMarkdownForm(form)) return;
if (!this.isValid(form)) return;
this.$emit('preview-markdown');
},
writeMarkdownTab(event, form) {
if (event.target.blur) event.target.blur();
if (this.isMarkdownForm(form)) return;
if (!this.isValid(form)) return;
this.$emit('write-markdown');
},
......
---
title: Make toggle markdown preview shortcut only toggle selected field
merge_request:
author:
type: fixed
---
title: "Replace the `project/commits/branches.feature` spinach test with an rspec analog"
merge_request: 18302
author: "@blackst0ne"
type: other
---
title: Replace the `project/issues/milestones.feature` spinach test with an rspec analog
merge_request: 18300
author: "@blackst0ne"
type: other
---
title: Detecting branchnames containing a commit uses Gitaly by default
merge_request:
author:
type: performance
---
title: Detecting tags containing a commit uses Gitaly by default
merge_request:
author:
type: performance
@project_commits
Feature: Project Commits Branches
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has protected branches
Scenario: I can see project all git branches
Given I visit project branches page
Then I should see "Shop" all branches list
Scenario: I can see project protected git branches
Given I visit project protected branches page
Then I should see "Shop" protected branches list
@javascript
Scenario: I create a branch
Given I visit project branches page
And I click new branch link
And I submit new branch form
Then I should see new branch created
@javascript
Scenario: I delete a branch
Given I visit project branches page
And I filter for branch improve/awesome
And I click branch 'improve/awesome' delete link
Then I should not see branch 'improve/awesome'
@javascript
Scenario: I create a branch with invalid name
Given I visit project branches page
And I click new branch link
And I submit new branch form with invalid name
Then I should see new an error that branch is invalid
@javascript
Scenario: I create a branch that already exists
Given I visit project branches page
And I click new branch link
And I submit new branch form with branch that already exists
Then I should see new an error that branch already exists
@project_issues
Feature: Project Issues Milestones
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has milestone "v2.2"
Given I visit project "Shop" milestones page
Scenario: I should see active milestones
Then I should see milestone "v2.2"
Scenario: I should see milestone
Given I click link "v2.2"
Then I should see milestone "v2.2"
@javascript
Scenario: I create and delete new milestone
Given I click link "New Milestone"
And I submit new milestone "v2.3"
Then I should see milestone "v2.3"
Given I click button to remove milestone
And I confirm in modal
When I visit project "Shop" activity page
Then I should see deleted milestone activity
@javascript
Scenario: I delete new milestone
Given I click button to remove milestone
And I confirm in modal
And I should see no milestones
@javascript
Scenario: Listing closed issues
Given the milestone has open and closed issues
And I click link "v2.2"
Then I should see 3 issues
# Markdown
Scenario: Headers inside the description should have ids generated for them.
Given I click link "v2.2"
# PLEASE USE the `have_header_with_correct_id_and_link(level, text, id, parent)` matcher on migrating this spec to rspec.
Then Header "Description header" should have correct id and link
......@@ -7,37 +7,14 @@ class Spinach::Features::ProjectCommitsBranches < Spinach::FeatureSteps
click_link "All"
end
step 'I should see "Shop" all branches list' do
expect(page).to have_content "Branches"
expect(page).to have_content "master"
end
step 'I click link "Protected"' do
click_link "Protected"
end
step 'I should see "Shop" protected branches list' do
page.within ".protected-branches-list" do
expect(page).to have_content "stable"
expect(page).not_to have_content "master"
end
end
step 'project "Shop" has protected branches' do
project = Project.find_by(name: "Shop")
create(:protected_branch, project: project, name: "stable")
end
step 'I click new branch link' do
click_link "New branch"
end
step 'I submit new branch form' do
fill_in 'branch_name', with: 'deploy_keys'
select_branch('master')
click_button 'Create branch'
end
step 'I submit new branch form with invalid name' do
fill_in 'branch_name', with: '1.0 stable'
page.find("body").click # defocus the branch_name input
......@@ -45,40 +22,6 @@ class Spinach::Features::ProjectCommitsBranches < Spinach::FeatureSteps
click_button 'Create branch'
end
step 'I submit new branch form with branch that already exists' do
fill_in 'branch_name', with: 'master'
select_branch('master')
click_button 'Create branch'
end
step 'I should see new branch created' do
expect(page).to have_content 'deploy_keys'
end
step 'I should see new an error that branch is invalid' do
expect(page).to have_content 'Branch name is invalid'
expect(page).to have_content "can't contain spaces"
end
step 'I should see new an error that branch already exists' do
expect(page).to have_content 'Branch already exists'
end
step 'I filter for branch improve/awesome' do
fill_in 'branch-search', with: 'improve/awesome'
find('#branch-search').native.send_keys(:enter)
end
step "I click branch 'improve/awesome' delete link" do
page.within '.js-branch-improve\/awesome' do
accept_alert { find('.btn-remove').click }
end
end
step "I should not see branch 'improve/awesome'" do
expect(page).to have_css('.js-branch-improve\\/awesome', visible: :hidden)
end
def select_branch(branch_name)
find('.git-revision-dropdown-toggle').click
......
......@@ -4,35 +4,6 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps
include SharedPaths
include SharedMarkdown
step 'I should see milestone "v2.2"' do
milestone = @project.milestones.find_by(title: "v2.2")
expect(page).to have_content(milestone.title[0..10])
expect(page).to have_content(milestone.expires_at)
expect(page).to have_content("Issues")
end
step 'I click link "v2.2"' do
click_link "v2.2"
end
step 'I click link "New Milestone"' do
page.within('.nav-controls') do
click_link "New milestone"
end
end
step 'I submit new milestone "v2.3"' do
fill_in "milestone_title", with: "v2.3"
click_button "Create milestone"
end
step 'I should see milestone "v2.3"' do
milestone = @project.milestones.find_by(title: "v2.3")
expect(page).to have_content(milestone.title[0..10])
expect(page).to have_content(milestone.expires_at)
expect(page).to have_content("Issues")
end
step 'project "Shop" has milestone "v2.2"' do
project = Project.find_by(name: "Shop")
milestone = create(:milestone,
......@@ -43,36 +14,7 @@ class Spinach::Features::ProjectIssuesMilestones < Spinach::FeatureSteps
3.times { create(:issue, project: project, milestone: milestone) }
end
step 'the milestone has open and closed issues' do
project = Project.find_by(name: "Shop")
milestone = project.milestones.find_by(title: 'v2.2')
# 3 Open issues created above; create one closed issue
create(:closed_issue, project: project, milestone: milestone)
end
step 'I should see deleted milestone activity' do
expect(page).to have_content('opened milestone in')
expect(page).to have_content('destroyed milestone in')
end
When 'I click link "All Issues"' do
click_link 'All Issues'
end
step 'I should see 3 issues' do
expect(page).to have_selector('#tab-issues li.issuable-row', count: 4)
end
step 'I click button to remove milestone' do
click_button 'Delete'
end
step 'I confirm in modal' do
click_button 'Delete milestone'
end
step 'I should see no milestones' do
expect(page).to have_content('No milestones to show')
end
end
......@@ -10,10 +10,6 @@ module SharedMarkdown
expect(find(:xpath, "#{node.path}/..").text).to eq text
end
step 'Header "Description header" should have correct id and link' do
header_should_have_correct_id_and_link(1, 'Description header', 'description-header')
end
step 'I should not see the Markdown preview' do
expect(find('.gfm-form .js-md-preview')).not_to be_visible
end
......
......@@ -284,10 +284,6 @@ module SharedPaths
visit project_path(project)
end
step 'I visit project "Shop" activity page' do
visit activity_project_path(project)
end
step 'I visit project "Forked Shop" merge requests page' do
visit project_merge_requests_path(@forked_project)
end
......@@ -296,14 +292,6 @@ module SharedPaths
visit edit_project_path(project)
end
step 'I visit project branches page' do
visit project_branches_path(@project)
end
step 'I visit project protected branches page' do
visit project_protected_branches_path(@project)
end
step 'I visit compare refs page' do
visit project_compare_index_path(@project)
end
......@@ -401,10 +389,6 @@ module SharedPaths
visit project_merge_requests_path(project)
end
step 'I visit project "Shop" milestones page' do
visit project_milestones_path(project)
end
step 'I visit project "Shop" team page' do
visit project_project_members_path(project)
end
......
......@@ -1389,7 +1389,8 @@ module Gitlab
end
def branch_names_contains_sha(sha)
gitaly_migrate(:branch_names_contains_sha) do |is_enabled|
gitaly_migrate(:branch_names_contains_sha,
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
gitaly_ref_client.branch_names_contains_sha(sha)
else
......@@ -1399,7 +1400,8 @@ module Gitlab
end
def tag_names_contains_sha(sha)
gitaly_migrate(:tag_names_contains_sha) do |is_enabled|
gitaly_migrate(:tag_names_contains_sha,
status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
gitaly_ref_client.tag_names_contains_sha(sha)
else
......
require 'active_support/hash_with_indifferent_access'
require_relative 'flaky_example'
module RspecFlaky
class FlakyExamplesCollection < SimpleDelegator
def initialize(collection = {})
......
require 'rails_helper'
describe 'Milestone show' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:milestone) { create(:milestone, project: project) }
let(:labels) { create_list(:label, 2, project: project) }
let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone, labels: labels } }
before do
project.add_user(user, :developer)
sign_in(user)
end
def visit_milestone
visit project_milestone_path(project, milestone)
end
it 'avoids N+1 database queries' do
create(:labeled_issue, issue_params)
control = ActiveRecord::QueryRecorder.new { visit_milestone }
create_list(:labeled_issue, 10, issue_params)
expect { visit_milestone }.not_to exceed_query_limit(control)
end
end
require "rails_helper"
describe "User creates milestone", :js do
set(:user) { create(:user) }
set(:project) { create(:project) }
before do
project.add_developer(user)
sign_in(user)
visit(new_project_milestone_path(project))
end
it "creates milestone" do
TITLE = "v2.3".freeze
fill_in("Title", with: TITLE)
fill_in("Description", with: "# Description header")
click_button("Create milestone")
expect(page).to have_content(TITLE)
.and have_content("Issues")
.and have_header_with_correct_id_and_link(1, "Description header", "description-header")
visit(activity_project_path(project))
expect(page).to have_content("#{user.name} opened milestone")
end
end
require "rails_helper"
describe "User deletes milestone", :js do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:milestone) { create(:milestone, project: project) }
before do
project.add_developer(user)
sign_in(user)
visit(project_milestones_path(project))
end
it "deletes milestone" do
click_button("Delete")
click_button("Delete milestone")
expect(page).to have_content("No milestones to show")
visit(activity_project_path(project))
expect(page).to have_content("#{user.name} destroyed milestone")
end
end
require "rails_helper"
describe "User views milestone" do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:milestone) { create(:milestone, project: project) }
set(:labels) { create_list(:label, 2, project: project) }
before do
project.add_developer(user)
sign_in(user)
end
it "avoids N+1 database queries" do
ISSUE_PARAMS = { project: project, assignees: [user], author: user, milestone: milestone, labels: labels }.freeze
create(:labeled_issue, ISSUE_PARAMS)
control = ActiveRecord::QueryRecorder.new { visit_milestone }
create(:labeled_issue, ISSUE_PARAMS)
expect { visit_milestone }.not_to exceed_query_limit(control)
end
private
def visit_milestone
visit(project_milestone_path(project, milestone))
end
end
require "rails_helper"
describe "User views milestones" do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:milestone) { create(:milestone, project: project) }
before do
project.add_developer(user)
sign_in(user)
visit(project_milestones_path(project))
end
it "shows milestone" do
expect(page).to have_content(milestone.title)
.and have_content(milestone.expires_at)
.and have_content("Issues")
end
context "with issues" do
set(:issue) { create(:issue, project: project, milestone: milestone) }
set(:closed_issue) { create(:closed_issue, project: project, milestone: milestone) }
it "opens milestone" do
click_link(milestone.title)
expect(current_path).to eq(project_milestone_path(project, milestone))
expect(page).to have_content(milestone.title)
.and have_selector("#tab-issues li.issuable-row", count: 2)
.and have_content(issue.title)
.and have_content(closed_issue.title)
end
end
end
require "spec_helper"
describe "User creates branch", :js do
include Spec::Support::Helpers::Features::BranchesHelpers
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
before do
project.add_developer(user)
sign_in(user)
visit(new_project_branch_path(project))
end
it "creates new branch" do
BRANCH_NAME = "deploy_keys".freeze
create_branch(BRANCH_NAME)
expect(page).to have_content(BRANCH_NAME)
end
context "when branch name is invalid" do
it "does not create new branch" do
INVALID_BRANCH_NAME = "1.0 stable".freeze
fill_in("branch_name", with: INVALID_BRANCH_NAME)
page.find("body").click # defocus the branch_name input
select_branch("master")
click_button("Create branch")
expect(page).to have_content("Branch name is invalid")
expect(page).to have_content("can't contain spaces")
end
end
context "when branch name already exists" do
it "does not create new branch" do
create_branch("master")
expect(page).to have_content("Branch already exists")
end
end
end
require "spec_helper"
describe "User deletes branch", :js do
set(:user) { create(:user) }
set(:project) { create(:project, :repository) }
before do
project.add_developer(user)
sign_in(user)
visit(project_branches_path(project))
end
it "deletes branch" do
fill_in("branch-search", with: "improve/awesome").native.send_keys(:enter)
page.within(".js-branch-improve\\/awesome") do
accept_alert { find(".btn-remove").click }
end
expect(page).to have_css(".js-branch-improve\\/awesome", visible: :hidden)
end
end
require "spec_helper"
describe "User views branches" do
set(:project) { create(:project, :repository) }
set(:user) { project.owner }
before do
sign_in(user)
end
context "all branches" do
before do
visit(project_branches_path(project))
end
it "shows branches" do
expect(page).to have_content("Branches").and have_content("master")
end
end
context "protected branches" do
set(:protected_branch) { create(:protected_branch, project: project) }
before do
visit(project_protected_branches_path(project))
end
it "shows branches" do
page.within(".protected-branches-list") do
expect(page).to have_content(protected_branch.name).and have_no_content("master")
end
end
end
end
import Vue from 'vue';
import $ from 'jquery';
import headerComponent from '~/vue_shared/components/markdown/header.vue';
describe('Markdown field header component', () => {
let vm;
beforeEach((done) => {
beforeEach(done => {
const Component = Vue.extend(headerComponent);
vm = new Component({
......@@ -17,24 +18,18 @@ describe('Markdown field header component', () => {
});
it('renders markdown buttons', () => {
expect(
vm.$el.querySelectorAll('.js-md').length,
).toBe(7);
expect(vm.$el.querySelectorAll('.js-md').length).toBe(7);
});
it('renders `write` link as active when previewMarkdown is false', () => {
expect(
vm.$el.querySelector('li:nth-child(1)').classList.contains('active'),
).toBeTruthy();
expect(vm.$el.querySelector('li:nth-child(1)').classList.contains('active')).toBeTruthy();
});
it('renders `preview` link as active when previewMarkdown is true', (done) => {
it('renders `preview` link as active when previewMarkdown is true', done => {
vm.previewMarkdown = true;
Vue.nextTick(() => {
expect(
vm.$el.querySelector('li:nth-child(2)').classList.contains('active'),
).toBeTruthy();
expect(vm.$el.querySelector('li:nth-child(2)').classList.contains('active')).toBeTruthy();
done();
});
......@@ -52,16 +47,24 @@ describe('Markdown field header component', () => {
expect(vm.$emit).toHaveBeenCalledWith('write-markdown');
});
it('blurs preview link after click', (done) => {
it('does not emit toggle markdown event when triggered from another form', () => {
spyOn(vm, '$emit');
$(document).triggerHandler('markdown-preview:show', [
$('<form><textarea class="markdown-area"></textarea></textarea></form>'),
]);
expect(vm.$emit).not.toHaveBeenCalled();
});
it('blurs preview link after click', done => {
const link = vm.$el.querySelector('li:nth-child(2) a');
spyOn(HTMLElement.prototype, 'blur');
link.click();
setTimeout(() => {
expect(
link.blur,
).toHaveBeenCalled();
expect(link.blur).toHaveBeenCalled();
done();
});
......
# These helpers allow you to manipulate with sorting features.
#
# Usage:
# describe "..." do
# include Spec::Support::Helpers::Features::BranchesHelpers
# ...
#
# create_branch("feature")
# select_branch("master")
#
module Spec
module Support
module Helpers
module Features
module BranchesHelpers
def create_branch(branch_name, source_branch_name = "master")
fill_in("branch_name", with: branch_name)
select_branch(source_branch_name)
click_button("Create branch")
end
def select_branch(branch_name)
find(".git-revision-dropdown-toggle").click
page.within("#new-branch-form .dropdown-menu") do
click_link(branch_name)
end
end
end
end
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