Skip to content

Commit

Permalink
Fix bug - publish_related_items_confirm trying to access event.assays
Browse files Browse the repository at this point in the history
  • Loading branch information
fherreazcue committed Sep 8, 2023
1 parent 5efe05f commit 9f9125d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ul class="publishing_options">

<% @items_for_publishing.each do |item| %>
<% if item.is_a?(Assay) || !item.assays.empty? %>
<% if item.is_a?(Assay) || (!item.is_a?(Event) && !item.assays.empty?) %>
<li class="type_and_title">
<%= text_for_resource item -%>: <%= link_to item.title, item, :target => "_blank" -%>
<% if item.is_published? %>
Expand Down
21 changes: 20 additions & 1 deletion test/functional/publishing/batch_publishing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def setup

get :check_gatekeeper_required, params: params.merge(id: person.id)
assert_response :success
pp(params.merge(id: person.id))

# Publishable shown in immediate publishing section
assert_select 'h2', text: /The following items will be published:/, count: 1
Expand Down Expand Up @@ -139,6 +138,26 @@ def setup
end
end

test 'Events are skipped *in publish related items' do
person = User.current_user.person
assay = FactoryBot.create(:assay, contributor: person)
df = FactoryBot.create(:data_file, projects: [person.projects.first], assays: [assay], contributor: person)
event = FactoryBot.create(:event, contributor: person)
login_as(person.user)
assert df.can_publish?
assert event.can_publish?

params = { publish: {} }
[df, event].each do |asset|
params[:publish][asset.class.name] ||= {}
params[:publish][asset.class.name][asset.id.to_s] = '1'
end

get :check_related_items, params: params.merge(id: person.id)
assert_response :success

end

test 'do not have not_publishable_type item in batch_publishing_preview' do
item = FactoryBot.create(:publication,
contributor: User.current_user.person,
Expand Down

0 comments on commit 9f9125d

Please sign in to comment.