From bcb1464615312018fed62f2d453de1a737f9c45e Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Tue, 28 Jan 2025 13:38:56 +0000 Subject: [PATCH 1/4] added flag for multiplexed to submission resource for use in limber when deciding to show the pooling tab --- app/resources/api/v2/submission_resource.rb | 6 +++++ .../api/v2/submission_resource_spec.rb | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/resources/api/v2/submission_resource.rb b/app/resources/api/v2/submission_resource.rb index aa17be7fe6..27a99431c0 100644 --- a/app/resources/api/v2/submission_resource.rb +++ b/app/resources/api/v2/submission_resource.rb @@ -37,6 +37,7 @@ class SubmissionResource < BaseResource attribute :updated_at, readonly: true attribute :used_tags, write_once: true attribute :lanes_of_sequencing, write_once: true + attribute :is_multiplexed, readonly: true # Filters filter :uuid, apply: ->(records, value, _options) { records.with_uuid(value) } @@ -48,6 +49,11 @@ def lanes_of_sequencing _model.sequencing_requests.size end + # Added for use in Limber Presenters to decide whether to show the pooling tab + def is_multiplexed + _model.multiplexed? + end + # Class method overrides end end diff --git a/spec/resources/api/v2/submission_resource_spec.rb b/spec/resources/api/v2/submission_resource_spec.rb index 00840b82a6..882d74d18b 100644 --- a/spec/resources/api/v2/submission_resource_spec.rb +++ b/spec/resources/api/v2/submission_resource_spec.rb @@ -18,6 +18,7 @@ expect(resource).to have_attribute :created_at expect(resource).to have_attribute :updated_at expect(resource).to have_attribute :lanes_of_sequencing + expect(resource).to have_attribute :is_multiplexed expect(resource).not_to have_updatable_field(:id) expect(resource).not_to have_updatable_field(:uuid) expect(resource).not_to have_updatable_field(:state) @@ -42,4 +43,26 @@ expect(resource.lanes_of_sequencing).to eq 3 end end + + describe '#is_multiplexed' do + context 'when the submission is multiplexed' do + before do + allow(resource_model).to receive(:multiplexed?).and_return(true) + end + + it 'returns whether the submission is multiplexed' do + expect(resource.is_multiplexed).to eq true + end + end + + context 'when the submission is not multiplexed' do + before do + allow(resource_model).to receive(:multiplexed?).and_return(false) + end + + it 'returns whether the submission is multiplexed' do + expect(resource.is_multiplexed).to eq false + end + end + end end From 9ddc0914269fb901ee4085e448b06e6d0951667a Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Tue, 28 Jan 2025 13:53:41 +0000 Subject: [PATCH 2/4] linted --- spec/resources/api/v2/submission_resource_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/resources/api/v2/submission_resource_spec.rb b/spec/resources/api/v2/submission_resource_spec.rb index 882d74d18b..dd9cb3bd84 100644 --- a/spec/resources/api/v2/submission_resource_spec.rb +++ b/spec/resources/api/v2/submission_resource_spec.rb @@ -46,9 +46,7 @@ describe '#is_multiplexed' do context 'when the submission is multiplexed' do - before do - allow(resource_model).to receive(:multiplexed?).and_return(true) - end + before { allow(resource_model).to receive(:multiplexed?).and_return(true) } it 'returns whether the submission is multiplexed' do expect(resource.is_multiplexed).to eq true @@ -56,9 +54,7 @@ end context 'when the submission is not multiplexed' do - before do - allow(resource_model).to receive(:multiplexed?).and_return(false) - end + before { allow(resource_model).to receive(:multiplexed?).and_return(false) } it 'returns whether the submission is multiplexed' do expect(resource.is_multiplexed).to eq false From d98cee718b2993519d167118ae440a0ab52cd01b Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Tue, 28 Jan 2025 14:47:37 +0000 Subject: [PATCH 3/4] lint - renamed attribute --- app/resources/api/v2/submission_resource.rb | 6 ++---- spec/resources/api/v2/submission_resource_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/resources/api/v2/submission_resource.rb b/app/resources/api/v2/submission_resource.rb index 27a99431c0..235d96d1e7 100644 --- a/app/resources/api/v2/submission_resource.rb +++ b/app/resources/api/v2/submission_resource.rb @@ -37,7 +37,7 @@ class SubmissionResource < BaseResource attribute :updated_at, readonly: true attribute :used_tags, write_once: true attribute :lanes_of_sequencing, write_once: true - attribute :is_multiplexed, readonly: true + attribute :multiplexed?, readonly: true # Filters filter :uuid, apply: ->(records, value, _options) { records.with_uuid(value) } @@ -50,9 +50,7 @@ def lanes_of_sequencing end # Added for use in Limber Presenters to decide whether to show the pooling tab - def is_multiplexed - _model.multiplexed? - end + delegate :multiplexed?, to: :_model # Class method overrides end diff --git a/spec/resources/api/v2/submission_resource_spec.rb b/spec/resources/api/v2/submission_resource_spec.rb index dd9cb3bd84..5564b39042 100644 --- a/spec/resources/api/v2/submission_resource_spec.rb +++ b/spec/resources/api/v2/submission_resource_spec.rb @@ -18,7 +18,7 @@ expect(resource).to have_attribute :created_at expect(resource).to have_attribute :updated_at expect(resource).to have_attribute :lanes_of_sequencing - expect(resource).to have_attribute :is_multiplexed + expect(resource).to have_attribute :multiplexed? expect(resource).not_to have_updatable_field(:id) expect(resource).not_to have_updatable_field(:uuid) expect(resource).not_to have_updatable_field(:state) @@ -44,12 +44,12 @@ end end - describe '#is_multiplexed' do + describe '#multiplexed?' do context 'when the submission is multiplexed' do before { allow(resource_model).to receive(:multiplexed?).and_return(true) } it 'returns whether the submission is multiplexed' do - expect(resource.is_multiplexed).to eq true + expect(resource.multiplexed?).to be true end end @@ -57,7 +57,7 @@ before { allow(resource_model).to receive(:multiplexed?).and_return(false) } it 'returns whether the submission is multiplexed' do - expect(resource.is_multiplexed).to eq false + expect(resource.multiplexed?).to be false end end end From 368e91bb1103e2aa0525f10dfd9aa1de52228ac6 Mon Sep 17 00:00:00 2001 From: Andrew Sparkes Date: Wed, 5 Mar 2025 15:40:57 +0000 Subject: [PATCH 4/4] fix indentation, attempting to fix flakey test --- features/api/users.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/api/users.feature b/features/api/users.feature index ad3ed6f5b3..7fb65a8d37 100644 --- a/features/api/users.feature +++ b/features/api/users.feature @@ -14,7 +14,7 @@ Feature: Access users through the API And the WTSI single sign-on service recognises "I-am-authenticated" as "John Smith" Given I am using the latest version of the API -And I have a "full" authorised user with the key "cucumber" + And I have a "full" authorised user with the key "cucumber" @read Scenario: Reading the JSON for a user UUID