diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-07-02 10:43:06 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-07-09 21:13:08 +0800 |
commit | 4ee08b77bc5ae11553d59c182ea8292b77699115 (patch) | |
tree | 3aac1871cd8dcefc88d52f11dcacbf238b2340a9 /spec | |
parent | 612f5e63b3cf76c354e50f4aa6c4163e5465b115 (diff) | |
download | gitlab-ce-4ee08b77bc5ae11553d59c182ea8292b77699115.tar.gz |
Updates from `rubocop -a`
Diffstat (limited to 'spec')
77 files changed, 169 insertions, 171 deletions
diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb index e20623c0ac1..945b6142abf 100644 --- a/spec/controllers/projects/forks_controller_spec.rb +++ b/spec/controllers/projects/forks_controller_spec.rb @@ -31,7 +31,7 @@ describe Projects::ForksController do context 'when fork is private' do before do - forked_project.update_attributes(visibility_level: Project::PRIVATE, group: group) + forked_project.update(visibility_level: Project::PRIVATE, group: group) end it 'is not be visible for non logged in users' do diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb index 72f6af112b3..78c6f7839b4 100644 --- a/spec/controllers/projects/group_links_controller_spec.rb +++ b/spec/controllers/projects/group_links_controller_spec.rb @@ -23,7 +23,7 @@ describe Projects::GroupLinksController do context 'when project is not allowed to be shared with a group' do before do - group.update_attributes(share_with_group_lock: false) + group.update(share_with_group_lock: false) end include_context 'link project to group' diff --git a/spec/controllers/projects/imports_controller_spec.rb b/spec/controllers/projects/imports_controller_spec.rb index 812833cc86b..6f06210f3de 100644 --- a/spec/controllers/projects/imports_controller_spec.rb +++ b/spec/controllers/projects/imports_controller_spec.rb @@ -29,7 +29,7 @@ describe Projects::ImportsController do context 'when import is in progress' do before do - project.update_attributes(import_status: :started) + project.update(import_status: :started) end it 'renders template' do @@ -47,7 +47,7 @@ describe Projects::ImportsController do context 'when import failed' do before do - project.update_attributes(import_status: :failed) + project.update(import_status: :failed) end it 'redirects to new_namespace_project_import_path' do @@ -59,7 +59,7 @@ describe Projects::ImportsController do context 'when import finished' do before do - project.update_attributes(import_status: :finished) + project.update(import_status: :finished) end context 'when project is a fork' do @@ -108,7 +108,7 @@ describe Projects::ImportsController do context 'when import never happened' do before do - project.update_attributes(import_status: :none) + project.update(import_status: :none) end it 'redirects to namespace_project_path' do diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 7f5f0b76c51..444415011a9 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -315,7 +315,7 @@ describe Projects::MergeRequestsController do context 'when the merge request is not mergeable' do before do - merge_request.update_attributes(title: "WIP: #{merge_request.title}") + merge_request.update(title: "WIP: #{merge_request.title}") post :merge, base_params end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index a2dfc43e9f7..fd7d867f9e5 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -166,7 +166,7 @@ describe ProjectsController do User.project_views.keys.each do |project_view| context "with #{project_view} view set" do before do - user.update_attributes(project_view: project_view) + user.update(project_view: project_view) get :show, namespace_id: empty_project.namespace, id: empty_project end @@ -188,7 +188,7 @@ describe ProjectsController do User.project_views.keys.each do |project_view| context "with #{project_view} view set" do before do - user.update_attributes(project_view: project_view) + user.update(project_view: project_view) get :show, namespace_id: empty_project.namespace, id: empty_project end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index 3a35bdd25de..4d4f74e101e 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -27,7 +27,7 @@ FactoryBot.define do end after(:create) do |issue, evaluator| - issue.update_attributes(labels: evaluator.labels) + issue.update(labels: evaluator.labels) end end end diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index 3441ce1b8cb..f722bb9cb0d 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -117,7 +117,7 @@ FactoryBot.define do end after(:create) do |merge_request, evaluator| - merge_request.update_attributes(labels: evaluator.labels) + merge_request.update(labels: evaluator.labels) end end end diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 87fa3f60826..29fcf89fa7a 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -89,7 +89,7 @@ describe 'Commits' do context 'Download artifacts' do before do - build.update_attributes(legacy_artifacts_file: artifacts_file) + build.update(legacy_artifacts_file: artifacts_file) end it do @@ -146,7 +146,7 @@ describe 'Commits' do context "when logged as reporter" do before do project.add_reporter(user) - build.update_attributes(legacy_artifacts_file: artifacts_file) + build.update(legacy_artifacts_file: artifacts_file) visit pipeline_path(pipeline) end @@ -168,7 +168,7 @@ describe 'Commits' do project.update( visibility_level: Gitlab::VisibilityLevel::INTERNAL, public_builds: false) - build.update_attributes(legacy_artifacts_file: artifacts_file) + build.update(legacy_artifacts_file: artifacts_file) visit pipeline_path(pipeline) end diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 8647616101b..4daacc61d85 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -59,7 +59,7 @@ describe 'Dashboard Projects' do context 'when last_repository_updated_at, last_activity_at and update_at are present' do it 'shows the last_repository_updated_at attribute as the update date' do - project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago) + project.update!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago) visit dashboard_projects_path @@ -67,7 +67,7 @@ describe 'Dashboard Projects' do end it 'shows the last_activity_at attribute as the update date' do - project.update_attributes!(last_repository_updated_at: 1.hour.ago, last_activity_at: Time.now) + project.update!(last_repository_updated_at: 1.hour.ago, last_activity_at: Time.now) visit dashboard_projects_path @@ -77,7 +77,7 @@ describe 'Dashboard Projects' do context 'when last_repository_updated_at and last_activity_at are missing' do it 'shows the updated_at attribute as the update date' do - project.update_attributes!(last_repository_updated_at: nil, last_activity_at: nil) + project.update!(last_repository_updated_at: nil, last_activity_at: nil) project.touch visit dashboard_projects_path diff --git a/spec/features/groups/members/request_access_spec.rb b/spec/features/groups/members/request_access_spec.rb index 1c833c36a61..94510f917a3 100644 --- a/spec/features/groups/members/request_access_spec.rb +++ b/spec/features/groups/members/request_access_spec.rb @@ -13,7 +13,7 @@ describe 'Groups > Members > Request access' do end it 'request access feature is disabled' do - group.update_attributes(request_access_enabled: false) + group.update(request_access_enabled: false) visit group_path(group) expect(page).not_to have_content 'Request Access' diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index b4cb3835a13..3050f23c130 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -112,7 +112,7 @@ describe 'Issue Sidebar' do context 'editing issue labels', :js do before do - issue.update_attributes(labels: [label]) + issue.update(labels: [label]) page.within('.block.labels') do find('.edit-link').click end diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb index 13cc5f256eb..02d19db3828 100644 --- a/spec/features/merge_request/user_posts_diff_notes_spec.rb +++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb @@ -198,7 +198,7 @@ describe 'Merge request > User posts diff notes', :js do context 'when the MR only supports legacy diff notes' do before do - merge_request.merge_request_diff.update_attributes(start_commit_sha: nil) + merge_request.merge_request_diff.update(start_commit_sha: nil) visit diffs_project_merge_request_path(project, merge_request, view: 'inline') end diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index f9c6ff90ca1..5e3569e4beb 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -117,7 +117,7 @@ describe 'Profile > Password' do before do sign_in(user) - user.update_attributes(password_expires_at: 1.hour.ago) + user.update(password_expires_at: 1.hour.ago) user.identities.delete expect(user.ldap_user?).to eq false end diff --git a/spec/features/projects/files/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb index 41f6c52fb8a..9b1395d5e0a 100644 --- a/spec/features/projects/files/user_browses_files_spec.rb +++ b/spec/features/projects/files/user_browses_files_spec.rb @@ -147,8 +147,6 @@ describe "User browses files" do page.within(".tree-table") do click_link("README.md") end - - # rubocop:disable Lint/Void # Test the full URLs of links instead of relative paths by `have_link(text: "...", href: "...")`. find("a", text: /^empty$/)["href"] == project_blob_url(project, "markdown/d/README.md") # rubocop:enable Lint/Void diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb index e9588daf37d..e639f0cf82e 100644 --- a/spec/features/projects/jobs/permissions_spec.rb +++ b/spec/features/projects/jobs/permissions_spec.rb @@ -90,7 +90,7 @@ describe 'Project Jobs Permissions' do before do archive = fixture_file_upload('spec/fixtures/ci_build_artifacts.zip') - job.update_attributes(legacy_artifacts_file: archive) + job.update(legacy_artifacts_file: archive) end context 'when public access for jobs is disabled' do diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index c742eb79392..35b1c46ecf6 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -187,7 +187,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do context "Download artifacts" do before do - job.update_attributes(legacy_artifacts_file: artifacts_file) + job.update(legacy_artifacts_file: artifacts_file) visit project_job_path(project, job) end @@ -198,8 +198,8 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do context 'Artifacts expire date' do before do - job.update_attributes(legacy_artifacts_file: artifacts_file, - artifacts_expire_at: expire_at) + job.update(legacy_artifacts_file: artifacts_file, + artifacts_expire_at: expire_at) visit project_job_path(project, job) end @@ -530,14 +530,14 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do describe "GET /:project/jobs/:id/download" do before do - job.update_attributes(legacy_artifacts_file: artifacts_file) + job.update(legacy_artifacts_file: artifacts_file) visit project_job_path(project, job) click_link 'Download' end context "Build from other project" do before do - job2.update_attributes(legacy_artifacts_file: artifacts_file) + job2.update(legacy_artifacts_file: artifacts_file) visit download_project_job_artifacts_path(project, job2) end diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index 35d6ac1c650..5599cc9bf1b 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -11,7 +11,7 @@ describe 'Projects > Members > User requests access', :js do end it 'request access feature is disabled' do - project.update_attributes(request_access_enabled: false) + project.update(request_access_enabled: false) visit project_path(project) expect(page).not_to have_content 'Request Access' diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 9c165b17704..7d47e342e92 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -606,7 +606,7 @@ describe 'Pipelines', :js do describe 'user clicks the button' do context 'when project already has jobs_cache_index' do before do - project.update_attributes(jobs_cache_index: 1) + project.update(jobs_cache_index: 1) end it 'increments jobs_cache_index' do diff --git a/spec/features/projects/remote_mirror_spec.rb b/spec/features/projects/remote_mirror_spec.rb index 53a3f6f474b..97db4a2b8f2 100644 --- a/spec/features/projects/remote_mirror_spec.rb +++ b/spec/features/projects/remote_mirror_spec.rb @@ -13,7 +13,7 @@ describe 'Project remote mirror', :feature do context 'when last_error is present but last_update_at is not' do it 'renders error message without timstamp' do - remote_mirror.update_attributes(last_error: 'Some new error', last_update_at: nil) + remote_mirror.update(last_error: 'Some new error', last_update_at: nil) visit project_mirror_path(project) @@ -23,7 +23,7 @@ describe 'Project remote mirror', :feature do context 'when last_error and last_update_at are present' do it 'renders error message with timestamp' do - remote_mirror.update_attributes(last_error: 'Some new error', last_update_at: Time.now - 5.minutes) + remote_mirror.update(last_error: 'Some new error', last_update_at: Time.now - 5.minutes) visit project_mirror_path(project) diff --git a/spec/features/projects/services/user_activates_slack_notifications_spec.rb b/spec/features/projects/services/user_activates_slack_notifications_spec.rb index fae9ebd1bd6..727b1fe2d11 100644 --- a/spec/features/projects/services/user_activates_slack_notifications_spec.rb +++ b/spec/features/projects/services/user_activates_slack_notifications_spec.rb @@ -29,7 +29,7 @@ describe 'User activates Slack notifications' do context 'when service is already configured' do before do service.fields - service.update_attributes( + service.update( push_channel: 1, issue_channel: 2, merge_request_channel: 3, diff --git a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb index aa23bef6fd8..d9d57298929 100644 --- a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb +++ b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb @@ -8,7 +8,7 @@ describe 'Projects > Show > User sees a deletion failure message' do end it 'shows error message if deletion for project fails' do - project.update_attributes(delete_error: "Something went wrong", pending_delete: false) + project.update(delete_error: "Something went wrong", pending_delete: false) visit project_path(project) diff --git a/spec/features/signed_commits_spec.rb b/spec/features/signed_commits_spec.rb index db141ef7096..bc9443c6093 100644 --- a/spec/features/signed_commits_spec.rb +++ b/spec/features/signed_commits_spec.rb @@ -23,7 +23,7 @@ describe 'GPG signed commits', :js do # user changes his email which makes the gpg key verified Sidekiq::Testing.inline! do user.skip_reconfirmation! - user.update_attributes!(email: GpgHelpers::User1.emails.first) + user.update!(email: GpgHelpers::User1.emails.first) end visit project_commits_path(project, :'signed-commits') diff --git a/spec/finders/group_projects_finder_spec.rb b/spec/finders/group_projects_finder_spec.rb index be80ee7d767..0a69c03e491 100644 --- a/spec/finders/group_projects_finder_spec.rb +++ b/spec/finders/group_projects_finder_spec.rb @@ -81,7 +81,7 @@ describe GroupProjectsFinder do context "with external user" do before do - current_user.update_attributes(external: true) + current_user.update(external: true) end it { is_expected.to match_array([shared_project_2, shared_project_1]) } @@ -112,7 +112,7 @@ describe GroupProjectsFinder do context "with external user" do before do - current_user.update_attributes(external: true) + current_user.update(external: true) end context 'with subgroups projects', :nested_groups do diff --git a/spec/finders/joined_groups_finder_spec.rb b/spec/finders/joined_groups_finder_spec.rb index 29a47e005a6..7f77a713b12 100644 --- a/spec/finders/joined_groups_finder_spec.rb +++ b/spec/finders/joined_groups_finder_spec.rb @@ -53,7 +53,7 @@ describe JoinedGroupsFinder do context 'external users' do before do - profile_visitor.update_attributes(external: true) + profile_visitor.update(external: true) end context 'if not a member' do diff --git a/spec/finders/move_to_project_finder_spec.rb b/spec/finders/move_to_project_finder_spec.rb index 74639d4147f..e1faf3d569c 100644 --- a/spec/finders/move_to_project_finder_spec.rb +++ b/spec/finders/move_to_project_finder_spec.rb @@ -45,7 +45,7 @@ describe MoveToProjectFinder do it 'does not return projects for which issues are disabled' do reporter_project.add_reporter(user) - reporter_project.update_attributes(issues_enabled: false) + reporter_project.update(issues_enabled: false) other_reporter_project = create(:project) other_reporter_project.add_reporter(user) diff --git a/spec/finders/personal_projects_finder_spec.rb b/spec/finders/personal_projects_finder_spec.rb index 00c551a1f65..ef7dd0cd4a8 100644 --- a/spec/finders/personal_projects_finder_spec.rb +++ b/spec/finders/personal_projects_finder_spec.rb @@ -35,7 +35,7 @@ describe PersonalProjectsFinder do context 'external' do before do - current_user.update_attributes(external: true) + current_user.update(external: true) end it { is_expected.to eq([public_project, private_project]) } diff --git a/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb b/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb index ee60e498b59..2e77e80ee46 100644 --- a/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb +++ b/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb @@ -7,7 +7,7 @@ describe Gitlab::BackgroundMigration::MovePersonalSnippetFiles do let(:snippet) do snippet = create(:personal_snippet) create_upload_for_snippet(snippet) - snippet.update_attributes!(description: markdown_linking_file(snippet)) + snippet.update!(description: markdown_linking_file(snippet)) snippet end diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb index b411aaa19da..0a8c77b0ad9 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb @@ -281,7 +281,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, : it "doesn't break when the namespace was renamed" do subject.rename_namespace(namespace) - namespace.update_attributes!(path: 'renamed-afterwards') + namespace.update!(path: 'renamed-afterwards') expect { subject.revert_renames }.not_to raise_error end diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb index b4896d69077..d4d7a83921c 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb @@ -169,7 +169,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :de it "doesn't break when the project was renamed" do subject.rename_project(project) - project.update_attributes!(path: 'renamed-afterwards') + project.update!(path: 'renamed-afterwards') expect { subject.revert_renames }.not_to raise_error end diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb index 6fbffc38444..1a2c6ef25c4 100644 --- a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb +++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb @@ -141,7 +141,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do expect(invalid_gpg_signature.reload.verification_status).to eq 'unverified_key' # InvalidGpgSignatureUpdater is called by the after_update hook - user.update_attributes!(email: GpgHelpers::User1.emails.first) + user.update!(email: GpgHelpers::User1.emails.first) expect(invalid_gpg_signature.reload).to have_attributes( project: project, @@ -166,7 +166,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do ) # InvalidGpgSignatureUpdater is called by the after_update hook - user.update_attributes!(email: 'still.unrelated@example.com') + user.update!(email: 'still.unrelated@example.com') expect(invalid_gpg_signature.reload).to have_attributes( project: project, diff --git a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb index dd2b08099f2..495e86ee888 100644 --- a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb +++ b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb @@ -14,7 +14,7 @@ describe IssuesMovedToIdForeignKey, :migration, schema: 20171114150259 do it 'removes the orphaned moved_to_id' do subject.down - issue_third.update_attributes(moved_to_id: 100000) + issue_third.update(moved_to_id: 100000) subject.up diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb index df009cec25c..6f729fec460 100644 --- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb +++ b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb @@ -12,7 +12,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do class KubernetesService < ActiveRecord::Base self.table_name = 'services' - serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize + serialize :properties, JSON default_value_for :active, true default_value_for :type, 'KubernetesService' diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb index 7e75d5a5411..6dba132184c 100644 --- a/spec/models/ci/build_metadata_spec.rb +++ b/spec/models/ci/build_metadata_spec.rb @@ -30,7 +30,7 @@ describe Ci::BuildMetadata do context 'when runner is assigned to the job' do before do - build.update_attributes(runner: runner) + build.update(runner: runner) end context 'when runner timeout is lower than project timeout' do diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 090ca159e08..234d2d8aa3a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -186,18 +186,18 @@ describe Ci::Build do let(:runner) { create(:ci_runner, :project, projects: [build.project]) } before do - runner.update_attributes(contacted_at: 1.second.ago) + runner.update(contacted_at: 1.second.ago) end it { is_expected.to be_truthy } it 'that is inactive' do - runner.update_attributes(active: false) + runner.update(active: false) is_expected.to be_falsey end it 'that is not online' do - runner.update_attributes(contacted_at: nil) + runner.update(contacted_at: nil) is_expected.to be_falsey end @@ -261,7 +261,7 @@ describe Ci::Build do context 'artifacts metadata does not exist' do before do - build.update_attributes(legacy_artifacts_metadata: nil) + build.update(legacy_artifacts_metadata: nil) end it { is_expected.to be_falsy } @@ -1535,7 +1535,7 @@ describe Ci::Build do expect(ProjectStatistics) .not_to receive(:increment_statistic) - build.project.update_attributes(pending_delete: true) + build.project.update(pending_delete: true) build.project.destroy! end end @@ -1662,7 +1662,7 @@ describe Ci::Build do end before do - build.update_attributes(user: user) + build.update(user: user) end it { user_variables.each { |v| is_expected.to include(v) } } @@ -1740,7 +1740,7 @@ describe Ci::Build do context 'when build started manually' do before do - build.update_attributes(when: :manual) + build.update(when: :manual) end let(:manual_variable) do @@ -1756,7 +1756,7 @@ describe Ci::Build do end before do - build.update_attributes(tag: true) + build.update(tag: true) end it { is_expected.to include(tag_variable) } diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb index 2f87fb5f25d..0fd7612c011 100644 --- a/spec/models/ci/job_artifact_spec.rb +++ b/spec/models/ci/job_artifact_spec.rb @@ -163,7 +163,7 @@ describe Ci::JobArtifact do expect(ProjectStatistics) .not_to receive(:increment_statistic) - project.update_attributes(pending_delete: true) + project.update(pending_delete: true) project.destroy! end end diff --git a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb index c16b245bea8..e5392fe0462 100644 --- a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb +++ b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb @@ -4,8 +4,8 @@ describe BatchDestroyDependentAssociations do class TestProject < ActiveRecord::Base self.table_name = 'projects' - has_many :builds, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent - has_many :notification_settings, as: :source, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent + has_many :builds, dependent: :destroy + has_many :notification_settings, as: :source, dependent: :delete_all has_many :pages_domains has_many :todos diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb index c73ea6aa94c..a9b237fa9ea 100644 --- a/spec/models/concerns/mentionable_spec.rb +++ b/spec/models/concerns/mentionable_spec.rb @@ -136,7 +136,7 @@ describe Issue, "Mentionable" do expect(SystemNoteService).not_to receive(:cross_reference) - issue.update_attributes(description: 'New description') + issue.update(description: 'New description') issue.create_new_cross_references! end @@ -145,7 +145,7 @@ describe Issue, "Mentionable" do expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args) - issue.update_attributes(description: issues[1].to_reference) + issue.update(description: issues[1].to_reference) issue.create_new_cross_references! end @@ -155,7 +155,7 @@ describe Issue, "Mentionable" do expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args) - note.update_attributes(note: issues[1].to_reference) + note.update(note: issues[1].to_reference) note.create_new_cross_references! end end diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index 8cb50d7465c..ed3e28fbeca 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -29,7 +29,7 @@ describe Group, 'Routable' do end it 'updates route record on path change' do - group.update_attributes(path: 'wow', name: 'much') + group.update(path: 'wow', name: 'much') expect(group.route.path).to eq('wow') expect(group.route.name).to eq('much') diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 25d6597084c..4bded9efe91 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -562,7 +562,7 @@ describe Environment do it "is not regenerated if name changes" do original_slug = environment.slug - environment.update_attributes!(name: environment.name.reverse) + environment.update!(name: environment.name.reverse) expect(environment.slug).to eq(original_slug) end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 9fe1186a8c9..aeec485358e 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -617,7 +617,7 @@ describe Group do expect(group).to receive(:system_hook_service).and_return(system_hook_service) expect(system_hook_service).to receive(:execute_hooks_for).with(group, :rename) - group.update_attributes!(path: new_path) + group.update!(path: new_path) end end @@ -625,7 +625,7 @@ describe Group do it 'does not trigger system hook' do expect(group).not_to receive(:system_hook_service) - group.update_attributes!(name: 'new name') + group.update!(name: 'new name') end end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 8c6b411ec9a..c7eead2bdaa 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1891,7 +1891,7 @@ describe MergeRequest do end it 'returns false if the merge request is merged' do - merge_request.update_attributes(state: 'merged') + merge_request.update(state: 'merged') expect(merge_request.reload.reopenable?).to be_falsey end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 70f1a1c8b38..c1b385aaf76 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -200,7 +200,7 @@ describe Namespace do end it "moves dir if path changed" do - namespace.update_attributes(path: namespace.full_path + '_new') + namespace.update(path: namespace.full_path + '_new') expect(gitlab_shell.exists?(project.repository_storage, "#{namespace.path}/#{project.path}.git")).to be_truthy end @@ -279,7 +279,7 @@ describe Namespace do it "repository directory remains unchanged if path changed" do before_disk_path = project.disk_path - namespace.update_attributes(path: namespace.full_path + '_new') + namespace.update(path: namespace.full_path + '_new') expect(before_disk_path).to eq(project.disk_path) expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_truthy diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index 12681a147b4..d7c5f26ab67 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -58,7 +58,7 @@ RSpec.describe NotificationSetting do 1.upto(4) do |i| setting = create(:notification_setting, user: user) - setting.project.update_attributes(pending_delete: true) if i.even? + setting.project.update(pending_delete: true) if i.even? end end diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index 63c6fbda3f2..cd7f77024da 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -77,7 +77,7 @@ describe ProjectFeature do context 'repository related features' do before do - project.project_feature.update_attributes( + project.project_feature.update( merge_requests_access_level: ProjectFeature::DISABLED, builds_access_level: ProjectFeature::DISABLED, repository_access_level: ProjectFeature::PRIVATE diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index b9512b81678..bbf37ca59b9 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -567,15 +567,15 @@ describe Project do end it 'returns the most recent timestamp' do - project.update_attributes(updated_at: nil, - last_activity_at: timestamp, - last_repository_updated_at: timestamp - 1.hour) + project.update(updated_at: nil, + last_activity_at: timestamp, + last_repository_updated_at: timestamp - 1.hour) expect(project.last_activity_date).to be_like_time(timestamp) - project.update_attributes(updated_at: timestamp, - last_activity_at: timestamp - 1.hour, - last_repository_updated_at: nil) + project.update(updated_at: timestamp, + last_activity_at: timestamp - 1.hour, + last_repository_updated_at: nil) expect(project.last_activity_date).to be_like_time(timestamp) end @@ -1768,7 +1768,7 @@ describe Project do it 'resets project import_error' do error_message = 'Some error' mirror = create(:project_empty_repo, :import_started) - mirror.import_state.update_attributes(last_error: error_message) + mirror.import_state.update(last_error: error_message) expect { mirror.import_finish }.to change { mirror.import_error }.from(error_message).to(nil) end @@ -1929,7 +1929,7 @@ describe Project do end it 'returns false when remote mirror is disabled' do - project.remote_mirrors.first.update_attributes(enabled: false) + project.remote_mirrors.first.update(enabled: false) is_expected.to be_falsy end @@ -1959,7 +1959,7 @@ describe Project do end it 'does not sync disabled remote mirrors' do - project.remote_mirrors.first.update_attributes(enabled: false) + project.remote_mirrors.first.update(enabled: false) expect_any_instance_of(RemoteMirror).not_to receive(:sync) diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb index 3597b080021..c2ef0435c8e 100644 --- a/spec/models/remote_mirror_spec.rb +++ b/spec/models/remote_mirror_spec.rb @@ -85,7 +85,7 @@ describe RemoteMirror do expect(RepositoryRemoveRemoteWorker).to receive(:perform_async).with(mirror.project.id, mirror.remote_name).and_call_original - mirror.update_attributes(url: 'http://test.com') + mirror.update(url: 'http://test.com') end end end @@ -167,7 +167,7 @@ describe RemoteMirror do context 'with remote mirroring disabled' do it 'returns nil' do - remote_mirror.update_attributes(enabled: false) + remote_mirror.update(enabled: false) expect(remote_mirror.sync).to be_nil end @@ -229,7 +229,7 @@ describe RemoteMirror do end before do - remote_mirror.update_attributes(last_update_started_at: Time.now) + remote_mirror.update(last_update_started_at: Time.now) end context 'when remote mirror does not have status failed' do @@ -244,7 +244,7 @@ describe RemoteMirror do context 'when remote mirror has status failed' do it 'returns false when last update started after the timestamp' do - remote_mirror.update_attributes(update_status: 'failed') + remote_mirror.update(update_status: 'failed') expect(remote_mirror.updated_since?(timestamp)).to be false end diff --git a/spec/models/route_spec.rb b/spec/models/route_spec.rb index 01238a89a81..48799781b87 100644 --- a/spec/models/route_spec.rb +++ b/spec/models/route_spec.rb @@ -29,12 +29,12 @@ describe Route do context 'after update' do it 'calls #create_redirect_for_old_path' do expect(route).to receive(:create_redirect_for_old_path) - route.update_attributes(path: 'foo') + route.update(path: 'foo') end it 'calls #delete_conflicting_redirects' do expect(route).to receive(:delete_conflicting_redirects) - route.update_attributes(path: 'foo') + route.update(path: 'foo') end end @@ -70,7 +70,7 @@ describe Route do context 'path update' do context 'when route name is set' do before do - route.update_attributes(path: 'bar') + route.update(path: 'bar') end it 'updates children routes with new path' do @@ -89,7 +89,7 @@ describe Route do end it "does not fail" do - expect(route.update_attributes(path: 'bar')).to be_truthy + expect(route.update(path: 'bar')).to be_truthy end end @@ -100,7 +100,7 @@ describe Route do let!(:conflicting_redirect3) { route.create_redirect('gitlab-org') } it 'deletes the conflicting redirects' do - route.update_attributes(path: 'bar') + route.update(path: 'bar') expect(RedirectRoute.exists?(path: 'bar/test')).to be_falsey expect(RedirectRoute.exists?(path: 'bar/test/foo')).to be_falsey @@ -111,7 +111,7 @@ describe Route do context 'name update' do it 'updates children routes with new path' do - route.update_attributes(name: 'bar') + route.update(name: 'bar') expect(described_class.exists?(name: 'bar')).to be_truthy expect(described_class.exists?(name: 'bar / test')).to be_truthy @@ -123,7 +123,7 @@ describe Route do # Note: using `update_columns` to skip all validation and callbacks route.update_columns(name: nil) - expect { route.update_attributes(name: 'bar') } + expect { route.update(name: 'bar') } .to change { route.name }.from(nil).to('bar') end end diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index a849af062c5..029ad7f3e9f 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -280,7 +280,7 @@ describe Service do service.save! expect do - service.update_attributes(active: false) + service.update(active: false) end.to change { service.project.has_external_issue_tracker }.from(true).to(false) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 097144d04ce..164c27d2416 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -383,7 +383,7 @@ describe User do let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user) } it 'allows a verfied secondary email to be used as the primary without needing reconfirmation' do - user.update_attributes!(email: secondary.email) + user.update!(email: secondary.email) user.reload expect(user.email).to eq secondary.email expect(user.unconfirmed_email).to eq nil @@ -405,11 +405,11 @@ describe User do it 'gets called when email updated' do expect(@user).to receive(:update_emails_with_primary_email) - @user.update_attributes!(email: 'new_primary@example.com') + @user.update!(email: 'new_primary@example.com') end it 'adds old primary to secondary emails when secondary is a new email ' do - @user.update_attributes!(email: 'new_primary@example.com') + @user.update!(email: 'new_primary@example.com') @user.reload expect(@user.emails.count).to eq 2 @@ -417,7 +417,7 @@ describe User do end it 'adds old primary to secondary emails if secondary is becoming a primary' do - @user.update_attributes!(email: @secondary.email) + @user.update!(email: @secondary.email) @user.reload expect(@user.emails.count).to eq 1 @@ -425,7 +425,7 @@ describe User do end it 'transfers old confirmation values into new secondary' do - @user.update_attributes!(email: @secondary.email) + @user.update!(email: @secondary.email) @user.reload expect(@user.emails.count).to eq 1 @@ -494,12 +494,12 @@ describe User do it 'does nothing when the name is updated' do expect(user).not_to receive(:update_invalid_gpg_signatures) - user.update_attributes!(name: 'Bette') + user.update!(name: 'Bette') end it 'synchronizes the gpg keys when the email is updated' do expect(user).to receive(:update_invalid_gpg_signatures).at_most(:twice) - user.update_attributes!(email: 'shawnee.ritchie@denesik.com') + user.update!(email: 'shawnee.ritchie@denesik.com') end end end @@ -617,13 +617,13 @@ describe User do it 'receives callback when external changes' do expect(user).to receive(:ensure_user_rights_and_limits) - user.update_attributes(external: false) + user.update(external: false) end it 'ensures correct rights and limits for user' do stub_config_setting(default_can_create_group: true) - expect { user.update_attributes(external: false) }.to change { user.can_create_group }.to(true) + expect { user.update(external: false) }.to change { user.can_create_group }.to(true) .and change { user.projects_limit }.to(Gitlab::CurrentSettings.default_projects_limit) end end @@ -634,11 +634,11 @@ describe User do it 'receives callback when external changes' do expect(user).to receive(:ensure_user_rights_and_limits) - user.update_attributes(external: true) + user.update(external: true) end it 'ensures correct rights and limits for user' do - expect { user.update_attributes(external: true) }.to change { user.can_create_group }.to(false) + expect { user.update(external: true) }.to change { user.can_create_group }.to(false) .and change { user.projects_limit }.to(0) end end @@ -2461,18 +2461,18 @@ describe User do it 'changes the namespace (just to compare to when username is not changed)' do expect do - user.update_attributes!(username: new_username) + user.update!(username: new_username) end.to change { user.namespace.updated_at } end it 'updates the namespace name' do - user.update_attributes!(username: new_username) + user.update!(username: new_username) expect(user.namespace.name).to eq(new_username) end it 'updates the namespace path' do - user.update_attributes!(username: new_username) + user.update!(username: new_username) expect(user.namespace.path).to eq(new_username) end @@ -2481,12 +2481,12 @@ describe User do let!(:conflicting_namespace) { create(:group, path: new_username) } it 'causes the user save to fail' do - expect(user.update_attributes(username: new_username)).to be_falsey + expect(user.update(username: new_username)).to be_falsey expect(user.namespace.errors.messages[:path].first).to eq('has already been taken') end it 'adds the namespace errors to the user' do - user.update_attributes(username: new_username) + user.update(username: new_username) expect(user.errors.full_messages.first).to eq('Username has already been taken') end @@ -2496,7 +2496,7 @@ describe User do context 'when the username is not changed' do it 'does not change the namespace' do expect do - user.update_attributes!(email: 'asdf@asdf.com') + user.update!(email: 'asdf@asdf.com') end.not_to change { user.namespace.updated_at } end end @@ -2526,7 +2526,7 @@ describe User do expect(system_hook_service).to receive(:execute_hooks_for).with(user, :rename) expect(user).to receive(:system_hook_service).and_return(system_hook_service) - user.update_attributes!(username: new_username) + user.update!(username: new_username) end end @@ -2534,7 +2534,7 @@ describe User do it 'does not trigger system hook' do expect(user).not_to receive(:system_hook_service) - user.update_attributes!(email: 'asdf@asdf.com') + user.update!(email: 'asdf@asdf.com') end end end diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb index 24389f28b21..ffca7ab8e45 100644 --- a/spec/requests/api/access_requests_spec.rb +++ b/spec/requests/api/access_requests_spec.rb @@ -88,7 +88,7 @@ describe API::AccessRequests do context 'when authenticated as a stranger' do context "when access request is disabled for the #{source_type}" do before do - source.update_attributes(request_access_enabled: false) + source.update(request_access_enabled: false) end it 'returns 403' do diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index d8a51f36dba..0a789d58fd8 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -201,7 +201,7 @@ describe API::Helpers do end it 'does not allow expired tokens' do - personal_access_token.update_attributes!(expires_at: 1.day.ago) + personal_access_token.update!(expires_at: 1.day.ago) env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token expect { current_user }.to raise_error Gitlab::Auth::ExpiredError diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index dd568c24c72..f4cf5bd0530 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -71,7 +71,7 @@ describe API::Notes do context "issue is confidential" do before do - ext_issue.update_attributes(confidential: true) + ext_issue.update(confidential: true) end it "returns 404" do @@ -104,7 +104,7 @@ describe API::Notes do context "when issue is confidential" do before do - issue.update_attributes(confidential: true) + issue.update(confidential: true) end it "returns 404" do diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 91d4d5d3de9..173f2a0dea0 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -22,7 +22,7 @@ describe API::PipelineSchedules do .each do |pipeline_schedule| create(:user).tap do |user| project.add_developer(user) - pipeline_schedule.update_attributes(owner: user) + pipeline_schedule.update(owner: user) end pipeline_schedule.pipelines << build(:ci_pipeline, project: project) end diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 97dffdc9233..24b7835abf5 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -157,7 +157,7 @@ describe API::ProjectImport do it 'returns the import status and the error if failed' do project = create(:project, :import_failed) project.add_master(user) - project.import_state.update_attributes(last_error: 'error') + project.import_state.update(last_error: 'error') get api("/projects/#{project.id}/import", user) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index abf9ad738bd..de540ba7a10 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -312,7 +312,7 @@ describe API::Projects do before do project_member - user3.update_attributes(starred_projects: [project, project2, project3, public_project]) + user3.update(starred_projects: [project, project2, project3, public_project]) end it 'returns the starred projects viewable by the user' do @@ -333,7 +333,7 @@ describe API::Projects do let!(:project9) { create(:project, :public, path: 'gitlab9') } before do - user.update_attributes(starred_projects: [project5, project7, project8, project9]) + user.update(starred_projects: [project5, project7, project8, project9]) end context 'including owned filter' do @@ -1451,7 +1451,7 @@ describe API::Projects do end it 'updates visibility_level from public to private' do - project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) + project3.update({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) project_param = { visibility: 'private' } put api("/projects/#{project3.id}", user), project_param diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 969710d6613..8df08dd1818 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -109,7 +109,7 @@ describe API::Tags do before do release = project.releases.find_or_initialize_by(tag: tag_name) - release.update_attributes(description: description) + release.update(description: description) end it 'returns an array of project tags with release info' do @@ -400,7 +400,7 @@ describe API::Tags do context 'on tag with existing release' do before do release = project.releases.find_or_initialize_by(tag: tag_name) - release.update_attributes(description: description) + release.update(description: description) end it 'returns 409 if there is already a release' do @@ -422,7 +422,7 @@ describe API::Tags do context 'on tag with existing release' do before do release = project.releases.find_or_initialize_by(tag: tag_name) - release.update_attributes(description: description) + release.update(description: description) end it 'updates the release description' do diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index decb5d22f59..4197277719f 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -49,7 +49,7 @@ describe Ci::RetryBuildService do # Make sure that build has both `stage_id` and `stage` because FactoryBot # can reset one of the fields when assigning another. We plan to deprecate # and remove legacy `stage` column in the future. - build.update_attributes(stage: 'test', stage_id: stage.id) + build.update(stage: 'test', stage_id: stage.id) end describe 'clone accessors' do diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 158541d36e3..4cbf1a52e29 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -501,7 +501,7 @@ describe Issues::UpdateService, :mailer do let(:params) { { label_ids: [], remove_label_ids: [label.id] } } before do - issue.update_attributes(labels: [label, label3]) + issue.update(labels: [label, label3]) end it 'ignores the label_ids parameter' do @@ -517,7 +517,7 @@ describe Issues::UpdateService, :mailer do let(:params) { { add_label_ids: [label3.id], remove_label_ids: [label.id] } } before do - issue.update_attributes(labels: [label]) + issue.update(labels: [label]) end it 'adds the passed labels' do diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index 36b6e5a701e..b4e9f6af43a 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -142,8 +142,8 @@ describe Members::DestroyService do context 'with an access requester' do before do - group_project.update_attributes(request_access_enabled: true) - group.update_attributes(request_access_enabled: true) + group_project.update(request_access_enabled: true) + group.update(request_access_enabled: true) group_project.request_access(member_user) group.request_access(member_user) end diff --git a/spec/services/merge_requests/conflicts/list_service_spec.rb b/spec/services/merge_requests/conflicts/list_service_spec.rb index 97da8a88660..a5520e7373e 100644 --- a/spec/services/merge_requests/conflicts/list_service_spec.rb +++ b/spec/services/merge_requests/conflicts/list_service_spec.rb @@ -34,7 +34,7 @@ describe MergeRequests::Conflicts::ListService do it 'returns a falsey value when the MR does not support new diff notes' do merge_request = create_merge_request('conflict-resolvable') - merge_request.merge_request_diff.update_attributes(start_commit_sha: nil) + merge_request.merge_request_diff.update(start_commit_sha: nil) expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index ef2738ef504..33eea2cf5c3 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -63,7 +63,7 @@ describe MergeRequests::MergeService do let(:commit) { double('commit', safe_message: "Fixes #{jira_issue.to_reference}") } before do - project.update_attributes!(has_external_issue_tracker: true) + project.update!(has_external_issue_tracker: true) jira_service_settings stub_jira_urls(jira_issue.id) allow(merge_request).to receive(:commits).and_return([commit]) diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 0eadc83bfe3..ab91176737d 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -1314,7 +1314,7 @@ describe NotificationService, :mailer do describe 'when merge_when_pipeline_succeeds is true' do before do - merge_request.update_attributes( + merge_request.update( merge_when_pipeline_succeeds: true, merge_user: create(:user) ) diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index c15f5120b8a..f89f9b54f53 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -135,7 +135,7 @@ describe Projects::ForkService do context "when project has restricted visibility level" do context "and only one visibility level is restricted" do before do - @from_project.update_attributes(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + @from_project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL) stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL]) end diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb index 1bffeee6790..a4c103e6f30 100644 --- a/spec/services/projects/update_pages_service_spec.rb +++ b/spec/services/projects/update_pages_service_spec.rb @@ -24,8 +24,8 @@ describe Projects::UpdatePagesService do let(:extension) { 'zip' } before do - build.update_attributes(legacy_artifacts_file: file) - build.update_attributes(legacy_artifacts_metadata: metadata) + build.update(legacy_artifacts_file: file) + build.update(legacy_artifacts_metadata: metadata) end describe 'pages artifacts' do @@ -62,13 +62,13 @@ describe Projects::UpdatePagesService do end it 'fails if sha on branch is not latest' do - build.update_attributes(ref: 'feature') + build.update(ref: 'feature') expect(execute).not_to eq(:success) end it 'fails for empty file fails' do - build.update_attributes(legacy_artifacts_file: empty_file) + build.update(legacy_artifacts_file: empty_file) expect { execute } .to raise_error(Projects::UpdatePagesService::FailedToExtractError) @@ -118,7 +118,7 @@ describe Projects::UpdatePagesService do end it 'fails if sha on branch is not latest' do - build.update_attributes(ref: 'feature') + build.update(ref: 'feature') expect(execute).not_to eq(:success) end @@ -188,7 +188,7 @@ describe Projects::UpdatePagesService do end it 'fails for invalid archive' do - build.update_attributes(legacy_artifacts_file: invalid_file) + build.update(legacy_artifacts_file: invalid_file) expect(execute).not_to eq(:success) end @@ -199,8 +199,8 @@ describe Projects::UpdatePagesService do file = fixture_file_upload('spec/fixtures/pages.zip') metafile = fixture_file_upload('spec/fixtures/pages.zip.meta') - build.update_attributes(legacy_artifacts_file: file) - build.update_attributes(legacy_artifacts_metadata: metafile) + build.update(legacy_artifacts_file: file) + build.update(legacy_artifacts_metadata: metafile) allow(build).to receive(:artifacts_metadata_entry) .and_return(metadata) diff --git a/spec/services/reset_project_cache_service_spec.rb b/spec/services/reset_project_cache_service_spec.rb index de475d16586..1490ad5fe3b 100644 --- a/spec/services/reset_project_cache_service_spec.rb +++ b/spec/services/reset_project_cache_service_spec.rb @@ -18,7 +18,7 @@ describe ResetProjectCacheService do context 'when project cache_index is a numeric value' do before do - project.update_attributes(jobs_cache_index: 1) + project.update(jobs_cache_index: 1) end it 'increments project cache index' do diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index 51396d34f8f..e0335880e8e 100644 --- a/spec/services/system_hooks_service_spec.rb +++ b/spec/services/system_hooks_service_spec.rb @@ -75,7 +75,7 @@ describe SystemHooksService do end it 'handles nil datetime columns' do - user.update_attributes(created_at: nil, updated_at: nil) + user.update(created_at: nil, updated_at: nil) data = event_data(user, :destroy) expect(data[:created_at]).to be(nil) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 46ec1bcef24..bd564cc60a6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,7 @@ SimpleCovEnv.start! ENV["RAILS_ENV"] = 'test' ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true' -require File.expand_path("../../config/environment", __FILE__) +require File.expand_path('../config/environment', __dir__) require 'rspec/rails' require 'shoulda/matchers' require 'rspec/retry' diff --git a/spec/support/api/repositories_shared_context.rb b/spec/support/api/repositories_shared_context.rb index ea38fe4f5b8..f1341804e56 100644 --- a/spec/support/api/repositories_shared_context.rb +++ b/spec/support/api/repositories_shared_context.rb @@ -1,6 +1,6 @@ shared_context 'disabled repository' do before do - project.project_feature.update_attributes!( + project.project_feature.update!( repository_access_level: ProjectFeature::DISABLED, merge_requests_access_level: ProjectFeature::DISABLED, builds_access_level: ProjectFeature::DISABLED diff --git a/spec/support/api/time_tracking_shared_examples.rb b/spec/support/api/time_tracking_shared_examples.rb index 52e1bc55191..fee464c15a3 100644 --- a/spec/support/api/time_tracking_shared_examples.rb +++ b/spec/support/api/time_tracking_shared_examples.rb @@ -85,7 +85,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'subtracts time of the total spent time' do Timecop.travel(1.minute.from_now) do expect do - issuable.update_attributes!(spend_time: { duration: 7200, user_id: user.id }) + issuable.update!(spend_time: { duration: 7200, user_id: user.id }) end.to change { issuable.reload.updated_at } end @@ -99,7 +99,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| context 'when time to subtract is greater than the total spent time' do it 'does not modify the total time spent' do - issuable.update_attributes!(spend_time: { duration: 7200, user_id: user.id }) + issuable.update!(spend_time: { duration: 7200, user_id: user.id }) Timecop.travel(1.minute.from_now) do expect do @@ -135,8 +135,8 @@ shared_examples 'time tracking endpoints' do |issuable_name| describe "GET /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/time_stats" do it "returns the time stats for #{issuable_name}" do - issuable.update_attributes!(spend_time: { duration: 1800, user_id: user.id }, - time_estimate: 3600) + issuable.update!(spend_time: { duration: 1800, user_id: user.id }, + time_estimate: 3600) get api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_stats", user) diff --git a/spec/support/generate-seed-repo-rb b/spec/support/generate-seed-repo-rb index 44b3de23b99..bee9d419376 100755 --- a/spec/support/generate-seed-repo-rb +++ b/spec/support/generate-seed-repo-rb @@ -15,7 +15,7 @@ require 'erb' require 'tempfile' -SOURCE = File.expand_path('../gitlab-git-test.git', __FILE__).freeze +SOURCE = File.expand_path('gitlab-git-test.git', __dir__).freeze SCRIPT_NAME = 'generate-seed-repo-rb'.freeze REPO_NAME = 'gitlab-git-test.git'.freeze diff --git a/spec/support/helpers/jira_service_helper.rb b/spec/support/helpers/jira_service_helper.rb index 88a7aeba461..f4d5343c4ed 100644 --- a/spec/support/helpers/jira_service_helper.rb +++ b/spec/support/helpers/jira_service_helper.rb @@ -12,7 +12,7 @@ module JiraServiceHelper jira_issue_transition_id: '1' } - jira_tracker.update_attributes(properties: properties, active: true) + jira_tracker.update(properties: properties, active: true) end def jira_issue_comments diff --git a/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb b/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb index 7c34c7b4977..940c24c8d67 100644 --- a/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb +++ b/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb @@ -130,7 +130,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do context "event channels" do it "uses the right channel for push event" do - chat_service.update_attributes(push_channel: "random") + chat_service.update(push_channel: "random") expect(Slack::Notifier).to receive(:new) .with(webhook_url, channel: "random") @@ -142,7 +142,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it "uses the right channel for merge request event" do - chat_service.update_attributes(merge_request_channel: "random") + chat_service.update(merge_request_channel: "random") expect(Slack::Notifier).to receive(:new) .with(webhook_url, channel: "random") @@ -154,7 +154,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it "uses the right channel for issue event" do - chat_service.update_attributes(issue_channel: "random") + chat_service.update(issue_channel: "random") expect(Slack::Notifier).to receive(:new) .with(webhook_url, channel: "random") @@ -169,7 +169,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do let(:issue_service_options) { { title: 'Secret', confidential: true } } it "uses confidential issue channel" do - chat_service.update_attributes(confidential_issue_channel: 'confidential') + chat_service.update(confidential_issue_channel: 'confidential') expect(Slack::Notifier).to execute_with_options(channel: 'confidential') @@ -177,7 +177,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it 'falls back to issue channel' do - chat_service.update_attributes(issue_channel: 'fallback_channel') + chat_service.update(issue_channel: 'fallback_channel') expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel') @@ -186,7 +186,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it "uses the right channel for wiki event" do - chat_service.update_attributes(wiki_page_channel: "random") + chat_service.update(wiki_page_channel: "random") expect(Slack::Notifier).to receive(:new) .with(webhook_url, channel: "random") @@ -203,7 +203,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it "uses the right channel" do - chat_service.update_attributes(note_channel: "random") + chat_service.update(note_channel: "random") note_data = Gitlab::DataBuilder::Note.build(issue_note, user) @@ -222,7 +222,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it "uses confidential channel" do - chat_service.update_attributes(confidential_note_channel: "confidential") + chat_service.update(confidential_note_channel: "confidential") note_data = Gitlab::DataBuilder::Note.build(issue_note, user) @@ -232,7 +232,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do end it 'falls back to note channel' do - chat_service.update_attributes(note_channel: "fallback_channel") + chat_service.update(note_channel: "fallback_channel") note_data = Gitlab::DataBuilder::Note.build(issue_note, user) diff --git a/spec/views/projects/imports/new.html.haml_spec.rb b/spec/views/projects/imports/new.html.haml_spec.rb index 32d73d0c5ab..fc389641fcd 100644 --- a/spec/views/projects/imports/new.html.haml_spec.rb +++ b/spec/views/projects/imports/new.html.haml_spec.rb @@ -7,7 +7,7 @@ describe "projects/imports/new.html.haml" do let(:project) { create(:project_empty_repo, :import_failed, import_type: :gitlab_project, import_source: '/var/opt/gitlab/gitlab-rails/shared/tmp/project_exports/uploads/t.tar.gz', import_url: nil) } before do - project.import_state.update_attributes(last_error: '<a href="http://googl.com">Foo</a>') + project.import_state.update(last_error: '<a href="http://googl.com">Foo</a>') sign_in(user) project.add_master(user) end diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb index 264e0ce0b40..fe6ad26a6f6 100644 --- a/spec/views/projects/merge_requests/show.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb @@ -52,7 +52,7 @@ describe 'projects/merge_requests/show.html.haml' do context 'when the merge request is open' do it 'closes the merge request if the source project does not exist' do - closed_merge_request.update_attributes(state: 'open') + closed_merge_request.update(state: 'open') forked_project.destroy # Reload merge request so MergeRequest#source_project turns to `nil` closed_merge_request.reload diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index f0884ad0aff..d07e40377d4 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -51,7 +51,7 @@ describe RepositoryImportWorker do it 'hide the credentials that were used in the import URL' do error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } - project.update_attributes(import_jid: '123') + project.update(import_jid: '123') expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error }) expect do @@ -63,7 +63,7 @@ describe RepositoryImportWorker do it 'updates the error on Import/Export' do error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } - project.update_attributes(import_jid: '123', import_type: 'gitlab_project') + project.update(import_jid: '123', import_type: 'gitlab_project') expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error }) expect do diff --git a/spec/workers/repository_update_remote_mirror_worker_spec.rb b/spec/workers/repository_update_remote_mirror_worker_spec.rb index 152ba2509b9..4f1ad2474f5 100644 --- a/spec/workers/repository_update_remote_mirror_worker_spec.rb +++ b/spec/workers/repository_update_remote_mirror_worker_spec.rb @@ -13,7 +13,7 @@ describe RepositoryUpdateRemoteMirrorWorker do describe '#perform' do context 'with status none' do before do - remote_mirror.update_attributes(update_status: 'none') + remote_mirror.update(update_status: 'none') end it 'sets status as finished when update remote mirror service executes successfully' do @@ -34,7 +34,7 @@ describe RepositoryUpdateRemoteMirrorWorker do end it 'does nothing if last_update_started_at is higher than the time the job was scheduled in' do - remote_mirror.update_attributes(last_update_started_at: Time.now) + remote_mirror.update(last_update_started_at: Time.now) expect_any_instance_of(RemoteMirror).to receive(:updated_since?).with(scheduled_time).and_return(true) expect_any_instance_of(Projects::UpdateRemoteMirrorService).not_to receive(:execute).with(remote_mirror) @@ -56,7 +56,7 @@ describe RepositoryUpdateRemoteMirrorWorker do context 'with another worker already running' do before do - remote_mirror.update_attributes(update_status: 'started') + remote_mirror.update(update_status: 'started') end it 'raises RemoteMirrorUpdateAlreadyInProgressError' do @@ -68,11 +68,11 @@ describe RepositoryUpdateRemoteMirrorWorker do context 'with status failed' do before do - remote_mirror.update_attributes(update_status: 'failed') + remote_mirror.update(update_status: 'failed') end it 'sets status as finished if last_update_started_at is higher than the time the job was scheduled in' do - remote_mirror.update_attributes(last_update_started_at: Time.now) + remote_mirror.update(last_update_started_at: Time.now) expect_any_instance_of(RemoteMirror).to receive(:updated_since?).with(scheduled_time).and_return(false) expect_any_instance_of(Projects::UpdateRemoteMirrorService).to receive(:execute).with(remote_mirror).and_return(status: :success) diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb index af7675c8cab..2169c14218b 100644 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -51,7 +51,7 @@ describe StuckImportJobsWorker do let(:project) { create(:project, :import_scheduled) } before do - project.import_state.update_attributes(jid: '123') + project.import_state.update(jid: '123') end end end @@ -61,7 +61,7 @@ describe StuckImportJobsWorker do let(:project) { create(:project, :import_started) } before do - project.import_state.update_attributes(jid: '123') + project.import_state.update(jid: '123') end end end |