Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Discard pagination for CSV activities
Browse files Browse the repository at this point in the history
Fixes #1022

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Sep 27, 2016
1 parent 5c304eb commit 7f12034
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/controllers/admin/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ class Admin::ActivitiesController < Admin::BaseController
respond_to :html, :csv

def index
@activities = PublicActivity::Activity.order("created_at DESC").page(params[:page])
respond_to do |format|
format.html
format.html do
@activities = PublicActivity::Activity.order("created_at DESC").page(params[:page])
end
format.csv do
@activities = PublicActivity::Activity.order("created_at DESC")
headers["Content-Disposition"] = 'attachment; filename="activities.csv"'
headers["Content-Type"] = "text/csv"
end
Expand Down
14 changes: 13 additions & 1 deletion spec/controllers/admin/activities_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@

expect(response.body).to eq(csv)
end
end

it "generates an CSV file with all the entries" do
# Create activities way beyond a single page.
50.times do
team = Team.new(name: "team#{rand(1000..10000)}")
team.owners << user
team.save
team.create_activity :create, owner: user
end

get :index, format: :csv
expect(response.body.split("\n").size).to eq 61
end
end
end

0 comments on commit 7f12034

Please sign in to comment.