Skip to content

Commit

Permalink
fix two minor bugs in test "admin can get all reports"
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredbeck committed Apr 2, 2012
1 parent c342782 commit 763b3cd
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions test/functional/reports_controller_test.rb
Expand Up @@ -9,27 +9,23 @@ class ReportsControllerTest < ActionController::TestCase

test "admin can get all reports" do
sign_in @admin

# Because there is no data in the test db, it is feasible to run all
# of the reports, just to make sure they are successful


# The following reports take no paramters, and only respond to html
%w[index invoices emails activities outstanding_balances
tournaments user_invoices].each do |r|
get r, :year => Time.now.year
%w[index invoices emails activities outstanding_balances tournaments].each do |r|
get r, :year => @admin.year
assert_response :success
end

# These reports also respond to csv
%w[attendees transactions].each do |r|
%w[html csv].each do |f|
get r, :format => f, :year => Time.now.year
get r, :format => f, :year => @admin.year
end
end
# Finally, these two reports take a min and max parameter
%w[atn_badges_all atn_reg_sheets].each do |r|
get r, :year => Time.now.year, :min => 'a', :max => 'z'

# Finally, these reports take a min and max parameter
%w[atn_badges_all atn_reg_sheets user_invoices].each do |r|
get r, :year => @admin.year, :min => 'a', :max => 'z'
assert_response :success
end
end
Expand All @@ -45,16 +41,16 @@ class ReportsControllerTest < ActionController::TestCase
get :attendees, :format => 'csv', :year => Time.now.year
assert_response 403
end

test "transaction report limited to current year" do
sign_in @admin

# create transactions in different years
1.upto(3) { FactoryGirl.create(:tr_sale, year: Time.now.year + 1) }
this_year_sales = []
1.upto(3) { this_year_sales << FactoryGirl.create(:tr_sale) }
expected_sum = this_year_sales.map(&:amount).reduce(:+)

# expect to only see this year's sales on report
get :transactions, :year => Time.now.year
assert_response :success
Expand Down

0 comments on commit 763b3cd

Please sign in to comment.