summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-07-02 10:43:06 +0000
committerLin Jen-Shin <godfat@godfat.org>2018-07-09 21:13:08 +0800
commit4ee08b77bc5ae11553d59c182ea8292b77699115 (patch)
tree3aac1871cd8dcefc88d52f11dcacbf238b2340a9 /spec/models
parent612f5e63b3cf76c354e50f4aa6c4163e5465b115 (diff)
downloadgitlab-ce-4ee08b77bc5ae11553d59c182ea8292b77699115.tar.gz
Updates from `rubocop -a`
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/build_metadata_spec.rb2
-rw-r--r--spec/models/ci/build_spec.rb16
-rw-r--r--spec/models/ci/job_artifact_spec.rb2
-rw-r--r--spec/models/concerns/batch_destroy_dependent_associations_spec.rb4
-rw-r--r--spec/models/concerns/mentionable_spec.rb6
-rw-r--r--spec/models/concerns/routable_spec.rb2
-rw-r--r--spec/models/environment_spec.rb2
-rw-r--r--spec/models/group_spec.rb4
-rw-r--r--spec/models/merge_request_spec.rb2
-rw-r--r--spec/models/namespace_spec.rb4
-rw-r--r--spec/models/notification_setting_spec.rb2
-rw-r--r--spec/models/project_feature_spec.rb2
-rw-r--r--spec/models/project_spec.rb18
-rw-r--r--spec/models/remote_mirror_spec.rb8
-rw-r--r--spec/models/route_spec.rb14
-rw-r--r--spec/models/service_spec.rb2
-rw-r--r--spec/models/user_spec.rb38
17 files changed, 64 insertions, 64 deletions
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