more reports controller specs

This commit is contained in:
Marc Anguera Insa
2021-03-08 23:57:20 +01:00
parent d6706def53
commit 16c4e44f31
3 changed files with 26 additions and 8 deletions

View File

@ -133,7 +133,7 @@ GEM
fabrication (2.21.1)
faker (2.16.0)
i18n (>= 1.6, < 2)
ffi (1.14.2)
ffi (1.15.0)
formtastic (4.0.0)
actionpack (>= 5.2.0)
formtastic_i18n (0.6.0)
@ -199,16 +199,16 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0212)
mime-types-data (3.2021.0225)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.3)
minitest (5.14.4)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
netrc (0.11.0)
nio4r (2.5.5)
nio4r (2.5.7)
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
@ -279,7 +279,7 @@ GEM
ffi (~> 1.0)
rdiscount (2.2.0.2)
redis (4.2.5)
regexp_parser (2.0.3)
regexp_parser (2.1.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
@ -307,7 +307,7 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rubocop (1.10.0)
rubocop (1.11.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
@ -390,7 +390,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.5.0)
webdrivers (4.6.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)

View File

@ -4,7 +4,7 @@
<tr>
<th></th>
<th><%= @post_type.model_name.human %></th>
<th><%= Post.human_attribute_name(:tag_list) %></th>
<th><%= Post.human_attribute_name :tag_list %></th>
<th><%= User.model_name.human %></th>
<th><%= Post.human_attribute_name :created_at %></th>
</tr>

View File

@ -45,6 +45,8 @@ RSpec.describe ReportsController do
end
describe 'GET #post_list' do
let(:report_posts) { test_organization.posts.of_active_members.group_by(&:category) }
it 'do NOT show the inactive members' do
get :post_list, params: { type: 'offer' }
@ -52,6 +54,22 @@ RSpec.describe ReportsController do
expect(posts.size).to eq(active_organization_offers.size)
expect(posts.map(&:id)).to match_array(active_organization_offers.map(&:id))
end
it 'downloads a csv' do
get :post_list, params: { type: 'offer', format: 'csv' }
report = Report::Csv::Post.new(test_organization, report_posts, Offer)
expect(response.body).to eq(report.run)
expect(response.media_type).to eq("text/csv")
end
it 'downloads a pdf' do
get :post_list, params: { type: 'offer', format: 'pdf' }
report = Report::Pdf::Post.new(test_organization, report_posts, Offer)
expect(response.body).to eq(report.run)
expect(response.media_type).to eq("application/pdf")
end
end
end
end