Browse Source

CLDC-1843 Hide download csv link for sales logs (#1230)

* Hide download csv link for sales logs

* refactor
pull/1245/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
740f4cbdd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/views/logs/_log_list.html.erb
  2. 1
      spec/requests/lettings_logs_controller_spec.rb
  3. 5
      spec/requests/organisations_controller_spec.rb

4
app/views/logs/_log_list.html.erb

@ -1,6 +1,8 @@
<h2 class="govuk-body">
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv" %>
<% if logs&.first&.lettings? %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv" %>
<% end %>
</h2>
<% logs.map do |log| %>
<%= render(LogSummaryComponent.new(current_user:, log:)) %>

1
spec/requests/lettings_logs_controller_spec.rb

@ -458,6 +458,7 @@ RSpec.describe LettingsLogsController, type: :request do
it "includes the search on the CSV link" do
search_term = "foo"
FactoryBot.create(:lettings_log, created_by: user, owning_organisation: user.organisation, tenancycode: "foo")
get "/lettings-logs?search=#{search_term}", headers: headers, params: {}
expect(page).to have_link("Download (CSV)", href: "/lettings-logs/csv-download?search=#{search_term}")
end

5
spec/requests/organisations_controller_spec.rb

@ -1141,10 +1141,11 @@ RSpec.describe OrganisationsController, type: :request do
context "when they view the logs tab" do
before do
FactoryBot.create(:lettings_log, owning_organisation: organisation)
get "/organisations/#{organisation.id}/lettings-logs"
end
it "has a CSV download button with the correct path" do
it "has a CSV download button with the correct path if at least 1 log exists" do
expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/logs/csv-download")
end
@ -1152,7 +1153,7 @@ RSpec.describe OrganisationsController, type: :request do
let(:other_organisation) { FactoryBot.create(:organisation) }
before do
FactoryBot.create_list(:lettings_log, 3, owning_organisation: organisation)
FactoryBot.create_list(:lettings_log, 2, owning_organisation: organisation)
FactoryBot.create_list(:lettings_log, 2, owning_organisation: other_organisation)
end

Loading…
Cancel
Save