Commit 2159694e authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'master' into fe-commit-mr-pipelines

* master:
  Backport changes from EE squash
  replace `find_with_namespace` with `find_by_full_path`
  PlantUML support for Markdown
  Update api docs and minor changes
  Force new password after password reset via API
  Fixed protected branches dropdown
  Fixed up tests
  Fixed the active branch selected indicator
  Changed how the data is returned - we only care about the branch/tag name
  Uses take rather than Kaminari
  Use cloneNode instead of createElement
  Improved ref switcher dropdown performance
parents ea43f586 806b038a
......@@ -109,7 +109,7 @@ gem 'org-ruby', '~> 0.9.12'
gem 'creole', '~> 0.5.0'
gem 'wikicloth', '0.8.1'
gem 'asciidoctor', '~> 1.5.2'
gem 'asciidoctor-plantuml', '0.0.6'
gem 'asciidoctor-plantuml', '0.0.7'
gem 'rouge', '~> 2.0'
gem 'truncato', '~> 0.7.8'
......
......@@ -54,7 +54,7 @@ GEM
faraday_middleware-multi_json (~> 0.0)
oauth2 (~> 1.0)
asciidoctor (1.5.3)
asciidoctor-plantuml (0.0.6)
asciidoctor-plantuml (0.0.7)
asciidoctor (~> 1.5)
ast (2.3.0)
attr_encrypted (3.0.3)
......@@ -841,7 +841,7 @@ DEPENDENCIES
allocations (~> 1.0)
asana (~> 0.4.0)
asciidoctor (~> 1.5.2)
asciidoctor-plantuml (= 0.0.6)
asciidoctor-plantuml (= 0.0.7)
attr_encrypted (~> 3.0.0)
awesome_print (~> 1.2.0)
babosa (~> 1.0.2)
......
......@@ -58,6 +58,11 @@
};
Project.prototype.initRefSwitcher = function() {
var refListItem = document.createElement('li'),
refLink = document.createElement('a');
refLink.href = '#';
return $('.js-project-refs-dropdown').each(function() {
var $dropdown, selected;
$dropdown = $(this);
......@@ -67,7 +72,8 @@
return $.ajax({
url: $dropdown.data('refs-url'),
data: {
ref: $dropdown.data('ref')
ref: $dropdown.data('ref'),
search: term
},
dataType: "json"
}).done(function(refs) {
......@@ -76,16 +82,29 @@
},
selectable: true,
filterable: true,
filterRemote: true,
filterByText: true,
fieldName: $dropdown.data('field-name'),
renderRow: function(ref) {
var link;
var li = refListItem.cloneNode(false);
if (ref.header != null) {
return $('<li />').addClass('dropdown-header').text(ref.header);
li.className = 'dropdown-header';
li.textContent = ref.header;
} else {
link = $('<a />').attr('href', '#').addClass(ref === selected ? 'is-active' : '').text(ref).attr('data-ref', ref);
return $('<li />').append(link);
var link = refLink.cloneNode(false);
if (ref === selected) {
link.className = 'is-active';
}
link.textContent = ref;
link.dataset.ref = ref;
li.appendChild(link);
}
return li;
},
id: function(obj, $el) {
return $el.attr('data-ref');
......
......@@ -49,7 +49,7 @@ class ProtectedBranchDropdown {
onClickCreateWildcard() {
// Refresh the dropdown's data, which ends up calling `getProtectedBranches`
this.$dropdown.data('glDropdown').remote.execute();
this.$dropdown.data('glDropdown').selectRowAtIndex(0);
this.$dropdown.data('glDropdown').selectRowAtIndex();
}
getProtectedBranches(term, callback) {
......
......@@ -56,15 +56,24 @@
&.right {
float: right;
padding-right: 0;
}
a {
color: $gl-text-color;
}
.modify-merge-commit-link {
color: $gl-text-color;
}
.remove_source_checkbox {
.merge-param-checkbox {
margin: 0;
}
a .fa-question-circle {
color: $gl-text-color-secondary;
&:hover,
&:focus {
color: $link-hover-color;
}
}
}
}
......
......@@ -45,7 +45,7 @@ class Admin::ProjectsController < Admin::ApplicationController
protected
def project
@project = Project.find_with_namespace(
@project = Project.find_by_full_path(
[params[:namespace_id], '/', params[:id]].join('')
)
@project || render_404
......
......@@ -24,7 +24,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
private
def project
@project = Project.find_with_namespace(
@project = Project.find_by_full_path(
[params[:namespace_id], '/', params[:project_id]].join('')
)
@project || render_404
......
......@@ -24,7 +24,7 @@ class Projects::ApplicationController < ApplicationController
end
project_path = "#{namespace}/#{id}"
@project = Project.find_with_namespace(project_path)
@project = Project.find_by_full_path(project_path)
if can?(current_user, :read_project, @project) && !@project.pending_delete?
if @project.path_with_namespace != project_path
......
......@@ -79,7 +79,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
if project_id.blank?
@project = nil
else
@project = Project.find_with_namespace("#{params[:namespace_id]}/#{project_id}")
@project = Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}")
end
end
......
......@@ -36,7 +36,7 @@ class Projects::UploadsController < Projects::ApplicationController
namespace = params[:namespace_id]
id = params[:project_id]
file_project = Project.find_with_namespace("#{namespace}/#{id}")
file_project = Project.find_by_full_path("#{namespace}/#{id}")
if file_project.nil?
@uploader = nil
......
......@@ -231,12 +231,16 @@ class ProjectsController < Projects::ApplicationController
end
def refs
branches = BranchesFinder.new(@repository, params).execute.map(&:name)
options = {
'Branches' => @repository.branch_names,
'Branches' => branches.take(100),
}
unless @repository.tag_count.zero?
options['Tags'] = VersionSorter.rsort(@repository.tag_names)
tags = TagsFinder.new(@repository, params).execute.map(&:name)
options['Tags'] = tags.take(100)
end
# If reference is commit id - we should add it to branch/tag selectbox
......
......@@ -37,7 +37,7 @@ module ApplicationHelper
if project_id.is_a?(Project)
project_id
else
Project.find_with_namespace(project_id)
Project.find_by_full_path(project_id)
end
if project.avatar_url
......
......@@ -143,4 +143,16 @@ module MergeRequestsHelper
def different_base?(version1, version2)
version1 && version2 && version1.base_commit_sha != version2.base_commit_sha
end
def merge_params(merge_request)
{
merge_when_build_succeeds: true,
should_remove_source_branch: true,
sha: merge_request.diff_head_sha
}.merge(merge_params_ee(merge_request))
end
def merge_params_ee(merge_request)
{}
end
end
......@@ -370,10 +370,6 @@ class Project < ActiveRecord::Base
def group_ids
joins(:namespace).where(namespaces: { type: 'Group' }).select(:namespace_id)
end
# Add alias for Routable method for compatibility with old code.
# In future all calls `find_with_namespace` should be replaced with `find_by_full_path`
alias_method :find_with_namespace, :find_by_full_path
end
def lfs_enabled?
......@@ -1352,6 +1348,6 @@ class Project < ActiveRecord::Base
def pending_delete_twin
return false unless path
Project.unscoped.where(pending_delete: true).find_with_namespace(path_with_namespace)
Project.unscoped.where(pending_delete: true).find_by_full_path(path_with_namespace)
end
end
......@@ -913,11 +913,11 @@ class Repository
end
end
def merge(user, merge_request, options = {})
def merge(user, source, merge_request, options = {})
GitOperationService.new(user, self).with_branch(
merge_request.target_branch) do |start_commit|
our_commit = start_commit.sha
their_commit = merge_request.diff_head_sha
their_commit = source
raise 'Invalid merge target' unless our_commit
raise 'Invalid merge source' unless their_commit
......
......@@ -61,7 +61,7 @@ module Auth
end
def process_repository_access(type, name, actions)
requested_project = Project.find_with_namespace(name)
requested_project = Project.find_by_full_path(name)
return unless requested_project
actions = actions.select do |action|
......
......@@ -6,13 +6,17 @@ module MergeRequests
# Executed when you do merge via GitLab UI
#
class MergeService < MergeRequests::BaseService
attr_reader :merge_request
attr_reader :merge_request, :source
def execute(merge_request)
@merge_request = merge_request
return log_merge_error('Merge request is not mergeable', true) unless @merge_request.mergeable?
@source = find_merge_source
return log_merge_error('No source for merge', true) unless @source
merge_request.in_locked_state do
if commit
after_merge
......@@ -34,7 +38,7 @@ module MergeRequests
committer: committer
}
commit_id = repository.merge(current_user, merge_request, options)
commit_id = repository.merge(current_user, source, merge_request, options)
if commit_id
merge_request.update(merge_commit_sha: commit_id)
......@@ -73,9 +77,11 @@ module MergeRequests
end
def merge_request_info
project = merge_request.project
merge_request.to_reference(full: true)
end
"#{project.to_reference}#{merge_request.to_reference}"
def find_merge_source
merge_request.diff_head_sha
end
end
end
......@@ -35,10 +35,10 @@
The source branch will be removed.
- elsif @merge_request.can_remove_source_branch?(current_user)
.accept-control.checkbox
= label_tag :should_remove_source_branch, class: "remove_source_checkbox" do
= label_tag :should_remove_source_branch, class: "merge-param-checkbox" do
= check_box_tag :should_remove_source_branch
Remove source branch
.accept-control.right
.accept-control
= link_to "#", class: "modify-merge-commit-link js-toggle-button" do
= icon('edit')
Modify commit message
......
......@@ -19,7 +19,7 @@
- if remove_source_branch_button || user_can_cancel_automatic_merge
.clearfix.prepend-top-10
- if remove_source_branch_button
= link_to merge_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, merge_when_build_succeeds: true, should_remove_source_branch: true, sha: @merge_request.diff_head_sha), remote: true, method: :post, class: "btn btn-grouped btn-primary btn-sm remove_source_branch" do
= link_to merge_namespace_project_merge_request_path(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, merge_params(@merge_request)), remote: true, method: :post, class: "btn btn-grouped btn-primary btn-sm remove_source_branch" do
= icon('times')
Remove Source Branch When Merged
......
......@@ -43,6 +43,8 @@
= render 'shared/issuable/form/branch_chooser', issuable: issuable, form: form
= render 'shared/issuable/form/merge_params', issuable: issuable
- if @merge_request_for_resolving_discussions
.form-group
.col-sm-10.col-sm-offset-2
......
......@@ -19,12 +19,3 @@
- if issuable.new_record?
&nbsp;
= link_to 'Change branches', mr_change_branches_path(issuable)
- if issuable.can_remove_source_branch?(current_user)
.form-group
.col-sm-10.col-sm-offset-2
.checkbox
= label_tag 'merge_request[force_remove_source_branch]' do
= hidden_field_tag 'merge_request[force_remove_source_branch]', '0', id: nil
= check_box_tag 'merge_request[force_remove_source_branch]', '1', issuable.force_remove_source_branch?
Remove source branch when merge request is accepted.
- issuable = local_assigns.fetch(:issuable)
- return unless issuable.is_a?(MergeRequest)
- return if issuable.closed_without_fork?
-# This check is duplicated below, to avoid conflicts with EE.
- return unless issuable.can_remove_source_branch?(current_user)
.form-group
.col-sm-10.col-sm-offset-2
- if issuable.can_remove_source_branch?(current_user)
.checkbox
= label_tag 'merge_request[force_remove_source_branch]' do
= hidden_field_tag 'merge_request[force_remove_source_branch]', '0', id: nil
= check_box_tag 'merge_request[force_remove_source_branch]', '1', issuable.force_remove_source_branch?
Remove source branch when merge request is accepted.
---
title: Force new password after password reset via API
merge_request:
author: George Andrinopoulos
---
title: replace `find_with_namespace` with `find_by_full_path`
merge_request: 8949
author: Adam Pahlevi
---
title: PlantUML support for Markdown
merge_request: 8588
author: Horacio Sanson
# Touch the lexers so it is registered with Rouge
Rouge::Lexers::Plantuml
......@@ -26,7 +26,7 @@ Gitlab::Seeder.quiet do
end
end
project = Project.find_with_namespace('gitlab-org/gitlab-test')
project = Project.find_by_full_path('gitlab-org/gitlab-test')
params = {
source_branch: 'feature',
......
......@@ -3,8 +3,8 @@
> [Introduced][ce-7810] in GitLab 8.16.
When [PlantUML](http://plantuml.com) integration is enabled and configured in
GitLab we are able to create simple diagrams in AsciiDoc documents created in
snippets, wikis, and repos.
GitLab we are able to create simple diagrams in AsciiDoc and Markdown documents
created in snippets, wikis, and repos.
## PlantUML Server
......@@ -54,7 +54,7 @@ that, login with an Admin account and do following:
## Creating Diagrams
With PlantUML integration enabled and configured, we can start adding diagrams to
our AsciiDoc snippets, wikis and repos using blocks:
our AsciiDoc snippets, wikis and repos using delimited blocks:
```
[plantuml, format="png", id="myDiagram", width="200px"]
......@@ -64,7 +64,14 @@ Alice -> Bob : Go Away
--
```
The above block will be converted to an HTML img tag with source pointing to the
And in Markdown using fenced code blocks:
```plantuml
Bob -> Alice : hello
Alice -> Bob : Go Away
```
The above blocks will be converted to an HTML img tag with source pointing to the
PlantUML instance. If the PlantUML server is correctly configured, this should
render a nice diagram instead of the block:
......@@ -77,7 +84,7 @@ Inside the block you can add any of the supported diagrams by PlantUML such as
and [Object](http://plantuml.com/object-diagram) diagrams. You do not need to use the PlantUML
diagram delimiters `@startuml`/`@enduml` as these are replaced by the AsciiDoc `plantuml` block.
Some parameters can be added to the block definition:
Some parameters can be added to the AsciiDoc block definition:
- *format*: Can be either `png` or `svg`. Note that `svg` is not supported by
all browsers so use with care. The default is `png`.
......@@ -85,3 +92,4 @@ Some parameters can be added to the block definition:
- *width*: Width attribute added to the img tag.
- *height*: Height attribute added to the img tag.
Markdown does not support any parameters and will always use PNG format.
......@@ -271,6 +271,7 @@ Parameters:
- `can_create_group` (optional) - User can create groups - true or false
- `external` (optional) - Flags the user as external - true or false(default)
On password update, user will be forced to change it upon next login.
Note, at the moment this method does only return a `404` error,
even in cases where a `409` (Conflict) would be more appropriate,
e.g. when renaming the email address to some existing one.
......
......@@ -45,7 +45,7 @@ module API
if id =~ /^\d+$/
Project.find_by(id: id)
else
Project.find_with_namespace(id)
Project.find_by_full_path(id)
end
end
......
......@@ -30,7 +30,7 @@ module API
def wiki?
@wiki ||= project_path.end_with?('.wiki') &&
!Project.find_with_namespace(project_path)
!Project.find_by_full_path(project_path)
end
def project
......@@ -41,7 +41,7 @@ module API
# the wiki repository as well.
project_path.chomp!('.wiki') if wiki?
Project.find_with_namespace(project_path)
Project.find_by_full_path(project_path)
end
end
......
......@@ -160,6 +160,8 @@ module API
end
end
user_params.merge!(password_expires_at: Time.now) if user_params[:password].present?
if user.update_attributes(user_params.except(:extern_uid, :provider))
present user, with: Entities::UserPublic
else
......
......@@ -14,7 +14,7 @@ module Banzai
def project_from_ref(ref)
return context[:project] unless ref
Project.find_with_namespace(ref)
Project.find_by_full_path(ref)
end
end
end
require "nokogiri"
require "asciidoctor-plantuml/plantuml"
module Banzai
module Filter
# HTML that replaces all `code plantuml` tags with PlantUML img tags.
#
class PlantumlFilter < HTML::Pipeline::Filter
def call
return doc unless doc.at('pre.plantuml') and settings.plantuml_enabled
plantuml_setup
doc.css('pre.plantuml').each do |el|
img_tag = Nokogiri::HTML::DocumentFragment.parse(
Asciidoctor::PlantUml::Processor.plantuml_content(el.content, {}))
el.replace img_tag
end
doc
end
private
def settings
ApplicationSetting.current || ApplicationSetting.create_from_defaults
end
def plantuml_setup
Asciidoctor::PlantUml.configure do |conf|
conf.url = settings.plantuml_url
conf.png_enable = settings.plantuml_enabled
conf.svg_enable = false
conf.txt_enable = false
end
end
end
end
end
......@@ -10,6 +10,7 @@ module Banzai
def self.filters
@filters ||= FilterArray[
Filter::SyntaxHighlightFilter,
Filter::PlantumlFilter,
Filter::SanitizationFilter,
Filter::MathFilter,
......
......@@ -8,6 +8,6 @@ class ProjectUrlConstrainer
return false
end
Project.find_with_namespace(full_path).present?
Project.find_by_full_path(full_path).present?
end
end
......@@ -34,7 +34,7 @@ module Gitlab
end
def project
@project ||= Project.find_with_namespace(project_path)
@project ||= Project.find_by_full_path(project_path)
end
private
......
......@@ -30,11 +30,11 @@ module Gitlab
def retrieve_project_and_type
@type = :project
@project = Project.find_with_namespace(@repo_path)
@project = Project.find_by_full_path(@repo_path)
if @repo_path.end_with?('.wiki') && !@project
@type = :wiki
@project = Project.find_with_namespace(@repo_path.gsub(/\.wiki\z/, ''))
@project = Project.find_by_full_path(@repo_path.gsub(/\.wiki\z/, ''))
end
end
......
module Rouge
module Lexers
class Plantuml < Lexer
title "A passthrough lexer used for PlantUML input"
desc "A boring lexer that doesn't highlight anything"
tag 'plantuml'
mimetypes 'text/plain'
default_options token: 'Text'
def token
@token ||= Token[option :token]
end
def stream_tokens(string, &b)
yield self.token, string
end
end
end
end
......@@ -58,7 +58,7 @@ namespace :gitlab do
sub(%r{^/*}, '').
chomp('.git').
chomp('.wiki')
next if Project.find_with_namespace(repo_with_namespace)
next if Project.find_by_full_path(repo_with_namespace)
new_path = path + move_suffix
puts path.inspect + ' -> ' + new_path.inspect
File.rename(path, new_path)
......
......@@ -29,7 +29,7 @@ namespace :gitlab do
next
end
project = Project.find_with_namespace(path)
project = Project.find_by_full_path(path)
if project
puts " * #{project.name} (#{repo_path}) exists"
......
......@@ -7,7 +7,7 @@ namespace :gitlab do
unless args.project.present?
abort "Please specify the project you want to drop PostReceive jobs for:\n rake gitlab:sidekiq:drop_post_receive[group/project]"
end
project_path = Project.find_with_namespace(args.project).repository.path_to_repo
project_path = Project.find_by_full_path(args.project).repository.path_to_repo
Sidekiq.redis do |redis|
unless redis.exists(QUEUE)
......
......@@ -17,14 +17,15 @@ feature 'Ref switcher', feature: true, js: true do
page.within '.project-refs-form' do
input = find('input[type="search"]')
input.set 'expand'
input.set 'binary'
wait_for_ajax
input.native.send_keys :down
input.native.send_keys :down
input.native.send_keys :enter
end
expect(page).to have_title 'expand-collapse-files'
expect(page).to have_title 'binary-encoding'
end
it "user selects ref with special characters" do
......
......@@ -24,7 +24,7 @@ describe Banzai::CrossProjectReference, lib: true do
it 'returns the referenced project' do
project2 = double('referenced project')
expect(Project).to receive(:find_with_namespace).
expect(Project).to receive(:find_by_full_path).
with('cross/reference').and_return(project2)
expect(project_from_ref('cross/reference')).to eq project2
......
require 'spec_helper'
describe Banzai::Filter::PlantumlFilter, lib: true do
include FilterSpecHelper
it 'should replace plantuml pre tag with img tag' do
stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080")
input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>'
output = '<div class="imageblock"><div class="content"><img class="plantuml" src="http://localhost:8080/png/U9npoazIqBLJ24uiIbImKl18pSd91m0rkGMq"></div></div>'
doc = filter(input)
expect(doc.to_s).to eq output
end
it 'should not replace plantuml pre tag with img tag if disabled' do
stub_application_setting(plantuml_enabled: false)
input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>'
output = '<pre class="plantuml"><code>Bob -&gt; Sara : Hello</code><pre></pre></pre>'
doc = filter(input)
expect(doc.to_s).to eq output
end
it 'should not replace plantuml pre tag with img tag if url is invalid' do
stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid")
input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>'
output = '<div class="listingblock"><div class="content"><pre class="plantuml plantuml-error"> PlantUML Error: cannot connect to PlantUML server at "invalid"</pre></div></div>'
doc = filter(input)
expect(doc.to_s).to eq output
end
end
......@@ -1640,7 +1640,9 @@ describe Gitlab::Diff::PositionTracer, lib: true do
}
merge_request = create(:merge_request, source_branch: second_create_file_commit.sha, target_branch: branch_name, source_project: project)
repository.merge(current_user, merge_request, options)
repository.merge(current_user, merge_request.diff_head_sha, merge_request, options)
project.commit(branch_name)
end
......
......@@ -15,7 +15,12 @@ describe Repository, models: true do
let(:merge_commit) do
merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
merge_commit_id = repository.merge(user, merge_request, commit_options)
merge_commit_id = repository.merge(user,
merge_request.diff_head_sha,
merge_request,
commit_options)
repository.commit(merge_commit_id)
end
......@@ -1082,8 +1087,11 @@ describe Repository, models: true do
it 'sets the `in_progress_merge_commit_sha` flag for the given merge request' do
merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
merge_commit_id = repository.merge(user, merge_request, commit_options)
repository.commit(merge_commit_id)
merge_commit_id = repository.merge(user,
merge_request.diff_head_sha,
merge_request,
commit_options)
expect(merge_request.in_progress_merge_commit_sha).to eq(merge_commit_id)
end
......
......@@ -305,6 +305,13 @@ describe API::Users, api: true do
expect(user.reload.bio).to eq('new test bio')
end
it "updates user with new password and forces reset on next login" do
put api("/users/#{user.id}", admin), password: '12345678'
expect(response).to have_http_status(200)
expect(user.reload.password_expires_at).to be <= Time.now
end
it "updates user with organization" do
put api("/users/#{user.id}", admin), { organization: 'GitLab' }
......
......@@ -2,8 +2,8 @@ require 'spec_helper'
describe 'project routing' do
before do
allow(Project).to receive(:find_with_namespace).and_return(false)
allow(Project).to receive(:find_with_namespace).with('gitlab/gitlabhq').and_return(true)
allow(Project).to receive(:find_by_full_path).and_return(false)
allow(Project).to receive(:find_by_full_path).with('gitlab/gitlabhq').and_return(true)
end
# Shared examples for a resource inside a Project
......@@ -86,13 +86,13 @@ describe 'project routing' do
end
context 'name with dot' do
before { allow(Project).to receive(:find_with_namespace).with('gitlab/gitlabhq.keys').and_return(true) }
before { allow(Project).to receive(:find_by_full_path).with('gitlab/gitlabhq.keys').and_return(true) }
it { expect(get('/gitlab/gitlabhq.keys')).to route_to('projects#show', namespace_id: 'gitlab', id: 'gitlabhq.keys') }
end
context 'with nested group' do
before { allow(Project).to receive(:find_with_namespace).with('gitlab/subgroup/gitlabhq').and_return(true) }
before { allow(Project).to receive(:find_by_full_path).with('gitlab/subgroup/gitlabhq').and_return(true) }
it { expect(get('/gitlab/subgroup/gitlabhq')).to route_to('projects#show', namespace_id: 'gitlab/subgroup', id: 'gitlabhq') }
end
......
......@@ -89,7 +89,7 @@ describe MergeRequests::RefreshService, services: true do
# Merge master -> feature branch
author = { email: 'test@gitlab.com', time: Time.now, name: "Me" }
commit_options = { message: 'Test message', committer: author, author: author }
@project.repository.merge(@user, @merge_request, commit_options)
@project.repository.merge(@user, @merge_request.diff_head_sha, @merge_request, commit_options)
commit = @project.repository.commit('feature')
service.new(@project, @user).execute(@oldrev, commit.id, 'refs/heads/feature')
reload_mrs
......
......@@ -36,7 +36,8 @@ module TestEnv
'conflict-non-utf8' => 'd0a293c',
'conflict-too-large' => '39fa04f',
'deleted-image-test' => '6c17798',
'wip' => 'b9238ee'
'wip' => 'b9238ee',
'csv' => '3dd0896'
}
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
......
......@@ -74,7 +74,7 @@ describe PostReceive do
context "webhook" do
it "fetches the correct project" do
expect(Project).to receive(:find_with_namespace).with(project.path_with_namespace).and_return(project)
expect(Project).to receive(:find_by_full_path).with(project.path_with_namespace).and_return(project)
PostReceive.new.perform(pwd(project), key_id, base64_changes)
end
......@@ -89,7 +89,7 @@ describe PostReceive do
end
it "asks the project to trigger all hooks" do
allow(Project).to receive(:find_with_namespace).and_return(project)
allow(Project).to receive(:find_by_full_path).and_return(project)
expect(project).to receive(:execute_hooks).twice
expect(project).to receive(:execute_services).twice
......@@ -97,7 +97,7 @@ describe PostReceive do
end
it "enqueues a UpdateMergeRequestsWorker job" do
allow(Project).to receive(:find_with_namespace).and_return(project)
allow(Project).to receive(:find_by_full_path).and_return(project)
expect(UpdateMergeRequestsWorker).to receive(:perform_async).with(project.id, project.owner.id, any_args)
PostReceive.new.perform(pwd(project), key_id, base64_changes)
......
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