* Allow export of mutes list * Allow importing of mutes list * Refactor to use Settings::Exports::BaseController and DRY up exports codeclosed-social-glitch-2
@ -0,0 +1,23 @@ | |||||
# frozen_string_literal: true | |||||
module Settings | |||||
module Exports | |||||
class BaseController < ApplicationController | |||||
before_action :authenticate_user! | |||||
def index | |||||
export_data = Export.new(export_accounts).to_csv | |||||
respond_to do |format| | |||||
format.csv { send_data export_data, filename: export_filename } | |||||
end | |||||
end | |||||
private | |||||
def export_filename | |||||
"#{controller_name}.csv" | |||||
end | |||||
end | |||||
end | |||||
end |
@ -0,0 +1,13 @@ | |||||
# frozen_string_literal: true | |||||
module Settings | |||||
module Exports | |||||
class MutedAccountsController < BaseController | |||||
private | |||||
def export_accounts | |||||
current_account.muting | |||||
end | |||||
end | |||||
end | |||||
end |
@ -0,0 +1,17 @@ | |||||
require 'rails_helper' | |||||
describe Settings::Exports::MutedAccountsController do | |||||
before do | |||||
sign_in Fabricate(:user), scope: :user | |||||
end | |||||
describe 'GET #index' do | |||||
it 'returns a csv of the muting accounts' do | |||||
get :index, format: :csv | |||||
expect(response).to have_http_status(:success) | |||||
expect(response.content_type).to eq 'text/csv' | |||||
expect(response.headers['Content-Disposition']).to eq 'attachment; filename="muted_accounts.csv"' | |||||
end | |||||
end | |||||
end |