Commit 56a1cb09 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fix_empty_line_after_final_let_lib_services' into 'master'

Automatically fixed EmptyLineAfterFinalLet in lib and service specs

See merge request gitlab-org/gitlab!19738
parents bd7700b2 27a6a150
......@@ -43,6 +43,7 @@ describe API::Helpers::RelatedResourcesHelpers do
describe '#expose_url' do
let(:path) { '/api/v4/awesome_endpoint' }
subject(:url) { helpers.expose_url(path) }
def stub_default_url_options(protocol: 'http', host: 'example.com', port: nil, script_name: '')
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Backup::Repository do
let(:progress) { StringIO.new }
let!(:project) { create(:project, :wiki_repo) }
subject { described_class.new(progress) }
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Backup::Uploads do
let(:progress) { StringIO.new }
subject(:backup) { described_class.new(progress) }
describe '#initialize' do
......
......@@ -96,21 +96,25 @@ describe Banzai::Filter::RelativeLinkFilter do
context 'with a project_wiki' do
let(:project_wiki) { double('ProjectWiki') }
include_examples :preserve_unchanged
end
context 'without a repository' do
let(:project) { create(:project) }
include_examples :preserve_unchanged
end
context 'with an empty repository' do
let(:project) { create(:project_empty_repo) }
include_examples :preserve_unchanged
end
context 'without project repository access' do
let(:project) { create(:project, :repository, repository_access_level: ProjectFeature::PRIVATE) }
include_examples :preserve_unchanged
end
......@@ -269,6 +273,7 @@ describe Banzai::Filter::RelativeLinkFilter do
context 'when requested path is a file in the repo' do
let(:requested_path) { 'doc/api/README.md' }
it 'rebuilds URL relative to the containing directory' do
doc = filter(link('users.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
......@@ -277,6 +282,7 @@ describe Banzai::Filter::RelativeLinkFilter do
context 'when requested path is a directory in the repo' do
let(:requested_path) { 'doc/api/' }
it 'rebuilds URL relative to the directory' do
doc = filter(link('users.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
......@@ -287,6 +293,7 @@ describe Banzai::Filter::RelativeLinkFilter do
let(:ref) { '100%branch' }
let(:commit) { project.commit('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') }
let(:requested_path) { 'foo/bar/' }
it 'correctly escapes the ref' do
doc = filter(link('.gitkeep'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep"
......@@ -316,6 +323,7 @@ describe Banzai::Filter::RelativeLinkFilter do
let(:ref) { 'master' }
let(:commit) { project.commit('38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e') }
let(:requested_path) { 'with space/' }
it 'does not escape the space twice' do
doc = filter(link('README.md'))
expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md"
......@@ -328,7 +336,9 @@ describe Banzai::Filter::RelativeLinkFilter do
end
context 'with a valid ref' do
let(:commit) { nil } # force filter to use ref instead of commit
# force filter to use ref instead of commit
let(:commit) { nil }
include_examples :valid_repository
end
......
......@@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::IssueParser do
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:link) { empty_html_link }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
describe '#nodes_visible_to_user' do
......
......@@ -200,6 +200,7 @@ describe Banzai::ReferenceParser::SnippetParser do
describe '#referenced_by' do
let(:snippet) { create(:snippet, project: project) }
describe 'when the link has a data-snippet attribute' do
context 'using an existing snippet ID' do
it 'returns an Array of snippets' do
......
......@@ -36,6 +36,7 @@ describe Banzai::ReferenceRedactor do
context 'when data-original attribute provided' do
let(:original_content) { '<code>foo</code>' }
it 'replaces redacted reference with original content' do
doc = Nokogiri::HTML.fragment("<a class='gfm' href='https://www.gitlab.com' data-reference-type='issue' data-original='#{original_content}'>bar</a>")
redactor.redact([doc])
......
......@@ -37,11 +37,13 @@ describe Constraints::ProjectUrlConstrainer do
context 'and is a GET request' do
let(:request) { build_request(namespace.full_path, old_project_path) }
it { expect(subject.matches?(request)).to be_truthy }
end
context 'and is NOT a GET request' do
let(:request) { build_request(namespace.full_path, old_project_path, 'POST') }
it { expect(subject.matches?(request)).to be_falsey }
end
end
......
......@@ -24,11 +24,13 @@ describe Constraints::UserUrlConstrainer do
context 'and is a GET request' do
let(:request) { build_request(redirect_route.path) }
it { expect(subject.matches?(request)).to be_truthy }
end
context 'and is NOT a GET request' do
let(:request) { build_request(redirect_route.path, 'POST') }
it { expect(subject.matches?(request)).to be_falsey }
end
end
......
......@@ -451,6 +451,7 @@ module Gitlab
context 'with path to a binary file' do
let(:blob) { fake_blob(path: 'dk.png', binary: true) }
include_examples :invalid_include
end
......@@ -500,6 +501,7 @@ module Gitlab
context 'without a commit (only ref)' do
let(:commit) { nil }
include_examples :valid_include
end
end
......@@ -511,6 +513,7 @@ module Gitlab
context 'without a commit (only ref)' do
let(:commit) { nil }
include_examples :valid_include
end
end
......
......@@ -253,6 +253,7 @@ describe Gitlab::Auth::OAuth::User do
context "and LDAP user has an account already" do
let!(:existing_user) { create(:omniauth_user, name: 'John Doe', email: 'john@example.com', extern_uid: dn, provider: 'ldapmain', username: 'john') }
it "adds the omniauth identity to the LDAP account" do
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user)
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Auth, :use_clean_rails_memory_store_caching do
let(:gl_auth) { described_class }
set(:project) { create(:project) }
describe 'constants' do
......
......@@ -10,6 +10,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
describe described_class::Storage::HashedProject do
let(:project) { double(id: 555) }
subject(:project_storage) { described_class.new(project) }
it 'has the correct disk_path' do
......@@ -19,6 +20,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
describe described_class::Storage::LegacyProject do
let(:project) { double(full_path: 'this/is/the/full/path') }
subject(:project_storage) { described_class.new(project) }
it 'has the correct disk_path' do
......@@ -28,6 +30,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
describe described_class::Project do
let(:project_record) { projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz') }
subject(:project) { described_class.find(project_record.id) }
describe '#full_path' do
......
......@@ -49,6 +49,7 @@ describe Gitlab::BranchPushMergeCommitAnalyzer do
context 'when relevant_commit_ids is provided' do
let(:relevant_commit_id) { '8a994512e8c8f0dfcf22bb16df6e876be7a61036' }
subject { described_class.new(commits, relevant_commit_ids: [relevant_commit_id]) }
it 'returns correct merge commit' do
......
......@@ -152,6 +152,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe '#blob' do
let(:file_entry) { |example| path(example) }
subject { file_entry.blob }
it 'returns a blob representing the entry data' do
......
......@@ -23,6 +23,7 @@ describe Gitlab::Ci::Status::Pipeline::Blocked do
describe '.matches?' do
let(:user) { double('user') }
subject { described_class.matches?(pipeline, user) }
context 'when pipeline is blocked' do
......
......@@ -23,6 +23,7 @@ describe Gitlab::Ci::Status::Pipeline::Delayed do
describe '.matches?' do
let(:user) { double('user') }
subject { described_class.matches?(pipeline, user) }
context 'when pipeline is scheduled' do
......
......@@ -21,6 +21,7 @@ describe Gitlab::Ci::Trace::SectionParser do
end
let(:lines) { build_lines('') }
subject { described_class.new(lines) }
describe '#sections' do
......
......@@ -1723,6 +1723,7 @@ module Gitlab
describe "Hidden jobs" do
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) }
subject { config_processor.stage_builds_attributes("test") }
shared_examples 'hidden_job_handling' do
......@@ -1767,6 +1768,7 @@ module Gitlab
describe "YAML Alias/Anchor" do
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) }
subject { config_processor.stage_builds_attributes("build") }
shared_examples 'job_templates_handling' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Cleanup::OrphanJobArtifactFiles do
let(:null_logger) { Logger.new('/dev/null') }
subject(:cleanup) { described_class.new(logger: null_logger) }
before do
......
......@@ -83,6 +83,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
describe '#rename_path_for_routable' do
context 'for namespaces' do
let(:namespace) { create(:namespace, path: 'the-path') }
it "renames namespaces called the-path" do
subject.rename_path_for_routable(migration_namespace(namespace))
......@@ -159,6 +160,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
describe '#perform_rename' do
describe 'for namespaces' do
let(:namespace) { create(:namespace, path: 'the-path') }
it 'renames the path' do
subject.perform_rename(migration_namespace(namespace), 'the-path', 'renamed')
......
......@@ -95,6 +95,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
describe '#move_repositories' do
let(:namespace) { create(:group, name: 'hello-group') }
it 'moves a project for a namespace' do
create(:project, :repository, :legacy_storage, namespace: namespace, path: 'hello-project')
expected_path = File.join(TestEnv.repos_path, 'bye-group', 'hello-project.git')
......
......@@ -7,6 +7,7 @@ describe Gitlab::Diff::DiffRefs do
describe '#==' do
let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
subject { commit.diff_refs }
context 'when shas are missing' do
......@@ -63,6 +64,7 @@ describe Gitlab::Diff::DiffRefs do
describe '#compare_in' do
context 'with diff refs for the initial commit' do
let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
subject { commit.diff_refs }
it 'returns an appropriate comparison' do
......@@ -74,6 +76,7 @@ describe Gitlab::Diff::DiffRefs do
context 'with diff refs for a commit' do
let(:commit) { project.commit('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
subject { commit.diff_refs }
it 'returns an appropriate comparison' do
......
......@@ -11,6 +11,7 @@ describe Gitlab::Diff::LineMapper do
let(:diffs) { commit.raw_diffs }
let(:diff) { diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) }
subject { described_class.new(diff_file) }
describe '#old_to_new' do
......
......@@ -11,6 +11,7 @@ describe Gitlab::Diff::ParallelDiff do
let(:diffs) { commit.raw_diffs }
let(:diff) { diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) }
subject { described_class.new(diff_file) }
describe '#parallelize' do
......
......@@ -191,6 +191,7 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
describe '#patch_attachments' do
let(:email_raw) { email_fixture('emails/merge_request_multiple_patches.eml') }
let(:mail) { Mail::Message.new(email_raw) }
subject(:handler) { described_class.new(mail, mail_key) }
it 'orders attachments ending in `.patch` by name' do
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::ExternalAuthorization::Client do
let(:user) { build(:user, email: 'dummy_user@example.com') }
let(:dummy_url) { 'https://dummy.net/' }
subject(:client) { described_class.new(user, 'dummy_label') }
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::ExternalAuthorization::Response do
let(:excon_response) { double }
subject(:response) { described_class.new(excon_response) }
describe '#valid?' do
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::FileFinder do
describe '#find' do
let(:project) { create(:project, :public, :repository) }
subject { described_class.new(project, project.default_branch) }
it_behaves_like 'file finder' do
......
......@@ -54,11 +54,13 @@ describe Gitlab::Gfm::ReferenceRewriter do
context 'code' do
let(:text) { "#1, but not `[#1]`" }
it { is_expected.to eq "#{issue_first.to_reference(new_project)}, but not `[#1]`" }
end
context 'code reverse' do
let(:text) { "not `#1`, but #1" }
it { is_expected.to eq "not `#1`, but #{issue_first.to_reference(new_project)}" }
end
......@@ -74,11 +76,13 @@ describe Gitlab::Gfm::ReferenceRewriter do
context 'label referenced by id' do
let(:text) { '#1 and ~123' }
it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} }
end
context 'label referenced by text' do
let(:text) { '#1 and ~"test"' }
it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} }
end
end
......@@ -93,11 +97,13 @@ describe Gitlab::Gfm::ReferenceRewriter do
context 'label referenced by id' do
let(:text) { '#1 and ~321' }
it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} }
end
context 'label referenced by text' do
let(:text) { '#1 and ~"group label"' }
it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} }
end
end
......
......@@ -542,6 +542,7 @@ describe Gitlab::Git::Commit, :seed_helper do
skip 'move this test to gitaly-ruby' do
describe '#init_from_rugged' do
let(:gitlab_commit) { described_class.new(repository, rugged_commit) }
subject { gitlab_commit }
describe '#id' do
......@@ -553,6 +554,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#init_from_hash' do
let(:commit) { described_class.new(repository, sample_commit_hash) }
subject { commit }
describe '#id' do
......@@ -608,6 +610,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#to_hash' do
let(:hash) { commit.to_hash }
subject { hash }
it { is_expected.to be_kind_of Hash }
......@@ -629,6 +632,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#ref_names' do
let(:commit) { described_class.find(repository, 'master') }
subject { commit.ref_names(repository) }
it 'has 2 element' do
......
......@@ -149,6 +149,7 @@ EOT
describe '.between' do
let(:diffs) { described_class.between(repository, 'feature', 'master') }
subject { diffs }
it { is_expected.to be_kind_of Gitlab::Git::DiffCollection }
......
......@@ -57,6 +57,7 @@ describe Gitlab::Git::HookEnv do
using RSpec::Parameterized::TableSyntax
let(:key) { 'GIT_OBJECT_DIRECTORY_RELATIVE' }
subject { described_class.to_env_hash(gl_repository) }
where(:input, :output) do
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::Git::MergeBase do
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject(:merge_base) { described_class.new(repository, refs) }
shared_context 'existing refs with a merge base', :existing_refs do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Git::RemoteRepository, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
subject { described_class.new(repository) }
describe '#empty?' do
......
......@@ -212,6 +212,7 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#ref_names' do
let(:ref_names) { repository.ref_names }
subject { ref_names }
it { is_expected.to be_kind_of Array }
......
......@@ -26,6 +26,7 @@ describe Gitlab::Git::User do
describe '.from_gitlab' do
context 'when no commit_email has been set' do
let(:user) { build(:user, email: 'alice@example.com', commit_email: nil) }
subject { described_class.from_gitlab(user) }
it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-')) }
......@@ -33,6 +34,7 @@ describe Gitlab::Git::User do
context 'when commit_email has been set' do
let(:user) { build(:user, email: 'alice@example.com', commit_email: 'bob@example.com') }
subject { described_class.from_gitlab(user) }
it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, 'user-')) }
......
......@@ -188,6 +188,7 @@ describe Gitlab::GitalyClient::CommitService do
describe '#find_commit' do
let(:revision) { Gitlab::Git::EMPTY_TREE_ID }
it 'sends an RPC request' do
request = Gitaly::FindCommitRequest.new(
repository: repository_message, revision: revision
......
......@@ -22,6 +22,7 @@ describe Gitlab::GitalyClient::RefService do
describe '#remote_branches' do
let(:remote_name) { 'my_remote' }
subject { client.remote_branches(remote_name) }
it 'sends a find_all_remote_branches message' do
......
......@@ -4,6 +4,7 @@ require "spec_helper"
describe Gitlab::GoogleCodeImport::Client do
let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) }
subject { described_class.new(raw_data) }
describe "#valid?" do
......
......@@ -25,6 +25,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeFieldService do
end
let(:current_user) { double(:current_user) }
subject(:service) { described_class.new(field) }
describe '#authorized_resolve' do
......@@ -34,6 +35,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeFieldService do
let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil)}
let(:query_context) { OpenStruct.new(schema: schema) }
let(:context) { GraphQL::Query::Context.new(query: OpenStruct.new(schema: schema, context: query_context), values: { current_user: current_user }, object: nil) }
subject(:resolved) { service.authorized_resolve.call(presented_type, {}, context) }
context 'scalar types' do
......
......@@ -27,6 +27,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do
let(:user) { build(:user) }
let(:project) { build(:project) }
subject(:loading_resource) { fake_class.new(user, project) }
context 'when the user is allowed to perform the action' do
......
......@@ -6,6 +6,7 @@ describe Gitlab::Graphql::Connections::FilterableArrayConnection do
let(:callback) { proc { |nodes| nodes } }
let(:all_nodes) { Gitlab::Graphql::FilterableArray.new(callback, 1, 2, 3, 4, 5) }
let(:arguments) { {} }
subject(:connection) do
described_class.new(all_nodes, arguments, max_page_size: 3)
end
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::Graphql::Connections::Keyset::Connection do
let(:nodes) { Project.all.order(id: :asc) }
let(:arguments) { {} }
subject(:connection) do
described_class.new(nodes, arguments, max_page_size: 3)
end
......
......@@ -15,6 +15,7 @@ describe Gitlab::HookData::BaseBuilder do
context 'with an upload prefix specified' do
let(:project_with_path) { double(full_path: 'baz/bar') }
let(:object_with_project) { double(project: project_with_path) }
subject { subclass.new(object_with_project) }
where do
......
......@@ -136,6 +136,7 @@ describe Gitlab::I18n::TranslationEntry do
describe '#contains_unescaped_chars' do
let(:data) { { msgid: '' } }
let(:entry) { described_class.new(data, 2) }
it 'is true when the msgid is an array' do
string = '「100%確定」'
......
......@@ -9,6 +9,7 @@ describe Gitlab::ImportExport::LfsRestorer do
let(:project) { create(:project) }
let(:shared) { project.import_export_shared }
let(:saver) { Gitlab::ImportExport::LfsSaver.new(project: project, shared: shared) }
subject(:restorer) { described_class.new(project: project, shared: shared) }
before do
......
......@@ -7,6 +7,7 @@ describe Gitlab::ImportExport::Saver do
let!(:project) { create(:project, :public, name: 'project') }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
subject { described_class.new(exportable: project, shared: shared) }
before do
......
......@@ -5,6 +5,7 @@ require 'fileutils'
describe Gitlab::ImportExport::Shared do
let(:project) { build(:project) }
subject { project.import_export_shared }
context 'with a repository on disk' do
......
......@@ -7,6 +7,7 @@ describe Gitlab::JsonCache do
let(:namespace) { 'geo' }
let(:key) { 'foo' }
let(:expanded_key) { "#{namespace}:#{key}:#{Gitlab::VERSION}:#{Rails.version}" }
set(:broadcast_message) { create(:broadcast_message) }
subject(:cache) { described_class.new(namespace: namespace, backend: backend) }
......
......@@ -18,6 +18,7 @@ describe Gitlab::Kubernetes::ConfigMap do
describe '#generate' do
let(:resource) { ::Kubeclient::Resource.new(metadata: metadata, data: application.files) }
subject { config_map.generate }
it 'builds a Kubeclient Resource' do
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::Kubernetes::Namespace do
let(:name) { 'a_namespace' }
let(:client) { double('kubernetes client') }
subject { described_class.new(name, client) }
it { expect(subject.name).to eq(name) }
......
......@@ -27,6 +27,7 @@ describe Gitlab::Kubernetes do
context 'with a path prefix in the API URL' do
let(:api_url) { 'https://example.com/prefix/' }
it { expect(result.path).to eq('/prefix/api/v1/namespaces/default/pods/pod1/exec') }
end
......
......@@ -265,6 +265,7 @@ describe Gitlab::LegacyGithubImport::Importer do
context 'when importing a GitHub project' do
let(:api_root) { 'https://api.github.com' }
let(:repo_root) { 'https://github.com' }
subject { described_class.new(project) }
it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute'
......@@ -287,6 +288,7 @@ describe Gitlab::LegacyGithubImport::Importer do
context 'when importing a Gitea project' do
let(:api_root) { 'https://try.gitea.io/api/v1' }
let(:repo_root) { 'https://try.gitea.io' }
subject { described_class.new(project) }
before do
......
......@@ -89,6 +89,7 @@ describe Gitlab::LegacyGithubImport::MilestoneFormatter do
context 'when importing a Gitea project' do
let(:iid_attr) { :id }
before do
project.update(import_type: 'gitea')
end
......
......@@ -86,6 +86,7 @@ describe ::Gitlab::LetsEncrypt::Client do
describe '#load_order' do
let(:url) { 'https://example.com/order' }
subject { client.load_order(url) }
before do
......@@ -102,6 +103,7 @@ describe ::Gitlab::LetsEncrypt::Client do
describe '#load_challenge' do
let(:url) { 'https://example.com/challenge' }
subject { client.load_challenge(url) }
before do
......
......@@ -126,6 +126,7 @@ describe Gitlab::MarkdownCache::ActiveRecord::Extension do
describe '#cached_html_up_to_date?' do
let(:thing) { klass.create(title: updated_markdown, title_html: html, cached_markdown_version: nil) }
subject { thing.cached_html_up_to_date?(:title) }
it 'returns false if markdown has been changed but html has not' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Metrics::RequestsRackMiddleware do
let(:app) { double('app') }
subject { described_class.new(app) }
describe '#call' do
......
......@@ -52,6 +52,7 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do
context 'unicorn listens on tcp sockets' do
let(:tcp_socket_address) { '0.0.0.0:8080' }
let(:tcp_sockets) { [tcp_socket_address] }
before do
allow(unicorn).to receive(:listener_names).and_return(tcp_sockets)
end
......
......@@ -49,6 +49,7 @@ describe Gitlab::Pagination::Keyset do
context 'with other order-by columns' do
let(:order_by) { { created_at: :desc, id: :desc } }
it 'returns false for Project' do
expect(subject.available?(request_context, Project.all)).to be_falsey
end
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::PhabricatorImport::Cache::Map, :clean_gitlab_redis_cache do
set(:project) { create(:project) }
let(:redis) { Gitlab::Redis::Cache }
subject(:map) { described_class.new(project) }
describe '#get_gitlab_model' do
......
......@@ -11,6 +11,7 @@ describe Gitlab::PhabricatorImport::Importer do
describe '#execute' do
let(:project) { create(:project, :import_scheduled) }
subject(:importer) { described_class.new(project) }
it 'sets a custom jid that will be kept up to date' do
......
......@@ -8,6 +8,7 @@ describe Gitlab::PhabricatorImport::ProjectCreator do
phabricator_server_url: 'http://phab.example.com',
api_token: 'the-token' }
end
subject(:creator) { described_class.new(user, params) }
describe '#execute' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::PhabricatorImport::UserFinder, :clean_gitlab_redis_cache do
let(:project) { create(:project, namespace: create(:group)) }
subject(:finder) { described_class.new(project, ['first-phid', 'second-phid']) }
before do
......
......@@ -53,6 +53,7 @@ describe Gitlab::ProjectSearchResults do
context "when #{entity_type} is disabled" do
let(:project) { disabled_project }
it "hides #{blob_kind} from members" do
project.add_reporter(user)
......
......@@ -5,8 +5,8 @@ require 'spec_helper'
describe Gitlab::Prometheus::Queries::DeploymentQuery do
let(:environment) { create(:environment, slug: 'environment-slug') }
let(:deployment) { create(:deployment, environment: environment) }
let(:client) { double('prometheus_client') }
subject { described_class.new(client) }
around do |example|
......
......@@ -7,8 +7,8 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do
let(:project) { create(:project) }
let(:serverless_func) { Serverless::Function.new(project, 'test-name', 'test-ns') }
let(:client) { double('prometheus_client') }
subject { described_class.new(client) }
context 'verify queries' do
......
......@@ -327,6 +327,7 @@ describe Gitlab::PrometheusClient do
context "without response code" do
let(:response_error) { Gitlab::HTTP::ResponseError }
it 'raises PrometheusClient::Error' do
expect { subject.proxy('query', { query: prometheus_query }) }.to(
raise_error(Gitlab::PrometheusClient::Error, 'Network connection error')
......
......@@ -9,6 +9,7 @@ Hello! Let's do this!
/sub_name I like this stuff
EOF
end
subject do
described_class.new(:sub_name, action_block: proc { |text| "#{text} foo" })
end
......
......@@ -113,11 +113,13 @@ describe Gitlab::SlashCommands::Command do
context 'IssueMove is triggered' do
let(:params) { { text: 'issue move #78291 to gitlab/gitlab-ci' } }
it { is_expected.to eq(Gitlab::SlashCommands::IssueMove) }
end
context 'IssueComment is triggered' do
let(:params) { { text: "issue comment #503\ncomment body" } }
it { is_expected.to eq(Gitlab::SlashCommands::IssueComment) }
end
end
......
......@@ -42,6 +42,7 @@ describe Gitlab::SlashCommands::IssueSearch do
describe 'self.match' do
let(:query) { "my search keywords" }
it 'matches the query' do
match = described_class.match("issue search #{query}")
......
......@@ -10,6 +10,7 @@ describe Gitlab::SlashCommands::Presenters::IssueComment do
describe '#present' do
let(:attachment) { subject[:attachments].first }
subject { described_class.new(note).present }
it { is_expected.to be_a(Hash) }
......
......@@ -116,6 +116,7 @@ describe Gitlab::Workhorse do
describe '.send_git_patch' do
let(:diff_refs) { double(base_sha: "base", head_sha: "head") }
subject { described_class.send_git_patch(repository, diff_refs) }
it 'sets the header correctly' do
......@@ -178,6 +179,7 @@ describe Gitlab::Workhorse do
describe '.send_git_diff' do
let(:diff_refs) { double(base_sha: "base", head_sha: "head") }
subject { described_class.send_git_diff(repository, diff_refs) }
it 'sets the header correctly' do
......
......@@ -41,6 +41,7 @@ describe JSONWebToken::RSAToken do
context 'for invalid key to raise an exception' do
let(:new_key) { OpenSSL::PKey::RSA.generate(512) }
subject { JWT.decode(rsa_encoded, new_key, true, { algorithm: 'RS256' }) }
it { expect {subject}.to raise_error(JWT::DecodeError) }
......
......@@ -7,6 +7,7 @@ describe AwardEmojis::AddService do
set(:project) { create(:project) }
set(:awardable) { create(:note, project: project) }
let(:name) { 'thumbsup' }
subject(:service) { described_class.new(awardable, name, user) }
describe '#execute' do
......
......@@ -10,6 +10,7 @@ describe AwardEmojis::DestroyService do
let!(:award_from_other_user) do
create(:award_emoji, name: name, awardable: awardable, user: create(:user))
end
subject(:service) { described_class.new(awardable, name, user) }
describe '#execute' do
......
......@@ -7,6 +7,7 @@ describe AwardEmojis::ToggleService do
set(:project) { create(:project, :public) }
set(:awardable) { create(:note, project: project) }
let(:name) { 'thumbsup' }
subject(:service) { described_class.new(awardable, name, user) }
describe '#execute' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Branches::CreateService do
let(:user) { create(:user) }
subject(:service) { described_class.new(project, user) }
describe '#execute' do
......
......@@ -6,6 +6,7 @@ describe Branches::DeleteService do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
subject(:service) { described_class.new(project, user) }
shared_examples 'a deleted branch' do |branch_name|
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Branches::ValidateNewService do
let(:project) { create(:project, :repository) }
subject(:service) { described_class.new(project) }
describe '#execute' do
......
......@@ -76,6 +76,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
context 'when installation POD succeeded' do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
expect(service).to receive(:pod_phase).once.and_return(phase)
end
......@@ -137,6 +138,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
context 'when installation POD succeeded' do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
expect(service).to receive(:pod_phase).once.and_return(phase)
end
......
......@@ -46,6 +46,7 @@ describe Clusters::Applications::CheckUninstallProgressService do
context 'when installation POD succeeded' do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
expect_any_instance_of(Gitlab::Kubernetes::Helm::Api)
.to receive(:delete_pod!)
......
......@@ -26,6 +26,7 @@ describe Clusters::Kubernetes::FetchKubernetesTokenService do
context 'when params correct' do
let(:decoded_token) { 'xxx.token.xxx' }
let(:token) { Base64.encode64(decoded_token) }
context 'when the secret exists' do
before do
stub_kubeclient_get_secret(
......
......@@ -28,6 +28,7 @@ describe CompareService do
context 'compare with source branch that does not exist' do
let(:service) { described_class.new(project, 'non-existent-branch') }
subject { service.execute(project, 'non-existent-ref') }
it { expect(subject).to be_nil }
......
......@@ -191,6 +191,7 @@ describe Issues::MoveService do
context 'issue is not persisted' do
include_context 'user can move issue'
let(:old_issue) { build(:issue, project: old_project, author: author) }
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
end
......
......@@ -151,6 +151,7 @@ describe Issues::UpdateService, :mailer do
context 'when current user cannot admin issues in the project' do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
......
......@@ -29,6 +29,7 @@ describe Lfs::UnlockFileService do
context 'when lock does not exists' do
let(:params) { { id: 123 } }
it "doesn't succeed" do
result = subject.execute
......
......@@ -47,6 +47,7 @@ describe MergeRequests::GetUrlsService do
context 'pushing to default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'no_merge_request_url'
end
......@@ -62,28 +63,33 @@ describe MergeRequests::GetUrlsService do
context 'pushing one completely new branch' do
let(:changes) { new_branch_changes }
it_behaves_like 'new_merge_request_link'
end
context 'pushing to existing branch but no merge request' do
let(:changes) { existing_branch_changes }
it_behaves_like 'new_merge_request_link'
end
context 'pushing to deleted branch' do
let(:changes) { deleted_branch_changes }
it_behaves_like 'no_merge_request_url'
end
context 'pushing to existing branch and merge request opened' do
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
it_behaves_like 'show_merge_request_url'
end
context 'pushing to existing branch and merge request is reopened' do
let!(:merge_request) { create(:merge_request, :opened, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
it_behaves_like 'show_merge_request_url'
end
......@@ -105,12 +111,14 @@ describe MergeRequests::GetUrlsService do
context 'pushing to existing branch and merge request is closed' do
let!(:merge_request) { create(:merge_request, :closed, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
it_behaves_like 'new_merge_request_link'
end
context 'pushing to existing branch and merge request is merged' do
let!(:merge_request) { create(:merge_request, :merged, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
it_behaves_like 'new_merge_request_link'
end
......
......@@ -608,6 +608,7 @@ describe MergeRequests::RefreshService do
context 'marking the merge request as work in progress' do
let(:refresh_service) { service.new(@project, @user) }
before do
allow(refresh_service).to receive(:execute_hooks)
end
......
......@@ -6,6 +6,7 @@ describe MergeRequests::ResolvedDiscussionNotificationService do
let(:merge_request) { create(:merge_request) }
let(:user) { create(:user) }
let(:project) { merge_request.project }
subject { described_class.new(project, user) }
describe "#execute" do
......
......@@ -154,6 +154,7 @@ describe NotificationService, :mailer do
describe '#async' do
let(:async) { notification.async }
set(:key) { create(:personal_key) }
it 'returns an Async object with the correct parent' do
......
......@@ -26,6 +26,7 @@ describe Projects::ContainerRepository::DeleteTagsService do
describe '#execute' do
let(:tags) { %w[A] }
subject { service.execute(repository) }
context 'without permissions' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Projects::ForksCountService, :use_clean_rails_memory_store_caching do
let(:project) { build(:project) }
subject { described_class.new(project) }
it_behaves_like 'a counter caching service'
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_caching do
let(:project) { create(:project) }
subject { described_class.new(project) }
it_behaves_like 'a counter caching service'
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Prometheus::AdapterService do
let(:project) { create(:project) }
subject { described_class.new(project) }
describe '#prometheus_adapter' do
......
......@@ -1370,6 +1370,7 @@ describe QuickActions::InterpretService do
context 'if issuable is a Commit' do
let(:content) { '/award :100:' }
let(:issuable) { commit }
it_behaves_like 'empty command'
end
end
......@@ -1497,23 +1498,27 @@ describe QuickActions::InterpretService do
context 'if the given label does not exist' do
let(:issuable) { issue }
let(:content) { '/board_move ~"Fake Label"' }
it_behaves_like 'empty command', 'Failed to move this issue because label was not found.'
end
context 'if multiple labels are given' do
let(:issuable) { issue }
let(:content) { %{/board_move ~"#{inreview.title}" ~"#{todo.title}"} }
it_behaves_like 'empty command', 'Failed to move this issue because only a single label can be provided.'
end
context 'if the given label is not a list on the board' do
let(:issuable) { issue }
let(:content) { %{/board_move ~"#{bug.title}"} }
it_behaves_like 'empty command', 'Failed to move this issue because label was not found.'
end
context 'if issuable is not an Issue' do
let(:issuable) { merge_request }
it_behaves_like 'empty command'
end
end
......
......@@ -20,6 +20,7 @@ describe Search::GroupService do
let!(:project3) { create(:project, :internal, namespace: nested_group.parent, name: "Outer #{term}") }
let(:results) { described_class.new(user, search_group, search: term).execute }
subject { results.objects('projects') }
context 'in parent group' do
......
......@@ -618,6 +618,7 @@ describe ::SystemNotes::IssuablesService do
context 'when notable is an ExternalIssue' do
let(:noteable) { ExternalIssue.new('EXT-1234', project) }
it 'is truthy' do
mentioner = noteable.dup
expect(service.cross_reference_disallowed?(mentioner))
......
......@@ -441,6 +441,7 @@ describe TodoService do
context 'leaving a note on a commit in a public project' do
let(:project) { create(:project, :repository, :public) }
it 'creates a todo for each valid mentioned user' do
expected_todo = base_commit_todo_attrs.merge(
action: Todo::MENTIONED,
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
let(:user) { create(:user) }
subject { described_class.new(user) }
it_behaves_like 'a counter caching service'
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Users::RepairLdapBlockedService do
let(:user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') }
let(:identity) { user.ldap_identity }
subject(:service) { described_class.new(user) }
describe '#execute' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Users::SetStatusService do
let(:current_user) { create(:user) }
subject(:service) { described_class.new(current_user, params) }
describe '#execute' do
......
......@@ -174,6 +174,7 @@ describe Wikis::CreateAttachmentService do
describe '#execute' do
let(:wiki) { project.wiki }
subject(:service_execute) { service.execute[:result] }
context 'creates branch if it does not exists' do
......
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