dossier 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/{README.markdown → README.md} +10 -5
  3. data/Rakefile +1 -0
  4. data/app/controllers/dossier/reports_controller.rb +9 -38
  5. data/app/helpers/dossier/application_helper.rb +7 -1
  6. data/app/views/dossier/layouts/application.html.haml +6 -0
  7. data/app/views/dossier/reports/multi.html.haml +8 -3
  8. data/app/views/dossier/reports/show.html.haml +4 -2
  9. data/config/routes.rb +2 -2
  10. data/lib/dossier.rb +4 -8
  11. data/lib/dossier/adapter/active_record.rb +1 -1
  12. data/lib/dossier/formatter.rb +20 -3
  13. data/lib/dossier/multi_report.rb +17 -9
  14. data/lib/dossier/naming.rb +51 -0
  15. data/lib/dossier/renderer.rb +63 -0
  16. data/lib/dossier/report.rb +22 -7
  17. data/lib/dossier/responder.rb +34 -0
  18. data/lib/dossier/result.rb +5 -7
  19. data/lib/dossier/stream_csv.rb +10 -3
  20. data/lib/dossier/version.rb +1 -1
  21. data/lib/dossier/view_context_with_report_formatter.rb +7 -0
  22. data/lib/dossier/xls.rb +2 -2
  23. data/lib/generators/dossier/views/templates/show.html.haml +5 -3
  24. data/spec/dossier/adapter/active_record_spec.rb +1 -1
  25. data/spec/dossier/formatter_spec.rb +38 -3
  26. data/spec/dossier/multi_report_spec.rb +18 -1
  27. data/spec/dossier/naming_spec.rb +29 -0
  28. data/spec/dossier/renderer_spec.rb +57 -0
  29. data/spec/dossier/report_spec.rb +23 -2
  30. data/spec/dossier/responder_spec.rb +59 -0
  31. data/spec/dossier/result_spec.rb +4 -0
  32. data/spec/dossier/stream_csv_spec.rb +75 -0
  33. data/spec/dossier_spec.rb +0 -13
  34. data/spec/dummy/app/controllers/site_controller.rb +0 -4
  35. data/spec/dummy/app/reports/cats/are/super_fun_report.rb +9 -0
  36. data/spec/dummy/app/reports/combination_report.rb +9 -0
  37. data/spec/{support → dummy/app}/reports/employee_report.rb +0 -0
  38. data/spec/{support → dummy/app}/reports/employee_with_custom_client_report.rb +0 -0
  39. data/spec/dummy/app/reports/employee_with_custom_view_report.rb +27 -0
  40. data/spec/dummy/app/reports/hello_my_friends_report.rb +2 -0
  41. data/spec/{support → dummy/app}/reports/test_report.rb +0 -0
  42. data/spec/dummy/app/views/dossier/reports/combination/_options.html.haml +4 -0
  43. data/spec/dummy/app/views/dossier/reports/employee_with_custom_view.html.haml +5 -1
  44. data/spec/dummy/app/views/dossier/reports/employee_with_custom_view/_options.html.haml +6 -0
  45. data/spec/dummy/config/database.yml.travis +5 -0
  46. data/spec/dummy/db/test.sqlite3 +0 -0
  47. data/spec/dummy/log/development.log +3865 -0
  48. data/spec/dummy/log/test.log +44084 -0
  49. data/spec/dummy/tmp/cache/assets/CEA/5A0/sprockets%2Fc0534884cbc43494a05d9e957ea1298d +0 -0
  50. data/spec/dummy/tmp/cache/assets/D40/0D0/sprockets%2F15a6bb0a1346b6d7fe859c14bf729a49 +0 -0
  51. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  52. data/spec/dummy/tmp/cache/assets/D51/510/sprockets%2Fca0353abc266080173bbc3c13efa935a +0 -0
  53. data/spec/dummy/tmp/cache/assets/D6C/400/sprockets%2F7fa180a6e05c7ca4346ef58c54bb30f8 +0 -0
  54. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  55. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  56. data/spec/dummy/{dossier_test → tmp/restart.txt} +0 -0
  57. data/spec/features/combination_report_spec.rb +13 -10
  58. data/spec/features/employee_spec.rb +76 -0
  59. data/spec/{requests → features}/employee_with_custom_client_spec.rb +3 -2
  60. data/spec/{requests → features}/employee_with_custom_controller_spec.rb +3 -2
  61. data/spec/features/namespaced_report_spec.rb +15 -0
  62. data/spec/fixtures/db/mysql2.yml.travis +4 -0
  63. data/spec/fixtures/db/sqlite3.yml.travis +2 -0
  64. data/spec/helpers/dossier/application_helper_spec.rb +24 -0
  65. data/spec/spec_helper.rb +11 -0
  66. metadata +99 -92
  67. data/spec/fixtures/reports/employee.html +0 -54
  68. data/spec/fixtures/reports/employee_with_custom_client.html +0 -54
  69. data/spec/fixtures/reports/employee_with_custom_view.html +0 -15
  70. data/spec/fixtures/reports/employee_with_footer.html +0 -56
  71. data/spec/fixtures/reports/employee_with_parameters.html +0 -38
  72. data/spec/requests/employee_spec.rb +0 -61
  73. data/spec/support/reports/combination_report.rb +0 -8
  74. data/spec/support/reports/employee_with_custom_view_report.rb +0 -8
  75. data/spec/support/reports/hello_my_friends_report.rb +0 -6
@@ -1,54 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css" />
6
- <script src="/assets/application.js" type="text/javascript"></script>
7
-
8
- </head>
9
- <body>
10
-
11
- <h1>Employee Report</h1>
12
- <a href="/reports/employee.csv?" class="download-csv">Download CSV</a>
13
- <table>
14
- <thead>
15
- <tr>
16
- <th>Id</th>
17
- <th>Name</th>
18
- <th>Division</th>
19
- <th>Salary</th>
20
- <th>Suspended</th>
21
- <th>Hired On</th>
22
- </tr>
23
- </thead>
24
- <tbody>
25
- <tr>
26
- <td>3</td>
27
- <td>Employee Elise Elderberry</td>
28
- <td>Corporate Malfeasance</td>
29
- <td>Who's Asking?</td>
30
- <td>No</td>
31
- <td>2013-01-11</td>
32
- </tr>
33
- <tr>
34
- <td>2</td>
35
- <td>Employee Jimmy Jackalope, Jr.</td>
36
- <td>Tedious Toiling</td>
37
- <td>$20,000.00</td>
38
- <td>Yes</td>
39
- <td>2013-01-11</td>
40
- </tr>
41
- <tr>
42
- <td>1</td>
43
- <td>Employee Moustafa McMann</td>
44
- <td>Zany Inventions</td>
45
- <td>$30,000.00</td>
46
- <td>No</td>
47
- <td>2010-10-02</td>
48
- </tr>
49
- </tbody>
50
- </table>
51
-
52
-
53
- </body>
54
- </html>
@@ -1,54 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css" />
6
- <script src="/assets/application.js" type="text/javascript"></script>
7
-
8
- </head>
9
- <body>
10
-
11
- <h1>Employee With Custom Client Report</h1>
12
- <a href="/reports/employee_with_custom_client.csv?" class="download-csv">Download CSV</a>
13
- <table>
14
- <thead>
15
- <tr>
16
- <th>Id</th>
17
- <th>Name</th>
18
- <th>Division</th>
19
- <th>Salary</th>
20
- <th>Suspended</th>
21
- <th>Hired On</th>
22
- </tr>
23
- </thead>
24
- <tbody>
25
- <tr>
26
- <td>1</td>
27
- <td>MOUSTAFA MCMANN</td>
28
- <td>Zany Inventions</td>
29
- <td>30000</td>
30
- <td>0</td>
31
- <td>2010-10-02</td>
32
- </tr>
33
- <tr>
34
- <td>2</td>
35
- <td>JIMMY JACKALOPE, JR.</td>
36
- <td>Tedious Toiling</td>
37
- <td>20000</td>
38
- <td>1</td>
39
- <td>2013-01-11</td>
40
- </tr>
41
- <tr>
42
- <td>3</td>
43
- <td>ELISE ELDERBERRY</td>
44
- <td>Corporate Malfeasance</td>
45
- <td>99000</td>
46
- <td>0</td>
47
- <td>2013-01-11</td>
48
- </tr>
49
- </tbody>
50
- </table>
51
-
52
-
53
- </body>
54
- </html>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css" />
6
- <script src="/assets/application.js" type="text/javascript"></script>
7
-
8
- </head>
9
- <body>
10
-
11
- <h1>Yeah. Did you get that memo?</h1>
12
-
13
-
14
- </body>
15
- </html>
@@ -1,56 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css" />
6
- <script src="/assets/application.js" type="text/javascript"></script>
7
-
8
- </head>
9
- <body>
10
-
11
- <h1>Employee Report</h1>
12
- <a href="/reports/employee.csv?options%5Bfooter%5D=1" class="download-csv">Download CSV</a>
13
- <table>
14
- <thead>
15
- <tr>
16
- <th>Id</th>
17
- <th>Name</th>
18
- <th>Division</th>
19
- <th>Salary</th>
20
- <th>Suspended</th>
21
- <th>Hired On</th>
22
- </tr>
23
- </thead>
24
- <tbody>
25
- <tr>
26
- <td>3</td>
27
- <td>Employee Elise Elderberry</td>
28
- <td>Corporate Malfeasance</td>
29
- <td>Who's Asking?</td>
30
- <td>No</td>
31
- <td>2013-01-11</td>
32
- </tr>
33
- <tr>
34
- <td>2</td>
35
- <td>Employee Jimmy Jackalope, Jr.</td>
36
- <td>Tedious Toiling</td>
37
- <td>$20,000.00</td>
38
- <td>Yes</td>
39
- <td>2013-01-11</td>
40
- </tr>
41
- </tbody>
42
- <tfoot>
43
- <tr>
44
- <th>1</th>
45
- <th>Employee Moustafa McMann</th>
46
- <th>Zany Inventions</th>
47
- <th>$30,000.00</th>
48
- <th>No</th>
49
- <th>2010-10-02</th>
50
- </tr>
51
- </tfoot>
52
- </table>
53
-
54
-
55
- </body>
56
- </html>
@@ -1,38 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <link href="/assets/application.css" media="all" rel="stylesheet" type="text/css" />
6
- <script src="/assets/application.js" type="text/javascript"></script>
7
-
8
- </head>
9
- <body>
10
-
11
- <h1>Employee Report</h1>
12
- <a href="/reports/employee.csv?options%5Bdivisions%5D%5B%5D=Tedious+Toiling&amp;options%5Bnames%5D%5B%5D=Jimmy+Jackalope&amp;options%5Bnames%5D%5B%5D=Moustafa+McMann&amp;options%5Border%5D=desc&amp;options%5Bsalary%5D=true" class="download-csv">Download CSV</a>
13
- <table>
14
- <thead>
15
- <tr>
16
- <th>Id</th>
17
- <th>Name</th>
18
- <th>Division</th>
19
- <th>Salary</th>
20
- <th>Suspended</th>
21
- <th>Hired On</th>
22
- </tr>
23
- </thead>
24
- <tbody>
25
- <tr>
26
- <td>2</td>
27
- <td>Employee Jimmy Jackalope, Jr.</td>
28
- <td>Tedious Toiling</td>
29
- <td>$20,000.00</td>
30
- <td>Yes</td>
31
- <td>2013-01-11</td>
32
- </tr>
33
- </tbody>
34
- </table>
35
-
36
-
37
- </body>
38
- </html>
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "employee report" do
4
-
5
- describe "rendering HTML" do
6
-
7
- context "when a custom view exists for the report" do
8
-
9
- it "uses the custom view" do
10
- get '/reports/employee_with_custom_view'
11
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee_with_custom_view.html'))
12
- end
13
-
14
- end
15
-
16
- context "when no custom view exists for the report" do
17
-
18
- it "creates an HTML report using its standard 'show' view" do
19
- get '/reports/employee'
20
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee.html'))
21
- end
22
-
23
- it "uses any options provided" do
24
- get '/reports/employee', options: {
25
- salary: true, order: 'desc',
26
- names: ['Jimmy Jackalope', 'Moustafa McMann'],
27
- divisions: ['Tedious Toiling']
28
- }
29
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee_with_parameters.html'))
30
- end
31
-
32
- it "moves the specified number of rows into the footer" do
33
- get '/reports/employee', options: {
34
- footer: 1
35
- }
36
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee_with_footer.html'))
37
- end
38
-
39
- end
40
-
41
- end
42
-
43
- describe "rendering CSV" do
44
-
45
- it "creates a standard CSV report" do
46
- get '/reports/employee.csv'
47
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee.csv'))
48
- end
49
-
50
- end
51
-
52
- describe "rendering XLS" do
53
-
54
- it "creates a standard XLS report" do
55
- get '/reports/employee.xls'
56
- expect(response.body).to eq(File.read('spec/fixtures/reports/employee.xls'))
57
- end
58
-
59
- end
60
-
61
- end
@@ -1,8 +0,0 @@
1
- require Rails.root.join(*%w[.. support reports employee_report])
2
- require Rails.root.join(*%w[.. support reports employee_with_custom_view_report])
3
-
4
- class CombinationReport < Dossier::MultiReport
5
-
6
- combine EmployeeReport, EmployeeWithCustomViewReport
7
-
8
- end
@@ -1,8 +0,0 @@
1
- class EmployeeWithCustomViewReport < Dossier::Report
2
- # See spec/dummy/app/views
3
-
4
- def sql
5
- "SELECT * FROM employees WHERE suspended = true"
6
- end
7
-
8
- end
@@ -1,6 +0,0 @@
1
- class HelloMyFriendsReport < Dossier::Report
2
- def sql
3
- # Doesn't matter; not meant to be run.
4
- "select * from employees"
5
- end
6
- end