Skip to content

Commit

Permalink
Remove additional option processing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yoldas committed Jan 20, 2025
1 parent c41a02c commit 7b10089
Showing 1 changed file with 0 additions and 123 deletions.
123 changes: 0 additions & 123 deletions spec/controllers/studies_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,129 +76,6 @@
expect(Study.count).to eq(@initial_study_count)
end
end

context 'with poly_metadata options' do
let(:option_key) { 'scrna_core_pbmc_donor_pooling_required_number_of_cells' }
let(:option_value) { '1000' }
let(:params) do
# Extend parent context's params with poly_metadata options.
super().merge('poly_metadata' => { option_key => option_value })
end

context 'with specified value' do
it 'creates poly_metadatum with the value' do
poly_metadatum = Study.last.poly_metadatum_by_key(option_key)
expect(poly_metadatum.value).to eq(option_value)
end
end

context 'with empty value' do
let(:option_value) { '' } # Override parent context's option_value.

it 'does not create poly_metadatum' do
poly_metadatum = Study.last.poly_metadatum_by_key(option_key)
expect(poly_metadatum).to be_nil
end
end
end
end

describe '#update' do
context 'with poly_metadata options' do
let(:option_key) { 'scrna_core_pbmc_donor_pooling_required_number_of_cells' }
let(:option_value) { '1000' }

let!(:study) do
# Create a study without poly_metadata options.
post(:create, params:)
Study.last
end

let(:update_params) { params.merge('id' => study.id).merge('poly_metadata' => { option_key => option_value }) }

context 'without existing poly_metadatum' do
context 'with specified value' do
it 'creates poly_metadatum with the value' do
# Existing
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).to be_nil

post :update, params: update_params
study.reload

# Updated
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).not_to be_nil
expect(poly_metadatum.value).to eq(option_value)
end
end

context 'with empty value' do
let(:option_value) { '' }

it 'does not create poly_metadatum' do
# Existing
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).to be_nil

post :update, params: update_params
study.reload

# Updated
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).to be_nil
end
end
end

context 'with existing poly_metadatum' do
let(:new_option_value) { '2000' }
let(:new_update_params) do
params.merge('poly_metadata' => { option_key => new_option_value }).merge('id' => study.id)
end

before do
post :update, params: update_params # Update once
study.reload
end

context 'with specified value' do
it 'creates poly_metadatum with the value' do
# Existing
poly_metadatum_existing = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum_existing).not_to be_nil
expect(poly_metadatum_existing.value).to eq(option_value)

post :update, params: new_update_params # Update with new value
study.reload

# Updated
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).not_to be_nil
expect(poly_metadatum.value).to eq(new_option_value) # New value
expect(poly_metadatum.id).to eq(poly_metadatum_existing.id) # Same record
end
end

context 'with empty value' do
let(:new_option_value) { '' }

it 'does not create poly_metadatum' do
# Existing
poly_metadatum_existing = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum_existing).not_to be_nil
expect(poly_metadatum_existing.value).to eq(option_value)

post :update, params: new_update_params # Update with new value
study.reload

# Updated
poly_metadatum = study.poly_metadatum_by_key(option_key)
expect(poly_metadatum).to be_nil # Deleted
end
end
end
end
end

describe '#grant_role' do
Expand Down

0 comments on commit 7b10089

Please sign in to comment.