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 122 additions and 64 deletions
Loading
Loading
@@ -136,7 +136,9 @@ describe Gitlab::Auth::LDAP::Access do
context 'without ActiveDirectory enabled' do
before do
allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true)
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:active_directory).and_return(false)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive(:active_directory).and_return(false)
end
end
 
it 'returns true' do
Loading
Loading
Loading
Loading
@@ -58,7 +58,9 @@ describe Gitlab::Auth::LDAP::AuthHash do
end
 
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:attributes).and_return(attributes)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive(:attributes).and_return(attributes)
end
end
 
it "has the correct username" do
Loading
Loading
Loading
Loading
@@ -18,8 +18,9 @@ describe Gitlab::Auth::LDAP::Authentication do
 
# try only to fake the LDAP call
adapter = double('adapter', dn: dn).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:adapter).and_return(adapter)
end
 
expect(described_class.login(login, password)).to be_truthy
end
Loading
Loading
@@ -27,8 +28,9 @@ describe Gitlab::Auth::LDAP::Authentication do
it "is false if the user does not exist" do
# try only to fake the LDAP call
adapter = double('adapter', dn: dn).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:adapter).and_return(adapter)
end
 
expect(described_class.login(login, password)).to be_falsey
end
Loading
Loading
@@ -38,8 +40,9 @@ describe Gitlab::Auth::LDAP::Authentication do
 
# try only to fake the LDAP call
adapter = double('adapter', bind_as: nil).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:adapter).and_return(adapter)
end
 
expect(described_class.login(login, password)).to be_falsey
end
Loading
Loading
Loading
Loading
@@ -396,7 +396,9 @@ describe Gitlab::Auth::OAuth::User do
context "and no account for the LDAP user" do
context 'dont block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: false)
end
end
 
it do
Loading
Loading
@@ -408,7 +410,9 @@ describe Gitlab::Auth::OAuth::User do
 
context 'block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: true)
end
end
 
it do
Loading
Loading
@@ -424,7 +428,9 @@ describe Gitlab::Auth::OAuth::User do
 
context 'dont block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: false)
end
end
 
it do
Loading
Loading
@@ -436,7 +442,9 @@ describe Gitlab::Auth::OAuth::User do
 
context 'block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: true)
end
end
 
it do
Loading
Loading
@@ -480,7 +488,9 @@ describe Gitlab::Auth::OAuth::User do
 
context 'dont block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: false)
end
end
 
it do
Loading
Loading
@@ -492,7 +502,9 @@ describe Gitlab::Auth::OAuth::User do
 
context 'block on create (LDAP)' do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
allow_next_instance_of(Gitlab::Auth::LDAP::Config) do |instance|
allow(instance).to receive_messages(block_auto_created_users: true)
end
end
 
it do
Loading
Loading
Loading
Loading
@@ -75,7 +75,9 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
end
 
it 'does not schedule an import' do
expect_any_instance_of(Project).not_to receive(:import_schedule)
expect_next_instance_of(Project) do |instance|
expect(instance).not_to receive(:import_schedule)
end
 
importer.create_project_if_needed
end
Loading
Loading
Loading
Loading
@@ -9,7 +9,9 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
 
describe '.load_for_project' do
it "loads the status" do
expect_any_instance_of(described_class).to receive(:load_status)
expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:load_status)
end
 
described_class.load_for_project(project)
end
Loading
Loading
Loading
Loading
@@ -32,7 +32,9 @@ describe Gitlab::Checks::BranchCheck do
end
 
it 'raises an error if the user is not allowed to merge to protected branches' do
expect_any_instance_of(Gitlab::Checks::MatchingMergeRequest).to receive(:match?).and_return(true)
expect_next_instance_of(Gitlab::Checks::MatchingMergeRequest) do |instance|
expect(instance).to receive(:match?).and_return(true)
end
expect(user_access).to receive(:can_merge_to_branch?).and_return(false)
expect(user_access).to receive(:can_push_to_branch?).and_return(false)
 
Loading
Loading
Loading
Loading
@@ -14,31 +14,41 @@ describe Gitlab::Checks::ChangeAccess do
end
 
it 'calls pushes checks' do
expect_any_instance_of(Gitlab::Checks::PushCheck).to receive(:validate!)
expect_next_instance_of(Gitlab::Checks::PushCheck) do |instance|
expect(instance).to receive(:validate!)
end
 
subject.exec
end
 
it 'calls branches checks' do
expect_any_instance_of(Gitlab::Checks::BranchCheck).to receive(:validate!)
expect_next_instance_of(Gitlab::Checks::BranchCheck) do |instance|
expect(instance).to receive(:validate!)
end
 
subject.exec
end
 
it 'calls tags checks' do
expect_any_instance_of(Gitlab::Checks::TagCheck).to receive(:validate!)
expect_next_instance_of(Gitlab::Checks::TagCheck) do |instance|
expect(instance).to receive(:validate!)
end
 
subject.exec
end
 
it 'calls lfs checks' do
expect_any_instance_of(Gitlab::Checks::LfsCheck).to receive(:validate!)
expect_next_instance_of(Gitlab::Checks::LfsCheck) do |instance|
expect(instance).to receive(:validate!)
end
 
subject.exec
end
 
it 'calls diff checks' do
expect_any_instance_of(Gitlab::Checks::DiffCheck).to receive(:validate!)
expect_next_instance_of(Gitlab::Checks::DiffCheck) do |instance|
expect(instance).to receive(:validate!)
end
 
subject.exec
end
Loading
Loading
Loading
Loading
@@ -12,12 +12,16 @@ describe Gitlab::Ci::Build::Credentials::Factory do
end
 
before do
allow_any_instance_of(described_class).to receive(:providers).and_return([TestProvider])
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:providers).and_return([TestProvider])
end
end
 
context 'when provider is valid' do
before do
allow_any_instance_of(TestProvider).to receive(:valid?).and_return(true)
allow_next_instance_of(TestProvider) do |instance|
allow(instance).to receive(:valid?).and_return(true)
end
end
 
it 'generates an array of credentials objects' do
Loading
Loading
@@ -29,7 +33,9 @@ describe Gitlab::Ci::Build::Credentials::Factory do
 
context 'when provider is not valid' do
before do
allow_any_instance_of(TestProvider).to receive(:valid?).and_return(false)
allow_next_instance_of(TestProvider) do |instance|
allow(instance).to receive(:valid?).and_return(false)
end
end
 
it 'generates an array without specific credential object' do
Loading
Loading
Loading
Loading
@@ -15,8 +15,9 @@ describe Gitlab::Ci::Config::External::File::Project do
before do
project.add_developer(user)
 
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!)
end
end
 
describe '#matching?' do
Loading
Loading
@@ -159,8 +160,8 @@ describe Gitlab::Ci::Config::External::File::Project do
private
 
def stub_project_blob(ref, path)
allow_any_instance_of(Repository)
.to receive(:blob_data_at)
.with(ref, path) { yield }
allow_next_instance_of(Repository) do |instance|
allow(instance).to receive(:blob_data_at).with(ref, path) { yield }
end
end
end
Loading
Loading
@@ -21,8 +21,9 @@ describe Gitlab::Ci::Config::External::File::Remote do
end
 
before do
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!)
end
end
 
describe '#matching?' do
Loading
Loading
Loading
Loading
@@ -14,8 +14,9 @@ describe Gitlab::Ci::Config::External::File::Template do
let(:template_file) { described_class.new(params, context) }
 
before do
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!)
end
end
 
describe '#matching?' do
Loading
Loading
Loading
Loading
@@ -23,8 +23,9 @@ describe Gitlab::Ci::Config::External::Mapper do
before do
stub_full_request(remote_url).to_return(body: file_content)
 
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!)
end
end
 
describe '#process' do
Loading
Loading
Loading
Loading
@@ -8,8 +8,9 @@ describe Gitlab::Ci::Config do
set(:user) { create(:user) }
 
before do
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!)
end
end
 
let(:config) do
Loading
Loading
@@ -358,18 +359,11 @@ describe Gitlab::Ci::Config do
 
context "when it takes too long to evaluate includes" do
before do
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
.and_call_original
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:set_deadline)
.with(described_class::TIMEOUT_SECONDS)
.and_call_original
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:execution_expired?)
.and_return(true)
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!).and_call_original
allow(instance).to receive(:set_deadline).with(described_class::TIMEOUT_SECONDS).and_call_original
allow(instance).to receive(:execution_expired?).and_return(true)
end
end
 
it 'raises error TimeoutError' do
Loading
Loading
@@ -384,9 +378,9 @@ describe Gitlab::Ci::Config do
 
context 'when context expansion timeout is disabled' do
before do
allow_any_instance_of(Gitlab::Ci::Config::External::Context)
.to receive(:check_execution_time!)
.and_call_original
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
allow(instance).to receive(:check_execution_time!).and_call_original
end
 
allow(Feature)
.to receive(:enabled?)
Loading
Loading
Loading
Loading
@@ -81,7 +81,9 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
 
context 'when a ref is protected' do
before do
allow_any_instance_of(Project).to receive(:protected_for?).and_return(true)
allow_next_instance_of(Project) do |instance|
allow(instance).to receive(:protected_for?).and_return(true)
end
end
 
it 'returns protected builds' do
Loading
Loading
@@ -91,7 +93,9 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
 
context 'when a ref is not protected' do
before do
allow_any_instance_of(Project).to receive(:protected_for?).and_return(false)
allow_next_instance_of(Project) do |instance|
allow(instance).to receive(:protected_for?).and_return(false)
end
end
 
it 'returns unprotected builds' do
Loading
Loading
Loading
Loading
@@ -112,8 +112,9 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
 
it 'calls get_chunk only once' do
expect_any_instance_of(Gitlab::Ci::Trace::ChunkedIO)
.to receive(:current_chunk).once.and_call_original
expect_next_instance_of(Gitlab::Ci::Trace::ChunkedIO) do |instance|
expect(instance).to receive(:current_chunk).once.and_call_original
end
 
chunked_io.each_line { |line| }
end
Loading
Loading
Loading
Loading
@@ -9,7 +9,9 @@ shared_examples 'base stage' do
 
before do
allow(stage).to receive(:project_median).and_return(1.12)
allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({})
allow_next_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher) do |instance|
allow(instance).to receive(:event_result).and_return({})
end
end
 
it 'has the median data value' do
Loading
Loading
Loading
Loading
@@ -17,7 +17,9 @@ describe Gitlab::CycleAnalytics::UsageData do
projects.each_with_index do |project, time|
issue = create(:issue, project: project, created_at: (time + 1).hour.ago)
 
allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue])
allow_next_instance_of(Gitlab::ReferenceExtractor) do |instance|
allow(instance).to receive(:issues).and_return([issue])
end
 
milestone = create(:milestone, project: project)
mr = create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}")
Loading
Loading
Loading
Loading
@@ -10,17 +10,25 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
 
describe '#diff_files' do
it 'does not highlight binary files' do
allow_any_instance_of(Gitlab::Diff::File).to receive(:text?).and_return(false)
allow_next_instance_of(Gitlab::Diff::File) do |instance|
allow(instance).to receive(:text?).and_return(false)
end
 
expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
expect_next_instance_of(Gitlab::Diff::File) do |instance|
expect(instance).not_to receive(:highlighted_diff_lines)
end
 
diff_files
end
 
it 'does not highlight files marked as undiffable in .gitattributes' do
allow_any_instance_of(Gitlab::Diff::File).to receive(:diffable?).and_return(false)
allow_next_instance_of(Gitlab::Diff::File) do |instance|
allow(instance).to receive(:diffable?).and_return(false)
end
 
expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
expect_next_instance_of(Gitlab::Diff::File) do |instance|
expect(instance).not_to receive(:highlighted_diff_lines)
end
 
diff_files
end
Loading
Loading
Loading
Loading
@@ -95,7 +95,9 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
context "something is wrong" do
context "when the merge request could not be saved" do
before do
allow_any_instance_of(MergeRequest).to receive(:save).and_return(false)
allow_next_instance_of(MergeRequest) do |instance|
allow(instance).to receive(:save).and_return(false)
end
end
 
it "raises an InvalidMergeRequestError" do
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