Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/20250202-maintenance-release-tes…
Browse files Browse the repository at this point in the history
…ts' into staging
  • Loading branch information
amtuannguyen committed Jan 16, 2025
2 parents 7b0213c + a3ab67c commit 4a58d34
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ class HomeControllerTest < ActionDispatch::IntegrationTest
requests = get_instance_var(:requests)
assert_equal 3, requests.size, 'Should only be 1 cancelled'
end

should 'default location name is "All locations"' do
get root_path, params: { which: Request::OPEN, page: 1, location: 'all' }

assert_select 'button.dropdown-toggle', text: 'All Locations'

assert_select 'ul.dropdown-menu li:first-child a', text: 'All Locations'
end

end

context 'User' do
Expand Down
12 changes: 12 additions & 0 deletions test/controllers/items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ class ItemsControllerTest < ActionDispatch::IntegrationTest
end
end

should 'create a new item with other_isbn_issn' do
assert_difference('Item.count') do
post request_items_path(@_request), params: {
item: attributes_for(:item, other_isbn_issn: '1234-5678').except(:request)
}
item = get_instance_var(:item)
assert_equal 0, item.errors.size, "Should be no errors, #{item.errors.messages}"
assert_redirected_to request_item_path(@_request, item)
assert_equal '1234-5678', item.other_isbn_issn, 'other_isbn_issn should match'
end
end

should 'send en email to location email, after item created, if enabled' do
@_request.location.setting_bcc_location_on_new_item = true
@_request.location.save
Expand Down
32 changes: 31 additions & 1 deletion test/controllers/request_wizard_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,23 @@ class RequestWizardControllerTest < ActionDispatch::IntegrationTest

assert_response :success
assert_equal 1, request.errors.size, "Should be 1 error, #{request.errors.messages.inspect}"
end
end

should 'handle empty new request' do
assert_no_difference('Request.count') do
request_attributes = attributes_for(:request, reserve_location_id: @location.id)
request_attributes[:course_attributes] = attributes_for(:course, name: '', code: '')
request_attributes[:user] = { office: '', department: '', phone: '' }

post new_request_step_one_save_path, params: { request: request_attributes }
request = get_instance_var(:request)
assert_not_empty request.errors, 'There should be validation errors'

assert_response :success
assert_match /can&#39;t be blank/, @response.body
end

end

should 'load the request and any items, if comping back to this' do
request = create(:request, status: Request::INCOMPLETE)
Expand Down Expand Up @@ -96,4 +111,19 @@ class RequestWizardControllerTest < ActionDispatch::IntegrationTest
assert_response :redirect
assert_redirected_to request_path(request), 'Show request details'
end

test 'should not allow finishing the request without items' do
request = create(:request, status: Request::INCOMPLETE)

get new_request_step_two_path(request)
assert_response :success
assert_match /Save this request for later/, @response.body
assert_no_match /I am done, submit this request/, @response.body

post new_request_finish_path(request)
assert_redirected_to new_request_step_two_path(request)
follow_redirect!
assert_match /You must add at least one active item for this request to be submitted!/, @response.body
end

end

0 comments on commit 4a58d34

Please sign in to comment.