Make rubocop happier

pull/10248/head
Christophe Bliard 3 years ago
parent 80d7033495
commit 4f6e52116f
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 6
      lib/api/v3/utilities/endpoints/index.rb
  2. 16
      modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.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])

@ -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

Loading…
Cancel
Save