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

topics#show bcf api

ulfertscbaa85099457
diff --git a/modules/bcf/app/controllers/bcf/api/v2_1/topics_api.rb b/modules/bcf/app/controllers/bcf/api/v2_1/topics_api.rb
index eb79e64a981..ac5f3dba024 100644
--- a/modules/bcf/app/controllers/bcf/api/v2_1/topics_api.rb
+++ b/modules/bcf/app/controllers/bcf/api/v2_1/topics_api.rb
@@ -41,19 +41,21 @@ module Bcf::API::V2_1
authorize :view_linked_issues, context: @project
end
- get &::Bcf::API::V2_1::Endpoints::Index.new(model: Bcf::Issue,
- api_name: 'Topics',
- scope: -> { topics })
- .mount
+ get &::Bcf::API::V2_1::Endpoints::Index
+ .new(model: Bcf::Issue,
+ api_name: 'Topics',
+ scope: -> { topics })
+ .mount
route_param :uuid, regexp: /\A[a-f0-9\-]+\z/ do
after_validation do
- @issue = topics.find_by_uuid(params[:uuid])
+ @issue = topics.find_by_uuid!(params[:uuid])
end
get &::Bcf::API::V2_1::Endpoints::Show
- .new(model: Bcf::Issue, api_name: 'Topics')
- .mount
+ .new(model: Bcf::Issue,
+ api_name: 'Topics')
+ .mount
end
end
end
diff --git a/modules/bcf/spec/requests/api/bcf/v2_1/topics_api_spec.rb b/modules/bcf/spec/requests/api/bcf/v2_1/topics_api_spec.rb
index ece693fd280..5d79bdf1c2c 100644
--- a/modules/bcf/spec/requests/api/bcf/v2_1/topics_api_spec.rb
+++ b/modules/bcf/spec/requests/api/bcf/v2_1/topics_api_spec.rb
@@ -31,7 +31,7 @@ require 'rack/test'
require_relative './shared_responses'
-describe 'BCF 2.1 topics resource', type: :request, content_type: :json do
+describe 'BCF 2.1 topics resource', type: :request, content_type: :json, with_mail: false do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -109,4 +109,60 @@ describe 'BCF 2.1 topics resource', type: :request, content_type: :json do
it_behaves_like 'bcf api not allowed response'
end
end
+
+ describe 'GET /api/bcf/2.1/projects/:project_id/topics/:uuid' do
+ let(:path) { "/api/bcf/2.1/projects/#{project.id}/topics/#{bcf_issue.uuid}" }
+ let(:current_user) { view_only_user }
+
+ before do
+ login_as(current_user)
+ bcf_issue
+ get path
+ end
+
+ it_behaves_like 'bcf api successful response' do
+ let(:expected_body) do
+ {
+ "assigned_to": "[email protected]",
+ "creation_author": "[email protected]",
+ "creation_date": "2015-06-21T12:00:00Z",
+ "description": "This is a topic with all information present.",
+ "due_date": nil,
+ guid: bcf_issue.uuid,
+ "index": "0",
+ "labels": [
+ "Structural",
+ "IT Development"
+ ],
+ "modified_author": "[email protected]",
+ "modified_date": "2015-06-21T14:22:47Z",
+ "reference_links": [
+ api_v3_paths.work_package(work_package.id)
+ ],
+ "stage": "Construction start",
+ "title": "Maximum Content",
+ "topic_status": "Open",
+ "topic_type": "Structural"
+ }
+ end
+ end
+
+ context 'lacking permission to see project' do
+ let(:current_user) { non_member_user }
+
+ it_behaves_like 'bcf api not found response'
+ end
+
+ context 'invalid uuid' do
+ let(:path) { "/api/bcf/2.1/projects/#{project.id}/topics/0" }
+
+ it_behaves_like 'bcf api not found response'
+ end
+
+ context 'lacking permission to see linked issues' do
+ let(:current_user) { only_member_user }
+
+ it_behaves_like 'bcf api not allowed response'
+ end
+ end
end