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

Make rubocop happier

Christophe Bliard4f6e52116fc8
diff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rb
index 016745b27a7..529094b8869 100644
--- a/lib/api/v3/utilities/endpoints/index.rb
+++ b/lib/api/v3/utilities/endpoints/index.rb
@@ -61,7 +61,7 @@ module API
if query.valid?
render_success(query,
request.params,
- self_path.respond_to?(:call) ? request.instance_exec(&self_path) : request.api_v3_paths.send(self_path),
+ resolved_self_path,
scope ? request.instance_exec(&scope) : model)
else
render_error(query)
@@ -106,6 +106,10 @@ module API
current_user: User.current)
end
+ def resolved_self_path
+ self_path.respond_to?(:call) ? request.instance_exec(&self_path) : request.api_v3_paths.send(self_path)
+ end
+
def calculate_resulting_params(query, provided_params)
calculate_default_params(query).merge(provided_params.slice('offset', 'pageSize').symbolize_keys).tap do |params|
params[:offset] = to_i_or_nil(params[:offset])
diff --git a/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb
index 65520984b58..3540403c10b 100644
--- a/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb
+++ b/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb
@@ -45,14 +45,14 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
end
describe '_links' do
- context 'self' do
+ describe 'self' do
it_behaves_like 'has an untitled link' do
let(:link) { 'self' }
let(:href) { "/api/v3/work_packages/#{container.id}/file_links/#{file_link.id}" }
end
end
- context 'storage' do
+ describe 'storage' do
it_behaves_like 'has a titled link' do
let(:link) { 'storage' }
let(:href) { "/api/v3/storages/#{storage.id}" }
@@ -60,7 +60,7 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
end
end
- context 'container' do
+ describe 'container' do
it_behaves_like 'has a titled link' do
let(:link) { 'container' }
let(:href) { "/api/v3/work_packages/#{container.id}" }
@@ -68,7 +68,7 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
end
end
- context 'creator' do
+ describe 'creator' do
it_behaves_like 'has a titled link' do
let(:link) { 'creator' }
let(:href) { "/api/v3/users/#{creator.id}" }
@@ -76,7 +76,7 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
end
end
- context 'delete' do
+ describe 'delete' do
let(:permission) { :manage_file_links }
it_behaves_like 'has an untitled action link' do
@@ -86,14 +86,14 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
end
end
- context 'originOpen' do
+ describe 'originOpen' do
it_behaves_like 'has an untitled link' do
let(:link) { 'originOpen' }
let(:href) { "#{storage.host}/f/#{file_link.origin_id}" }
end
end
- context 'staticOriginOpen' do
+ describe 'staticOriginOpen' do
it_behaves_like 'has an untitled link' do
let(:link) { 'staticOriginOpen' }
let(:href) { "/api/v3/work_packages/#{container.id}/file_links/#{file_link.id}/open" }
@@ -118,7 +118,7 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' do
let(:value) { file_link.updated_at }
end
- context 'originData' do
+ describe 'originData' do
it_behaves_like 'property', 'originData/id' do
let(:value) { file_link.origin_id }
end