Commit fb272910 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ce-to-ee-2018-05-14' into 'master'

CE upstream - 2018-05-14 10:03 UTC

Closes gitaly#1184 and gitaly#1169

See merge request gitlab-org/gitlab-ee!5689
parents 3c93c02e 56f85d29
......@@ -10,6 +10,7 @@ image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.7-golang-1.9-git
paths:
- vendor/ruby
- .yarn-cache/
- vendor/gitaly-ruby
.push-cache: &push-cache
cache:
......@@ -556,6 +557,7 @@ setup-test-env:
paths:
- tmp/tests
- config/secrets.yml
- vendor/gitaly-ruby
# EE jobs
rspec-pg-ee 0 2: *rspec-ee-pg
......
......@@ -747,6 +747,3 @@ When your code contains more than 500 changes, any major breaking changes, or an
[polling-etag]: https://docs.gitlab.com/ce/development/polling.html
[testing]: doc/development/testing_guide/index.md
[us-english]: https://en.wikipedia.org/wiki/American_English
[^1]: Please note that specs other than JavaScript specs are considered backend
code.
......@@ -41,7 +41,7 @@ module EventsHelper
key = key.to_s
active = 'active' if @event_filter.active?(key)
link_opts = {
class: "event-filter-link has-tooltip",
class: "event-filter-link",
id: "#{key}_event_filter",
title: tooltip
}
......
......@@ -5,7 +5,6 @@ require 'rainbow/refinement'
using Rainbow
BRANCH_PREFIX = 'security'.freeze
STABLE_BRANCH_SUFFIX = 'stable'.freeze
REMOTE = 'dev'.freeze
options = { version: nil, branch: nil, sha: nil }
......@@ -37,9 +36,9 @@ abort("Missing options. Use #{$0} --help to see the list of options available".r
abort("Wrong version format #{options[:version].bold}".red) unless options[:version] =~ /\A\d*\-\d*\Z/
branch = [BRANCH_PREFIX, options[:branch], options[:version]].join('-').freeze
stable_branch = "#{options[:version]}-#{STABLE_BRANCH_SUFFIX}".freeze
stable_branch = "#{BRANCH_PREFIX}-#{options[:version]}".freeze
command = "git checkout #{stable_branch} && git pull #{REMOTE} #{stable_branch} && git checkout -B #{branch} && git cherry-pick #{options[:sha]} && git push #{REMOTE} #{branch}"
command = "git fetch #{REMOTE} #{stable_branch} && git checkout #{stable_branch} && git pull #{REMOTE} #{stable_branch} && git checkout -B #{branch} && git cherry-pick #{options[:sha]} && git push #{REMOTE} #{branch}"
_stdin, stdout, stderr = Open3.popen3(command)
......
---
title: Fix system hook not firing for blocked users when LDAP sign-in is used
merge_request:
author:
type: fixed
......@@ -22,7 +22,7 @@ Parameters:
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user |
| `iids[]` | Array[integer] | optional | Return only the milestones having the given `iid` |
| `state` | string | optional | Return only `active` or `closed` milestones` |
| `state` | string | optional | Return only `active` or `closed` milestones |
| `search` | string | optional | Return only milestones with a title or description matching the provided string |
```bash
......
......@@ -29,6 +29,10 @@ There are a few rules to get your merge request accepted:
to ask one of the [Merge request coaches][team].
1. The reviewer will assign the merge request to a maintainer once the
reviewer is satisfied with the state of the merge request.
1. Keep in mind that maintainers are also going to perform a final code review.
The ideal scenario is that the reviewer has already addressed any concerns
the maintainer would have found, and the maintainer only has to perform the
merge, but be prepared for further review comments.
For more guidance, see [CONTRIBUTING.md](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md).
......@@ -207,3 +211,4 @@ Largely based on the [thoughtbot code review guide].
[projects]: https://about.gitlab.com/handbook/engineering/projects/
[team]: https://about.gitlab.com/team/
[build handbook]: https://about.gitlab.com/handbook/build/handbook/build#how-to-work-with-build
[^1]: Please note that specs other than JavaScript specs are considered backend code.
# GitLab Runner Helm Chart
> **Note:**
These charts have been tested on Google Kubernetes Engine and Azure Container Service. Other Kubernetes installations may work as well, if not please [open an issue](https://gitlab.com/charts/charts.gitlab.io/issues).
These charts have been tested on Google Kubernetes Engine and Azure Container Service. Other Kubernetes installations may work as well, if not please [open an issue](https://gitlab.com/charts/gitlab-runner/issues).
The `gitlab-runner` Helm chart deploys a GitLab Runner instance into your
Kubernetes cluster.
......@@ -25,7 +25,7 @@ For more information on available GitLab Helm Charts, please see our [overview](
Create a `values.yaml` file for your GitLab Runner configuration. See [Helm docs](https://github.com/kubernetes/helm/blob/master/docs/chart_template_guide/values_files.md)
for information on how your values file will override the defaults.
The default configuration can always be found in the [values.yaml](https://gitlab.com/charts/charts.gitlab.io/blob/master/charts/gitlab-runner/values.yaml) in the chart repository.
The default configuration can always be found in the [values.yaml](https://gitlab.com/charts/gitlab-runner/blob/master/values.yaml) in the chart repository.
### Required configuration
......@@ -39,7 +39,7 @@ Unless you need to specify additional configuration, you are [ready to install](
### Other configuration
The rest of the configuration is [documented in the `values.yaml`](https://gitlab.com/charts/charts.gitlab.io/blob/master/charts/gitlab-runner/values.yaml) in the chart repository.
The rest of the configuration is [documented in the `values.yaml`](https://gitlab.com/charts/gitlab-runner/blob/master/values.yaml) in the chart repository.
Here is a snippet of the important settings:
......
@project_commits
Feature: Project Commits Diff Comments
Background:
Given I sign in as a user
And I own project "Shop"
And I visit project commit page
@javascript
Scenario: I can comment on a commit diff
Given I leave a diff comment like "Typo, please fix"
Then I should see a diff comment saying "Typo, please fix"
@javascript
Scenario: I can add a diff comment with a single emoji
Given I open a diff comment form
And I write a diff comment like ":smile:"
Then I should see a diff comment with an emoji image
@javascript
Scenario: I get a temporary form for the first comment on a diff line
Given I open a diff comment form
Then I should see a temporary diff comment form
@javascript
Scenario: I have a cancel button on the diff form
Given I open a diff comment form
Then I should see the cancel comment button
@javascript
Scenario: I can cancel a diff form
Given I open a diff comment form
And I cancel the diff comment
Then I should not see the diff comment form
@javascript
Scenario: I can't open a second form for a diff line
Given I open a diff comment form
And I open a diff comment form
Then I should only see one diff form
@javascript
Scenario: I can have multiple forms
Given I open a diff comment form
And I write a diff comment like ":-1: I don't like this"
And I open another diff comment form
Then I should see a diff comment form with ":-1: I don't like this"
And I should see an empty diff comment form
@javascript
Scenario: I can preview multiple forms separately
Given I preview a diff comment text like "Should fix it :smile:"
And I preview another diff comment text like "DRY this up"
Then I should see two separate previews
@javascript
Scenario: I have a reply button in discussions
Given I leave a diff comment like "Typo, please fix"
Then I should see a discussion reply button
@javascript
Scenario: I can preview with text
Given I open a diff comment form
And I write a diff comment like ":-1: I don't like this"
Then The diff comment preview tab should display rendered Markdown
@javascript
Scenario: I preview a diff comment
Given I preview a diff comment text like "Should fix it :smile:"
Then I should see the diff comment preview
And I should not see the diff comment text field
@javascript
Scenario: I can edit after preview
Given I preview a diff comment text like "Should fix it :smile:"
Then I should see the diff comment write tab
@javascript
Scenario: The form gets removed after posting
Given I preview a diff comment text like "Should fix it :smile:"
And I submit the diff comment
Then I should not see the diff comment form
And I should see a discussion reply button
@javascript
Scenario: I can add a comment on a side-by-side commit diff (left side)
Given I open a diff comment form
And I click side-by-side diff button
When I leave a diff comment in a parallel view on the left side like "Old comment"
Then I should see a diff comment on the left side saying "Old comment"
@javascript
Scenario: I can add a comment on a side-by-side commit diff (right side)
Given I open a diff comment form
And I click side-by-side diff button
When I leave a diff comment in a parallel view on the right side like "New comment"
Then I should see a diff comment on the right side saying "New comment"
......@@ -7,12 +7,6 @@ module SharedDiffNote
wait_for_requests if javascript_test?
end
step 'I cancel the diff comment' do
page.within(diff_file_selector) do
find(".js-close-discussion-note-form").click
end
end
step 'I delete a diff comment' do
find('.note').hover
find(".js-note-delete").click
......@@ -24,96 +18,6 @@ module SharedDiffNote
end
end
step 'I leave a diff comment like "Typo, please fix"' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.line_code)
page.within("form[data-line-code='#{sample_commit.line_code}']") do
fill_in "note[note]", with: "Typo, please fix"
find(".js-comment-button").click
end
end
end
step 'I leave a diff comment in a parallel view on the left side like "Old comment"' do
click_parallel_diff_line(sample_commit.del_line_code, 'old')
page.within("#{diff_file_selector} form[data-line-code='#{sample_commit.del_line_code}']") do
fill_in "note[note]", with: "Old comment"
find(".js-comment-button").click
end
end
step 'I leave a diff comment in a parallel view on the right side like "New comment"' do
click_parallel_diff_line(sample_commit.line_code, 'new')
page.within("#{diff_file_selector} form[data-line-code='#{sample_commit.line_code}']") do
fill_in "note[note]", with: "New comment"
find(".js-comment-button").click
end
end
step 'I preview a diff comment text like "Should fix it :smile:"' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.line_code)
page.within("form[data-line-code='#{sample_commit.line_code}']") do
fill_in "note[note]", with: "Should fix it :smile:"
find('.js-md-preview-button').click
end
end
end
step 'I preview another diff comment text like "DRY this up"' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.del_line_code)
page.within("form[data-line-code='#{sample_commit.del_line_code}']") do
fill_in "note[note]", with: "DRY this up"
find('.js-md-preview-button').click
end
end
end
step 'I open a diff comment form' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.line_code)
end
end
step 'I open another diff comment form' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.del_line_code)
end
end
step 'I write a diff comment like ":-1: I don\'t like this"' do
page.within(diff_file_selector) do
fill_in "note[note]", with: ":-1: I don\'t like this"
end
end
step 'I write a diff comment like ":smile:"' do
page.within(diff_file_selector) do
click_diff_line(sample_commit.line_code)
page.within("form[data-line-code='#{sample_commit.line_code}']") do
fill_in 'note[note]', with: ':smile:'
click_button('Comment')
end
end
end
step 'I submit the diff comment' do
page.within(diff_file_selector) do
click_button("Comment")
end
end
step 'I should not see the diff comment form' do
page.within(diff_file_selector) do
expect(page).not_to have_css("form.new_note")
end
end
step 'The diff comment preview tab should say there is nothing to do' do
page.within(diff_file_selector) do
find('.js-md-preview-button').click
......@@ -121,103 +25,6 @@ module SharedDiffNote
end
end
step 'I should not see the diff comment text field' do
page.within(diff_file_selector) do
expect(find('.js-note-text')).not_to be_visible
end
end
step 'I should only see one diff form' do
page.within(diff_file_selector) do
expect(page).to have_css("form.new-note", count: 1)
end
end
step 'I should see a diff comment form with ":-1: I don\'t like this"' do
page.within(diff_file_selector) do
expect(page).to have_field("note[note]", with: ":-1: I don\'t like this")
end
end
step 'I should see a diff comment saying "Typo, please fix"' do
page.within("#{diff_file_selector} .note") do
expect(page).to have_content("Typo, please fix")
end
end
step 'I should see a diff comment on the left side saying "Old comment"' do
page.within("#{diff_file_selector} .notes_content.parallel.old") do
expect(page).to have_content("Old comment")
end
end
step 'I should see a diff comment on the right side saying "New comment"' do
page.within("#{diff_file_selector} .notes_content.parallel.new") do
expect(page).to have_content("New comment")
end
end
step 'I should see a discussion reply button' do
page.within(diff_file_selector) do
expect(page).to have_button('Reply...')
end
end
step 'I should see a temporary diff comment form' do
page.within(diff_file_selector) do
expect(page).to have_css(".js-temp-notes-holder form.new-note")
end
end
step 'I should see an empty diff comment form' do
page.within(diff_file_selector) do
expect(page).to have_field("note[note]", with: "")
end
end
step 'I should see the cancel comment button' do
page.within("#{diff_file_selector} form") do
expect(page).to have_css(".js-close-discussion-note-form", text: "Cancel")
end
end
step 'I should see the diff comment preview' do
page.within("#{diff_file_selector} form") do
expect(page).to have_css('.js-md-preview', visible: true)
end
end
step 'I should see the diff comment write tab' do
page.within(diff_file_selector) do
expect(page).to have_css('.js-md-write-button', visible: true)
end
end
step 'The diff comment preview tab should display rendered Markdown' do
page.within(diff_file_selector) do
find('.js-md-preview-button').click
expect(find('.js-md-preview')).to have_css('gl-emoji', visible: true)
end
end
step 'I should see two separate previews' do
page.within(diff_file_selector) do
expect(page).to have_css('.js-md-preview', visible: true, count: 2)
expect(page).to have_content('Should fix it')
expect(page).to have_content('DRY this up')
end
end
step 'I should see a diff comment with an emoji image' do
page.within("#{diff_file_selector} .note") do
expect(page).to have_xpath("//gl-emoji[@data-name='smile']")
end
end
step 'I click side-by-side diff button' do
find('#parallel-diff-btn').click
end
step 'I see side-by-side diff button' do
expect(page).to have_content "Side-by-side"
end
......
......@@ -307,10 +307,6 @@ module SharedPaths
visit project_tags_path(@project)
end
step 'I visit project commit page' do
visit project_commit_path(@project, sample_commit.id)
end
step 'I visit issue page "Release 0.4"' do
issue = Issue.find_by(title: "Release 0.4")
visit project_issue_path(issue.project, issue)
......
......@@ -13,13 +13,6 @@ module SharedProject
@project.add_master(@user)
end
# Create a specific project called "Shop"
step 'I own project "Shop"' do
@project = Project.find_by(name: "Shop")
@project ||= create(:project, :repository, name: "Shop", namespace: @user.namespace)
@project.add_master(@user)
end
def current_project
@project ||= Project.first
end
......
......@@ -17,7 +17,9 @@ module Gitlab
# message passed along by Warden.
return unless message == User::BLOCKED_MESSAGE
login = env.dig(ACTIVE_RECORD_REQUEST_PARAMS, 'user', 'login')
# Check for either LDAP or regular GitLab account logins
login = env.dig(ACTIVE_RECORD_REQUEST_PARAMS, 'username') ||
env.dig(ACTIVE_RECORD_REQUEST_PARAMS, 'user', 'login')
return unless login.present?
......
......@@ -2,28 +2,29 @@
require 'fileutils'
require_relative 'gitaly_test'
# This script assumes tmp/tests/gitaly already contains the correct
# Gitaly version. We just have to compile it and run its 'bundle
# install'. We have this separate script for that because weird things
# were happening in CI when we have a 'bundle exec' process that later
# called 'bundle install' using a different Gemfile, as happens with
# gitlab-ce and gitaly.
# install'. We have this separate script for that to avoid bundle
# poisoning in CI. This script should only be run in CI.
class GitalyTestBuild
include GitalyTest
tmp_tests_gitaly_dir = File.expand_path('../tmp/tests/gitaly', __dir__)
def run
abort 'gitaly build failed' unless system(env, 'make', chdir: tmp_tests_gitaly_dir)
# Use the top-level bundle vendor folder so that we don't reinstall gems twice
bundle_vendor_path = File.expand_path('../vendor', __dir__)
check_gitaly_config!
env = {
# This ensure the `clean` config set in `scripts/prepare_build.sh` isn't taken into account
'BUNDLE_IGNORE_CONFIG' => 'true',
'BUNDLE_GEMFILE' => File.join(tmp_tests_gitaly_dir, 'ruby', 'Gemfile'),
'BUNDLE_FLAGS' => "--jobs=4 --path=#{bundle_vendor_path} --retry=3"
}
# Starting gitaly further validates its configuration
pid = start_gitaly
Process.kill('TERM', pid)
abort 'gitaly build failed' unless system(env, 'make', chdir: tmp_tests_gitaly_dir)
# Make the 'gitaly' executable look newer than 'GITALY_SERVER_VERSION'.
# Without this a gitaly executable created in the setup-test-env job
# will look stale compared to GITALY_SERVER_VERSION.
FileUtils.touch(File.join(tmp_tests_gitaly_dir, 'gitaly'), mtime: Time.now + (1 << 24))
end
end
# Make the 'gitaly' executable look newer than 'GITALY_SERVER_VERSION'.
# Without this a gitaly executable created in the setup-test-env job
# will look stale compared to GITALY_SERVER_VERSION.
FileUtils.touch(File.join(tmp_tests_gitaly_dir, 'gitaly'), mtime: Time.now + (1 << 24))
GitalyTestBuild.new.run
#!/usr/bin/env ruby
gitaly_dir = 'tmp/tests/gitaly'
env = { 'HOME' => File.expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':') }
args = %W[#{gitaly_dir}/gitaly #{gitaly_dir}/config.toml]
# This script is used both in CI and in local development 'rspec' runs.
# Print the PID of the spawned process
puts spawn(env, *args, [:out, :err] => 'log/gitaly-test.log')
require_relative 'gitaly_test'
class GitalyTestSpawn
include GitalyTest
def run
check_gitaly_config!
# # Uncomment line below to see all gitaly logs merged into CI trace
# spawn('sleep 1; tail -f log/gitaly-test.log')
pid = start_gitaly
# In local development this pid file is used by rspec.
IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), pid)
end
end
GitalyTestSpawn.new.run
# This file contains environment settings for gitaly when it's running
# as part of the gitlab-ce/ee test suite.
#
# Please be careful when modifying this file. Your changes must work
# both for local development rspec runs, and in CI.
require 'socket'
module GitalyTest
def tmp_tests_gitaly_dir
File.expand_path('../tmp/tests/gitaly', __dir__)
end
def gemfile
File.join(tmp_tests_gitaly_dir, 'ruby', 'Gemfile')
end
def env
env_hash = {
'HOME' => File.expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_APP_CONFIG' => File.join(File.dirname(gemfile), '.bundle/config'),
'BUNDLE_FLAGS' => "--jobs=4 --retry=3",
'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_GEMFILE' => gemfile,
'RUBYOPT' => nil
}
if ENV['CI']
bundle_path = File.expand_path('../vendor/gitaly-ruby', __dir__)
env_hash['BUNDLE_FLAGS'] << " --path=#{bundle_path}"
end
env_hash
end
def config_path
File.join(tmp_tests_gitaly_dir, 'config.toml')
end
def start_gitaly
args = %W[#{tmp_tests_gitaly_dir}/gitaly #{config_path}]
pid = spawn(env, *args, [:out, :err] => 'log/gitaly-test.log')
begin
try_connect!
rescue
Process.kill('TERM', pid)
raise
end
pid
end
def check_gitaly_config!
puts 'Checking gitaly-ruby bundle...'
abort 'bundle check failed' unless system(env, 'bundle', 'check', chdir: File.dirname(gemfile))
end
def read_socket_path
# This code needs to work in an environment where we cannot use bundler,
# so we cannot easily use the toml-rb gem. This ad-hoc parser should be
# good enough.
config_text = IO.read(config_path)
config_text.lines.each do |line|
match_data = line.match(/^\s*socket_path\s*=\s*"([^"]*)"$/)
return match_data[1] if match_data
end
raise "failed to find socket_path in #{config_path}"
end
def try_connect!
print "Trying to connect to gitaly: "
timeout = 20
delay = 0.1
socket = read_socket_path
Integer(timeout / delay).times do
begin
UNIXSocket.new(socket)
puts ' OK'
return
rescue Errno::ENOENT, Errno::ECONNREFUSED
print '.'
sleep delay
end
end
puts ' FAILED'
raise "could not connect to #{socket}"
end
end
require "spec_helper"
describe "User adds a comment on a commit", :js do
include Spec::Support::Helpers::Features::NotesHelpers
include RepoHelpers
let(:comment_text) { "XML attached" }
let(:another_comment_text) { "SVG attached" }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
project.add_developer(user)
end
context "inline view" do
before do
visit(project_commit_path(project, sample_commit.id))
end
it "adds a comment" do
page.within(".js-main-target-form") do
expect(page).not_to have_link("Cancel")
emoji = ":+1:"
fill_in("note[note]", with: "#{comment_text} #{emoji}")
# Check on `Preview` tab
click_link("Preview")
expect(find(".js-md-preview")).to have_content(comment_text).and have_css("gl-emoji")
expect(page).not_to have_css(".js-note-text")
# Check on the `Write` tab
click_link("Write")
expect(page).to have_field("note[note]", with: "#{comment_text} #{emoji}")
# Submit comment from the `Preview` tab to get rid of a separate `it` block
# which would specially tests if everything gets cleared from the note form.
click_link("Preview")
click_button("Comment")
end
wait_for_requests
page.within(".note") do
expect(page).to have_content(comment_text).and have_css("gl-emoji")
end
page.within(".js-main-target-form") do
expect(page).to have_field("note[note]", with: "").and have_no_css(".js-md-preview")
end
end
context "when commenting on diff" do
it "adds a comment" do
page.within(".diff-file:nth-of-type(1)") do
# Open a form for a comment and check UI elements are visible and acting as expecting.
click_diff_line(sample_commit.line_code)
expect(page).to have_css(".js-temp-notes-holder form.new-note")
.and have_css(".js-close-discussion-note-form", text: "Cancel")
# The `Cancel` button closes the current form. The page should not have any open forms after that.
find(".js-close-discussion-note-form").click
expect(page).not_to have_css("form.new_note")
# Try to open the same form twice. There should be only one form opened.
click_diff_line(sample_commit.line_code)
click_diff_line(sample_commit.line_code)
expect(page).to have_css("form.new-note", count: 1)
# Fill in a form.
page.within("form[data-line-code='#{sample_commit.line_code}']") do
fill_in("note[note]", with: "#{comment_text} :smile:")
end
# Open another form and check we have two forms now (because the first one is filled in).
click_diff_line(sample_commit.del_line_code)
expect(page).to have_field("note[note]", with: "#{comment_text} :smile:")
.and have_field("note[note]", with: "")
# Test Preview feature for both forms.
page.within("form[data-line-code='#{sample_commit.line_code}']") do
click_link("Preview")
end
page.within("form[data-line-code='#{sample_commit.del_line_code}']") do
fill_in("note[note]", with: another_comment_text)
click_link("Preview")
end
expect(page).to have_css(".js-md-preview", visible: true, count: 2)
.and have_content(comment_text)
.and have_content(another_comment_text)
.and have_xpath("//gl-emoji[@data-name='smile']")
# Test UI elements, then submit.
page.within("form[data-line-code='#{sample_commit.line_code}']") do
expect(find(".js-note-text", visible: false).text).to eq("")
expect(page).to have_css('.js-md-write-button')
click_button("Comment")
end
expect(page).to have_button("Reply...").and have_no_css("form.new_note")
end
# A comment should be added and visible.
page.within(".diff-file:nth-of-type(1) .note") do
expect(page).to have_content(comment_text).and have_xpath("//gl-emoji[@data-name='smile']")
end
end
end
end
context "side-by-side view" do
before do
visit(project_commit_path(project, sample_commit.id, view: "parallel"))
end
it "adds a comment" do
new_comment = "New comment"
old_comment = "Old comment"
# Left side.
click_parallel_diff_line(sample_commit.del_line_code)
page.within(".diff-file:nth-of-type(1) form[data-line-code='#{sample_commit.del_line_code}']") do
fill_in("note[note]", with: old_comment)
click_button("Comment")
end
page.within(".diff-file:nth-of-type(1) .notes_content.parallel.old") do
expect(page).to have_content(old_comment)
end
# Right side.
click_parallel_diff_line(sample_commit.line_code)
page.within(".diff-file:nth-of-type(1) form[data-line-code='#{sample_commit.line_code}']") do
fill_in("note[note]", with: new_comment)
click_button("Comment")
end
wait_for_requests
expect(all(".diff-file:nth-of-type(1) .notes_content.parallel.new")[1].text).to have_content(new_comment)
end
end
private
def click_diff_line(line)
find(".line_holder[id='#{line}'] td:nth-of-type(1)").hover
find(".line_holder[id='#{line}'] button").click
end
def click_parallel_diff_line(line)
find(".line_holder.parallel td[id='#{line}']").find(:xpath, 'preceding-sibling::*[1][self::td]').hover
find(".line_holder.parallel button[data-line-code='#{line}']").click
end
end
require "spec_helper"
describe "User deletes comments on a commit", :js do
include Spec::Support::Helpers::Features::NotesHelpers
include RepoHelpers
let(:comment_text) { "XML attached" }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
project.add_developer(user)
visit(project_commit_path(project, sample_commit.id))
add_note(comment_text)
end
it "deletes comment" do
page.within(".note") do
expect(page).to have_content(comment_text)
end
page.within(".main-notes-list") do
note = find(".note")
note.hover
find(".more-actions").click
find(".more-actions .dropdown-menu li", match: :first)
accept_confirm { find(".js-note-delete").click }
end
expect(page).not_to have_css(".note")
end
end
require "spec_helper"
describe "User edits a comment on a commit", :js do
include Spec::Support::Helpers::Features::NotesHelpers
include RepoHelpers
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
project.add_developer(user)
visit(project_commit_path(project, sample_commit.id))
add_note("XML attached")
end
it "edits comment" do
NEW_COMMENT_TEXT = "+1 Awesome!".freeze
page.within(".main-notes-list") do
note = find(".note")
note.hover
note.find(".js-note-edit").click
end
page.find(".current-note-edit-form textarea")
page.within(".current-note-edit-form") do
fill_in("note[note]", with: NEW_COMMENT_TEXT)
click_button("Save comment")
end
wait_for_requests
page.within(".note") do
expect(page).to have_content(NEW_COMMENT_TEXT)
end
end
end
require "spec_helper"
describe "User comments on commit", :js do
include Spec::Support::Helpers::Features::NotesHelpers
include RepoHelpers
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
COMMENT_TEXT = "XML attached".freeze
before do
sign_in(user)
project.add_developer(user)
visit(project_commit_path(project, sample_commit.id))
end
context "when adding new comment" do
it "adds comment" do
EMOJI = ":+1:".freeze
page.within(".js-main-target-form") do
expect(page).not_to have_link("Cancel")
fill_in("note[note]", with: "#{COMMENT_TEXT} #{EMOJI}")
# Check on `Preview` tab
click_link("Preview")
expect(find(".js-md-preview")).to have_content(COMMENT_TEXT).and have_css("gl-emoji")
expect(page).not_to have_css(".js-note-text")
# Check on `Write` tab
click_link("Write")
expect(page).to have_field("note[note]", with: "#{COMMENT_TEXT} #{EMOJI}")
# Submit comment from the `Preview` tab to get rid of a separate `it` block
# which would specially tests if everything gets cleared from the note form.
click_link("Preview")
click_button("Comment")
end
wait_for_requests
page.within(".note") do
expect(page).to have_content(COMMENT_TEXT).and have_css("gl-emoji")
end
page.within(".js-main-target-form") do
expect(page).to have_field("note[note]", with: "").and have_no_css(".js-md-preview")
end
end
end
context "when editing comment" do
before do
add_note(COMMENT_TEXT)
end
it "edits comment" do
NEW_COMMENT_TEXT = "+1 Awesome!".freeze
page.within(".main-notes-list") do
note = find(".note")
note.hover
note.find(".js-note-edit").click
end
page.find(".current-note-edit-form textarea")
page.within(".current-note-edit-form") do
fill_in("note[note]", with: NEW_COMMENT_TEXT)
click_button("Save comment")
end
wait_for_requests
page.within(".note") do
expect(page).to have_content(NEW_COMMENT_TEXT)
end
end
end
context "when deleting comment" do
before do
add_note(COMMENT_TEXT)
end
it "deletes comment" do
page.within(".note") do
expect(page).to have_content(COMMENT_TEXT)
end
page.within(".main-notes-list") do
note = find(".note")
note.hover
find(".more-actions").click
find(".more-actions .dropdown-menu li", match: :first)
accept_confirm { find(".js-note-delete").click }
end
expect(page).not_to have_css(".note")
end
end
end
import Vue from 'vue';
const mountComponent = (Component, props = {}, el = null) => new Component({
propsData: props,
}).$mount(el);
export const createComponentWithStore = (Component, store, propsData = {}) => new Component({
store,
propsData,
});
export const createComponentWithMixin = (mixins = [], state = {}, props = {}, template = '<div></div>') => {
const Component = Vue.extend({
template,
mixins,
data() {
return props;
},
});
return mountComponent(Component, props);
};
export const mountComponentWithStore = (Component, { el, props, store }) =>
new Component({
store,
propsData: props || { },
}).$mount(el);
export default (Component, props = {}, el = null) => new Component({
propsData: props,
}).$mount(el);
export default mountComponent;
......@@ -17,12 +17,8 @@ describe Gitlab::Auth::BlockedUserTracker do
end
context 'failed login due to blocked user' do
let(:env) do
{
'warden.options' => { message: User::BLOCKED_MESSAGE },
described_class::ACTIVE_RECORD_REQUEST_PARAMS => { 'user' => { 'login' => user.username } }
}
end
let(:base_env) { { 'warden.options' => { message: User::BLOCKED_MESSAGE } } }
let(:env) { base_env.merge(request_env) }
subject { described_class.log_if_user_blocked(env) }
......@@ -30,23 +26,37 @@ describe Gitlab::Auth::BlockedUserTracker do
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks_for).with(user, :failed_login)
end
it 'logs a blocked user' do
user.block!
context 'via GitLab login' do
let(:request_env) { { described_class::ACTIVE_RECORD_REQUEST_PARAMS => { 'user' => { 'login' => user.username } } } }
expect(subject).to be_truthy
end
it 'logs a blocked user' do
user.block!
expect(subject).to be_truthy
end
it 'logs a blocked user by e-mail' do
user.block!
env[described_class::ACTIVE_RECORD_REQUEST_PARAMS]['user']['login'] = user.email
it 'logs a blocked user by e-mail' do
user.block!
env[described_class::ACTIVE_RECORD_REQUEST_PARAMS]['user']['login'] = user.email
expect(subject).to be_truthy
expect(subject).to be_truthy
end
end
it 'logs a LDAP blocked user' do
user.ldap_block!
context 'via LDAP login' do
let(:request_env) { { described_class::ACTIVE_RECORD_REQUEST_PARAMS => { 'username' => user.username } } }
it 'logs a blocked user' do
user.block!
expect(subject).to be_truthy
end
it 'logs a LDAP blocked user' do
user.ldap_block!
expect(subject).to be_truthy
expect(subject).to be_truthy
end
end
end
end
......
......@@ -160,7 +160,11 @@ module TestEnv
end
spawn_script = Rails.root.join('scripts/gitaly-test-spawn').to_s
@gitaly_pid = Bundler.with_original_env { IO.popen([spawn_script], &:read).to_i }
Bundler.with_original_env do
raise "gitaly spawn failed" unless system(spawn_script)
end
@gitaly_pid = Integer(File.read('tmp/tests/gitaly.pid'))
Kernel.at_exit { stop_gitaly }
wait_gitaly
......
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