From 4ef7b22ec4ea7280f637b360e2c7c22e1958c9f5 Mon Sep 17 00:00:00 2001 From: John Pinto Date: Thu, 3 Mar 2022 11:44:40 +0000 Subject: [PATCH 1/2] DCC bug 697 - Fix for a roadmap-wide bug where the following were failing in the REST API V1 call "GET 0/api/v1/plans" for following reasons: (1) Plans policy initialize method was broken (2) Each plan in the json array was using the email for the user name. DCC issue https://github.com/DigitalCurationCentre/DMPonline-Service/issues/697 Changes made: (1) The initialize method in /policies/api/v1/plans super call requires no arguments, it was taking the ApiClient as an argument. (2) In /views/api/v1/contributors/_show.json.jbuilder we changed json.name as follows as we were previously using the 'User' rather than 'Contributor' object json.name contributor.is_a?(User) ? contributor.name(false) : contributor.name --- app/policies/api/v1/plans_policy.rb | 6 ++++++ app/views/api/v1/contributors/_show.json.jbuilder | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/policies/api/v1/plans_policy.rb b/app/policies/api/v1/plans_policy.rb index b873756aae..30c84c8ada 100644 --- a/app/policies/api/v1/plans_policy.rb +++ b/app/policies/api/v1/plans_policy.rb @@ -36,6 +36,12 @@ def plans_for_user ids += @user.org.plans.pluck(:id) if @user.can_org_admin? ids end + + def initialize(client, plan) + super() + @client = client + @plan = plan + end end end end diff --git a/app/views/api/v1/contributors/_show.json.jbuilder b/app/views/api/v1/contributors/_show.json.jbuilder index c0b9dda45b..833ea6ab72 100644 --- a/app/views/api/v1/contributors/_show.json.jbuilder +++ b/app/views/api/v1/contributors/_show.json.jbuilder @@ -4,7 +4,7 @@ is_contact ||= false -json.name contributor.name +json.name contributor.is_a?(User) ? contributor.name(false) : contributor.name json.mbox contributor.email if !is_contact && contributor.selected_roles.any? From 05e6c1dcc2f5a548787e90d70826a2b99f68f07b Mon Sep 17 00:00:00 2001 From: John Pinto Date: Thu, 3 Mar 2022 15:59:31 +0000 Subject: [PATCH 2/2] Temporarily commented Karma tests as per https://github.com/DMPRoadmap/roadmap/pull/3117/commits/99ab6534f1490bfe54a5e961e53c5e1c84accf43. --- .github/workflows/mysql.yml | 4 ++-- .github/workflows/postgres.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 6c6a4395fb..dfd2a43ff7 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -58,8 +58,8 @@ jobs: run: bin/rails assets:precompile # Run the JS tests - - name: 'Run Karma Tests' - run: yarn test + #- name: 'Run Karma Tests' + # run: yarn test # Run the unit and functional tests - name: 'Run Rspec Unit and Functional Tests' diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index 504983a12a..32338ad62a 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -82,8 +82,8 @@ jobs: run: bin/rails assets:precompile # Run the JS tests - - name: 'Run Karma Tests' - run: yarn test + #- name: 'Run Karma Tests' + # run: yarn test # Run the unit and functional tests - name: 'Run Rspec Unit and Functional Tests'