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

cleanup and linting

ulfertsf8075eaf9ebe
diff --git a/app/views/roles/_form.html.erb b/app/views/roles/_form.html.erb
index 0ece471765b..68160845db9 100644
--- a/app/views/roles/_form.html.erb
+++ b/app/views/roles/_form.html.erb
@@ -58,11 +58,13 @@ See COPYRIGHT and LICENSE files for more details.
<% if role.new_record? || role.is_a?(GlobalRole) %>
<div id="global_permissions" style=<%= role.new_record? && !role.is_a?(GlobalRole) ? "display:none" : ""%> >
- <%= render partial: "permissions", locals: {permissions: grouped_setable_permissions(GlobalRole.new), role: role, showGlobalRole: true }%>
+ <%= render partial: "permissions",
+ locals: { permissions: grouped_setable_permissions(GlobalRole.new), role: role, show_global_role: true }%>
</div>
<% end %>
<% if role.new_record? || !role.is_a?(GlobalRole) %>
<div id="member_permissions" style=<%= role.new_record? && role.is_a?(GlobalRole) ? "display:none" : ""%>>
- <%= render partial: "permissions", locals: {permissions: grouped_setable_permissions(role), role: role, showGlobalRole: false }%>
+ <%= render partial: "permissions",
+ locals: { permissions: grouped_setable_permissions(role), role: role, show_global_role: false }%>
</div>
<% end %>
diff --git a/app/views/roles/_permissions.html.erb b/app/views/roles/_permissions.html.erb
index 8199b8cdc0f..a0bc20c92e6 100644
--- a/app/views/roles/_permissions.html.erb
+++ b/app/views/roles/_permissions.html.erb
@@ -28,12 +28,12 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<% permissions.each do |mod, mod_permissions| %>
- <% global_prefix = showGlobalRole ? 'fieldset--global--' : 'fieldset--' %>
+ <% global_prefix = show_global_role ? 'fieldset--global--' : 'fieldset--' %>
<% module_name = mod.blank? ? 'fieldset--global--' + Project.model_name.human.downcase.gsub(' ', '_') : global_prefix + l_or_humanize(mod, prefix: 'project_module_').downcase.gsub(' ', '_') %>
<fieldset class="form--fieldset -collapsible" id="<%= module_name %>">
<legend class="form--fieldset-legend">
<% if mod.blank? %>
- <%= showGlobalRole ? t(:label_global) : Project.model_name.human %>
+ <%= show_global_role ? t(:label_global) : Project.model_name.human %>
<% else %>
<%= l_or_humanize(mod, prefix: 'project_module_') %>
<% end %>
@@ -48,7 +48,9 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field">
<div class="form--field-container">
<label class="form--label-with-check-box">
- <%= styled_check_box_tag 'role[permissions][]', permission.name, (role.permissions && role.permissions.include?(permission.name)) %>
+ <%= styled_check_box_tag 'role[permissions][]',
+ permission.name,
+ (role.permissions && role.permissions.include?(permission.name)) %>
<%= l_or_humanize(permission.name, prefix: 'permission_') %>
</label>
</div>
diff --git a/spec/models/capabilities/scopes/default_spec.rb b/spec/models/capabilities/scopes/default_spec.rb
index 4917f2a78b4..9710bc9f11f 100644
--- a/spec/models/capabilities/scopes/default_spec.rb
+++ b/spec/models/capabilities/scopes/default_spec.rb
@@ -28,6 +28,7 @@
require 'spec_helper'
+# rubocop:disable RSpec/MultipleMemoizedHelpers
describe Capabilities::Scopes::Default, type: :model do
# we focus on the non current user capabilities to make the tests easier to understand
subject(:scope) { Capability.default.where(principal_id: user.id) }
@@ -143,9 +144,9 @@ describe Capabilities::Scopes::Default, type: :model do
end
end
- context 'with a lgobal member with an action permission and the user being locked' do
- let(:permissions) { %i[manage_members] }
- let(:members) { [member] }
+ context 'with a global member with an action permission and the user being locked' do
+ let(:permissions) { %i[manage_user] }
+ let(:members) { [global_member] }
let(:user_status) { Principal.statuses[:locked] }
it_behaves_like 'is empty'
@@ -314,3 +315,4 @@ describe Capabilities::Scopes::Default, type: :model do
end
end
end
+# rubocop:enable RSpec/MultipleMemoizedHelpers
diff --git a/spec/requests/api/v3/action_resource_spec.rb b/spec/requests/api/v3/action_resource_spec.rb
index 6c444e0786c..ce252247bbb 100644
--- a/spec/requests/api/v3/action_resource_spec.rb
+++ b/spec/requests/api/v3/action_resource_spec.rb
@@ -46,18 +46,9 @@ describe 'API v3 action resource', type: :request, content_type: :json do
get path
end
- it 'returns a collection of actions' do
- expect(subject.body)
- .to be_json_eql(Action.count.to_json)
- .at_path('total')
-
- expect(subject.body)
- .to be_json_eql(Action.order(id: :asc).first.id.to_json)
- .at_path('_embedded/elements/0/id')
-
- expect(subject.body)
- .to be_json_eql(Action.order(id: :asc).first.id.to_json)
- .at_path("_embedded/elements/0/id")
+ # 20 because this is the standard pagination size
+ it_behaves_like 'API V3 collection response', Action.count, 20, 'Action' do
+ let(:elements) { Action.order(id: :asc).limit(20).to_a }
end
end
@@ -70,7 +61,7 @@ describe 'API v3 action resource', type: :request, content_type: :json do
it 'returns 200 OK' do
expect(subject.status)
- .to eql(200)
+ .to be(200)
end
it 'returns the action' do
@@ -88,7 +79,7 @@ describe 'API v3 action resource', type: :request, content_type: :json do
it 'returns 200 OK' do
expect(subject.status)
- .to eql(200)
+ .to be(200)
end
it 'returns the action' do
@@ -105,19 +96,13 @@ describe 'API v3 action resource', type: :request, content_type: :json do
context 'if querying a non existing action' do
let(:path) { api_v3_paths.action("foo/bar") }
- it 'returns 404 NOT FOUND' do
- expect(subject.status)
- .to be 404
- end
+ it_behaves_like 'not found'
end
context 'if querying with malformed id' do
let(:path) { api_v3_paths.action("foobar") }
- it 'returns 404 NOT FOUND' do
- expect(subject.status)
- .to be 404
- end
+ it_behaves_like 'not found'
end
end
end