Skip to content

Commit

Permalink
Merge branch 'seek-1.14' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Nov 7, 2023
2 parents 5b349f2 + e0f428e commit ed87f84
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/helpers/bootstrap_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def objects_input(element_name, existing_objects = [], options = {}, value_metho

tag = select_tag(element_name, select_options, options)
if options[:multiple]
hidden_field_tag(element_name, '', name: options[:name]) + tag
hidden_field_tag(element_name, '', name: options[:name], id: nil) + tag
else
tag
end
Expand Down
1 change: 1 addition & 0 deletions app/models/sample_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SampleAttribute < ApplicationRecord

belongs_to :isa_tag

auto_strip_attributes :pid
validates :sample_type, presence: true
validates :pid, format: { with: URI::regexp, allow_blank: true, allow_nil: true, message: 'not a valid URI' }
validate :validate_against_editing_constraints, if: -> { sample_type.present? }
Expand Down
8 changes: 3 additions & 5 deletions app/views/projects/guided_join.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
<% if @project %>
You are requesting to join <%= link_to(@project.title, @project) %>
<%= hidden_field_tag 'projects',@project.id %>
<%= hidden_field_tag 'project_ids[]', @project.id, id: 'project_ids' %>
<% else %>

<div class="help-block">
Expand Down Expand Up @@ -63,9 +62,8 @@
<script type='application/javascript'>

function checkSubmitButtonEnabled() {
var enabled = $j('select#institution_id').val()
&& $j('select#project_ids').val()
$j('#submit-button').prop('disabled',!enabled);
var enabled = $j('select#institution_id').val() && $j('#project_ids').val();
$j('#submit-button').prop('disabled', !enabled);
}

$j(document).ready(function () {
Expand Down
14 changes: 14 additions & 0 deletions lib/tasks/seek_upgrades.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace :seek do
decouple_extracted_samples_policies
decouple_extracted_samples_projects
link_sample_datafile_attributes
strip_sample_attribute_pids
]

# these are the tasks that are executes for each upgrade as standard, and rarely change
Expand Down Expand Up @@ -47,6 +48,19 @@ namespace :seek do
end
end

task(strip_sample_attribute_pids: [:environment]) do
puts '... Stripping Sample Attribute PIds ...'
n = 0
SampleAttribute.where('pid is NOT NULL AND pid !=?','').each do |attribute|
new_pid = attribute.pid.strip
if attribute.pid != new_pid
attribute.update_column(:pid, new_pid)
n += 1
end
end
puts "... Finished stripping #{n} Sample Attribute PIds."
end

task(decouple_extracted_samples_policies: [:environment]) do
puts '... creating independent policies for extracted samples...'
decoupled = 0
Expand Down
8 changes: 4 additions & 4 deletions test/functional/assays_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1061,14 +1061,14 @@ def check_fixtures_for_authorization_of_sops_and_datafiles_links
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'new should include tags element' do
get :new, params: { class: :experimental }
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'edit should include not include tags element when tags disabled' do
Expand All @@ -1078,7 +1078,7 @@ def check_fixtures_for_authorization_of_sops_and_datafiles_links
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -1087,7 +1087,7 @@ def check_fixtures_for_authorization_of_sops_and_datafiles_links
get :new, params: { class: :experimental }
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/functional/data_files_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1711,14 +1711,14 @@ def test_show_item_attributed_to_jerm_file
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'register form should include tags element' do
register_content_blob
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'edit should include not include tags element when tags disabled' do
Expand All @@ -1728,7 +1728,7 @@ def test_show_item_attributed_to_jerm_file
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -1737,7 +1737,7 @@ def test_show_item_attributed_to_jerm_file
register_content_blob
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand Down
12 changes: 6 additions & 6 deletions test/functional/investigations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,15 @@ def test_title
get :new
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'new should not include tags element when tags disabled' do
with_config_value :tagging_enabled, false do
get :new
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -784,7 +784,7 @@ def test_title
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'edit should not include tags element when tags disabled' do
Expand All @@ -794,7 +794,7 @@ def test_title
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -804,7 +804,7 @@ def test_title
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'show should not include tags box when tags disabled' do
Expand All @@ -814,7 +814,7 @@ def test_title
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/projects_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ def test_admin_can_edit

get :guided_join, params: { id: project.id }
assert_response :success
assert_select 'input#projects', value: project.id
assert_select '#project_ids', value: project.id
end

test 'invalid guided join' do
Expand Down
4 changes: 2 additions & 2 deletions test/functional/sops_annotation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ class SopsAnnotationTest < ActionController::TestCase
login_as p.user
get :new
assert_response :success
assert_select 'input#tag_list'
assert_select 'select#tag_list'

sop = FactoryBot.create :sop, contributor: p
get :edit, params: { id: sop }
assert_response :success
assert_select 'input#tag_list'
assert_select 'select#tag_list'
end
end
12 changes: 6 additions & 6 deletions test/functional/studies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1902,15 +1902,15 @@ def test_should_show_investigation_tab
get :new
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'new should not include tags element when tags disabled' do
with_config_value :tagging_enabled, false do
get :new
assert_response :success
assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -1920,7 +1920,7 @@ def test_should_show_investigation_tab
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'edit should not include tags element when tags disabled' do
Expand All @@ -1930,7 +1930,7 @@ def test_should_show_investigation_tab
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand All @@ -1940,7 +1940,7 @@ def test_should_show_investigation_tab
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 1
assert_select 'input#tag_list', count: 1
assert_select 'select#tag_list', count: 1
end

test 'show should not include tags box when tags disabled' do
Expand All @@ -1950,7 +1950,7 @@ def test_should_show_investigation_tab
assert_response :success

assert_select 'div.panel-heading', text: /Tags/, count: 0
assert_select 'input#tag_list', count: 0
assert_select 'select#tag_list', count: 0
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/unit/sample_attribute_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SampleAttributeTest < ActiveSupport::TestCase
sample_attribute_type: FactoryBot.create(:integer_sample_attribute_type),
sample_type: FactoryBot.create(:simple_sample_type)
refute attribute.valid?

attribute.pid = 'http://somewhere.org#fish'
assert attribute.valid?
attribute.pid = 'dc:fish'
Expand All @@ -76,6 +77,17 @@ class SampleAttributeTest < ActiveSupport::TestCase
refute attribute.valid?
end

test 'auto strip pid' do
attribute = SampleAttribute.new title: 'fish', pid:" wibble:12\t ",
sample_attribute_type: FactoryBot.create(:integer_sample_attribute_type),
sample_type: FactoryBot.create(:simple_sample_type)
assert attribute.valid?
assert_equal 'wibble:12', attribute.pid
attribute.pid = " wibble:12\n "
assert attribute.valid?
assert_equal 'wibble:12', attribute.pid
end

test 'validate value - without required' do
attribute = SampleAttribute.new title: 'fish', sample_attribute_type: FactoryBot.create(:integer_sample_attribute_type),
sample_type: FactoryBot.create(:simple_sample_type)
Expand Down

0 comments on commit ed87f84

Please sign in to comment.