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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Test nullification: BCF comment's ref to viewpoint
Wieland Lindenthalb18bf1dfd54c
diff --git a/modules/bcf/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb b/modules/bcf/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rbindex 7135d1364be..229bba458ef 100644--- a/modules/bcf/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb+++ b/modules/bcf/spec/requests/api/bcf/v2_1/viewpoints_api_spec.rb@@ -61,7 +61,8 @@ describe 'BCF 2.1 viewpoints resource', type: :request, content_type: :json, witFactoryBot.create(:work_package, project: project)endend- shared_let(:bcf_issue) { FactoryBot.create(:bcf_issue_with_viewpoint, work_package: work_package) }++ let(:bcf_issue) { FactoryBot.create(:bcf_issue_with_viewpoint, work_package: work_package) }let(:viewpoint) { bcf_issue.viewpoints.first }let(:viewpoint_json) { viewpoint.json_viewpoint }@@ -124,14 +125,31 @@ describe 'BCF 2.1 viewpoints resource', type: :request, content_type: :json, witdelete pathend- it_behaves_like 'bcf api successful response' do- let(:expected_status) { 204 }- let(:expected_body) { nil }- let(:no_content) { true }+ shared_examples "successfully deletes the viewpoint" do+ it_behaves_like 'bcf api successful response' do+ let(:expected_status) { 204 }+ let(:expected_body) { nil }+ let(:no_content) { true }+ end++ it 'deletes the viewpoint' do+ expect(Bcf::Viewpoint.where(id: viewpoint.id)).not_to be_exist+ endend- it 'deletes the viewpoint' do- expect(Bcf::Viewpoint.where(id: viewpoint.id)).not_to be_exist+ context "no BCF comment holds a reference to that viewpoint" do+ it_behaves_like "successfully deletes the viewpoint"+ end++ context "one BCF comment holds a reference to that viewpoint" do+ let(:bcf_issue) { FactoryBot.create(:bcf_issue_with_comment, work_package: work_package) }+ let(:comment) { bcf_issue.comments.first }++ it "nullifies the comment's reference to the viewpoint" do+ expect(comment.viewpoint).to be_nil+ end++ it_behaves_like "successfully deletes the viewpoint"endcontext 'lacking permission to see project' do