Commit 1ae0dc22 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '228860-resolve-rspec-emptylineafterletblock-exceptions-ee' into 'master'

Resolve RSpec/EmptyLineAfterLetBlock Exceptions in EE

See merge request gitlab-org/gitlab!38582
parents a782b882 a9dba1d0
......@@ -290,100 +290,6 @@ RSpec/ContextWording:
RSpec/EmptyLineAfterLetBlock:
Enabled: true
Exclude:
- 'ee/spec/controllers/admin/application_settings_controller_spec.rb'
- 'ee/spec/controllers/ee/projects/protected_branches_controller_spec.rb'
- 'ee/spec/controllers/ee/sent_notifications_controller_spec.rb'
- 'ee/spec/controllers/projects/security/network_policies_controller_spec.rb'
- 'ee/spec/features/admin/admin_emails_spec.rb'
- 'ee/spec/features/merge_request/user_creates_merge_request_spec.rb'
- 'ee/spec/features/merge_requests/user_filters_by_approvers_spec.rb'
- 'ee/spec/features/merge_requests/user_resets_approvers_spec.rb'
- 'ee/spec/finders/group_saml_identity_finder_spec.rb'
- 'ee/spec/finders/merge_requests/by_approvers_finder_spec.rb'
- 'ee/spec/finders/security/vulnerability_findings_finder_spec.rb'
- 'ee/spec/helpers/application_helper_spec.rb'
- 'ee/spec/helpers/ee/namespaces_helper_spec.rb'
- 'ee/spec/helpers/push_rules_helper_spec.rb'
- 'ee/spec/helpers/vulnerabilities_helper_spec.rb'
- 'ee/spec/lib/audit/details_spec.rb'
- 'ee/spec/lib/container_registry/client_spec.rb'
- 'ee/spec/lib/ee/api/entities/analytics/code_review/merge_request_spec.rb'
- 'ee/spec/lib/ee/gitlab/auth/ldap/access_levels_spec.rb'
- 'ee/spec/lib/ee/gitlab/auth/ldap/group_spec.rb'
- 'ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb'
- 'ee/spec/lib/ee/gitlab/background_migration/move_epic_issues_after_epics_spec.rb'
- 'ee/spec/lib/ee/gitlab/ci/config_spec.rb'
- 'ee/spec/lib/gitlab/auth/ldap/user_spec.rb'
- 'ee/spec/lib/gitlab/auth/smartcard/ldap_certificate_spec.rb'
- 'ee/spec/lib/gitlab/auth_spec.rb'
- 'ee/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb'
- 'ee/spec/lib/gitlab/ci/reports/security/report_spec.rb'
- 'ee/spec/lib/gitlab/contribution_analytics/data_collector_spec.rb'
- 'ee/spec/lib/gitlab/elastic/client_spec.rb'
- 'ee/spec/lib/gitlab/elastic/search_results_spec.rb'
- 'ee/spec/lib/gitlab/expiring_subscription_message_spec.rb'
- 'ee/spec/lib/gitlab/graphql/aggregations/epics/lazy_epic_aggregate_spec.rb'
- 'ee/spec/lib/gitlab/insights/finders/issuable_finder_spec.rb'
- 'ee/spec/lib/gitlab/insights/reducers/count_per_label_reducer_spec.rb'
- 'ee/spec/lib/gitlab/insights/reducers/count_per_period_reducer_spec.rb'
- 'ee/spec/lib/gitlab/insights/reducers/label_count_per_period_reducer_spec.rb'
- 'ee/spec/lib/gitlab/prometheus/queries/packet_flow_metrics_query_spec.rb'
- 'ee/spec/lib/gitlab/prometheus/queries/packet_flow_query_spec.rb'
- 'ee/spec/lib/gitlab/subscription_portal/client_spec.rb'
- 'ee/spec/lib/pseudonymizer/uploader_spec.rb'
- 'ee/spec/migrations/set_report_type_for_vulnerabilities_spec.rb'
- 'ee/spec/migrations/set_resolved_state_on_vulnerabilities_spec.rb'
- 'ee/spec/models/burndown_spec.rb'
- 'ee/spec/models/ci/build_spec.rb'
- 'ee/spec/models/elasticsearch_indexed_namespace_spec.rb'
- 'ee/spec/models/elasticsearch_indexed_project_spec.rb'
- 'ee/spec/models/group_member_spec.rb'
- 'ee/spec/models/operations/feature_flag_spec.rb'
- 'ee/spec/models/vulnerability_spec.rb'
- 'ee/spec/policies/project_policy_spec.rb'
- 'ee/spec/requests/api/epics_spec.rb'
- 'ee/spec/requests/api/feature_flags_spec.rb'
- 'ee/spec/requests/api/geo_spec.rb'
- 'ee/spec/requests/api/graphql/current_user/todos_query_spec.rb'
- 'ee/spec/requests/api/graphql/geo/geo_node_spec.rb'
- 'ee/spec/requests/api/graphql/group/epic/epic_aggregate_query_spec.rb'
- 'ee/spec/requests/api/helpers_spec.rb'
- 'ee/spec/requests/api/internal/base_spec.rb'
- 'ee/spec/requests/api/license_spec.rb'
- 'ee/spec/requests/api/merge_request_approval_rules_spec.rb'
- 'ee/spec/requests/api/projects_spec.rb'
- 'ee/spec/requests/api/settings_spec.rb'
- 'ee/spec/requests/api/v3/github_spec.rb'
- 'ee/spec/requests/lfs_http_spec.rb'
- 'ee/spec/requests/projects/mirrors_controller_spec.rb'
- 'ee/spec/requests/smartcard_controller_spec.rb'
- 'ee/spec/serializers/user_analytics_entity_spec.rb'
- 'ee/spec/services/approval_rules/params_filtering_service_spec.rb'
- 'ee/spec/services/dashboard/operations/list_service_spec.rb'
- 'ee/spec/services/ee/audit_events/bulk_insert_service_spec.rb'
- 'ee/spec/services/ee/issues/create_from_vulnerability_data_service_spec.rb'
- 'ee/spec/services/ee/merge_requests/create_from_vulnerability_data_service_spec.rb'
- 'ee/spec/services/ee/merge_requests/refresh_service_spec.rb'
- 'ee/spec/services/ee/preview_markdown_service_spec.rb'
- 'ee/spec/services/elastic/indexing_control_service_spec.rb'
- 'ee/spec/services/epics/update_dates_service_spec.rb'
- 'ee/spec/services/epics/update_service_spec.rb'
- 'ee/spec/services/geo/file_registry_removal_service_spec.rb'
- 'ee/spec/services/group_saml/saml_provider/update_service_spec.rb'
- 'ee/spec/services/groups/create_service_spec.rb'
- 'ee/spec/services/groups/destroy_service_spec.rb'
- 'ee/spec/services/groups/update_service_spec.rb'
- 'ee/spec/services/projects/create_service_spec.rb'
- 'ee/spec/services/projects/destroy_service_spec.rb'
- 'ee/spec/services/projects/group_links/create_service_spec.rb'
- 'ee/spec/services/projects/group_links/destroy_service_spec.rb'
- 'ee/spec/services/projects/prometheus/alerts/notify_service_spec.rb'
- 'ee/spec/services/projects/transfer_service_spec.rb'
- 'ee/spec/services/projects/update_service_spec.rb'
- 'ee/spec/services/search/snippet_service_spec.rb'
- 'ee/spec/services/todo_service_spec.rb'
- 'ee/spec/support/shared_examples/requests/api/graphql/geo/registries_shared_examples.rb'
- 'ee/spec/workers/concerns/elastic/indexing_control_spec.rb'
- 'qa/qa/specs/features/api/3_create/repository/changing_repository_storage_spec.rb'
- 'qa/qa/specs/features/browser_ui/3_create/gitaly/high_availability_spec.rb'
- 'qa/qa/specs/features/browser_ui/3_create/repository/move_project_create_fork_spec.rb'
......
......@@ -92,6 +92,7 @@ RSpec.describe Admin::ApplicationSettingsController do
mirror_capacity_threshold: 2
}
end
let(:feature) { :repository_mirrors }
it_behaves_like 'settings for licensed features'
......@@ -136,6 +137,7 @@ RSpec.describe Admin::ApplicationSettingsController do
maintenance_mode_message: 'GitLab is in maintenance'
}
end
let(:feature) { :geo }
it_behaves_like 'settings for licensed features'
......
......@@ -27,6 +27,7 @@ RSpec.describe Projects::ProtectedBranchesController do
{ merge_access_levels_attributes: maintainer_access_level,
push_access_levels_attributes: maintainer_access_level }
end
let(:create_params) do
attributes_for(:protected_branch).merge(access_level_params)
end
......
......@@ -11,6 +11,7 @@ RSpec.describe SentNotificationsController do
epic.subscriptions.create!(user: user, project: nil, subscribed: true)
end
end
let(:sent_notification) { create(:sent_notification, project: nil, noteable: epic, recipient: user) }
before do
......
......@@ -188,6 +188,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
ingress: [{ from: [{ namespaceSelector: { matchLabels: { project: 'myproject' } } }] }]
)
end
let(:manifest) do
<<~POLICY
apiVersion: networking.k8s.io/v1
......@@ -251,6 +252,7 @@ RSpec.describe Projects::Security::NetworkPoliciesController do
ingress: [{ from: [{ namespaceSelector: { matchLabels: { project: 'myproject' } } }] }]
)
end
let(:manifest) do
<<~POLICY
apiVersion: networking.k8s.io/v1
......
......@@ -26,6 +26,7 @@ RSpec.describe 'Admin::Emails', :clean_gitlab_redis_shared_state do
'An email notification was recently sent from the admin panel. '\
'Please wait 10 minutes before attempting to send another message.'
end
let(:submit_button) { find('input[type="submit"]') }
before do
......
......@@ -9,6 +9,7 @@ RSpec.describe "User creates a merge request", :js do
let(:project) do
create(:project, :repository, merge_requests_template: template_text)
end
let(:template_text) { "This merge request should contain the following." }
let(:title) { "Some feature" }
let(:user) { create(:user) }
......
......@@ -17,6 +17,7 @@ RSpec.describe 'Merge Requests > User filters', :js do
let!(:merge_request_with_two_approvers) do
create(:merge_request, title: 'Bugfix2', approval_users: [user, first_user], source_project: project, source_branch: 'bugfix2')
end
let!(:merge_request) { create(:merge_request, title: 'Bugfix3', source_project: project, source_branch: 'bugfix3') }
let!(:merge_request_with_group_approver) do
group = create(:group)
......
......@@ -12,6 +12,7 @@ RSpec.describe 'Merge Requests > User resets approvers', :js do
let(:merge_request) do
create(:merge_request, approval_users: [first_user], title: 'Bugfix1', source_project: project)
end
let!(:rule) { create(:approval_project_rule, project: project, users: project_approvers, approvals_required: 1 )}
before do
......
......@@ -30,6 +30,7 @@ RSpec.describe GroupSamlIdentityFinder do
let!(:group_managed_identity) do
create(:group_saml_identity, saml_provider: saml_provider, user: create(:user, managing_group: group))
end
let!(:different_group_managed_identity) do
create(:group_saml_identity, saml_provider: saml_provider, user: create(:user, :group_managed))
end
......
......@@ -32,6 +32,7 @@ RSpec.describe MergeRequests::ByApproversFinder do
merge_request.approval_rules << rule
end
end
let!(:merge_request_with_project_group_approver) do
rule = create(:approval_project_rule, groups: [group])
create(:merge_request, source_project: create(:project, approval_rules: [rule]))
......
......@@ -140,6 +140,7 @@ RSpec.describe Security::VulnerabilityFindingsFinder do
project: project1,
project_fingerprint: finding1.project_fingerprint)
end
let!(:issue) do
create(:vulnerability_feedback, :sast, :issue,
pipeline: pipeline1,
......
......@@ -162,6 +162,7 @@ RSpec.describe ApplicationHelper do
let(:expected_partial_path) do
"app/views/#{File.dirname(partial)}/_#{File.basename(partial)}.html.haml"
end
let(:expected_view_path) do
"app/views/#{File.dirname(view)}/#{File.basename(view)}.html.haml"
end
......
......@@ -9,6 +9,7 @@ RSpec.describe EE::NamespacesHelper do
:private,
project_creation_level: admin_project_creation_level)
end
let!(:user) { create(:user) }
let!(:user_project_creation_level) { nil }
let!(:user_group) do
......
......@@ -17,6 +17,7 @@ RSpec.describe PushRulesHelper do
requires_admin_contact: /Contact an admin to change this setting/
}
end
let(:users) do
{
admin: admin,
......
......@@ -204,6 +204,7 @@ RSpec.describe Audit::Details do
ip_address: '127.0.0.1'
}
end
let(:message) { 'Failed to login with GOOGLE authentication' }
it 'shows the correct failed login meessage' do
......
......@@ -15,6 +15,7 @@ RSpec.describe ContainerRegistry::Client do
'User-Agent' => "GitLab/#{Gitlab::VERSION}"
}
end
let(:headers_with_accept_types) do
{
'Accept' => 'application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json',
......
......@@ -12,6 +12,7 @@ RSpec.describe EE::API::Entities::Analytics::CodeReview::MergeRequest do
metrics_data: { first_comment_at: 1.day.ago, merged_at: 1.hour.ago }
)
end
let(:project) { create :project, :repository }
let(:milestone) { create(:milestone, project: project) }
let!(:note) { create(:note_on_merge_request, project: project, noteable: merge_request) }
......
......@@ -35,6 +35,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::AccessLevels do
uid=jamesdoe,ou=users,dc=example,dc=com
}
end
let(:master_dns) do
%w{
uid=johndoe,ou=users,dc=example,dc=com
......
......@@ -47,6 +47,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Group do
member_attr: 'member'
)
end
let(:group2_entry) do
ldap_group_entry(
[user_dn('user3'), user_dn('user4')],
......@@ -56,6 +57,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Group do
member_of: group1_entry.dn
)
end
let(:group) { described_class.new(group1_entry, adapter) }
it 'resolves the correct member_dns when there are nested groups' do
......
......@@ -99,6 +99,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
cn: 'ldap_group1',
group_access: ::Gitlab::Access::DEVELOPER)
end
let(:ldap_group1) { ldap_group_entry(user_dn(user.username)) }
include_examples :group_state_machine
......@@ -114,6 +115,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
cn: 'ldap_group1',
group_access: ::Gitlab::Access::DEVELOPER)
end
let(:ldap_group1) { ldap_group_entry(user_dn(user.username)) }
include_examples :group_state_machine
......@@ -175,6 +177,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
cn: 'ldap_group1',
group_access: ::Gitlab::Access::DEVELOPER)
end
let(:sync_group) { described_class.new(group, proxy(adapter)) }
context 'with all functionality against one LDAP group type' do
......@@ -532,6 +535,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
member_attr: 'memberUid'
)
end
let(:ldap_user) do
ldap_user_entry(user.username)
end
......@@ -584,6 +588,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
create(:group_with_ldap_group_filter_link,
group_access: ::Gitlab::Access::DEVELOPER)
end
let(:sync_group) { described_class.new(group, proxy(adapter)) }
before do
......
......@@ -21,6 +21,7 @@ RSpec.describe Gitlab::BackgroundMigration::MoveEpicIssuesAfterEpics, schema: 20
author_id: user.id
}
end
let(:issue_params) do
{
title: 'Issue',
......
......@@ -13,6 +13,7 @@ RSpec.describe Gitlab::Ci::Config do
- echo 'test'
EOS
end
let(:template_yml) do
<<-EOS
sample_job:
......
......@@ -14,9 +14,11 @@ RSpec.describe Gitlab::Auth::Ldap::User do
nickname: 'john'
}
end
let(:auth_hash) do
OmniAuth::AuthHash.new(uid: 'uid=john,ou=people,dc=example,dc=com', provider: 'ldapmain', info: info)
end
let(:group_cn) { 'foo' }
let(:group_member_dns) { [auth_hash.uid] }
let(:external_groups) { [] }
......
......@@ -13,6 +13,7 @@ RSpec.describe Gitlab::Auth::Smartcard::LdapCertificate do
{ issuer: issuer,
serial: '42' } )
end
let(:ldap_provider) { 'ldapmain' }
let(:ldap_connection) { instance_double(::Net::LDAP) }
let(:ldap_person_name) { 'John Doe' }
......
......@@ -10,6 +10,7 @@ RSpec.describe Gitlab::Auth do
password: password,
password_confirmation: password)
end
let(:username) { 'John' } # username isn't lowercase, test this
let(:password) { 'my-secret' }
......
......@@ -54,10 +54,12 @@ RSpec.describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMent
epics.create!(iid: 1, group_id: group.id, author_id: author.id, title: "epic title @#{author.username}",
title_html: "epic title @#{author.username}", description: description_mentions)
end
let!(:epic2) do
epics.create!(iid: 2, group_id: group.id, author_id: author.id, title: "epic title}",
title_html: "epic title", description: 'simple description')
end
let!(:epic3) do
epics.create!(iid: 3, group_id: group.id, author_id: author.id, title: "epic title}",
title_html: "epic title", description: 'description with an email@example.com and some other @ char here.')
......
......@@ -82,6 +82,7 @@ RSpec.describe Gitlab::Ci::Reports::Security::Report do
identifiers: [create(:ci_reports_security_identifier)]
)
end
let(:other_report) do
create(
:ci_reports_security_report,
......
......@@ -44,6 +44,7 @@ RSpec.describe Gitlab::ContributionAnalytics::DataCollector do
[11, Issue.name, Event.actions[:closed]] => 11
}
end
let(:data_collector) { described_class.new(group: Group.new) }
before do
......
......@@ -635,6 +635,7 @@ RSpec.describe Gitlab::Elastic::SearchResults, :elastic, :sidekiq_might_not_need
FILE
end
let(:file_name) { 'elastic_specialchars_test.md' }
before do
......
......@@ -18,6 +18,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
namespace: namespace
).message
end
let(:grace_period_effective_from) { expired_date - 35.days }
let(:today) { Time.utc(2020, 3, 7, 10) }
let(:expired_date) { Time.utc(2020, 3, 9, 10).to_date }
......
......@@ -8,6 +8,7 @@ RSpec.describe Gitlab::Graphql::Aggregations::Epics::LazyEpicAggregate do
let(:query_ctx) do
{}
end
let(:epic_id) { 37 }
let(:epic_iid) { 18 }
let(:child_epic_id) { 38 }
......@@ -44,6 +45,7 @@ RSpec.describe Gitlab::Graphql::Aggregations::Epics::LazyEpicAggregate do
let(:single_record) do
{ iid: 6, issues_count: 4, issues_weight_sum: 9, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE, epic_state_id: OPENED_EPIC_STATE }
end
let(:epic_info_node) { Gitlab::Graphql::Aggregations::Epics::EpicNode.new(epic_id, [single_record] ) }
subject { described_class.new(query_ctx, epic_id, COUNT) }
......@@ -70,6 +72,7 @@ RSpec.describe Gitlab::Graphql::Aggregations::Epics::LazyEpicAggregate do
let(:fake_state) do
{ pending_ids: Set.new([epic_id, child_epic_id]), tree: {} }
end
let(:fake_data) do
{
epic_id => [{ epic_state_id: OPENED_EPIC_STATE, issues_count: 2, issues_weight_sum: 5, parent_id: nil, issues_state_id: OPENED_ISSUE_STATE }],
......
......@@ -132,6 +132,7 @@ RSpec.describe Gitlab::Insights::Finders::IssuableFinder do
filter_labels: [label_bug.title],
collection_labels: [label_manage.title, label_plan.title, label_create.title])
end
let(:projects) { {} }
subject { find(entity, query: query, projects: projects) }
......
......@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Insights::Reducers::CountPerLabelReducer do
period_limit: 5
}
end
let(:issuable_relation) { find_issuables(project, query) }
subject { reduce(issuable_relation, query[:collection_labels]) }
......
......@@ -38,6 +38,7 @@ RSpec.describe Gitlab::Insights::Reducers::CountPerPeriodReducer do
period_limit: 5
}
end
let(:expected) do
{
'January 2019' => 0,
......
......@@ -23,6 +23,7 @@ RSpec.describe Gitlab::Insights::Reducers::LabelCountPerPeriodReducer do
period_limit: 5
}
end
let(:issuable_relation) { find_issuables(project, query) }
subject { reduce(issuable_relation, query[:group_by], query[:collection_labels]) }
......
......@@ -10,6 +10,7 @@ RSpec.describe Gitlab::Prometheus::Queries::PacketFlowMetricsQuery do
{ "metric" => { "verdict" => "DROPPED" }, "value" => [1582231596.64, "5.002730665588791"] }
]
end
let(:client) { double('prometheus_client', query: query_response) }
subject { described_class.new(client) }
......
......@@ -17,12 +17,14 @@ RSpec.describe Gitlab::Prometheus::Queries::PacketFlowQuery do
{ "metric" => { "verdict" => "DROPPED" }, "values" => [[1582231596.64, "5.002730665588791"]] }
]
end
let(:query_response) do
[
{ "metric" => { "verdict" => "FORWARDED" }, "value" => [1582231596.64, "73772.43143284984"] },
{ "metric" => { "verdict" => "DROPPED" }, "value" => [1582231596.64, "5.002730665588791"] }
]
end
let(:result) { subject.query(namespace) }
it 'returns ops_rate metric' do
......
......@@ -7,6 +7,7 @@ RSpec.describe Gitlab::SubscriptionPortal::Client do
let(:httparty_response) do
double(code: http_response.code, response: http_response, body: {}, parsed_response: {})
end
let(:http_method) { :post }
shared_examples 'when response is successful' do
......
......@@ -9,6 +9,7 @@ RSpec.describe Pseudonymizer::Uploader do
config: YAML.load_file(Gitlab.config.pseudonymizer.manifest)
)
end
let(:remote_directory) { subject.send(:remote_directory) }
subject { described_class.new(options) }
......
......@@ -7,6 +7,7 @@ RSpec.describe SetReportTypeForVulnerabilities do
let(:confidence_levels) do
{ undefined: 0, ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 }
end
let(:severity_levels) { { undefined: 0, info: 1, unknown: 2, low: 4, medium: 5, high: 6, critical: 7 } }
let(:report_types) { { sast: 0, dependency_scanning: 1, container_scanning: 2, dast: 3 } }
......
......@@ -7,6 +7,7 @@ RSpec.describe SetResolvedStateOnVulnerabilities do
let(:confidence_levels) do
{ undefined: 0, ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 }
end
let(:severity_levels) { { undefined: 0, info: 1, unknown: 2, low: 4, medium: 5, high: 6, critical: 7 } }
let(:states) { { opened: 1, closed: 2, resolved: 3 } }
let(:report_types) { { sast: 0, dependency_scanning: 1, container_scanning: 2, dast: 3 } }
......
......@@ -160,6 +160,7 @@ RSpec.describe Burndown do
author: user
}
end
let(:scope) { project }
end
end
......@@ -188,6 +189,7 @@ RSpec.describe Burndown do
author: user
}
end
let(:scope) { group }
end
end
......@@ -204,6 +206,7 @@ RSpec.describe Burndown do
author: user
}
end
let(:scope) { group }
end
end
......
......@@ -519,6 +519,7 @@ RSpec.describe Ci::Build do
}
}
end
let(:build) { create(:ci_build, secrets: secrets) }
subject { build.runner_required_feature_names }
......
......@@ -23,6 +23,7 @@ RSpec.describe ElasticsearchIndexedNamespace do
let(:index_action) do
expect(ElasticNamespaceIndexerWorker).to receive(:perform_async).with(subject.namespace_id, :index)
end
let(:delete_action) do
expect(ElasticNamespaceIndexerWorker).to receive(:perform_async).with(subject.namespace_id, :delete)
end
......
......@@ -13,6 +13,7 @@ RSpec.describe ElasticsearchIndexedProject do
let(:index_action) do
expect(Elastic::ProcessBookkeepingService).to receive(:track!).with(subject.project)
end
let(:delete_action) do
expect(ElasticDeleteProjectWorker).to receive(:perform_async).with(subject.project.id, subject.project.es_id)
end
......
......@@ -129,9 +129,11 @@ RSpec.describe GroupMember do
create(:group_saml_identity, saml_provider: saml_provider, user: m.user)
end
end
let!(:member_without_identity) do
create(:group_member, group: group)
end
let!(:member_with_different_identity) do
create(:group_member, group: group).tap do |m|
create(:group_saml_identity, user: m.user)
......
......@@ -220,6 +220,7 @@ RSpec.describe Operations::FeatureFlag do
create(:operations_feature_flag, project: project,
name: 'feature1', active: true, version: 2)
end
let!(:strategy) do
create(:operations_strategy, feature_flag: feature_flag,
name: 'default', parameters: {})
......
......@@ -9,6 +9,7 @@ RSpec.describe Vulnerability do
let(:confidence_values) do
{ ignore: 1, unknown: 2, experimental: 3, low: 4, medium: 5, high: 6, confirmed: 7 }
end
let(:report_types) do
{ sast: 0,
dependency_scanning: 1,
......
......@@ -40,9 +40,11 @@ RSpec.describe ProjectPolicy do
let(:additional_guest_permissions) do
%i[read_issue_link]
end
let(:additional_reporter_permissions) do
%i[read_software_license_policy admin_issue_link]
end
let(:additional_developer_permissions) do
%i[
admin_vulnerability_feedback read_project_security_dashboard read_feature_flag
......@@ -50,9 +52,11 @@ RSpec.describe ProjectPolicy do
admin_vulnerability_issue_link read_merge_train
]
end
let(:additional_maintainer_permissions) do
%i[push_code_to_protected_branches admin_feature_flags_client modify_auto_fix_setting]
end
let(:auditor_permissions) do
%i[
download_code download_wiki_code read_project read_board read_list
......
......@@ -156,6 +156,7 @@ RSpec.describe API::Epics do
created_at: 3.days.ago,
updated_at: 2.days.ago)
end
let!(:epic2) do
create(:epic,
author: user2,
......@@ -165,6 +166,7 @@ RSpec.describe API::Epics do
created_at: 2.days.ago,
updated_at: 3.days.ago)
end
let!(:label) { create(:group_label, title: 'a-test', group: group) }
let!(:label_link) { create(:label_link, label: label, target: epic2) }
......
......@@ -105,9 +105,11 @@ RSpec.describe API::FeatureFlags do
let!(:feature_flag) do
create(:operations_feature_flag, :new_version_flag, project: project, name: 'feature1')
end
let!(:strategy) do
create(:operations_strategy, feature_flag: feature_flag, name: 'default', parameters: {})
end
let!(:scope) do
create(:operations_scope, strategy: strategy, environment_scope: 'production')
end
......
......@@ -14,6 +14,7 @@ RSpec.describe API::Geo do
let(:geo_token_header) do
{ 'X-Gitlab-Token' => secondary_node.system_hook.token }
end
let(:invalid_geo_auth_header) do
{ Authorization: "#{::Gitlab::Geo::BaseRequest::GITLAB_GEO_AUTH_TOKEN_TYPE}...Test" }
end
......
......@@ -14,6 +14,7 @@ RSpec.describe 'getting project information' do
}
QUERY
end
let(:query) do
graphql_query_for('currentUser', {}, query_graphql_field('todos', {}, fields))
end
......
......@@ -30,6 +30,7 @@ RSpec.describe 'Getting the current Geo node' do
}
QUERY
end
let(:current_user) { create(:user, :admin) }
before do
......
......@@ -13,6 +13,7 @@ RSpec.describe 'Epic aggregates (count and weight)' do
let(:query) do
graphql_query_for('group', { fullPath: target_epic.group.full_path }, query_graphql_field('epics', { iid: target_epic.iid }, epic_aggregates_query))
end
let(:epic_aggregates_query) do
<<~QUERY
nodes {
......
......@@ -19,6 +19,7 @@ RSpec.describe API::Helpers do
'CONTENT_TYPE' => 'text/plain;charset=utf-8'
}
end
let(:header) { }
let(:request) { Grape::Request.new(env)}
let(:params) { request.params }
......
......@@ -208,6 +208,7 @@ RSpec.describe API::Internal::Base do
protocol: 'ssh'
}
end
let(:allowed_ip) { '150.168.0.1' }
before do
......
......@@ -103,6 +103,7 @@ RSpec.describe API::License, api: true do
[build(:gitlab_license, starts_at: Date.today - 10, expires_at: Date.today - 1, restrictions: { add_ons: { 'GitLab_FileLocks' => 1 }, active_user_count: 10 }),
build(:gitlab_license, starts_at: Date.today - 20, expires_at: Date.today + 1, restrictions: { add_ons: { 'GitLab_DeployBoard' => 1 }, active_user_count: 20 })]
end
let!(:licenses) do
[create(:license, created_at: Time.now + 30, data: gl_licenses[0].export),
create(:license, created_at: Time.now + 20, data: gl_licenses[1].export)]
......
......@@ -154,6 +154,7 @@ RSpec.describe API::MergeRequestApprovalRules do
group_ids: group_ids
}
end
let(:user_ids) { [] }
let(:group_ids) { [] }
......
......@@ -930,6 +930,7 @@ RSpec.describe API::Projects do
let!(:target_namespace) do
create(:group).tap { |g| g.add_owner(user) }
end
let!(:group_project) { create(:project, namespace: group)}
let(:group) { create(:group) }
......@@ -941,6 +942,7 @@ RSpec.describe API::Projects do
let(:group) do
create(:saml_provider, :enforced_group_managed_accounts, prohibited_outer_forks: true).group
end
let(:user) do
create(:user, managing_group: group).tap do |u|
create(:group_saml_identity, user: u, saml_provider: group.saml_provider)
......
......@@ -179,6 +179,7 @@ RSpec.describe API::Settings, 'EE Settings' do
prevent_merge_requests_committers_approval: true
}
end
let(:feature) { :admin_merge_request_approvers_rules }
it_behaves_like 'settings for licensed features'
......@@ -202,6 +203,7 @@ RSpec.describe API::Settings, 'EE Settings' do
maintenance_mode_message: 'GitLab is in maintenance'
}
end
let(:feature) { :geo }
it_behaves_like 'settings for licensed features'
......
......@@ -46,6 +46,7 @@ RSpec.describe API::V3::Github do
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project)
end
let!(:note) do
create(:note, project: project, noteable: merge_request)
end
......@@ -203,6 +204,7 @@ RSpec.describe API::V3::Github do
let!(:merge_request) do
create(:merge_request, source_project: project, target_project: project, author: user, assignees: [assignee])
end
let!(:merge_request_2) do
create(:merge_request, source_project: project2, target_project: project2, author: user, assignees: [assignee, assignee2])
end
......
......@@ -14,6 +14,7 @@ RSpec.describe 'Git LFS API and storage' do
'X-Sendfile-Type' => sendfile
}.compact
end
let(:authorization) { }
let(:sendfile) { }
......
......@@ -9,6 +9,7 @@ RSpec.describe Projects::MirrorsController do
mirror_user: user,
import_url: 'http://user:pass@test.url')
end
let(:user) { create(:user) }
describe 'updates the mirror URL' do
......
......@@ -299,6 +299,7 @@ RSpec.describe SmartcardController, type: :request do
entry['mail'] = ldap_email
end
end
let(:ldap_user_search_scope) { 'dc=example,dc=com' }
let(:ldap_search_params) do
{ attributes: array_including('dn', 'cn', 'mail', 'uid', 'userid'),
......
......@@ -15,6 +15,7 @@ RSpec.describe UserAnalyticsEntity do
total_events: {}
}
end
let(:request) { double('request', data_collector: instance_double(Gitlab::ContributionAnalytics::DataCollector, totals: events)) }
subject(:json) { described_class.new(user, request: request).as_json }
......
......@@ -76,6 +76,7 @@ RSpec.describe ApprovalRules::ParamsFilteringService do
{ name: 'bar', user_ids: [outsider.id], group_ids: [accessible_group.id, inaccessible_group.id] }
]
end
let(:expected_groups) { [accessible_group] }
end
......@@ -203,6 +204,7 @@ RSpec.describe ApprovalRules::ParamsFilteringService do
]
}
end
let(:expected_groups) { [accessible_group, existing_private_group] }
end
......@@ -294,6 +296,7 @@ RSpec.describe ApprovalRules::ParamsFilteringService do
]
}
end
let(:expected_groups) { [accessible_group] }
end
end
......
......@@ -52,6 +52,7 @@ RSpec.describe Dashboard::Operations::ListService do
let(:production_deployment) do
create(:deployment, :success, project: project, environment: production, ref: 'master')
end
let(:staging_deployment) do
create(:deployment, :success, project: project, environment: staging, ref: 'wip')
end
......
......@@ -14,6 +14,7 @@ RSpec.describe EE::AuditEvents::BulkInsertService do
EE::AuditEvents::RepositoryPushAuditEventService.new(user, entity, target_ref, from, to)
end
end
let(:timestamp) { Time.zone.local(2019, 10, 10) }
let(:attrs) do
{
......
......@@ -135,6 +135,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
tool: 'find_sec_bugs'
}
end
let(:expected_title) { 'Investigate vulnerability: Predictable pseudorandom number generator' }
let(:expected_description) do
<<~DESC.chomp
......@@ -193,6 +194,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
}]
}
end
let(:expected_title) { 'Investigate vulnerability: Predictable pseudorandom number generator' }
let(:expected_description) do
<<~DESC.chomp
......@@ -238,6 +240,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
tool: 'find_sec_bugs'
}
end
let(:expected_title) { 'Investigate vulnerability: Predictable pseudorandom number generator' }
let(:expected_description) do
<<~DESC.chomp
......@@ -282,6 +285,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
}]
}
end
let(:expected_title) { 'Investigate vulnerability: CVE-2017-15650 in musl' }
let(:expected_description) do
<<~DESC.chomp
......@@ -325,6 +329,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
}]
}
end
let(:expected_title) { 'Investigate vulnerability: CVE-2017-15650 in musl' }
let(:expected_description) do
<<~DESC.chomp
......@@ -372,6 +377,7 @@ RSpec.describe Issues::CreateFromVulnerabilityDataService, '#execute' do
}]
}
end
let(:expected_title) { 'Investigate vulnerability: X-Content-Type-Options Header Missing' }
let(:expected_description) do
<<~DESC.chomp
......
......@@ -128,6 +128,7 @@ RSpec.describe MergeRequests::CreateFromVulnerabilityDataService, '#execute' do
urlPath: "/root/yarn-remediation/blob/9bade3fef995a9e2ca1de44d396b433864990ab9/yarn.lock"
}
end
let(:expected_title) { 'Resolve vulnerability: Authentication bypass via incorrect DOM traversal and canonicalization in saml2-js' }
let(:expected_description) do
<<~DESC.chomp
......@@ -173,6 +174,7 @@ RSpec.describe MergeRequests::CreateFromVulnerabilityDataService, '#execute' do
]
}
end
let(:expected_title) { 'Resolve vulnerability: Authentication bypass via incorrect DOM traversal and canonicalization in saml2-js' }
let(:expected_description) do
<<~DESC.chomp
......
......@@ -20,6 +20,7 @@ RSpec.describe MergeRequests::RefreshService do
target_branch: 'master',
target_project: project)
end
let(:another_merge_request) do
create(:merge_request,
source_project: project,
......@@ -27,6 +28,7 @@ RSpec.describe MergeRequests::RefreshService do
target_branch: 'test',
target_project: project)
end
let(:forked_merge_request) do
create(:merge_request,
source_project: forked_project,
......@@ -34,6 +36,7 @@ RSpec.describe MergeRequests::RefreshService do
target_branch: 'master',
target_project: project)
end
let(:oldrev) { TestEnv::BRANCH_SHA[source_branch] }
let(:newrev) { TestEnv::BRANCH_SHA['after-create-delete-modify-move'] } # Pretend source_branch is now updated
let(:service) { described_class.new(project, current_user) }
......
......@@ -15,6 +15,7 @@ RSpec.describe PreviewMarkdownService do
group: epic.group
}
end
let(:service) { described_class.new(nil, user, params) }
before do
......
......@@ -13,6 +13,7 @@ RSpec.describe Elastic::IndexingControlService, :clean_gitlab_redis_shared_state
prepend Elastic::IndexingControl
end
end
let(:worker_args) { [1, 2] }
let(:worker_context) { { 'correlation_id' => 'context_correlation_id' } }
......@@ -131,6 +132,7 @@ RSpec.describe Elastic::IndexingControlService, :clean_gitlab_redis_shared_state
prepend Elastic::IndexingControl
end
end
let(:other_subject) { described_class.new(second_worker_class) }
it 'allows to use queues independently of each other' do
......
......@@ -32,6 +32,7 @@ RSpec.describe Epics::UpdateDatesService do
group: group
)
end
let(:milestone2) do
create(
:milestone,
......@@ -69,6 +70,7 @@ RSpec.describe Epics::UpdateDatesService do
group: group
)
end
let(:milestone2) do
create(
:milestone,
......@@ -96,6 +98,7 @@ RSpec.describe Epics::UpdateDatesService do
group: group
)
end
let(:milestone2) do
create(
:milestone,
......
......@@ -171,6 +171,7 @@ RSpec.describe Epics::UpdateService do
author: user,
user: user)
end
let!(:todo2) do
create(:todo, :mentioned, :pending,
target: epic,
......
......@@ -362,6 +362,7 @@ RSpec.describe Geo::FileRegistryRemovalService, :geo do
PersonalFileUploader.new(snippet).store!(file)
Upload.find_by(model: snippet, uploader: PersonalFileUploader.name)
end
let!(:registry) { create(:geo_upload_registry, :personal_file, file_id: upload.id) }
let!(:file_path) { upload.retrieve_uploader.file.path }
......@@ -392,6 +393,7 @@ RSpec.describe Geo::FileRegistryRemovalService, :geo do
FaviconUploader.new(appearance).store!(file)
Upload.find_by(model: appearance, uploader: FaviconUploader.name)
end
let!(:registry) { create(:geo_upload_registry, :favicon, file_id: upload.id) }
let!(:file_path) { upload.retrieve_uploader.file.path }
......
......@@ -9,6 +9,7 @@ RSpec.describe GroupSaml::SamlProvider::UpdateService do
let(:saml_provider) do
create :saml_provider, enabled: false, enforced_sso: false
end
let(:group) { saml_provider.group }
include_examples 'base SamlProvider service'
......
......@@ -18,6 +18,7 @@ RSpec.describe Groups::CreateService, '#execute' do
let(:fail_condition!) do
allow(Gitlab::VisibilityLevel).to receive(:allowed_for?).and_return(false)
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -15,6 +15,7 @@ RSpec.describe Groups::DestroyService do
expect_any_instance_of(Group)
.to receive(:destroy).and_return(group)
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -30,6 +30,7 @@ RSpec.describe Groups::UpdateService, '#execute' do
let(:operation) do
update_group(group, user, visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
let(:fail_condition!) do
allow(group).to receive(:save).and_return(false)
end
......
......@@ -356,6 +356,7 @@ RSpec.describe Projects::CreateService, '#execute' do
let(:fail_condition!) do
allow(Gitlab::VisibilityLevel).to receive(:allowed_for?).and_return(false)
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -67,6 +67,7 @@ RSpec.describe Projects::DestroyService do
expect_any_instance_of(Project)
.to receive(:destroy!).and_raise(StandardError.new('Other error message'))
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -21,6 +21,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do
let(:fail_condition!) do
create(:project_group_link, project: project, group: group)
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -17,6 +17,7 @@ RSpec.describe Projects::GroupLinks::DestroyService do
expect_any_instance_of(ProjectGroupLink)
.to receive(:destroy).and_return(group_link)
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -33,6 +33,7 @@ RSpec.describe Projects::Prometheus::Alerts::NotifyService do
let(:prd_cluster) do
create(:cluster, :provided_by_user, projects: [project], enabled: true, environment_scope: '*')
end
let(:stg_cluster) do
create(:cluster, :provided_by_user, projects: [project], enabled: true, environment_scope: 'stg/*')
end
......
......@@ -34,6 +34,7 @@ RSpec.describe Projects::TransferService do
expect(instance).to receive(:has_container_registry_tags?).and_return(true)
end
end
let(:attributes) do
{
author_id: user.id,
......
......@@ -113,6 +113,7 @@ RSpec.describe Projects::UpdateService, '#execute' do
let(:operation) do
update_project(project, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
let(:fail_condition!) do
allow_any_instance_of(Project).to receive(:update).and_return(false)
end
......
......@@ -39,6 +39,7 @@ RSpec.describe Search::SnippetService do
{ snippet_level: :internal, project_level: :internal, feature_access_level: :enabled, membership: :non_member, expected_count: 1 }
]
end
let(:pending?) do
pendings.include?(
{
......
......@@ -173,10 +173,12 @@ RSpec.describe TodoService do
create(:todo, :assigned,
user: john_doe, project: nil, group: group, target: epic, author: author)
end
let!(:second_todo) do
create(:todo, :assigned,
user: john_doe, project: nil, group: group, target: epic, author: author)
end
let(:note) { create(:note, noteable: epic, project: nil, author: john_doe, note: mentions) }
context 'when a note is created for an epic' do
......
......@@ -28,6 +28,7 @@ RSpec.shared_examples 'gets registries for' do |args|
}
QUERY
end
let(:current_user) { create(:user, :admin) }
before do
......
......@@ -21,6 +21,7 @@ RSpec.describe Elastic::IndexingControl do
prepend Elastic::IndexingControl
end.new
end
let(:worker_args) { [project.id] }
let(:worker_context) { { 'correlation_id' => 'context_correlation_id' } }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment