Commit f15a7fc9 authored by James Lopez's avatar James Lopez

Merge branch 'replace-set-with-let_it_be-in-spec-models' into 'master'

Change set to let_it_be in spec/models (Batch 1)

See merge request gitlab-org/gitlab!24387
parents 09dc78fd 7dc92c9a
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe AbuseReport do describe AbuseReport do
set(:report) { create(:abuse_report) } let_it_be(:report, reload: true) { create(:abuse_report) }
set(:user) { create(:admin) } let_it_be(:user, reload: true) { create(:admin) }
subject { report } subject { report }
it { expect(subject).to be_valid } it { expect(subject).to be_valid }
......
...@@ -45,8 +45,8 @@ describe AwardEmoji do ...@@ -45,8 +45,8 @@ describe AwardEmoji do
end end
describe 'scopes' do describe 'scopes' do
set(:thumbsup) { create(:award_emoji, name: 'thumbsup') } let_it_be(:thumbsup) { create(:award_emoji, name: 'thumbsup') }
set(:thumbsdown) { create(:award_emoji, name: 'thumbsdown') } let_it_be(:thumbsdown) { create(:award_emoji, name: 'thumbsdown') }
describe '.upvotes' do describe '.upvotes' do
it { expect(described_class.upvotes).to contain_exactly(thumbsup) } it { expect(described_class.upvotes).to contain_exactly(thumbsup) }
......
...@@ -6,9 +6,8 @@ describe BlobViewer::GitlabCiYml do ...@@ -6,9 +6,8 @@ describe BlobViewer::GitlabCiYml do
include FakeBlobHelpers include FakeBlobHelpers
include RepoHelpers include RepoHelpers
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) } let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) } let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
let(:sha) { sample_commit.id } let(:sha) { sample_commit.id }
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Ci::ArtifactBlob do describe Ci::ArtifactBlob do
set(:project) { create(:project, :public) } let_it_be(:project) { create(:project, :public) }
set(:build) { create(:ci_build, :artifacts, project: project) } let_it_be(:build) { create(:ci_build, :artifacts, project: project) }
let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') } let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') }
subject { described_class.new(entry) } subject { described_class.new(entry) }
......
...@@ -7,7 +7,7 @@ describe Ci::Pipeline, :mailer do ...@@ -7,7 +7,7 @@ describe Ci::Pipeline, :mailer do
include StubRequests include StubRequests
let(:user) { create(:user) } let(:user) { create(:user) }
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:pipeline) do let(:pipeline) do
create(:ci_empty_pipeline, status: :created, project: project) create(:ci_empty_pipeline, status: :created, project: project)
...@@ -231,7 +231,7 @@ describe Ci::Pipeline, :mailer do ...@@ -231,7 +231,7 @@ describe Ci::Pipeline, :mailer do
describe '#legacy_detached_merge_request_pipeline?' do describe '#legacy_detached_merge_request_pipeline?' do
subject { pipeline.legacy_detached_merge_request_pipeline? } subject { pipeline.legacy_detached_merge_request_pipeline? }
set(:merge_request) { create(:merge_request) } let_it_be(:merge_request) { create(:merge_request) }
let(:ref) { 'feature' } let(:ref) { 'feature' }
let(:target_sha) { nil } let(:target_sha) { nil }
......
...@@ -544,7 +544,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do ...@@ -544,7 +544,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end end
describe '#applications' do describe '#applications' do
set(:cluster) { create(:cluster) } let_it_be(:cluster, reload: true) { create(:cluster) }
subject { cluster.applications } subject { cluster.applications }
......
...@@ -17,7 +17,7 @@ describe Commit do ...@@ -17,7 +17,7 @@ describe Commit do
end end
describe '.lazy' do describe '.lazy' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
context 'when the commits are found' do context 'when the commits are found' do
let(:oids) do let(:oids) do
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe CommitStatus do describe CommitStatus do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:pipeline) do let_it_be(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.id) create(:ci_pipeline, project: project, sha: project.commit.id)
end end
......
...@@ -15,7 +15,7 @@ describe BatchDestroyDependentAssociations do ...@@ -15,7 +15,7 @@ describe BatchDestroyDependentAssociations do
end end
describe '#dependent_associations_to_destroy' do describe '#dependent_associations_to_destroy' do
set(:project) { TestProject.new } let_it_be(:project) { TestProject.new }
it 'returns the right associations' do it 'returns the right associations' do
expect(project.dependent_associations_to_destroy.map(&:name)).to match_array([:builds]) expect(project.dependent_associations_to_destroy.map(&:name)).to match_array([:builds])
...@@ -23,9 +23,9 @@ describe BatchDestroyDependentAssociations do ...@@ -23,9 +23,9 @@ describe BatchDestroyDependentAssociations do
end end
describe '#destroy_dependent_associations_in_batches' do describe '#destroy_dependent_associations_in_batches' do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
set(:build) { create(:ci_build, project: project) } let_it_be(:build) { create(:ci_build, project: project) }
set(:notification_setting) { create(:notification_setting, project: project) } let_it_be(:notification_setting) { create(:notification_setting, project: project) }
let!(:todos) { create(:todo, project: project) } let!(:todos) { create(:todo, project: project) }
it 'destroys multiple builds' do it 'destroys multiple builds' do
......
...@@ -13,7 +13,7 @@ describe Identity do ...@@ -13,7 +13,7 @@ describe Identity do
end end
describe 'validations' do describe 'validations' do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
context 'with existing user and provider' do context 'with existing user and provider' do
before do before do
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
require 'spec_helper' require 'spec_helper'
describe LabelNote do describe LabelNote do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:label) { create(:label, project: project) } let_it_be(:label) { create(:label, project: project) }
set(:label2) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) }
let(:resource_parent) { project } let(:resource_parent) { project }
context 'when resource is issue' do context 'when resource is issue' do
set(:resource) { create(:issue, project: project) } let_it_be(:resource) { create(:issue, project: project) }
it_behaves_like 'label note created from events' it_behaves_like 'label note created from events'
end end
context 'when resource is merge request' do context 'when resource is merge request' do
set(:resource) { create(:merge_request, source_project: project, target_project: project) } let_it_be(:resource) { create(:merge_request, source_project: project, target_project: project) }
it_behaves_like 'label note created from events' it_behaves_like 'label note created from events'
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe LfsFileLock do describe LfsFileLock do
set(:lfs_file_lock) { create(:lfs_file_lock) } let_it_be(:lfs_file_lock, reload: true) { create(:lfs_file_lock) }
subject { lfs_file_lock } subject { lfs_file_lock }
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
......
...@@ -44,8 +44,8 @@ describe LfsObject do ...@@ -44,8 +44,8 @@ describe LfsObject do
end end
describe '#project_allowed_access?' do describe '#project_allowed_access?' do
set(:lfs_object) { create(:lfs_objects_project).lfs_object } let_it_be(:lfs_object) { create(:lfs_objects_project).lfs_object }
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
it 'returns true when project is linked' do it 'returns true when project is linked' do
create(:lfs_objects_project, lfs_object: lfs_object, project: project) create(:lfs_objects_project, lfs_object: lfs_object, project: project)
...@@ -58,9 +58,9 @@ describe LfsObject do ...@@ -58,9 +58,9 @@ describe LfsObject do
end end
context 'when project is a member of a fork network' do context 'when project is a member of a fork network' do
set(:fork_network) { create(:fork_network) } let_it_be(:fork_network) { create(:fork_network) }
set(:fork_network_root_project) { fork_network.root_project } let_it_be(:fork_network_root_project, reload: true) { fork_network.root_project }
set(:fork_network_membership) { create(:fork_network_member, project: project, fork_network: fork_network) } let_it_be(:fork_network_membership) { create(:fork_network_member, project: project, fork_network: fork_network) }
it 'returns true for all members when forked project is linked' do it 'returns true for all members when forked project is linked' do
create(:lfs_objects_project, lfs_object: lfs_object, project: project) create(:lfs_objects_project, lfs_object: lfs_object, project: project)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe LfsObjectsProject do describe LfsObjectsProject do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
subject do subject do
create(:lfs_objects_project, project: project) create(:lfs_objects_project, project: project)
......
...@@ -54,20 +54,20 @@ describe MergeRequestDiff do ...@@ -54,20 +54,20 @@ describe MergeRequestDiff do
end end
describe '.ids_for_external_storage_migration' do describe '.ids_for_external_storage_migration' do
set(:merge_request) { create(:merge_request) } let_it_be(:merge_request) { create(:merge_request) }
set(:outdated) { merge_request.merge_request_diff } let_it_be(:outdated) { merge_request.merge_request_diff }
set(:latest) { merge_request.create_merge_request_diff } let_it_be(:latest) { merge_request.create_merge_request_diff }
set(:closed_mr) { create(:merge_request, :closed_last_month) } let_it_be(:closed_mr) { create(:merge_request, :closed_last_month) }
let(:closed) { closed_mr.merge_request_diff } let(:closed) { closed_mr.merge_request_diff }
set(:merged_mr) { create(:merge_request, :merged_last_month) } let_it_be(:merged_mr) { create(:merge_request, :merged_last_month) }
let(:merged) { merged_mr.merge_request_diff } let(:merged) { merged_mr.merge_request_diff }
set(:recently_closed_mr) { create(:merge_request, :closed) } let_it_be(:recently_closed_mr) { create(:merge_request, :closed) }
let(:closed_recently) { recently_closed_mr.merge_request_diff } let(:closed_recently) { recently_closed_mr.merge_request_diff }
set(:recently_merged_mr) { create(:merge_request, :merged) } let_it_be(:recently_merged_mr) { create(:merge_request, :merged) }
let(:merged_recently) { recently_merged_mr.merge_request_diff } let(:merged_recently) { recently_merged_mr.merge_request_diff }
before do before do
......
...@@ -1091,8 +1091,8 @@ describe MergeRequest do ...@@ -1091,8 +1091,8 @@ describe MergeRequest do
end end
describe '#can_remove_source_branch?' do describe '#can_remove_source_branch?' do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:merge_request) { create(:merge_request, :simple) } let_it_be(:merge_request, reload: true) { create(:merge_request, :simple) }
subject { merge_request } subject { merge_request }
......
...@@ -517,9 +517,9 @@ describe Milestone do ...@@ -517,9 +517,9 @@ describe Milestone do
end end
describe '.sort_by_attribute' do describe '.sort_by_attribute' do
set(:milestone_1) { create(:milestone, title: 'Foo') } let_it_be(:milestone_1) { create(:milestone, title: 'Foo') }
set(:milestone_2) { create(:milestone, title: 'Bar') } let_it_be(:milestone_2) { create(:milestone, title: 'Bar') }
set(:milestone_3) { create(:milestone, title: 'Zoo') } let_it_be(:milestone_3) { create(:milestone, title: 'Zoo') }
context 'ordering by name ascending' do context 'ordering by name ascending' do
it 'sorts by title ascending' do it 'sorts by title ascending' do
...@@ -555,7 +555,7 @@ describe Milestone do ...@@ -555,7 +555,7 @@ describe Milestone do
end end
it 'returns the quantity of milestones in each possible state' do it 'returns the quantity of milestones in each possible state' do
expected_count = { opened: 5, closed: 6, all: 11 } expected_count = { opened: 2, closed: 6, all: 8 }
count = described_class.states_count(Project.all, Group.all) count = described_class.states_count(Project.all, Group.all)
expect(count).to eq(expected_count) expect(count).to eq(expected_count)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe ProjectAutoDevops do describe ProjectAutoDevops do
set(:project) { build(:project) } let_it_be(:project) { build(:project) }
it_behaves_like 'having unique enum values' it_behaves_like 'having unique enum values'
......
...@@ -40,7 +40,7 @@ describe Repository do ...@@ -40,7 +40,7 @@ describe Repository do
end end
describe '#branch_names_contains' do describe '#branch_names_contains' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
subject { repository.branch_names_contains(sample_commit.id) } subject { repository.branch_names_contains(sample_commit.id) }
...@@ -328,7 +328,7 @@ describe Repository do ...@@ -328,7 +328,7 @@ describe Repository do
end end
describe '#new_commits' do describe '#new_commits' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
subject { repository.new_commits(rev) } subject { repository.new_commits(rev) }
...@@ -356,7 +356,7 @@ describe Repository do ...@@ -356,7 +356,7 @@ describe Repository do
end end
describe '#commits_by' do describe '#commits_by' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:oids) { TestEnv::BRANCH_SHA.values } let(:oids) { TestEnv::BRANCH_SHA.values }
subject { project.repository.commits_by(oids: oids) } subject { project.repository.commits_by(oids: oids) }
...@@ -2575,7 +2575,7 @@ describe Repository do ...@@ -2575,7 +2575,7 @@ describe Repository do
end end
describe 'commit cache' do describe 'commit cache' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
it 'caches based on SHA' do it 'caches based on SHA' do
# Gets the commit oid, and warms the cache # Gets the commit oid, and warms the cache
...@@ -2723,7 +2723,7 @@ describe Repository do ...@@ -2723,7 +2723,7 @@ describe Repository do
end end
describe '#merge_base' do describe '#merge_base' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
subject(:repository) { project.repository } subject(:repository) { project.repository }
it 'only makes one gitaly call' do it 'only makes one gitaly call' do
...@@ -2782,7 +2782,7 @@ describe Repository do ...@@ -2782,7 +2782,7 @@ describe Repository do
end end
describe "#blobs_metadata" do describe "#blobs_metadata" do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
def expect_metadata_blob(thing) def expect_metadata_blob(thing)
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe SentNotification do describe SentNotification do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
describe 'validation' do describe 'validation' do
describe 'note validity' do describe 'note validity' do
......
...@@ -2196,7 +2196,7 @@ describe User, :do_not_mock_admin_mode do ...@@ -2196,7 +2196,7 @@ describe User, :do_not_mock_admin_mode do
describe '.find_by_private_commit_email' do describe '.find_by_private_commit_email' do
context 'with email' do context 'with email' do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
it 'returns user through private commit email' do it 'returns user through private commit email' do
expect(described_class.find_by_private_commit_email(user.private_commit_email)).to eq(user) expect(described_class.find_by_private_commit_email(user.private_commit_email)).to eq(user)
......
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