Skip to content

Commit 9513afb

Browse files
authored
Merge pull request #901 from ElixirTeSS/check-source-params
Source testing fix
2 parents 1bbfc99 + 03759e9 commit 9513afb

11 files changed

Lines changed: 185 additions & 10 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ gem 'sitemap-parser'
6161
gem 'slim'
6262
gem 'sunspot_rails', github: 'sunspot/sunspot', branch: 'master' # Contains Ruby 3 fixes that are not released
6363
gem 'terser'
64-
gem 'tess_rdf_extractors', git: 'https://github.com/ElixirTeSS/TeSS_RDF_Extractors', tag: '1.0.0'
64+
gem 'tess_rdf_extractors', git: 'https://github.com/ElixirTeSS/TeSS_RDF_Extractors', tag: '1.0.1'
6565
gem 'turbolinks'
6666
gem 'tzinfo'
6767
gem 'tzinfo-data'

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
GIT
22
remote: https://github.com/ElixirTeSS/TeSS_RDF_Extractors
3-
revision: f2f5173736d97166f7dc255ea3be4d749882a960
4-
tag: 1.0.0
3+
revision: e941e5f706e849eef36d33fb702282576c00f21d
4+
tag: 1.0.1
55
specs:
6-
tess_rdf_extractors (1.0.0)
6+
tess_rdf_extractors (1.0.1)
77
linkeddata (~> 3.2.0)
88

99
GIT

app/models/concerns/has_test_job.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def test_results=(results)
3434
end
3535
end
3636

37+
class_methods do
38+
def get_test_resource(type, params, **extras)
39+
klass = type.singularize.capitalize.constantize
40+
klass.new(params.with_indifferent_access.slice(*klass.attribute_names).merge(extras))
41+
end
42+
end
43+
3744
private
3845

3946
def test_job_id_key

app/views/content_providers/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<!-- Nodes: check feature enabled -->
3636
<% if TeSS::Config.feature['nodes'] %>
37-
<%= f.input :node_id, label: 'ELIXIR node', collection: Node.all, label_method: :title %>
37+
<%= f.input :node_id, label: 'ELIXIR node', collection: Node.order(:name).all, label_method: :name %>
3838
<% end %>
3939

4040
<div class="form-group">

app/views/events/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<!-- Field: Timezone -->
4444
<%= f.input :timezone, as: :time_zone, field_lock: true, priority: priority_time_zones,
45-
input_html: { title: t('events.hints.timezone') } %>
45+
input_html: { class: 'js-select2', title: t('events.hints.timezone') } %>
4646

4747
<!-- Field: Duration -->
4848
<%= f.input :duration, as: :string, input_html: { title: t('events.hints.duration') } %>

app/views/sources/_test_results.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
Showing <%= pluralize(sample.count, 'sample') %>
3030
<% end %>
3131
<% sample.each do |resource_params| %>
32-
<% resource = type.singularize.capitalize.constantize.new(resource_params.merge(user: User.get_default_user,
33-
content_provider: @content_provider)) %>
32+
<% resource = Source.get_test_resource(type, resource_params, user: User.get_default_user,
33+
content_provider: @content_provider) %>
3434
<% existing = klass.check_exists(resource) %>
3535
<div class="list-card bulk-import-row<%= ' new' unless existing -%>">
3636
<h4>

lib/ingestors/event_ingestion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Ingestors
22
module EventIngestion
33
def add_event(event)
4-
event = OpenStruct.new(event) if event.is_a?(Hash)
4+
event = OpenStruct.new(event.with_indifferent_access.slice(*Event.attribute_names)) if event.is_a?(Hash)
55
@events << event unless event.nil?
66
end
77

lib/ingestors/material_ingestion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Ingestors
22
module MaterialIngestion
33
def add_material(material)
4-
material = OpenStruct.new(material) if material.is_a?(Hash)
4+
material = OpenStruct.new(material.with_indifferent_access.slice(*Material.attribute_names)) if material.is_a?(Hash)
55
@materials << material unless material.nil?
66
end
77
end

test/controllers/sources_controller_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,27 @@ class SourcesControllerTest < ActionController::TestCase
570570

571571
refute source.reload.approval_requested?
572572
end
573+
574+
test 'ignores unrecognized fields when displaying test results' do
575+
source = sources(:unapproved_source)
576+
user = source.user
577+
sign_in user
578+
source.test_results = {
579+
events: [{ title: 'test 123', url: 'https://tess.elixir-europe.org', some_random_field: 'hello' }],
580+
materials: [],
581+
messages: [], run_time: 120, finished_at: Time.now }
582+
assert source.test_results
583+
584+
get :test_results, params: { id: source }, xhr: true
585+
586+
assert_response :success
587+
assert_select 'h4', text: 'Last Test Results'
588+
assert_select '#events' do
589+
assert_select 'h4', text: 'test 123'
590+
assert_select 'a[href=?]', 'https://tess.elixir-europe.org'
591+
end
592+
ensure
593+
path = source.send(:test_results_path)
594+
FileUtils.rm(path) if File.exist?(path)
595+
end
573596
end

test/fixtures/files/ingestion/sib_course.json

Lines changed: 130 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)