Skip to content
Snippets Groups Projects
Commit 4e375367 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 99ddca0d
No related branches found
No related tags found
No related merge requests found
Showing
with 182 additions and 40 deletions
Loading
Loading
@@ -38,8 +38,9 @@ describe Gitlab::EtagCaching::Middleware do
end
 
it 'generates ETag' do
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:touch).and_return('123')
expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
expect(instance).to receive(:touch).and_return('123')
end
 
middleware.call(build_request(path, if_none_match))
end
Loading
Loading
@@ -177,9 +178,9 @@ describe Gitlab::EtagCaching::Middleware do
'SCRIPT_NAME' => '/relative-gitlab'
}
 
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:get).with("/relative-gitlab#{enabled_path}")
.and_return(nil)
expect_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
expect(instance).to receive(:get).with("/relative-gitlab#{enabled_path}").and_return(nil)
end
 
middleware.call(env)
end
Loading
Loading
@@ -190,8 +191,9 @@ describe Gitlab::EtagCaching::Middleware do
end
 
def mock_value_in_store(value)
allow_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:get).and_return(value)
allow_next_instance_of(Gitlab::EtagCaching::Store) do |instance|
allow(instance).to receive(:get).and_return(value)
end
end
 
def build_request(path, if_none_match)
Loading
Loading
Loading
Loading
@@ -158,7 +158,9 @@ describe Gitlab::Experimentation do
 
context 'the user is part of the control group' do
before do
allow_any_instance_of(described_class).to receive(:experiment_enabled?).with(:test_experiment).and_return(false)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:experiment_enabled?).with(:test_experiment).and_return(false)
end
end
 
it 'pushes the right parameters to gon' do
Loading
Loading
Loading
Loading
@@ -20,6 +20,8 @@ describe Gitlab::FogbugzImport::Client do
end
 
def stub_api(users)
allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listPeople).and_return(users)
allow_next_instance_of(::Fogbugz::Interface) do |instance|
allow(instance).to receive(:command).with(:listPeople).and_return(users)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::FogbugzImport::Importer do
let(:project) { create(:project_empty_repo) }
let(:importer) { described_class.new(project) }
let(:repo) do
instance_double(Gitlab::FogbugzImport::Repository,
safe_name: 'vim',
path: 'vim',
raw_data: '')
end
let(:import_data) { { 'repo' => repo } }
let(:credentials) do
{
'fb_session' => {
'uri' => 'https://testing.fogbugz.com',
'token' => 'token'
}
}
end
let(:closed_bug) do
{
fOpen: 'false',
sTitle: 'Closed bug',
sLatestTextSummary: "",
dtOpened: Time.now.to_s,
dtLastUpdated: Time.now.to_s,
events: { event: [] }
}.with_indifferent_access
end
let(:opened_bug) do
{
fOpen: 'true',
sTitle: 'Opened bug',
sLatestTextSummary: "",
dtOpened: Time.now.to_s,
dtLastUpdated: Time.now.to_s,
events: { event: [] }
}.with_indifferent_access
end
let(:fogbugz_bugs) { [opened_bug, closed_bug] }
before do
project.create_import_data(data: import_data, credentials: credentials)
allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listCategories).and_return([])
allow_any_instance_of(Gitlab::FogbugzImport::Client).to receive(:cases).and_return(fogbugz_bugs)
end
it 'imports bugs' do
expect { importer.execute }.to change { Issue.count }.by(2)
end
it 'imports opened bugs' do
importer.execute
issue = Issue.where(project_id: project.id).find_by_title(opened_bug[:sTitle])
expect(issue.state_id).to eq(Issue.available_states[:opened])
end
it 'imports closed bugs' do
importer.execute
issue = Issue.where(project_id: project.id).find_by_title(closed_bug[:sTitle])
expect(issue.state_id).to eq(Issue.available_states[:closed])
end
end
Loading
Loading
@@ -134,7 +134,9 @@ describe Gitlab::Git::Blob, :seed_helper do
 
describe '.find with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
allow_next_instance_of(Rugged) do |instance|
allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
end
 
described_class.find(repository, SeedRepo::Commit::ID, 'files/images/6049019_460s.jpg')
end
Loading
Loading
Loading
Loading
@@ -176,7 +176,9 @@ describe Gitlab::Git::Commit, :seed_helper do
 
describe '.find with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
allow_next_instance_of(Rugged) do |instance|
allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
end
 
described_class.find(repository, SeedRepo::Commit::ID)
end
Loading
Loading
@@ -438,7 +440,9 @@ describe Gitlab::Git::Commit, :seed_helper do
it_should_behave_like '.batch_by_oid'
 
it 'calls out to the Rugged implementation' do
allow_any_instance_of(Rugged).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
allow_next_instance_of(Rugged) do |instance|
allow(instance).to receive(:rev_parse).with(SeedRepo::Commit::ID).and_call_original
end
 
described_class.batch_by_oid(repository, [SeedRepo::Commit::ID])
end
Loading
Loading
Loading
Loading
@@ -145,7 +145,9 @@ describe Gitlab::Git::Tree, :seed_helper do
 
describe '.where with Rugged enabled', :enable_rugged do
it 'calls out to the Rugged implementation' do
allow_any_instance_of(Rugged).to receive(:lookup).with(SeedRepo::Commit::ID)
allow_next_instance_of(Rugged) do |instance|
allow(instance).to receive(:lookup).with(SeedRepo::Commit::ID)
end
 
described_class.where(repository, SeedRepo::Commit::ID, 'files', false)
end
Loading
Loading
Loading
Loading
@@ -730,7 +730,9 @@ describe Gitlab::GitAccess do
it 'checks LFS integrity only for first change' do
allow(project).to receive(:lfs_enabled?).and_return(true)
 
expect_any_instance_of(Gitlab::Checks::LfsIntegrity).to receive(:objects_missing?).exactly(1).times
expect_next_instance_of(Gitlab::Checks::LfsIntegrity) do |instance|
expect(instance).to receive(:objects_missing?).exactly(1).times
end
 
push_access_check
end
Loading
Loading
Loading
Loading
@@ -10,10 +10,11 @@ describe Gitlab::GitalyClient::CleanupService do
 
describe '#apply_bfg_object_map_stream' do
it 'sends an apply_bfg_object_map_stream message' do
expect_any_instance_of(Gitaly::CleanupService::Stub)
.to receive(:apply_bfg_object_map_stream)
.with(kind_of(Enumerator), kind_of(Hash))
.and_return([])
expect_next_instance_of(Gitaly::CleanupService::Stub) do |instance|
expect(instance).to receive(:apply_bfg_object_map_stream)
.with(kind_of(Enumerator), kind_of(Hash))
.and_return([])
end
 
client.apply_bfg_object_map_stream(StringIO.new)
end
Loading
Loading
Loading
Loading
@@ -55,7 +55,9 @@ describe Gitlab::GitalyClient do
it 'returns an empty string when the storage is not found in the response' do
response = double("response")
allow(response).to receive(:storage_statuses).and_return([])
allow_any_instance_of(Gitlab::GitalyClient::ServerService).to receive(:info).and_return(response)
allow_next_instance_of(Gitlab::GitalyClient::ServerService) do |instance|
allow(instance).to receive(:info).and_return(response)
end
 
expect(described_class.filesystem_id('default')).to eq(nil)
end
Loading
Loading
Loading
Loading
@@ -144,9 +144,9 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
 
describe '#find_merge_request_id' do
it 'returns a merge request ID' do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
expect(instance).to receive(:database_id).and_return(10)
end
 
expect(importer.find_merge_request_id).to eq(10)
end
Loading
Loading
Loading
Loading
@@ -74,9 +74,9 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
 
describe '#find_target_id' do
it 'returns the ID of the issuable to create the label link for' do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
expect(instance).to receive(:database_id).and_return(10)
end
 
expect(importer.find_target_id).to eq(10)
end
Loading
Loading
Loading
Loading
@@ -50,8 +50,9 @@ describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cac
 
describe '#build_labels_cache' do
it 'builds the labels cache' do
expect_any_instance_of(Gitlab::GithubImport::LabelFinder)
.to receive(:build_cache)
expect_next_instance_of(Gitlab::GithubImport::LabelFinder) do |instance|
expect(instance).to receive(:build_cache)
end
 
importer.build_labels_cache
end
Loading
Loading
Loading
Loading
@@ -80,8 +80,9 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
 
describe '#build_milestones_cache' do
it 'builds the milestones cache' do
expect_any_instance_of(Gitlab::GithubImport::MilestoneFinder)
.to receive(:build_cache)
expect_next_instance_of(Gitlab::GithubImport::MilestoneFinder) do |instance|
expect(instance).to receive(:build_cache)
end
 
importer.build_milestones_cache
end
Loading
Loading
Loading
Loading
@@ -143,9 +143,9 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
 
describe '#find_noteable_id' do
it 'returns the ID of the noteable' do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
expect_next_instance_of(Gitlab::GithubImport::IssuableFinder) do |instance|
expect(instance).to receive(:database_id).and_return(10)
end
 
expect(importer.find_noteable_id).to eq(10)
end
Loading
Loading
Loading
Loading
@@ -9,8 +9,9 @@ describe Gitlab::GithubImport::SequentialImporter do
project = double(:project, id: 1, repository: repository)
importer = described_class.new(project, token: 'foo')
 
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
.to receive(:execute)
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
expect(instance).to receive(:execute)
end
 
described_class::SEQUENTIAL_IMPORTERS.each do |klass|
instance = double(:instance)
Loading
Loading
Loading
Loading
@@ -21,18 +21,24 @@ describe Gitlab::GitlabImport::Client do
it 'uses membership and simple flags' do
stub_request('/api/v4/projects?membership=true&page=1&per_page=100&simple=true')
 
expect_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
expect_next_instance_of(OAuth2::Response) do |instance|
expect(instance).to receive(:parsed).and_return([])
end
 
expect(client.projects.to_a).to eq []
end
 
shared_examples 'pagination params' do
before do
allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
allow_next_instance_of(OAuth2::Response) do |instance|
allow(instance).to receive(:parsed).and_return([])
end
end
 
it 'allows page_limit param' do
allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return(element_list)
allow_next_instance_of(OAuth2::Response) do |instance|
allow(instance).to receive(:parsed).and_return(element_list)
end
 
expect(client).to receive(:lazy_page_iterator).with(hash_including(page_limit: 2)).and_call_original
 
Loading
Loading
Loading
Loading
@@ -109,7 +109,9 @@ describe Gitlab::HttpIO do
end
 
it 'calls get_chunk only once' do
expect_any_instance_of(Net::HTTP).to receive(:request).once.and_call_original
expect_next_instance_of(Net::HTTP) do |instance|
expect(instance).to receive(:request).once.and_call_original
end
 
http_io.each_line { |line| }
end
Loading
Loading
Loading
Loading
@@ -43,7 +43,9 @@ describe Gitlab::RequestContext do
let(:ip) { '192.168.1.11' }
 
before do
allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip)
allow_next_instance_of(Rack::Request) do |instance|
allow(instance).to receive(:ip).and_return(ip)
end
described_class.new(app).call(env)
end
 
Loading
Loading
Loading
Loading
@@ -80,6 +80,17 @@ describe Commit do
expect(commit.author).to eq(user)
end
 
context 'with a user with an unconfirmed e-mail' do
before do
user = create(:user)
create(:email, user: user, email: commit.author_email)
end
it 'returns no user' do
expect(commit.author).to be_nil
end
end
context 'using eager loading' do
let!(:alice) { create(:user, email: 'alice@example.com') }
let!(:bob) { create(:user, email: 'hunter2@example.com') }
Loading
Loading
@@ -115,7 +126,7 @@ describe Commit do
let!(:commits) { [alice_commit, bob_commit, eve_commit, jeff_commit] }
 
before do
create(:email, user: bob, email: 'bob@example.com')
create(:email, :confirmed, user: bob, email: 'bob@example.com')
end
 
it 'executes only two SQL queries' do
Loading
Loading
@@ -179,6 +190,32 @@ describe Commit do
end
end
 
describe '#committer' do
context 'with a confirmed e-mail' do
it 'returns the user' do
user = create(:user, email: commit.committer_email)
expect(commit.committer).to eq(user)
end
end
context 'with an unconfirmed e-mail' do
let(:user) { create(:user) }
before do
create(:email, user: user, email: commit.committer_email)
end
it 'returns no user' do
expect(commit.committer).to be_nil
end
it 'returns the user' do
expect(commit.committer(confirmed: false)).to eq(user)
end
end
end
describe '#to_reference' do
let(:project) { create(:project, :repository, path: 'sample-project') }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment