clark_kent 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ class ClarkKent::ReportEmailTest < ActiveSupport::TestCase
4
+ test "sends report to s3" do
5
+ ClarkKent::ReportUploaderBucketName = 'test_bucket'
6
+ user = User.find_by(email: 'taproot@gmail.com')
7
+ report = ClarkKent::Report.first
8
+ report.update_columns(sharing_scope_type: 'Department', sharing_scope_id: user.department_id)
9
+ report_email = report.report_emails.create(name: 'test_emailer')
10
+ report_email.report_filters.create(
11
+ filter_name: "created_at",
12
+ filter_value: nil,
13
+ type: "ClarkKent::ReportDateFilter",
14
+ duration: "week",
15
+ kind_of_day: "Monday",
16
+ offset: "this_week")
17
+ bucket_mock = ->(string) { raise 'finished building report'}
18
+ err = assert_raises(RuntimeError) do
19
+ AWS::S3::Bucket.stub :new, bucket_mock, [String] do
20
+ report_email.send_email(user.id)
21
+ end
22
+ end
23
+ err.message.must_match('finished building report')
24
+ end
25
+
26
+ test "throws an error if required date filters are not present" do
27
+ user = User.find_by(email: 'taproot@gmail.com')
28
+ report = ClarkKent::Report.first
29
+ report.update_columns(sharing_scope_type: 'Department', sharing_scope_id: user.department_id)
30
+ report_email = report.report_emails.create(name: 'test_emailer')
31
+ assert_raises(ClarkKent::ReportFilterError) do
32
+ report_email.send_email(user.id)
33
+ end
34
+ end
35
+ end
@@ -9,7 +9,8 @@ def setup_db
9
9
  report.report_columns.create(column_name: 'id', column_order: 2)
10
10
  report.report_columns.create(column_name: 'amount', column_order: 3)
11
11
  report.report_columns.create(column_name: 'description', column_order: 4)
12
- u = User.create(name: 'Michael Hedges', email: 'taproot@gmail.com')
12
+ d = Department.create(name: 'silly walks')
13
+ u = User.create(name: 'Michael Hedges', email: 'taproot@gmail.com', department_id: d.id)
13
14
  Order.create(user_id: u.id, description: 'Guitar strings', amount: 1)
14
15
  end
15
16
 
data/test/test_helper.rb CHANGED
@@ -16,3 +16,6 @@ Rails.backtrace_cleaner.remove_silencers!
16
16
  # Load support files
17
17
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
18
18
 
19
+ class ActiveSupport::TestCase
20
+ extend MiniTest::Spec::DSL
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clark_kent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aws-sdk
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: sqlite3
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -276,11 +290,11 @@ files:
276
290
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
277
291
  - test/dummy/tmp/cache/assets/test/sprockets/ebe8eac74b8e6016fd44b19e6e708e61
278
292
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
279
- - test/dummy/tmp/pids/server.pid
280
293
  - test/fixtures/clark_kent/reports.yml
281
294
  - test/helpers/clark_kent/reports_helper_spec.rb
282
295
  - test/helpers/clark_kent/reports_helper_test.rb
283
296
  - test/integration/navigation_test.rb
297
+ - test/models/clark_kent/report_email_test.rb
284
298
  - test/models/clark_kent/report_test.rb
285
299
  - test/support/db_utils.rb
286
300
  - test/test_helper.rb
@@ -395,11 +409,11 @@ test_files:
395
409
  - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
396
410
  - test/dummy/tmp/cache/assets/test/sprockets/ebe8eac74b8e6016fd44b19e6e708e61
397
411
  - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
398
- - test/dummy/tmp/pids/server.pid
399
412
  - test/fixtures/clark_kent/reports.yml
400
413
  - test/helpers/clark_kent/reports_helper_spec.rb
401
414
  - test/helpers/clark_kent/reports_helper_test.rb
402
415
  - test/integration/navigation_test.rb
416
+ - test/models/clark_kent/report_email_test.rb
403
417
  - test/models/clark_kent/report_test.rb
404
418
  - test/support/db_utils.rb
405
419
  - test/test_helper.rb
@@ -1 +0,0 @@
1
- 58957