Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

rubocop

Markus Kahl96e7f858c945
diff --git a/app/models/group_user.rb b/app/models/group_user.rb
index 96b9bc8c1ee..cadad828c54 100644
--- a/app/models/group_user.rb
+++ b/app/models/group_user.rb
@@ -33,6 +33,6 @@ class GroupUser < ApplicationRecord
touch: true
belongs_to :user
- validates_presence_of :group
- validates_presence_of :user
+ validates :group, presence: true
+ validates :user, presence: true
end
diff --git a/modules/ldap_groups/spec/services/synchronize_filter_spec.rb b/modules/ldap_groups/spec/services/synchronize_filter_spec.rb
index 4c3176f2e78..8ce7f249a5f 100644
--- a/modules/ldap_groups/spec/services/synchronize_filter_spec.rb
+++ b/modules/ldap_groups/spec/services/synchronize_filter_spec.rb
@@ -28,12 +28,20 @@ describe LdapGroups::SynchronizeFilterService, with_ee: %i[ldap_groups] do
let(:group_bar) { FactoryBot.create :group, lastname: 'bar' }
let(:synced_foo) do
- FactoryBot.create :ldap_synchronized_group, dn: 'cn=foo,ou=groups,dc=example,dc=com', group: group_foo,
- auth_source: auth_source
+ FactoryBot.create(
+ :ldap_synchronized_group,
+ dn: 'cn=foo,ou=groups,dc=example,dc=com',
+ group: group_foo,
+ auth_source: auth_source
+ )
end
let(:synced_bar) do
- FactoryBot.create :ldap_synchronized_group, dn: 'cn=bar,ou=groups,dc=example,dc=com', group: group_bar,
- auth_source: auth_source
+ FactoryBot.create(
+ :ldap_synchronized_group,
+ dn: 'cn=bar,ou=groups,dc=example,dc=com',
+ group: group_bar,
+ auth_source: auth_source
+ )
end
let(:filter_foo_bar) { FactoryBot.create :ldap_synchronized_filter, auth_source: auth_source }
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 2c786338c29..86adcc7891b 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -73,7 +73,7 @@ describe Group, type: :model do
describe '#group_users' do
context 'when adding a user' do
- context 'which does not exist' do
+ context 'if it does not exist' do
it 'does not create a group user' do
count = group.group_users.count
gu = group.group_users.create user_id: User.maximum(:id).to_i + 1
diff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
index 832d72fd703..00946f95489 100644
--- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
+++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
@@ -58,7 +58,7 @@ shared_examples 'it supports direct uploads' do
request!
end
- it 'should respond with validation error' do
+ it 'responds with a validation error' do
expect(subject.status).to eq(422)
end
@@ -76,7 +76,7 @@ shared_examples 'it supports direct uploads' do
let(:metadata) { { fileName: 'cat.png' } }
let(:json) { JSON.parse subject.body }
- it 'should respond with 422 due to missing file size metadata' do
+ it 'responds with 422 due to missing file size metadata' do
expect(subject.status).to eq(422)
expect(subject.body).to include 'Size'
end
@@ -89,7 +89,7 @@ shared_examples 'it supports direct uploads' do
context 'with the correct parameters' do
let(:json) { JSON.parse subject.body }
- it 'should prepare a direct upload' do
+ it 'prepares a direct upload' do
expect(subject.status).to eq 201
expect(json["_type"]).to eq "AttachmentUpload"
@@ -117,15 +117,15 @@ shared_examples 'it supports direct uploads' do
expect(link).to be_present
end
- it 'should point to AWS' do
+ it 'points to AWS' do
expect(link["href"]).to eq "https://#{MockCarrierwave.bucket}.s3.amazonaws.com/"
end
- it 'should have the method POST' do
+ it 'has the method POST' do
expect(link["method"]).to eq "post"
end
- it 'should include form fields' do
+ it 'includes form fields' do
fields = link["form_fields"]
expect(fields).to be_present
@@ -140,7 +140,7 @@ shared_examples 'it supports direct uploads' do
expect(fields["key"]).to end_with "cat.png"
end
- it 'should also include the content type and the necessary policy in the form fields' do
+ it 'also includes the content type and the necessary policy in the form fields' do
fields = link["form_fields"]
expect(fields).to include("policy", "Content-Type")
@@ -159,7 +159,7 @@ shared_examples 'it supports direct uploads' do
context 'with an allowed content type' do
let(:metadata) { { fileName: 'cats.csv', fileSize: file.size, contentType: 'text/csv' } }
- it 'should succeed' do
+ it 'succeeds' do
expect(subject.status).to eq 201
end
end
@@ -167,7 +167,7 @@ shared_examples 'it supports direct uploads' do
context 'with a forbidden content type' do
let(:metadata) { { fileName: 'cats.txt', fileSize: file.size, contentType: 'text/plain' } }
- it 'should fail' do
+ it 'fails' do
expect(subject.status).to eq 422
expect(subject.body).to include "not whitelisted"
end
@@ -176,8 +176,8 @@ shared_examples 'it supports direct uploads' do
context 'with a non-specific content type not on the whitelist' do
let(:metadata) { { fileName: 'cats.bin', fileSize: file.size, contentType: 'application/binary' } }
- # the actual whitelist check will be performed in the FinishDirectUpload job in this case
- it 'should still succeed' do
+ # the actual whitelist check will be performed in the FinishDirectUpload job in this case
+ it 'still succeeds' do
expect(subject.status).to eq 201
end
end
@@ -233,11 +233,11 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
get get_path
end
- it 'should respond with 200' do
+ it 'responds with 200' do
expect(subject.status).to eq(200)
end
- it 'should respond with correct attachment' do
+ it 'responds with correct attachment' do
expect(subject.body).to be_json_eql(attachment.filename.to_json).at_path('fileName')
end
@@ -272,11 +272,11 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
subject(:response) { last_response }
- it 'should respond with HTTP Created' do
+ it 'responds with HTTP Created' do
expect(subject.status).to eq(201)
end
- it 'should return the new attachment without container' do
+ it 'returns the new attachment without container' do
expect(subject.body).to be_json_eql('Attachment'.to_json).at_path('_type')
expect(subject.body).to be_json_eql(nil.to_json).at_path('_links/container/href')
end
@@ -539,7 +539,7 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
get get_path
end
- it 'should respond with 200' do
+ it 'responds with 200' do
expect(subject.status).to eq(200)
end
@@ -558,11 +558,11 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
post request_path, request_parts
end
- it 'should respond with HTTP Created' do
+ it 'responds with HTTP Created' do
expect(subject.status).to eq(201)
end
- it 'should return the new attachment' do
+ it 'returns the new attachment' do
expect(subject.body).to be_json_eql('Attachment'.to_json).at_path('_type')
end