Commit ed0839d1 authored by James Fargher's avatar James Fargher

Fixed and reenabled EmptyLineAfterSubject

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