From 33b3e72d9a68b0f890a59fea5f87416cc6199b24 Mon Sep 17 00:00:00 2001 From: Jamie Little Date: Wed, 2 Oct 2019 14:41:42 -0500 Subject: [PATCH] Rename CSV Template link and filename This changes the links and filename to the CSV Import Template to Import Template. --- .../zizia/importer_documentation_controller.rb | 9 +++++++++ app/views/zizia/csv_imports/_form.html.erb | 2 +- config/routes.rb | 1 + lib/zizia/version.rb | 2 +- .../importer_documentation_controller_spec.rb | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 app/controllers/zizia/importer_documentation_controller.rb create mode 100644 spec/controllers/importer_documentation_controller_spec.rb diff --git a/app/controllers/zizia/importer_documentation_controller.rb b/app/controllers/zizia/importer_documentation_controller.rb new file mode 100644 index 0000000..51d3535 --- /dev/null +++ b/app/controllers/zizia/importer_documentation_controller.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Zizia + class ImporterDocumentationController < ::ApplicationController + def csv + send_data Zizia::CsvTemplate.new.to_s, type: 'text/csv; charset=utf-8', disposition: 'attachment', filename: 'import_template.csv' + end + end +end diff --git a/app/views/zizia/csv_imports/_form.html.erb b/app/views/zizia/csv_imports/_form.html.erb index 8c464b3..3234665 100644 --- a/app/views/zizia/csv_imports/_form.html.erb +++ b/app/views/zizia/csv_imports/_form.html.erb @@ -19,7 +19,7 @@

Download a CSV template to get started.

diff --git a/config/routes.rb b/config/routes.rb index 77573f3..831d927 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,7 @@ get 'importer_documentation/guide', to: 'metadata_details#show' get 'importer_documentation/profile', to: 'metadata_details#profile' + get 'importer_documentation/csv', to: 'importer_documentation#csv' get 'csv_import_details/index' get 'csv_import_details/show/:id', to: 'csv_import_details#show', as: 'csv_import_detail' diff --git a/lib/zizia/version.rb b/lib/zizia/version.rb index cc4e385..d8d96c6 100644 --- a/lib/zizia/version.rb +++ b/lib/zizia/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Zizia - VERSION = '4.4.0.alpha.01' + VERSION = '4.4.1.alpha.01' end diff --git a/spec/controllers/importer_documentation_controller_spec.rb b/spec/controllers/importer_documentation_controller_spec.rb new file mode 100644 index 0000000..95fc772 --- /dev/null +++ b/spec/controllers/importer_documentation_controller_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true +require 'rails_helper' + +RSpec.describe Zizia::ImporterDocumentationController, type: :controller do + routes { Zizia::Engine.routes } + + describe "GET csv" do + it "provides a csv download" do + get :csv + expect(response.headers['Content-Type']).to eq('text/csv; charset=utf-8') + expect(response.headers['Content-Disposition']).to eq('attachment; filename="import_template.csv"') + end + end +end