diff --git a/app/views/requests/show.html.erb b/app/views/requests/show.html.erb index 9d689bd42d..19a44d5cd5 100644 --- a/app/views/requests/show.html.erb +++ b/app/views/requests/show.html.erb @@ -107,8 +107,10 @@ <%= submit_button_to start_request_path(@request), {text: "Fulfill request", size: "md"} unless @request.distribution %> <%= view_button_to(distribution_path(@request.distribution), {text: "View Associated Distribution", size: "md"}) if @request.distribution %> <%= print_button_to print_picklist_request_path(@request), { format: :pdf, text: "Print", size: "md" } %> - <%= button_to 'Cancel', new_request_cancelation_path(request_id: @request.id), - method: :get, data: { disable_with: "Please wait..." }, form_class: 'd-inline', class: 'btn btn-danger btn-md' %> + <% unless @request.status_fulfilled? %> + <%= button_to 'Cancel', new_request_cancelation_path(request_id: @request.id), + method: :get, data: { disable_with: "Please wait..." }, form_class: 'd-inline', class: 'btn btn-danger btn-md' %> + <% end %> diff --git a/spec/requests/requests_requests_spec.rb b/spec/requests/requests_requests_spec.rb index 32e8760cf2..7bde1cc7b1 100644 --- a/spec/requests/requests_requests_spec.rb +++ b/spec/requests/requests_requests_spec.rb @@ -156,6 +156,19 @@ expect(response.body).not_to include('Units (if applicable)') end end + + context 'when the request has a Fulfilled status' do + it 'does not display the Cancel button' do + fulfilled_request = create(:request, :fulfilled) + + get requests_path(fulfilled_request) + + page = Nokogiri::HTML(response.body) + cancel_button = page.at_css('button') { |el| el.text.strip == 'Cancel' } + + expect(cancel_button).not_to be_present + end + end end describe 'POST #start' do