Commit abe38ad3 authored by Siddharth Asthana's avatar Siddharth Asthana

Fix Rails/SaveBang offenses

Changelog: other
EE: true
parent 250783d1
......@@ -3,9 +3,6 @@ Rails/SaveBang:
Exclude:
- ee/spec/initializers/fog_google_https_private_urls_spec.rb
- ee/spec/lib/analytics/merge_request_metrics_calculator_spec.rb
- ee/spec/lib/ee/gitlab/auth/ldap/sync/group_spec.rb
- ee/spec/lib/ee/gitlab/checks/push_rules/commit_check_spec.rb
- ee/spec/lib/ee/gitlab/ci/pipeline/quota/activity_spec.rb
- ee/spec/lib/gitlab/auth/ldap/access_spec.rb
- ee/spec/lib/gitlab/auth/o_auth/user_spec.rb
- ee/spec/lib/gitlab/auth/saml/user_spec.rb
......
......@@ -203,7 +203,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
it 'converts an existing membership access request to a real member' do
group.add_owner(create(:user))
access_requester = group.request_access(user)
access_requester.update(access_level: ::Gitlab::Access::MAINTAINER)
access_requester.update!(access_level: ::Gitlab::Access::MAINTAINER)
# Validate that the user is properly created as a requester first.
expect(group.requesters.pluck(:id)).to include(access_requester.id)
......@@ -246,7 +246,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
end
it 'does not alter an ldap member that has a permission override' do
group.members.create(
group.members.create!(
user: user,
access_level: ::Gitlab::Access::MAINTAINER,
ldap: true,
......@@ -316,7 +316,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
let(:ldap_group1) { ldap_group_entry(user_dn(user.username)) }
before do
group.update(parent: parent_group)
group.update!(parent: parent_group)
parent_group.add_maintainer(user)
end
......@@ -337,7 +337,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
end
it "does not alter an ldap member that has a permission override" do
group.members.create(
group.members.create!(
user: user,
access_level: ::Gitlab::Access::OWNER,
ldap: true,
......@@ -356,7 +356,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
let(:ldap_group1) { ldap_group_entry(user_dn(user.username)) }
before do
group.update(parent: parent_group)
group.update!(parent: parent_group)
parent_group.add_reporter(user)
end
......@@ -377,7 +377,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
end
it "does not alter an ldap member that has a permission override" do
group.members.create(
group.members.create!(
user: user,
access_level: ::Gitlab::Access::OWNER,
ldap: true,
......@@ -397,17 +397,17 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
let(:access_requester) { parent_group.request_access(user) }
before do
group.update(parent: parent_group)
group.update!(parent: parent_group)
parent_group.add_owner(create(:user))
end
it 'does not propagate the access level of the pending access request' do
group.members.create(
group.members.create!(
user: user,
access_level: ::Gitlab::Access::DEVELOPER,
ldap: true
)
access_requester.update(access_level: ::Gitlab::Access::MAINTAINER)
access_requester.update!(access_level: ::Gitlab::Access::MAINTAINER)
sync_group.update_permissions
......@@ -423,7 +423,7 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
let(:ldap_group1) { ldap_group_entry(user_dn('other_user')) }
before do
group.update(parent: parent_group)
group.update!(parent: parent_group)
parent_group.add_maintainer(user)
end
......@@ -445,13 +445,13 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
before do
group1.add_reporter(user)
group2.update(parent: group1)
group2.update!(parent: group1)
group2.add_maintainer(user)
group3.update(parent: group2)
group3.update!(parent: group2)
# no specific permission for user in group3
group.update(parent: group3)
group.update!(parent: group3)
end
it "applies the permission inherited from the closest ancestor when it's higher" do
......@@ -478,13 +478,13 @@ RSpec.describe EE::Gitlab::Auth::Ldap::Sync::Group do
it 'does not revert the overrides' do
create(:identity, user: user1, extern_uid: user_dn(user1.username))
create(:identity, user: user2, extern_uid: user_dn(user2.username).upcase)
group.members.create(
group.members.create!(
user: user1,
access_level: ::Gitlab::Access::MAINTAINER,
ldap: true,
override: true
)
group.members.create(
group.members.create!(
user: user2,
access_level: ::Gitlab::Access::OWNER,
ldap: true,
......
......@@ -205,14 +205,14 @@ RSpec.describe EE::Gitlab::Checks::PushRules::CommitCheck do
end
it 'allows the commit when they were done with another email that belongs to the current user' do
user.emails.create(email: 'secondary_email@user.com', confirmed_at: Time.now)
user.emails.create!(email: 'secondary_email@user.com', confirmed_at: Time.now)
allow_any_instance_of(Commit).to receive(:committer_email).and_return('secondary_email@user.com')
expect { subject.validate! }.not_to raise_error
end
it 'raises an error when the commit was done with an unverified email' do
user.emails.create(email: 'secondary_email@user.com')
user.emails.create!(email: 'secondary_email@user.com')
allow_any_instance_of(Commit).to receive(:committer_email).and_return('secondary_email@user.com')
expect { subject.validate! }
......
......@@ -18,7 +18,7 @@ RSpec.describe EE::Gitlab::Ci::Pipeline::Quota::Activity, :saas do
create(:ci_pipeline, project: project, status: 'pending')
create(:ci_pipeline, project: project, status: 'running')
plan_limits.update(ci_active_pipelines: 1)
plan_limits.update!(ci_active_pipelines: 1)
end
end
......
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