Skip to content

Commit

Permalink
tests: the decorator and the controller are covered
Browse files Browse the repository at this point in the history
I've also adapted the tests of members and offers decorators. Issue #596.
  • Loading branch information
franpb14 committed May 22, 2021
1 parent 79ac2f4 commit f8c27ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/decorators/report/detailed_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ def initialize(org)

def name(extension)
"#{@org.name.parameterize}_"\
"#{Date.today}."\
"#{I18n.t('global.detailed')}_"\
".#{extension}"
"#{Date.today}."\
"#{extension}"
end

def headers
Expand Down Expand Up @@ -76,7 +76,7 @@ def post_headers
end

def post_rows
make_rows(Post, %w[tsv], @org.posts.map)
make_rows(Post, %w[tsv], @org.posts)
end

def transfer_headers
Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/reports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
end
end

describe 'GET #download_csv_detailed' do
it 'downloads a CSV' do
get :download_csv_detailed
report = Report::Csv::Detailed.new(test_organization)

expect(response.body).to eq(report.run)
expect(response.media_type).to eq("text/csv")
end
end

describe 'GET #download_all' do
it 'downloads a zip' do
get :download_all
Expand All @@ -99,6 +109,7 @@
expect(response.body).to include('Offers')
expect(response.body).to include('Members')
expect(response.body).to include('Transfers')
expect(response.body).to include('Detaileds')
end

it 'redirects to download_all_report_path (retry) if zip is not ready' do
Expand Down
4 changes: 0 additions & 4 deletions spec/decorators/report/member_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
User.human_attribute_name(:alt_phone),
User.human_attribute_name(:created_at),
User.human_attribute_name(:last_sign_in_at),
User.human_attribute_name(:locale),
Account.human_attribute_name(:balance)
])
end

Expand All @@ -37,8 +35,6 @@
member.user.alt_phone,
member.user.created_at.to_s,
member.user.last_sign_in_at.to_s,
member.user.locale,
member.account_balance.to_s
]
])
end
Expand Down
3 changes: 1 addition & 2 deletions spec/decorators/report/post_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

it "#headers" do
expect(decorator.headers).to eq([
"",
Offer.model_name.human,
Post.human_attribute_name(:tag_list),
User.model_name.human,
Expand All @@ -38,7 +37,7 @@

expect(decorator.rows).to eq([
["", category.name, "", "", ""],
[offer.id, offer.title, offer.tag_list.to_s, "#{offer.user} (#{offer.member_uid})", offer.created_at.to_s]
[offer.title, offer.tag_list.to_s, "#{offer.user} (#{offer.member_uid})", offer.created_at.to_s]
])
end
end

0 comments on commit f8c27ab

Please sign in to comment.