Commit 0d1c0067 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'rails-save-bang-ee-spec-requests' into 'master'

Fix Rails/SaveBang offenses in ee/spec/requests

See merge request gitlab-org/gitlab!58078
parents 3ed62a3b 442bc80f
......@@ -97,26 +97,6 @@ Rails/SaveBang:
- 'ee/spec/models/visible_approvable_spec.rb'
- 'ee/spec/models/vulnerabilities/feedback_spec.rb'
- 'ee/spec/models/vulnerabilities/issue_link_spec.rb'
- 'ee/spec/requests/api/boards_spec.rb'
- 'ee/spec/requests/api/epic_issues_spec.rb'
- 'ee/spec/requests/api/epic_links_spec.rb'
- 'ee/spec/requests/api/epics_spec.rb'
- 'ee/spec/requests/api/geo_nodes_spec.rb'
- 'ee/spec/requests/api/geo_spec.rb'
- 'ee/spec/requests/api/graphql/group/epics_spec.rb'
- 'ee/spec/requests/api/graphql/mutations/epic_tree/reorder_spec.rb'
- 'ee/spec/requests/api/groups_spec.rb'
- 'ee/spec/requests/api/issues_spec.rb'
- 'ee/spec/requests/api/ldap_group_links_spec.rb'
- 'ee/spec/requests/api/merge_request_approval_rules_spec.rb'
- 'ee/spec/requests/api/merge_request_approvals_spec.rb'
- 'ee/spec/requests/api/merge_requests_spec.rb'
- 'ee/spec/requests/api/project_approvals_spec.rb'
- 'ee/spec/requests/api/projects_spec.rb'
- 'ee/spec/requests/api/protected_branches_spec.rb'
- 'ee/spec/requests/api/scim_spec.rb'
- 'ee/spec/requests/api/todos_spec.rb'
- 'ee/spec/requests/lfs_http_spec.rb'
- 'ee/spec/services/approval_rules/finalize_service_spec.rb'
- 'ee/spec/services/approval_rules/update_service_spec.rb'
- 'ee/spec/services/ee/boards/issues/create_service_spec.rb'
......
---
title: Fix Rails/SaveBang rubocop offenses in ee/spec/requests
merge_request: 58078
author: Abdul Wadood @abdulwd
type: fixed
......@@ -33,7 +33,7 @@ RSpec.describe API::Boards do
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}" }
it 'returns board with Upcoming milestone' do
board.update(milestone_id: Milestone::Upcoming.id)
board.update!(milestone_id: Milestone::Upcoming.id)
get api(url, user)
......@@ -41,7 +41,7 @@ RSpec.describe API::Boards do
end
it 'returns board with Started milestone' do
board.update(milestone_id: Milestone::Started.id)
board.update!(milestone_id: Milestone::Started.id)
get api(url, user)
......
......@@ -34,8 +34,8 @@ RSpec.describe API::EpicIssues do
end
it 'returns 404 not found error for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
get api(url, user)
......@@ -112,8 +112,8 @@ RSpec.describe API::EpicIssues do
end
it 'returns 404 not found error for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
post api(url, user)
......@@ -197,8 +197,8 @@ RSpec.describe API::EpicIssues do
end
it 'returns 404 not found error for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
delete api(url, user)
......@@ -282,8 +282,8 @@ RSpec.describe API::EpicIssues do
end
it 'returns 404 not found error for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
put api(url, user)
expect(response).to have_gitlab_http_status(:not_found)
......
......@@ -30,7 +30,7 @@ RSpec.describe API::EpicLinks do
end
it 'returns 404 not found error for a user without permissions to see the group' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject
......
......@@ -27,8 +27,8 @@ RSpec.describe API::Epics do
end
it 'returns 404 not found error for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
get api(url, user), params: params
......@@ -378,7 +378,7 @@ RSpec.describe API::Epics do
let(:parent_group) { create(:group) }
before do
group.update(parent_id: parent_group.id)
group.update!(parent_id: parent_group.id)
end
it 'exposes full reference path' do
......
......@@ -290,7 +290,7 @@ RSpec.describe API::GeoNodes, :request_store, :geo, :prometheus, api: true do
end
it 'enables the secondary node' do
secondary.update(enabled: false)
secondary.update!(enabled: false)
put api("/geo_nodes/#{secondary.id}"), params: { enabled: true }, headers: geo_base_request.headers
......@@ -299,7 +299,7 @@ RSpec.describe API::GeoNodes, :request_store, :geo, :prometheus, api: true do
end
it 'disables the secondary node' do
secondary.update(enabled: true)
secondary.update!(enabled: true)
put api("/geo_nodes/#{secondary.id}"), params: { enabled: false }, headers: geo_base_request.headers
......
......@@ -189,7 +189,7 @@ RSpec.describe API::Geo do
context 'when attachment has mount_point nil' do
it 'responds with 200 with X-Sendfile' do
resource.update(mount_point: nil)
resource.update!(mount_point: nil)
get api("/geo/transfers/attachment/#{resource.id}"), headers: req_header
......@@ -224,7 +224,7 @@ RSpec.describe API::Geo do
context 'avatar has mount_point nil' do
it 'responds with 200 with X-Sendfile' do
resource.update(mount_point: nil)
resource.update!(mount_point: nil)
get api("/geo/transfers/avatar/#{resource.id}"), headers: req_header
......@@ -432,7 +432,7 @@ RSpec.describe API::Geo do
end
it 'ignores invalid attributes upon update' do
GeoNodeStatus.create(data)
GeoNodeStatus.create!(data)
data.merge!(
{
'id' => nil,
......
......@@ -188,7 +188,7 @@ RSpec.describe 'Epics through GroupQuery' do
end.count
epics_with_parent = create_list(:epic, 3, group: group) do |epic|
epic.update(parent: create(:epic, group: group))
epic.update!(parent: create(:epic, group: group))
end
group.reload
......@@ -219,8 +219,8 @@ RSpec.describe 'Epics through GroupQuery' do
end
it 'returns a nil group for a user without permissions to see the group' do
project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
post_graphql(query, current_user: user)
......
......@@ -88,7 +88,7 @@ RSpec.describe 'Updating an epic tree' do
before do
other_epic = create(:epic, group: group)
epic2.update(parent: other_epic)
epic2.update!(parent: other_epic)
end
it 'updates the epics relative positions and updates the parent' do
......@@ -149,7 +149,7 @@ RSpec.describe 'Updating an epic tree' do
before do
stub_licensed_features(epics: true, subepics: false)
other_epic = create(:epic, group: group)
epic2.update(parent: other_epic)
epic2.update!(parent: other_epic)
end
it_behaves_like 'a mutation that does not update the tree'
......@@ -185,7 +185,7 @@ RSpec.describe 'Updating an epic tree' do
before do
other_epic = create(:epic, group: group)
epic_issue2.update(epic: other_epic)
epic_issue2.update!(epic: other_epic)
end
it "updates the epic's relative positions and parent" do
......
......@@ -14,7 +14,7 @@ RSpec.describe API::Groups do
before do
group.add_owner(user)
group.ldap_group_links.create cn: 'ldap-group', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap'
group.ldap_group_links.create! cn: 'ldap-group', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap'
end
shared_examples 'inaccessable by reporter role and lower' do
......@@ -211,7 +211,7 @@ RSpec.describe API::Groups do
context 'when authenticated as the group owner' do
it 'returns 200 if shared_runners_minutes_limit is not changing' do
group.update(shared_runners_minutes_limit: 133)
group.update!(shared_runners_minutes_limit: 133)
expect do
put api("/groups/#{group.id}", user), params: { shared_runners_minutes_limit: 133 }
......
......@@ -47,7 +47,7 @@ RSpec.describe API::Issues, :mailer do
context 'and epic issue is not present' do
it 'exposes epic as nil' do
issue_with_epic.epic_issue.destroy
issue_with_epic.epic_issue.destroy!
subject
......
......@@ -11,10 +11,10 @@ RSpec.describe API::LdapGroupLinks, api: true do
let!(:group_with_ldap_links) do
group = create(:group)
group.ldap_group_links.create cn: 'ldap-group1', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap1'
group.ldap_group_links.create cn: 'ldap-group2', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap2'
group.ldap_group_links.create cn: 'ldap-group3', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap2'
group.ldap_group_links.create filter: '(uid=mary)', group_access: Gitlab::Access::DEVELOPER, provider: 'ldap2'
group.ldap_group_links.create! cn: 'ldap-group1', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap1'
group.ldap_group_links.create! cn: 'ldap-group2', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap2'
group.ldap_group_links.create! cn: 'ldap-group3', group_access: Gitlab::Access::MAINTAINER, provider: 'ldap2'
group.ldap_group_links.create! filter: '(uid=mary)', group_access: Gitlab::Access::DEVELOPER, provider: 'ldap2'
group
end
......
......@@ -83,7 +83,7 @@ RSpec.describe API::MergeRequestApprovalRules do
before do
group.add_developer(approver)
merge_request.approvals.create(user: approver)
merge_request.approvals.create!(user: approver)
get api(url, current_user)
end
......
......@@ -60,7 +60,7 @@ RSpec.describe API::MergeRequestApprovals do
it 'retrieves the approval status' do
project.add_developer(approver)
project.add_developer(create(:user))
merge_request.approvals.create(user: approver)
merge_request.approvals.create!(user: approver)
rule.users << approver
rule.groups << group
......@@ -105,7 +105,7 @@ RSpec.describe API::MergeRequestApprovals do
before do
private_group = create(:group, :private)
private_group.add_developer(create(:user))
merge_request.approver_groups.create(group: private_group)
merge_request.approver_groups.create!(group: private_group)
end
it 'hides private group' do
......@@ -156,7 +156,7 @@ RSpec.describe API::MergeRequestApprovals do
before do
project.add_developer(approver)
merge_request.approvals.create(user: approver)
merge_request.approvals.create!(user: approver)
rule.users << approver
end
......@@ -250,7 +250,7 @@ RSpec.describe API::MergeRequestApprovals do
before do
project.add_developer(approver)
merge_request.approvals.create(user: approver)
merge_request.approvals.create!(user: approver)
rule.users << approver
end
......@@ -276,7 +276,7 @@ RSpec.describe API::MergeRequestApprovals do
shared_examples_for 'user allowed to override approvals_before_merge' do
context 'when disable_overriding_approvers_per_merge_request is false on the project' do
before do
project.update(disable_overriding_approvers_per_merge_request: false)
project.update!(disable_overriding_approvers_per_merge_request: false)
end
it 'allows you to set approvals required' do
......@@ -291,7 +291,7 @@ RSpec.describe API::MergeRequestApprovals do
context 'when disable_overriding_approvers_per_merge_request is true on the project' do
before do
project.update(disable_overriding_approvers_per_merge_request: true)
project.update!(disable_overriding_approvers_per_merge_request: true)
end
it 'does not allow you to set approvals_before_merge' do
......@@ -320,7 +320,7 @@ RSpec.describe API::MergeRequestApprovals do
context 'as a random user' do
before do
project.update(disable_overriding_approvers_per_merge_request: false)
project.update!(disable_overriding_approvers_per_merge_request: false)
end
it 'does not allow you to override approvals required' do
......@@ -403,8 +403,8 @@ RSpec.describe API::MergeRequestApprovals do
context 'when project requires force auth for approval' do
before do
project.update(require_password_to_approve: true)
approver.update(password: 'password')
project.update!(require_password_to_approve: true)
approver.update!(password: 'password')
end
it 'does not approve the merge request with no password' do
......@@ -431,7 +431,7 @@ RSpec.describe API::MergeRequestApprovals do
it 'only shows group approvers visible to the user' do
private_group = create(:group, :private)
merge_request.approver_groups.create(group: private_group)
merge_request.approver_groups.create!(group: private_group)
approve
......@@ -452,8 +452,8 @@ RSpec.describe API::MergeRequestApprovals do
project.add_developer(approver)
project.add_developer(unapprover)
project.add_developer(create(:user))
merge_request.approvals.create(user: approver)
merge_request.approvals.create(user: unapprover)
merge_request.approvals.create!(user: approver)
merge_request.approvals.create!(user: unapprover)
rule.users = [approver, unapprover]
end
......@@ -473,7 +473,7 @@ RSpec.describe API::MergeRequestApprovals do
it 'only shows group approvers visible to the user' do
private_group = create(:group, :private)
merge_request.approver_groups.create(group: private_group)
merge_request.approver_groups.create!(group: private_group)
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unapprove", unapprover)
......
......@@ -145,7 +145,7 @@ RSpec.describe API::MergeRequests do
context 'the approvals_before_merge param' do
context 'when the target project has disable_overriding_approvers_per_merge_request set to true' do
before do
project.update(disable_overriding_approvers_per_merge_request: true)
project.update!(disable_overriding_approvers_per_merge_request: true)
create_merge_request(approvals_before_merge: 1)
end
......@@ -156,7 +156,7 @@ RSpec.describe API::MergeRequests do
context 'when the target project has disable_overriding_approvers_per_merge_request set to false' do
before do
project.update(approvals_before_merge: 0)
project.update!(approvals_before_merge: 0)
create_merge_request(approvals_before_merge: 1)
end
......@@ -173,7 +173,7 @@ RSpec.describe API::MergeRequests do
describe "PUT /projects/:id/merge_requests/:merge_request_iid/merge" do
it 'returns 405 if merge request was not approved' do
project.add_developer(create(:user))
project.update(approvals_before_merge: 1)
project.update!(approvals_before_merge: 1)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
......@@ -184,8 +184,8 @@ RSpec.describe API::MergeRequests do
it 'returns 200 if merge request was approved' do
approver = create(:user)
project.add_developer(approver)
project.update(approvals_before_merge: 1)
merge_request.approvals.create(user: approver)
project.update!(approvals_before_merge: 1)
merge_request.approvals.create!(user: approver)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
......
......@@ -77,7 +77,7 @@ RSpec.describe API::ProjectApprovals do
project.merge_requests_author_approval = false
project.merge_requests_disable_committers_approval = true
project.require_password_to_approve = false
project.save
project.save!
settings = {
approvals_before_merge: 4,
......@@ -95,7 +95,7 @@ RSpec.describe API::ProjectApprovals do
it 'only shows approver groups that are visible to the current user' do
private_group = create(:group, :private)
project.approver_groups.create(group: private_group)
project.approver_groups.create!(group: private_group)
post api(url, current_user), params: { approvals_before_merge: 3 }
......
......@@ -171,7 +171,7 @@ RSpec.describe API::Projects do
before do
create(:ip_restriction, group: group)
group.add_maintainer(user)
project.update(namespace: group)
project.update!(namespace: group)
end
context 'when the group_ip_restriction feature is not available' do
......@@ -1019,7 +1019,7 @@ RSpec.describe API::Projects do
end
it 'restores project' do
project.update(archived: true, marked_for_deletion_at: 1.day.ago, deleting_user: user)
project.update!(archived: true, marked_for_deletion_at: 1.day.ago, deleting_user: user)
post api("/projects/#{project.id}/restore", user)
......@@ -1088,7 +1088,7 @@ RSpec.describe API::Projects do
let(:group) { create(:group) }
before do
group.namespace_settings.update(delayed_project_removal: true)
group.namespace_settings.update!(delayed_project_removal: true)
end
it_behaves_like 'marks project for deletion'
......
......@@ -29,8 +29,8 @@ RSpec.describe API::ProtectedBranches do
before do
project.add_developer(push_user)
project.project_group_links.create(group: merge_group)
project.project_group_links.create(group: unprotect_group)
project.project_group_links.create!(group: merge_group)
project.project_group_links.create!(group: unprotect_group)
protected_branch.push_access_levels.create!(user: push_user)
protected_branch.merge_access_levels.create!(group: merge_group)
protected_branch.unprotect_access_levels.create!(group: unprotect_group)
......
......@@ -362,7 +362,7 @@ RSpec.describe API::Scim do
let_it_be(:params) { { Operations: [{ 'op': 'Replace', 'path': 'active', 'value': 'true' }] }.to_query }
it 'activates the scim_identity' do
identity.update(active: false)
identity.update!(active: false)
call_patch_api(params)
......
......@@ -106,7 +106,7 @@ RSpec.describe API::Todos do
end
it 'returns an error if the epic is not accessible' do
group.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
subject
......
......@@ -178,7 +178,7 @@ RSpec.describe 'Git LFS API and storage' do
let(:authorization) { authorize_deploy_key }
before do
project.deploy_keys_projects.create(deploy_key: key, can_push: true)
project.deploy_keys_projects.create!(deploy_key: key, can_push: true)
end
it_behaves_like 'pushes new LFS objects'
......
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