Commit 1433fc2e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'empty_line_after_subject' into 'master'

Fixed and reenabled EmptyLineAfterSubject

See merge request gitlab-org/gitlab!18618
parents 88cadb53 ed0839d1
......@@ -273,11 +273,6 @@ RSpec/ContextWording:
RSpec/EmptyLineAfterFinalLet:
Enabled: false
# Offense count: 232
# Cop supports --auto-correct.
RSpec/EmptyLineAfterSubject:
Enabled: false
# Offense count: 719
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......
......@@ -66,6 +66,7 @@ describe Analytics::ProductivityAnalyticsController do
describe 'GET show.json' do
subject { get :show, format: :json, params: params }
let(:params) { {} }
let(:analytics_mock) { instance_double('ProductivityAnalytics') }
......
......@@ -15,6 +15,7 @@ describe Projects::ProjectMembersController do
source_project_id: another_project.id
})
end
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
......@@ -53,6 +54,7 @@ describe Projects::ProjectMembersController do
project_id: project
}
end
let(:access_level) { nil }
before do
......
......@@ -3,6 +3,7 @@
FactoryBot.define do
factory :smartcard_identity do
subject { 'CN=gitlab-user/emailAddress=gitlab-user@random-corp.org' }
issuer { 'O=Random Corp Ltd, CN=Random Corp' }
association :user
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe GroupMembersFinder do
subject(:finder) { described_class.new(group) }
let(:group) { create :group }
let(:non_owner_access_level) { Gitlab::Access.options.values.sample }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe ProductivityAnalyticsFinder do
subject { described_class.new(current_user, search_params.merge(state: :merged)) }
let(:current_user) { create(:admin) }
let(:search_params) { {} }
......
......@@ -55,6 +55,7 @@ describe EE::UserCalloutsHelper do
describe '.show_enable_hashed_storage_warning?' do
subject { helper.show_enable_hashed_storage_warning? }
let(:user) { create(:user) }
context 'when hashed storage is disabled' do
......@@ -87,6 +88,7 @@ describe EE::UserCalloutsHelper do
describe '.show_migrate_hashed_storage_warning?' do
subject { helper.show_migrate_hashed_storage_warning? }
let(:user) { create(:user) }
context 'when hashed storage is disabled' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Analytics::ProductivityCalculator do
subject { described_class.new(merge_request) }
let(:merge_request) { create(:merge_request_with_diff_notes, :merged, :with_diffs, created_at: 31.days.ago) }
describe '#productivity_data' do
......
......@@ -95,6 +95,7 @@ describe EE::API::Helpers do
describe '#authorize_change_param' do
subject { Class.new.include(described_class).new }
let(:project) { create(:project) }
before do
......
......@@ -265,6 +265,7 @@ describe Gitlab::Ci::Reports::LicenseScanning::Report do
describe '.parse_from' do
context 'when parsing a v1 report' do
subject { described_class.parse_from(v1_json) }
let(:v1_json) { fixture_file('security_reports/master/gl-license-management-report.json', dir: 'ee') }
it { expect(subject.version).to eql('1.0') }
......@@ -273,6 +274,7 @@ describe Gitlab::Ci::Reports::LicenseScanning::Report do
context 'when parsing a v2 report' do
subject { described_class.parse_from(v2_json) }
let(:v2_json) { fixture_file('security_reports/gl-license-management-report-v2.json', dir: 'ee') }
it { expect(subject.version).to eql('2.0') }
......
......@@ -63,6 +63,7 @@ describe Gitlab::Ci::Reports::Security::Occurrence do
describe "delegation" do
subject { create(:ci_reports_security_occurrence) }
%i[file_path start_line end_line].each do |attribute|
it "delegates attribute #{attribute} to location" do
expect(subject.public_send(attribute)).to eq(subject.location.public_send(attribute))
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe OmniAuth::Strategies::KerberosSpnego do
subject { described_class.new(:app) }
let(:session) { {} }
before do
......
......@@ -18,6 +18,7 @@ describe Emails::CsvExport do
let(:empty_project) { create(:project, path: 'myproject') }
let(:export_status) { { truncated: false, rows_expected: 3, rows_written: 3 } }
subject { Notify.issues_csv_email(user, empty_project, "dummy content", export_status) }
let(:attachment) { subject.attachments.first }
it 'attachment has csv mime type' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Approvable do
subject(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
let(:author) { merge_request.author }
......
......@@ -309,6 +309,7 @@ describe ApprovalMergeRequestRule do
context "when the rule is a `#{ApprovalRuleLike::DEFAULT_NAME_FOR_LICENSE_REPORT}` rule" do
subject { create(:report_approver_rule, :requires_approval, :license_management, merge_request: open_merge_request) }
let(:open_merge_request) { create(:merge_request, :opened, target_project: project, source_project: project) }
let!(:project_approval_rule) { create(:approval_project_rule, :requires_approval, :license_management, project: project) }
let(:project) { create(:project) }
......
......@@ -80,6 +80,7 @@ describe ApprovalProjectRule do
ApprovalProjectRule::REPORT_TYPES_BY_DEFAULT_NAME.each do |name, value|
context "when the project rule is for a `#{name}`" do
subject { create(:approval_project_rule, value, :requires_approval, project: project) }
let!(:result) { subject.apply_report_approver_rules_to(merge_request) }
specify { expect(merge_request.reload.approval_rules).to match_array([result]) }
......
......@@ -334,6 +334,7 @@ describe Ci::Build do
describe '#retryable?' do
subject { build.retryable? }
let(:pipeline) { merge_request.all_pipelines.last }
let!(:build) { create(:ci_build, :canceled, pipeline: pipeline) }
......
......@@ -526,6 +526,7 @@ describe Ci::Pipeline do
describe '#retryable?' do
subject { pipeline.retryable? }
let(:pipeline) { merge_request.all_pipelines.last }
let!(:build) { create(:ci_build, :canceled, pipeline: pipeline) }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe ResourceLabelEvent, type: :model do
subject { build(:resource_label_event) }
let(:epic) { create(:epic) }
describe 'validations' do
......
......@@ -162,6 +162,7 @@ describe MergeRequest do
describe '#has_license_management_reports?' do
subject { merge_request.has_license_management_reports? }
let(:project) { create(:project, :repository) }
before do
......@@ -183,6 +184,7 @@ describe MergeRequest do
describe '#has_dependency_scanning_reports?' do
subject { merge_request.has_dependency_scanning_reports? }
let(:project) { create(:project, :repository) }
before do
......@@ -204,6 +206,7 @@ describe MergeRequest do
describe '#has_container_scanning_reports?' do
subject { merge_request.has_container_scanning_reports? }
let(:project) { create(:project, :repository) }
before do
......@@ -225,6 +228,7 @@ describe MergeRequest do
describe '#has_sast_reports?' do
subject { merge_request.has_sast_reports? }
let(:project) { create(:project, :repository) }
before do
......@@ -246,6 +250,7 @@ describe MergeRequest do
describe '#has_metrics_reports?' do
subject { merge_request.has_metrics_reports? }
let(:project) { create(:project, :repository) }
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe ProductivityAnalytics do
subject(:analytics) { described_class.new(merge_requests: MergeRequest.all, sort: custom_sort) }
let(:custom_sort) { nil }
let(:long_mr) do
......
......@@ -2115,6 +2115,7 @@ describe Project do
describe '#allowed_to_share_with_group?' do
context 'for group related project' do
subject(:project) { build_stubbed(:project, namespace: group, group: group) }
let(:group) { build_stubbed :group }
context 'with lock_memberships_to_ldap application setting enabled' do
......@@ -2128,6 +2129,7 @@ describe Project do
context 'personal project' do
subject(:project) { build_stubbed(:project, namespace: namespace) }
let(:namespace) { build_stubbed :namespace }
context 'with lock_memberships_to_ldap application setting enabled' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe PrometheusAlertEvent do
subject { build(:prometheus_alert_event) }
let(:alert) { subject.prometheus_alert }
describe 'associations' do
......
......@@ -15,6 +15,7 @@ describe SoftwareLicensePolicy do
describe ".with_license_by_name" do
subject { described_class }
let!(:mit_policy) { create(:software_license_policy, software_license: mit) }
let!(:mit) { create(:software_license, :mit) }
let!(:apache_policy) { create(:software_license_policy, software_license: apache) }
......
......@@ -13,6 +13,7 @@ describe SoftwareLicense do
describe '.create_policy_for!' do
subject { described_class }
let(:project) { create(:project) }
context 'when a software license with a given name has already been created' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe ProductivityAnalyticsMergeRequestEntity do
subject { described_class.represent(merge_request).as_json.with_indifferent_access }
let(:merge_request) { create(:merge_request) }
before do
......
......@@ -86,6 +86,7 @@ describe ApprovalRules::CreateService do
ApprovalProjectRule::REPORT_TYPES_BY_DEFAULT_NAME.keys.each do |rule_name|
context "when the rule name is `#{rule_name}`" do
subject { described_class.new(target, user, { name: rule_name, approvals_required: 1 }) }
let(:result) { subject.execute }
specify { expect(result[:status]).to eq(:success) }
......
......@@ -18,6 +18,7 @@ describe FeatureFlags::CreateService do
subject do
described_class.new(project, user, params).execute
end
let(:feature_flag) { subject[:feature_flag] }
context 'when feature flag can not be created' do
......
......@@ -17,6 +17,7 @@ describe FeatureFlags::UpdateService do
describe '#execute' do
subject { described_class.new(project, user, params).execute(feature_flag) }
let(:params) { { name: 'new_name' } }
let(:audit_event_message) do
AuditEvent.last.present.action
......
......@@ -7,6 +7,7 @@ describe Geo::ProjectHousekeepingService do
include ::EE::GeoHelpers
subject(:service) { described_class.new(project) }
set(:project) { create(:project, :repository) }
let(:registry) { service.registry }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe GroupSaml::GroupManagedAccounts::CleanUpMembersService do
subject(:service) { described_class.new(current_user, group) }
let(:group) { Group.new }
let(:current_user) { instance_double('User') }
let(:destroy_member_service_spy) { spy('Members::DestroyService') }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe GroupSaml::SamlProvider::UpdateService do
subject(:service) { described_class.new(nil, saml_provider, params: params) }
let(:params) do
{
sso_url: 'https://test',
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe MergeRequests::SyncReportApproverApprovalRules do
subject(:service) { described_class.new(merge_request) }
let(:merge_request) { create(:merge_request) }
describe '#execute' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe ElasticBatchProjectIndexerWorker do
subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2) }
describe '#perform' do
......
......@@ -113,6 +113,7 @@ describe QA::Page::Element do
describe 'data-qa selectors' do
subject { described_class.new(:my_element) }
it 'properly translates to a data-qa-selector' do
expect(subject.selector_css).to include(%q([data-qa-selector="my_element"]))
end
......
......@@ -1180,6 +1180,7 @@ describe Projects::IssuesController do
name: emoji_name
})
end
let(:emoji_name) { 'thumbsup' }
it "toggles the award emoji" do
......
......@@ -713,6 +713,7 @@ describe Projects::NotesController do
end
subject { post(:toggle_award_emoji, params: request_params.merge(name: emoji_name)) }
let(:emoji_name) { 'thumbsup' }
it "toggles the award emoji" do
......
......@@ -78,6 +78,7 @@ describe Projects::Settings::CiCdController do
describe 'PUT #reset_registration_token' do
subject { put :reset_registration_token, params: { namespace_id: project.namespace, project_id: project } }
it 'resets runner registration token' do
expect { subject }.to change { project.reload.runners_token }
end
......
......@@ -12,6 +12,7 @@ FactoryBot.define do
Google::Protobuf::RepeatedField.new(:string, ids)
end
subject { "My commit" }
body { subject + "\nMy body" }
author { build(:gitaly_commit_author) }
committer { build(:gitaly_commit_author) }
......
......@@ -16,6 +16,7 @@ describe 'Internal Group access' do
describe "Group should be internal" do
describe '#internal?' do
subject { group.internal? }
it { is_expected.to be_truthy }
end
end
......
......@@ -16,6 +16,7 @@ describe 'Private Group access' do
describe "Group should be private" do
describe '#private?' do
subject { group.private? }
it { is_expected.to be_truthy }
end
end
......
......@@ -16,6 +16,7 @@ describe 'Public Group access' do
describe "Group should be public" do
describe '#public?' do
subject { group.public? }
it { is_expected.to be_truthy }
end
end
......
......@@ -14,6 +14,7 @@ describe "Internal Project Access" do
describe "Project should be internal" do
describe '#internal?' do
subject { project.internal? }
it { is_expected.to be_truthy }
end
end
......
......@@ -14,6 +14,7 @@ describe "Private Project Access" do
describe "Project should be private" do
describe '#private?' do
subject { project.private? }
it { is_expected.to be_truthy }
end
end
......
......@@ -14,6 +14,7 @@ describe "Public Project Access" do
describe "Project should be public" do
describe '#public?' do
subject { project.public? }
it { is_expected.to be_truthy }
end
end
......
......@@ -77,6 +77,7 @@ describe Clusters::KnativeServicesFinder do
describe '#knative_detected' do
subject { finder.knative_detected }
before do
synchronous_reactive_cache(finder)
end
......
......@@ -24,6 +24,7 @@ describe FinderWithCrossProjectAccess do
let(:user) { create(:user) }
subject(:finder) { finder_class.new(user) }
let!(:result) { create(:issue) }
before do
......
......@@ -39,6 +39,7 @@ describe MergeRequestsHelper do
let(:forked_project) { fork_project(project) }
let(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project) }
subject { format_mr_branch_names(merge_request) }
let(:source_title) { "#{forked_project.full_path}:#{merge_request.source_branch}" }
let(:target_title) { "#{project.full_path}:#{merge_request.target_branch}" }
......
......@@ -24,6 +24,7 @@ describe Backup::Files do
describe '#restore' do
subject { described_class.new('registry', '/var/gitlab-registry') }
let(:timestamp) { Time.utc(2017, 3, 22) }
around do |example|
......
......@@ -15,6 +15,7 @@ describe Banzai::Filter::ProjectReferenceFilter do
let(:project) { create(:project, :public) }
subject { project }
let(:subject_name) { "project" }
let(:reference) { get_reference(project) }
......
......@@ -12,6 +12,7 @@ describe Banzai::Filter::UserReferenceFilter do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
subject { user }
let(:subject_name) { "user" }
let(:reference) { get_reference(user) }
......
......@@ -8,6 +8,7 @@ describe Banzai::ReferenceParser::CommitParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -8,6 +8,7 @@ describe Banzai::ReferenceParser::CommitRangeParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -8,6 +8,7 @@ describe Banzai::ReferenceParser::ExternalIssueParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::LabelParser do
let(:user) { create(:user) }
let(:label) { create(:label, project: project) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::MergeRequestParser do
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request, source_project: project) }
subject { described_class.new(Banzai::RenderContext.new(merge_request.target_project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::MilestoneParser do
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#nodes_visible_to_user' do
......
......@@ -8,6 +8,7 @@ describe Banzai::ReferenceParser::ProjectParser do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#referenced_by' do
......
......@@ -12,6 +12,7 @@ describe Banzai::ReferenceParser::SnippetParser do
let(:project_member) { create(:user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
def visible_references(snippet_visibility, user = nil)
......
......@@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::UserParser do
let(:user) { create(:user) }
let(:project) { create(:project, :public, group: group, creator: user) }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
describe '#referenced_by' do
......
......@@ -34,27 +34,32 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe '#basename' do
subject { |example| path(example).basename }
it { is_expected.to eq 'absolute_path' }
end
end
describe 'path/dir_1/', path: 'path/dir_1/' do
subject { |example| path(example) }
it { is_expected.to have_parent }
it { is_expected.to be_directory }
describe '#basename' do
subject { |example| path(example).basename }
it { is_expected.to eq 'dir_1/' }
end
describe '#name' do
subject { |example| path(example).name }
it { is_expected.to eq 'dir_1' }
end
describe '#parent' do
subject { |example| path(example).parent }
it { is_expected.to eq entry('path/') }
end
......@@ -102,21 +107,25 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe '#nodes' do
subject { |example| path(example).nodes }
it { is_expected.to eq 2 }
end
describe '#exists?' do
subject { |example| path(example).exists? }
it { is_expected.to be true }
end
describe '#empty?' do
subject { |example| path(example).empty? }
it { is_expected.to be false }
end
describe '#total_size' do
subject { |example| path(example).total_size }
it { is_expected.to eq(30) }
end
end
......@@ -124,10 +133,12 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe 'empty path', path: '' do
subject { |example| path(example) }
it { is_expected.not_to have_parent }
describe '#children' do
subject { |example| path(example).children }
it { expect(subject.count).to eq 3 }
end
end
......@@ -135,6 +146,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe 'path/dir_1/subdir/subfile', path: 'path/dir_1/subdir/subfile' do
describe '#nodes' do
subject { |example| path(example).nodes }
it { is_expected.to eq 4 }
end
......@@ -153,11 +165,13 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe 'non-existent/', path: 'non-existent/' do
describe '#empty?' do
subject { |example| path(example).empty? }
it { is_expected.to be true }
end
describe '#exists?' do
subject { |example| path(example).exists? }
it { is_expected.to be false }
end
end
......@@ -165,6 +179,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
describe 'another_directory/', path: 'another_directory/' do
describe '#empty?' do
subject { |example| path(example).empty? }
it { is_expected.to be true }
end
end
......
......@@ -76,21 +76,25 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
describe '#to_entry' do
subject { metadata('').to_entry }
it { is_expected.to be_an_instance_of(Gitlab::Ci::Build::Artifacts::Metadata::Entry) }
end
describe '#full_version' do
subject { metadata('').full_version }
it { is_expected.to eq 'GitLab Build Artifacts Metadata 0.0.1' }
end
describe '#version' do
subject { metadata('').version }
it { is_expected.to eq '0.0.1' }
end
describe '#errors' do
subject { metadata('').errors }
it { is_expected.to eq({}) }
end
end
......
......@@ -69,6 +69,7 @@ describe Gitlab::Ci::Config::Entry::Cache do
context 'when entry value is not correct' do
describe '#errors' do
subject { entry.errors }
context 'when is not a hash' do
let(:config) { 'ls' }
......
......@@ -11,11 +11,13 @@ describe Gitlab::Ci::Config::Entry::Coverage do
describe '#errors' do
subject { entry.errors }
it { is_expected.to include(/coverage config must be a regular expression/) }
end
describe '#valid?' do
subject { entry }
it { is_expected.not_to be_valid }
end
end
......@@ -25,16 +27,19 @@ describe Gitlab::Ci::Config::Entry::Coverage do
describe '#value' do
subject { entry.value }
it { is_expected.to eq(config[1...-1]) }
end
describe '#errors' do
subject { entry.errors }
it { is_expected.to be_empty }
end
describe '#valid?' do
subject { entry }
it { is_expected.to be_valid }
end
end
......@@ -44,11 +49,13 @@ describe Gitlab::Ci::Config::Entry::Coverage do
describe '#errors' do
subject { entry.errors }
it { is_expected.to include(/coverage config must be a regular expression/) }
end
describe '#valid?' do
subject { entry }
it { is_expected.not_to be_valid }
end
end
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Cleanup::ProjectUploads do
subject { described_class.new(logger: logger) }
let(:logger) { double(:logger) }
before do
......
......@@ -8,6 +8,7 @@ require 'gitlab/danger/teammate'
describe Gitlab::Danger::Teammate do
subject { described_class.new(options.stringify_keys) }
let(:options) { { username: 'luigi', projects: projects, role: role } }
let(:projects) { { project => capabilities } }
let(:role) { 'Engineer, Manage' }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::DowntimeCheck do
subject { described_class.new }
let(:path) { 'foo.rb' }
describe '#check' do
......
......@@ -28,90 +28,107 @@ describe Gitlab::Email::Message::RepositoryPush do
describe '#project' do
subject { message.project }
it { is_expected.to eq project }
it { is_expected.to be_an_instance_of Project }
end
describe '#project_namespace' do
subject { message.project_namespace }
it { is_expected.to eq group }
it { is_expected.to be_kind_of Namespace }
end
describe '#project_name_with_namespace' do
subject { message.project_name_with_namespace }
it { is_expected.to eq "#{group.name} / #{project.path}" }
end
describe '#author' do
subject { message.author }
it { is_expected.to eq author }
it { is_expected.to be_an_instance_of User }
end
describe '#author_name' do
subject { message.author_name }
it { is_expected.to eq 'Author' }
end
describe '#commits' do
subject { message.commits }
it { is_expected.to be_kind_of Array }
it { is_expected.to all(be_instance_of Commit) }
end
describe '#diffs' do
subject { message.diffs }
it { is_expected.to all(be_an_instance_of Gitlab::Diff::File) }
end
describe '#diffs_count' do
subject { message.diffs_count }
it { is_expected.to eq raw_compare.diffs.size }
end
describe '#compare' do
subject { message.compare }
it { is_expected.to be_an_instance_of Compare }
end
describe '#compare_timeout' do
subject { message.compare_timeout }
it { is_expected.to eq raw_compare.diffs.overflow? }
end
describe '#reverse_compare?' do
subject { message.reverse_compare? }
it { is_expected.to eq false }
end
describe '#disable_diffs?' do
subject { message.disable_diffs? }
it { is_expected.to eq false }
end
describe '#send_from_committer_email?' do
subject { message.send_from_committer_email? }
it { is_expected.to eq true }
end
describe '#action_name' do
subject { message.action_name }
it { is_expected.to eq 'pushed to' }
end
describe '#ref_name' do
subject { message.ref_name }
it { is_expected.to eq 'master' }
end
describe '#ref_type' do
subject { message.ref_type }
it { is_expected.to eq 'branch' }
end
describe '#target_url' do
subject { message.target_url }
it { is_expected.to include 'compare' }
it { is_expected.to include compare.commits.first.parents.first.id }
it { is_expected.to include compare.commits.last.id }
......@@ -119,6 +136,7 @@ describe Gitlab::Email::Message::RepositoryPush do
describe '#subject' do
subject { message.subject }
it { is_expected.to include "[Git][#{project.full_path}]" }
it { is_expected.to include "#{compare.commits.length} commits" }
it { is_expected.to include compare.commits.first.message.split("\n").first }
......
......@@ -75,6 +75,7 @@ describe Gitlab::Experimentation do
describe '.enabled?' do
subject { described_class.enabled?(:test_experiment, experimentation_subject_index) }
let(:experimentation_subject_index) { 9 }
context 'feature toggle is enabled, we are on the right environment and we are selected' do
......
......@@ -84,11 +84,13 @@ describe Gitlab::Gfm::UploadsRewriter do
describe '#needs_rewrite?' do
subject { rewriter.needs_rewrite? }
it { is_expected.to eq true }
end
describe '#files' do
subject { rewriter.files }
it { is_expected.to be_an(Array) }
end
end
......
......@@ -44,6 +44,7 @@ describe Gitlab::Git::Branch, :seed_helper do
describe '#size' do
subject { super().size }
it { is_expected.to eq(SeedRepo::Repo::BRANCHES.size) }
end
......
......@@ -174,6 +174,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#id' do
subject { super().id }
it { is_expected.to eq(SeedRepo::LastCommit::ID) }
end
end
......@@ -183,6 +184,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#id' do
subject { super().id }
it { is_expected.to eq(SeedRepo::Commit::ID) }
end
end
......@@ -192,6 +194,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#id' do
subject { super().id }
it { is_expected.to eq(SeedRepo::BigCommit::ID) }
end
end
......@@ -544,11 +547,13 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#id' do
subject { super().id }
it { is_expected.to eq(sample_commit_hash[:id])}
end
describe '#message' do
subject { super().message }
it { is_expected.to eq(sample_commit_hash[:message])}
end
end
......@@ -558,16 +563,19 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#additions' do
subject { super().additions }
it { is_expected.to eq(11) }
end
describe '#deletions' do
subject { super().deletions }
it { is_expected.to eq(6) }
end
describe '#total' do
subject { super().total }
it { is_expected.to eq(17) }
end
end
......@@ -596,6 +604,7 @@ describe Gitlab::Git::Commit, :seed_helper do
describe '#keys' do
subject { super().keys.sort }
it { is_expected.to match(sample_commit_hash.keys.sort) }
end
end
......
......@@ -10,6 +10,7 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
expanded: expanded
)
end
let(:iterator) { MutatingConstantIterator.new(file_count, fake_diff(line_length, line_count)) }
let(:file_count) { 0 }
let(:line_length) { 1 }
......@@ -21,6 +22,7 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#to_a' do
subject { super().to_a }
it { is_expected.to be_kind_of ::Array }
end
......@@ -52,16 +54,19 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('3') }
end
......@@ -76,6 +81,7 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -84,16 +90,19 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('3') }
end
......@@ -108,6 +117,7 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
end
......@@ -118,21 +128,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('0+') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq 1000 }
end
......@@ -143,21 +157,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('3') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -174,21 +192,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('10+') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq 10 }
end
......@@ -199,21 +221,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('11') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -226,21 +252,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('3+') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq 120 }
end
......@@ -251,21 +281,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('11') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -282,21 +316,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('10') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -310,21 +348,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('9+') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -335,21 +377,25 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('10') }
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq file_count * line_count }
end
......@@ -363,26 +409,31 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
describe '#overflow?' do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_truthy }
end
describe '#size' do
subject { super().size }
it { is_expected.to eq(0) }
end
describe '#real_size' do
subject { super().real_size }
it { is_expected.to eq('0')}
end
describe '#line_count' do
subject { super().line_count }
it { is_expected.to eq 0 }
end
end
......
......@@ -93,6 +93,7 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#last' do
subject { super().last }
it { is_expected.to eq("v1.2.1") }
end
it { is_expected.to include("v1.0.0") }
......@@ -215,11 +216,13 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#first' do
subject { super().first }
it { is_expected.to eq('feature') }
end
describe '#last' do
subject { super().last }
it { is_expected.to eq('v1.2.1') }
end
end
......
......@@ -52,6 +52,7 @@ describe Gitlab::GitlabImport::Client do
describe '#projects' do
subject(:method) { :projects }
let(:args) { [] }
let(:element_list) { build_list(:project, 2) }
......@@ -67,6 +68,7 @@ describe Gitlab::GitlabImport::Client do
describe '#issues' do
subject(:method) { :issues }
let(:args) { [1] }
let(:element_list) { build_list(:issue, 2) }
......@@ -82,6 +84,7 @@ describe Gitlab::GitlabImport::Client do
describe '#issue_comments' do
subject(:method) { :issue_comments }
let(:args) { [1, 1] }
let(:element_list) { build_list(:note_on_issue, 2) }
......
......@@ -11,12 +11,14 @@ describe Gitlab::Graphs::Commits do
describe '#commit_per_day' do
context 'when range is only commits from today' do
subject { described_class.new([commit2, commit1]).commit_per_day }
it { is_expected.to eq 2 }
end
end
context 'when range is only commits from today' do
subject { described_class.new([commit2, commit1]) }
describe '#commit_per_day' do
it { expect(subject.commit_per_day).to eq 2 }
end
......@@ -28,6 +30,7 @@ describe Gitlab::Graphs::Commits do
context 'with commits from yesterday and today' do
subject { described_class.new([commit2, commit1_yesterday]) }
describe '#commit_per_day' do
it { expect(subject.commit_per_day).to eq 1.0 }
end
......
......@@ -30,6 +30,7 @@ describe Gitlab::HealthChecks::GitalyCheck do
describe '#metrics' do
subject { described_class.metrics }
let(:server) { double(storage: 'default', read_writeable?: up) }
before do
......
shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
describe '#metrics' do
subject { described_class.metrics }
context 'Check is passing' do
before do
allow(described_class).to receive(:check).and_return success_result
......@@ -34,6 +35,7 @@ shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
describe '#readiness' do
subject { described_class.readiness }
context 'Check returns ok' do
before do
allow(described_class).to receive(:check).and_return success_result
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Metrics::Samplers::PumaSampler do
subject { described_class.new(5) }
let(:null_metric) { double('null_metric', set: nil, observe: nil) }
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::PhabricatorImport::WorkerState, :clean_gitlab_redis_shared_state do
subject(:state) { described_class.new('weird-project-id') }
let(:key) { 'phabricator-import/jobs/project-weird-project-id/job-count' }
describe '#add_job' do
......
......@@ -259,6 +259,7 @@ describe Gitlab::ReferenceExtractor do
describe '.references_pattern' do
subject { described_class.references_pattern }
it { is_expected.to be_kind_of Regexp }
end
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::RequestContext do
describe '#client_ip' do
subject { described_class.client_ip }
let(:app) { -> (env) {} }
let(:env) { Hash.new }
......
......@@ -396,6 +396,7 @@ describe Gitlab::Shell do
describe 'namespace actions' do
subject { described_class.new }
let(:storage) { Gitlab.config.repositories.storages.keys.first }
describe '#add_namespace' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::SidekiqMiddleware::MemoryKiller do
subject { described_class.new }
let(:pid) { 999 }
let(:worker) { double(:worker, class: ProjectCacheWorker) }
......
......@@ -151,6 +151,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is prepending it' do
subject { extension }
let(:klass) { prepending_class }
it_behaves_like 'checking as intended'
......@@ -158,6 +159,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is including it' do
subject { extension }
let(:klass) { including_class }
it_behaves_like 'checking as intended, nothing was overridden'
......@@ -177,6 +179,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is prepending it' do
subject { extension }
let(:klass) { prepending_class }
it_behaves_like 'nothing happened'
......@@ -184,6 +187,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is including it' do
subject { extension }
let(:klass) { including_class }
it 'does not complain when it is overriding something' do
......@@ -215,6 +219,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is prepending it' do
subject { extension }
let(:klass) { prepending_class_methods }
it_behaves_like 'checking as intended'
......@@ -222,6 +227,7 @@ describe Gitlab::Utils::Override do
context 'when subject is a module, and class is extending it' do
subject { extension }
let(:klass) { extending_class_methods }
it_behaves_like 'checking as intended, nothing was overridden'
......
......@@ -54,6 +54,7 @@ describe GoogleApi::CloudPlatform::Client do
describe '#projects_zones_clusters_get' do
subject { client.projects_zones_clusters_get(spy, spy, spy) }
let(:gke_cluster) { double }
before do
......@@ -160,6 +161,7 @@ describe GoogleApi::CloudPlatform::Client do
describe '#projects_zones_operations' do
subject { client.projects_zones_operations(spy, spy, spy) }
let(:operation) { double }
before do
......
......@@ -16,6 +16,7 @@ describe JSONWebToken::Token do
context 'embeds default payload' do
subject { token.payload }
let(:default) { token.send(:default_payload) }
it { is_expected.to include(default) }
......
......@@ -8,6 +8,7 @@ describe OmniAuth::Strategies::Jwt do
context '#decoded' do
subject { described_class.new({}) }
let(:timestamp) { Time.now.to_i }
let(:jwt_config) { Devise.omniauth_configs[:jwt] }
let(:claims) do
......
......@@ -574,6 +574,7 @@ describe Ci::Build do
describe '#artifacts_metadata?' do
subject { build.artifacts_metadata? }
context 'artifacts metadata does not exist' do
it { is_expected.to be_falsy }
end
......@@ -586,6 +587,7 @@ describe Ci::Build do
describe '#artifacts_expire_in' do
subject { build.artifacts_expire_in }
it { is_expected.to be_nil }
context 'when artifacts_expire_at is specified' do
......@@ -1265,6 +1267,7 @@ describe Ci::Build do
describe '#erasable?' do
subject { build.erasable? }
it { is_expected.to be_truthy }
end
......
......@@ -686,11 +686,13 @@ describe Ci::Runner do
describe '#has_tags?' do
context 'when runner has tags' do
subject { create(:ci_runner, tag_list: ['tag']) }
it { is_expected.to have_tags }
end
context 'when runner does not have tags' do
subject { create(:ci_runner, tag_list: []) }
it { is_expected.not_to have_tags }
end
end
......
......@@ -6,6 +6,7 @@ describe Noteable do
let!(:active_diff_note1) { create(:diff_note_on_merge_request) }
let(:project) { active_diff_note1.project }
subject { active_diff_note1.noteable }
let!(:active_diff_note2) { create(:diff_note_on_merge_request, project: project, noteable: subject, in_reply_to: active_diff_note1) }
let!(:active_diff_note3) { create(:diff_note_on_merge_request, project: project, noteable: subject, position: active_position2) }
let!(:outdated_diff_note1) { create(:diff_note_on_merge_request, project: project, noteable: subject, position: outdated_position) }
......
......@@ -17,6 +17,7 @@ describe User, 'TokenAuthenticatable' do
describe 'ensures authentication token' do
subject { create(:user).send(token_field) }
it { is_expected.to be_a String }
end
end
......
......@@ -16,6 +16,7 @@ describe DeployKeysProject do
describe "Destroying" do
let(:project) { create(:project) }
subject { create(:deploy_keys_project, project: project) }
let(:deploy_key) { subject.deploy_key }
context "when the deploy key is only used by this project" do
......
......@@ -100,26 +100,31 @@ describe Event do
describe '#membership_changed?' do
context "created" do
subject { build(:event, :created).membership_changed? }
it { is_expected.to be_falsey }
end
context "updated" do
subject { build(:event, :updated).membership_changed? }
it { is_expected.to be_falsey }
end
context "expired" do
subject { build(:event, :expired).membership_changed? }
it { is_expected.to be_truthy }
end
context "left" do
subject { build(:event, :left).membership_changed? }
it { is_expected.to be_truthy }
end
context "joined" do
subject { build(:event, :joined).membership_changed? }
it { is_expected.to be_truthy }
end
end
......
......@@ -20,6 +20,7 @@ RSpec.describe GpgSignature do
describe 'validation' do
subject { described_class.new }
it { is_expected.to validate_presence_of(:commit_sha) }
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:gpg_key_primary_keyid) }
......
......@@ -277,6 +277,7 @@ describe Issue do
context 'checking destination project also' do
subject { issue.can_move?(user, to_project) }
let(:to_project) { create(:project) }
context 'destination project allowed' do
......
......@@ -541,6 +541,7 @@ describe MergeRequest do
context 'with diffs' do
subject { create(:merge_request, :with_diffs) }
it 'returns the sha of the source branch last commit' do
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
end
......@@ -548,6 +549,7 @@ describe MergeRequest do
context 'without diffs' do
subject { create(:merge_request, :without_diffs) }
it 'returns the sha of the source branch last commit' do
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
end
......@@ -570,6 +572,7 @@ describe MergeRequest do
context 'when the merge request is being created' do
subject { build(:merge_request, source_branch: nil, compare_commits: []) }
it 'returns nil' do
expect(subject.source_branch_sha).to be_nil
end
......@@ -2495,6 +2498,7 @@ describe MergeRequest do
describe "#diff_refs" do
context "with diffs" do
subject { create(:merge_request, :with_diffs) }
let(:expected_diff_refs) do
Gitlab::Diff::DiffRefs.new(
base_sha: subject.merge_request_diff.base_commit_sha,
......@@ -2840,6 +2844,7 @@ describe MergeRequest do
describe '#merge_request_diff_for' do
subject { create(:merge_request, importing: true) }
let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
......@@ -2870,6 +2875,7 @@ describe MergeRequest do
describe '#version_params_for' do
subject { create(:merge_request, importing: true) }
let(:project) { subject.project }
let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
......
......@@ -55,11 +55,13 @@ describe Note do
context 'when noteable and note project are the same' do
subject { create(:note) }
it { is_expected.to be_valid }
end
context 'when project is missing for a project related note' do
subject { build(:note, project: nil, noteable: build_stubbed(:issue)) }
it { is_expected.to be_invalid }
end
......@@ -741,6 +743,7 @@ describe Note do
describe '#to_discussion' do
subject { create(:discussion_note_on_merge_request) }
let!(:note2) { create(:discussion_note_on_merge_request, project: subject.project, noteable: subject.noteable, in_reply_to: subject) }
it "returns a discussion with just this note" do
......@@ -808,6 +811,7 @@ describe Note do
context 'for a note' do
context 'when part of a discussion' do
subject { create(:discussion_note_on_issue) }
let(:note) { create(:discussion_note_on_issue, in_reply_to: subject) }
it 'checks if the note is in reply to the other discussion' do
......@@ -821,6 +825,7 @@ describe Note do
context 'when not part of a discussion' do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
it 'checks if the note is in reply to the other noteable' do
......@@ -835,6 +840,7 @@ describe Note do
context 'for a discussion' do
context 'when part of the same discussion' do
subject { create(:diff_note_on_merge_request) }
let(:note) { create(:diff_note_on_merge_request, in_reply_to: subject) }
it 'returns true' do
......@@ -844,6 +850,7 @@ describe Note do
context 'when not part of the same discussion' do
subject { create(:diff_note_on_merge_request) }
let(:note) { create(:diff_note_on_merge_request) }
it 'returns false' do
......@@ -855,6 +862,7 @@ describe Note do
context 'for a noteable' do
context 'when a comment on the same noteable' do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
it 'returns true' do
......@@ -864,6 +872,7 @@ describe Note do
context 'when not a comment on the same noteable' do
subject { create(:note) }
let(:note) { create(:note) }
it 'returns false' do
......@@ -887,6 +896,7 @@ describe Note do
context 'when not part of a discussion' do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
it 'returns the noteable' do
......
......@@ -293,11 +293,13 @@ describe PagesDomain do
describe "#https?" do
context "when a certificate is present" do
subject { build(:pages_domain) }
it { is_expected.to be_https }
end
context "when no certificate is present" do
subject { build(:pages_domain, :without_certificate) }
it { is_expected.not_to be_https }
end
end
......
......@@ -5014,6 +5014,7 @@ describe Project do
describe '#git_objects_poolable?' do
subject { project }
context 'when not using hashed storage' do
let(:project) { create(:project, :legacy_storage, :public, :repository) }
......
......@@ -109,6 +109,7 @@ describe ProjectWiki do
context "when the wiki repository is empty" do
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_truthy }
end
end
......@@ -121,6 +122,7 @@ describe ProjectWiki do
describe '#empty?' do
subject { super().empty? }
it { is_expected.to be_falsey }
it 'only instantiates a Wiki page once' do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe ResourceLabelEvent, type: :model do
subject { build(:resource_label_event, issue: issue) }
let(:issue) { create(:issue) }
let(:merge_request) { create(:merge_request) }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Timelog do
subject { build(:timelog) }
let(:issue) { create(:issue) }
let(:merge_request) { create(:merge_request) }
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe UserInteractedProject do
describe '.track' do
subject { described_class.track(event) }
let(:event) { build(:event) }
Event::ACTIONS.each do |action|
......
......@@ -2170,6 +2170,7 @@ describe User do
describe "#contributed_projects" do
subject { create(:user) }
let!(:project1) { create(:project) }
let!(:project2) { fork_project(project3) }
let!(:project3) { create(:project) }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe IdentityProviderPolicy do
subject(:policy) { described_class.new(user, provider) }
let(:user) { User.new }
let(:provider) { :a_provider }
......
......@@ -53,21 +53,25 @@ describe MergeRequestPolicy do
describe 'the author' do
subject { author }
it_behaves_like 'a denied user'
end
describe 'a guest' do
subject { guest }
it_behaves_like 'a denied user'
end
describe 'a developer' do
subject { developer }
it_behaves_like 'a denied user'
end
describe 'any other user' do
subject { non_team_member }
it_behaves_like 'a denied user'
end
end
......@@ -82,11 +86,13 @@ describe MergeRequestPolicy do
describe 'a non-team-member' do
subject { non_team_member }
it_behaves_like 'a denied user'
end
describe 'a developer' do
subject { developer }
it_behaves_like 'a user with access'
end
end
......
......@@ -2,6 +2,7 @@ require 'spec_helper'
describe ConversationalDevelopmentIndex::MetricPresenter do
subject { described_class.new(metric) }
let(:metric) { build(:conversational_development_index_metric) }
describe '#cards' do
......
......@@ -67,6 +67,7 @@ describe 'getting projects' do
context 'when the namespace is a user' do
subject { user.namespace }
let(:include_subgroups) { false }
it_behaves_like 'a graphql namespace'
......
......@@ -27,6 +27,7 @@ describe "Internal Project Pages Access" do
describe "Project should be internal" do
describe '#internal?' do
subject { project.internal? }
it { is_expected.to be_truthy }
end
end
......
......@@ -27,6 +27,7 @@ describe "Private Project Pages Access" do
describe "Project should be private" do
describe '#private?' do
subject { project.private? }
it { is_expected.to be_truthy }
end
end
......
......@@ -27,6 +27,7 @@ describe "Public Project Pages Access" do
describe "Project should be public" do
describe '#public?' do
subject { project.public? }
it { is_expected.to be_truthy }
end
end
......
......@@ -9,6 +9,7 @@ describe RuboCop::Cop::Migration::AddTimestamps do
include CopHelper
subject(:cop) { described_class.new }
let(:migration_with_add_timestamps) do
%q(
class Users < ActiveRecord::Migration[4.2]
......
......@@ -9,6 +9,7 @@ describe RuboCop::Cop::Migration::Timestamps do
include CopHelper
subject(:cop) { described_class.new }
let(:migration_with_timestamps) do
%q(
class Users < ActiveRecord::Migration[4.2]
......
......@@ -10,6 +10,7 @@ describe RuboCop::Cop::Scalability::FileUploads do
include ExpectOffense
subject(:cop) { described_class.new }
let(:message) { 'Do not upload files without workhorse acceleration. Please refer to https://docs.gitlab.com/ee/development/uploads.html' }
context 'with required params' do
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
describe ClusterBasicEntity do
describe '#as_json' do
subject { described_class.new(cluster, request: request).as_json }
let(:maintainer) { create(:user) }
let(:developer) { create(:user) }
let(:current_user) { maintainer }
......
......@@ -139,6 +139,7 @@ describe PipelineSerializer do
describe 'number of queries when preloaded' do
subject { serializer.represent(resource, preload: true) }
let(:resource) { Ci::Pipeline.all }
before do
......
......@@ -58,6 +58,7 @@ describe Git::TagHooksService, :service do
describe 'Push data' do
shared_examples_for 'tag push data expectations' do
subject(:push_data) { service.send(:push_data) }
it 'has expected push data attributes' do
is_expected.to match a_hash_including(
object_kind: 'tag_push',
......
......@@ -13,6 +13,7 @@ describe MergeRequests::CreateFromIssueService do
let(:custom_source_branch) { 'custom-source-branch' }
subject(:service) { described_class.new(project, user, service_params) }
subject(:service_with_custom_source_branch) { described_class.new(project, user, branch_name: custom_source_branch, **service_params) }
before do
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Projects::HousekeepingService do
subject { described_class.new(project) }
set(:project) { create(:project, :repository) }
before do
......
......@@ -90,6 +90,7 @@ RSpec.shared_examples "redis_shared_examples" do
describe '._raw_config' do
subject { described_class._raw_config }
let(:config_file_name) { '/var/empty/doesnotexist' }
it 'is frozen' do
......
......@@ -111,6 +111,7 @@ shared_examples 'cluster application status specs' do |application_name|
describe '#make_errored' do
subject { create(application_name, :installing) }
let(:reason) { 'some errors' }
it 'is errored' do
......
......@@ -19,6 +19,7 @@ describe 'check.rake' do
describe 'gitlab:check rake task' do
subject { run_rake_task('gitlab:check') }
let(:name) { 'GitLab subtasks' }
it_behaves_like 'system check rake task'
......@@ -26,6 +27,7 @@ describe 'check.rake' do
describe 'gitlab:gitlab_shell:check rake task' do
subject { run_rake_task('gitlab:gitlab_shell:check') }
let(:name) { 'GitLab Shell' }
it_behaves_like 'system check rake task'
......@@ -33,6 +35,7 @@ describe 'check.rake' do
describe 'gitlab:gitaly:check rake task' do
subject { run_rake_task('gitlab:gitaly:check') }
let(:name) { 'Gitaly' }
it_behaves_like 'system check rake task'
......@@ -40,6 +43,7 @@ describe 'check.rake' do
describe 'gitlab:sidekiq:check rake task' do
subject { run_rake_task('gitlab:sidekiq:check') }
let(:name) { 'Sidekiq' }
it_behaves_like 'system check rake task'
......@@ -47,6 +51,7 @@ describe 'check.rake' do
describe 'gitlab:incoming_email:check rake task' do
subject { run_rake_task('gitlab:incoming_email:check') }
let(:name) { 'Incoming Email' }
it_behaves_like 'system check rake task'
......@@ -56,6 +61,7 @@ describe 'check.rake' do
include LdapHelpers
subject { run_rake_task('gitlab:ldap:check') }
let(:name) { 'LDAP' }
it_behaves_like 'system check rake task'
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe HashedStorage::MigratorWorker do
subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2, :legacy_storage, :empty_repo) }
let(:ids) { projects.map(&:id) }
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe HashedStorage::RollbackerWorker do
subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2, :empty_repo) }
let(:ids) { projects.map(&:id) }
......
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