Commit 7dc92c9a authored by Vitali Tatarintev's avatar Vitali Tatarintev

Change set to let_it_be in spec/models

Changes set to let_it_be in spec/models (Batch 1)
parent c274e589
......@@ -3,8 +3,8 @@
require 'spec_helper'
describe AbuseReport do
set(:report) { create(:abuse_report) }
set(:user) { create(:admin) }
let_it_be(:report, reload: true) { create(:abuse_report) }
let_it_be(:user, reload: true) { create(:admin) }
subject { report }
it { expect(subject).to be_valid }
......
......@@ -45,8 +45,8 @@ describe AwardEmoji do
end
describe 'scopes' do
set(:thumbsup) { create(:award_emoji, name: 'thumbsup') }
set(:thumbsdown) { create(:award_emoji, name: 'thumbsdown') }
let_it_be(:thumbsup) { create(:award_emoji, name: 'thumbsup') }
let_it_be(:thumbsdown) { create(:award_emoji, name: 'thumbsdown') }
describe '.upvotes' do
it { expect(described_class.upvotes).to contain_exactly(thumbsup) }
......
......@@ -6,9 +6,8 @@ describe BlobViewer::GitlabCiYml do
include FakeBlobHelpers
include RepoHelpers
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
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(:sha) { sample_commit.id }
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
describe Ci::ArtifactBlob do
set(:project) { create(:project, :public) }
set(:build) { create(:ci_build, :artifacts, project: project) }
let_it_be(:project) { create(:project, :public) }
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') }
subject { described_class.new(entry) }
......
......@@ -7,7 +7,7 @@ describe Ci::Pipeline, :mailer do
include StubRequests
let(:user) { create(:user) }
set(:project) { create(:project) }
let_it_be(:project) { create(:project) }
let(:pipeline) do
create(:ci_empty_pipeline, status: :created, project: project)
......@@ -231,7 +231,7 @@ describe Ci::Pipeline, :mailer do
describe '#legacy_detached_merge_request_pipeline?' do
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(:target_sha) { nil }
......
......@@ -544,7 +544,7 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do
end
describe '#applications' do
set(:cluster) { create(:cluster) }
let_it_be(:cluster, reload: true) { create(:cluster) }
subject { cluster.applications }
......
......@@ -17,7 +17,7 @@ describe Commit do
end
describe '.lazy' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
context 'when the commits are found' do
let(:oids) do
......
......@@ -3,9 +3,9 @@
require 'spec_helper'
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)
end
......
......@@ -15,7 +15,7 @@ describe BatchDestroyDependentAssociations do
end
describe '#dependent_associations_to_destroy' do
set(:project) { TestProject.new }
let_it_be(:project) { TestProject.new }
it 'returns the right associations' do
expect(project.dependent_associations_to_destroy.map(&:name)).to match_array([:builds])
......@@ -23,9 +23,9 @@ describe BatchDestroyDependentAssociations do
end
describe '#destroy_dependent_associations_in_batches' do
set(:project) { create(:project) }
set(:build) { create(:ci_build, project: project) }
set(:notification_setting) { create(:notification_setting, project: project) }
let_it_be(:project) { create(:project) }
let_it_be(:build) { create(:ci_build, project: project) }
let_it_be(:notification_setting) { create(:notification_setting, project: project) }
let!(:todos) { create(:todo, project: project) }
it 'destroys multiple builds' do
......
......@@ -13,7 +13,7 @@ describe Identity do
end
describe 'validations' do
set(:user) { create(:user) }
let_it_be(:user) { create(:user) }
context 'with existing user and provider' do
before do
......
......@@ -3,20 +3,20 @@
require 'spec_helper'
describe LabelNote do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
set(:label) { create(:label, project: project) }
set(:label2) { create(:label, project: project) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let_it_be(:label) { create(:label, project: project) }
let_it_be(:label2) { create(:label, project: project) }
let(:resource_parent) { project }
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'
end
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'
end
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
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 }
it { is_expected.to belong_to(:project) }
......
......@@ -44,8 +44,8 @@ describe LfsObject do
end
describe '#project_allowed_access?' do
set(:lfs_object) { create(:lfs_objects_project).lfs_object }
set(:project) { create(:project) }
let_it_be(:lfs_object) { create(:lfs_objects_project).lfs_object }
let_it_be(:project, reload: true) { create(:project) }
it 'returns true when project is linked' do
create(:lfs_objects_project, lfs_object: lfs_object, project: project)
......@@ -58,9 +58,9 @@ describe LfsObject do
end
context 'when project is a member of a fork network' do
set(:fork_network) { create(:fork_network) }
set(:fork_network_root_project) { fork_network.root_project }
set(:fork_network_membership) { create(:fork_network_member, project: project, fork_network: fork_network) }
let_it_be(:fork_network) { create(:fork_network) }
let_it_be(:fork_network_root_project, reload: true) { fork_network.root_project }
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
create(:lfs_objects_project, lfs_object: lfs_object, project: project)
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
describe LfsObjectsProject do
set(:project) { create(:project) }
let_it_be(:project) { create(:project) }
subject do
create(:lfs_objects_project, project: project)
......
......@@ -54,20 +54,20 @@ describe MergeRequestDiff do
end
describe '.ids_for_external_storage_migration' do
set(:merge_request) { create(:merge_request) }
set(:outdated) { merge_request.merge_request_diff }
set(:latest) { merge_request.create_merge_request_diff }
let_it_be(:merge_request) { create(:merge_request) }
let_it_be(:outdated) { merge_request.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 }
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 }
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 }
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 }
before do
......
......@@ -1091,8 +1091,8 @@ describe MergeRequest do
end
describe '#can_remove_source_branch?' do
set(:user) { create(:user) }
set(:merge_request) { create(:merge_request, :simple) }
let_it_be(:user) { create(:user) }
let_it_be(:merge_request, reload: true) { create(:merge_request, :simple) }
subject { merge_request }
......
......@@ -517,9 +517,9 @@ describe Milestone do
end
describe '.sort_by_attribute' do
set(:milestone_1) { create(:milestone, title: 'Foo') }
set(:milestone_2) { create(:milestone, title: 'Bar') }
set(:milestone_3) { create(:milestone, title: 'Zoo') }
let_it_be(:milestone_1) { create(:milestone, title: 'Foo') }
let_it_be(:milestone_2) { create(:milestone, title: 'Bar') }
let_it_be(:milestone_3) { create(:milestone, title: 'Zoo') }
context 'ordering by name ascending' do
it 'sorts by title ascending' do
......@@ -555,7 +555,7 @@ describe Milestone do
end
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)
expect(count).to eq(expected_count)
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
describe ProjectAutoDevops do
set(:project) { build(:project) }
let_it_be(:project) { build(:project) }
it_behaves_like 'having unique enum values'
......
......@@ -40,7 +40,7 @@ describe Repository do
end
describe '#branch_names_contains' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject { repository.branch_names_contains(sample_commit.id) }
......@@ -328,7 +328,7 @@ describe Repository do
end
describe '#new_commits' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject { repository.new_commits(rev) }
......@@ -356,7 +356,7 @@ describe Repository do
end
describe '#commits_by' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
let(:oids) { TestEnv::BRANCH_SHA.values }
subject { project.repository.commits_by(oids: oids) }
......@@ -2575,7 +2575,7 @@ describe Repository do
end
describe 'commit cache' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
it 'caches based on SHA' do
# Gets the commit oid, and warms the cache
......@@ -2723,7 +2723,7 @@ describe Repository do
end
describe '#merge_base' do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
subject(:repository) { project.repository }
it 'only makes one gitaly call' do
......@@ -2782,7 +2782,7 @@ describe Repository do
end
describe "#blobs_metadata" do
set(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
def expect_metadata_blob(thing)
......
......@@ -3,8 +3,8 @@
require 'spec_helper'
describe SentNotification do
set(:user) { create(:user) }
set(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
describe 'validation' do
describe 'note validity' do
......
......@@ -2196,7 +2196,7 @@ describe User, :do_not_mock_admin_mode do
describe '.find_by_private_commit_email' do
context 'with email' do
set(:user) { create(:user) }
let_it_be(:user) { create(:user) }
it 'returns user through private commit email' do
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