Skip to content

Commit

Permalink
changed visual icon and fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Deli authored and Dennis Deli committed Feb 5, 2025
1 parent 623543d commit 714414e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/views/items/_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<% end %>
</div>
<div class="col-md-2 item_actions">
<%= render partial: "items/item_actions", locals: { item: item, notes: notes } unless local_assigns[:hide_item_actions] == true %>
<%= render partial: "items/item_actions", locals: { item: item, notes: notes } unless local_assigns[:hide_item_actions] == true %>
</div>
</div>
<% if [Item::TYPE_EJOURNAL, Item::TYPE_EBOOK, Item::TYPE_MULTIMEDIA, Item::TYPE_PHOTOCOPY, Item::TYPE_COURSE_KIT].include? item.item_type %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/items/_item_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
<%= link_to 'Add a Note / History Log', '#', data: { toggle: 'modal', target: "#item_history_popup_#{item.id}", remote: true }, class: 'btn btn-xs btn-default' %>

<% if notes.any? %>
<span id="notes-icon-<%= item.id %>" style="font-size: 1.8rem;">📝</span>
<span id="notes-icon-<%= item.id %>" style="font-size: 1.5rem; margin-left: 3px;">⚠️</span>
<% else %>
<span id="notes-icon-<%= item.id %>" style="font-size: 1.8rem;"></span>
<span id="notes-icon-<%= item.id %>" style="font-size: 1.5rem; margin-left: 3px;"></span>
<% end %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/request_history/create.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

var notesIcon = document.getElementById("notes-icon-<%= @aud.associated_id %>");
if (notesIcon) {
notesIcon.innerHTML = '<span style="font-size: 1.8rem;">📝</span>';
notesIcon.innerHTML = '<span style="font-size: 1.5rem;">⚠️</span>';
}

<% if @aud.comment.blank? %>
Expand Down
47 changes: 42 additions & 5 deletions test/controllers/items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,50 @@ class ItemsControllerTest < ActionDispatch::IntegrationTest
end

should 'list all items for request' do
create(:item)
create_list(:item, 3, request: @_request)
items = create_list(:item, 2, request: @_request)

items.each_with_index do |item, index|
Audited::Audit.create!(
auditable_id: @_request.id,
auditable_type: "Request",
associated_id: item.id,
associated_type: "item",
action: "note",
comment: "Note #{index + 1}",
user: @user
)
end

@notes_by_item = {}
@_request.items.each do |item|
@notes_by_item[item.id] = Audited::Audit.where(
auditable_id: @_request.id,
auditable_type: "Request",
associated_id: item.id,
associated_type: "item",
action: "note"
)
end

get request_items_path(@_request)
get request_path(@_request)
assert_response :success
items = get_instance_var(:items)
assert_equal 3, items.size, '3 Items'

items.each do |item|
has_notes = Audited::Audit.exists?(
auditable_id: @_request.id,
auditable_type: "Request",
associated_id: item.id,
associated_type: "item",
action: "note"
)

expected_text = has_notes ? "⚠️" : ""

assert_select "#notes-icon-#{item.id}", text: expected_text,
message: "Notes icon should be #{has_notes ? 'present' : 'absent'} for item #{item.id}"
end


end

should 'show new item form' do
Expand Down

0 comments on commit 714414e

Please sign in to comment.