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. 2
      app/views/logs/_log_list.html.erb
  2. 1
      spec/requests/lettings_logs_controller_spec.rb
  3. 5
      spec/requests/organisations_controller_spec.rb

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

@ -1,6 +1,8 @@
<h2 class="govuk-body"> <h2 class="govuk-body">
<%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %> <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", path: request.path)) %>
<% if logs&.first&.lettings? %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv" %> <%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv" %>
<% end %>
</h2> </h2>
<% logs.map do |log| %> <% logs.map do |log| %>
<%= render(LogSummaryComponent.new(current_user:, 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 it "includes the search on the CSV link" do
search_term = "foo" 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: {} get "/lettings-logs?search=#{search_term}", headers: headers, params: {}
expect(page).to have_link("Download (CSV)", href: "/lettings-logs/csv-download?search=#{search_term}") expect(page).to have_link("Download (CSV)", href: "/lettings-logs/csv-download?search=#{search_term}")
end 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 context "when they view the logs tab" do
before do before do
FactoryBot.create(:lettings_log, owning_organisation: organisation)
get "/organisations/#{organisation.id}/lettings-logs" get "/organisations/#{organisation.id}/lettings-logs"
end 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") expect(page).to have_link("Download (CSV)", href: "/organisations/#{organisation.id}/logs/csv-download")
end end
@ -1152,7 +1153,7 @@ RSpec.describe OrganisationsController, type: :request do
let(:other_organisation) { FactoryBot.create(:organisation) } let(:other_organisation) { FactoryBot.create(:organisation) }
before do 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) FactoryBot.create_list(:lettings_log, 2, owning_organisation: other_organisation)
end end

Loading…
Cancel
Save