report_cat 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +147 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/javascripts/report_cat/application.js +13 -0
  6. data/app/assets/stylesheets/report_cat/application.css +13 -0
  7. data/app/controllers/report_cat/reports_controller.rb +43 -0
  8. data/app/helpers/report_cat/reports_helper.rb +132 -0
  9. data/app/models/report_cat/date_range.rb +94 -0
  10. data/app/views/report_cat/reports/_google_charts.html.erb +61 -0
  11. data/app/views/report_cat/reports/index.html.erb +2 -0
  12. data/app/views/report_cat/reports/show.html.erb +15 -0
  13. data/config/locales/en.yml +26 -0
  14. data/config/routes.rb +7 -0
  15. data/db/migrate/20130918075200_create_date_ranges.rb +13 -0
  16. data/lib/report_cat/config.rb +30 -0
  17. data/lib/report_cat/core/chart.rb +50 -0
  18. data/lib/report_cat/core/column.rb +70 -0
  19. data/lib/report_cat/core/param.rb +35 -0
  20. data/lib/report_cat/core/report.rb +127 -0
  21. data/lib/report_cat/engine.rb +11 -0
  22. data/lib/report_cat/matchers/have_chart.rb +58 -0
  23. data/lib/report_cat/matchers/have_column.rb +45 -0
  24. data/lib/report_cat/matchers/have_param.rb +52 -0
  25. data/lib/report_cat/reports/cohort_report.rb +113 -0
  26. data/lib/report_cat/reports/date_range_report.rb +66 -0
  27. data/lib/report_cat/version.rb +3 -0
  28. data/lib/report_cat.rb +39 -0
  29. data/lib/tasks/report_cat.rake +4 -0
  30. data/spec/controllers/report_cat/reports_controller_spec.rb +100 -0
  31. data/spec/coverage_spec.rb +18 -0
  32. data/spec/data/helpers/report_charts.html +1 -0
  33. data/spec/data/helpers/report_charts.html.tmp +1 -0
  34. data/spec/data/helpers/report_form.html +63 -0
  35. data/spec/data/helpers/report_form.html.tmp +63 -0
  36. data/spec/data/helpers/report_form_param.html +1 -0
  37. data/spec/data/helpers/report_form_param.html.tmp +1 -0
  38. data/spec/data/helpers/report_list.html +1 -0
  39. data/spec/data/helpers/report_list.html.tmp +1 -0
  40. data/spec/data/helpers/report_param_checkbox.html +1 -0
  41. data/spec/data/helpers/report_param_checkbox.html.tmp +1 -0
  42. data/spec/data/helpers/report_param_date.html +60 -0
  43. data/spec/data/helpers/report_param_date.html.tmp +60 -0
  44. data/spec/data/helpers/report_param_hidden.html +1 -0
  45. data/spec/data/helpers/report_param_hidden.html.tmp +1 -0
  46. data/spec/data/helpers/report_param_select.html +3 -0
  47. data/spec/data/helpers/report_param_select.html.tmp +3 -0
  48. data/spec/data/helpers/report_param_text_field.html +1 -0
  49. data/spec/data/helpers/report_param_text_field.html.tmp +1 -0
  50. data/spec/data/helpers/report_table.html +1 -0
  51. data/spec/data/helpers/report_table.html.tmp +1 -0
  52. data/spec/data/helpers/report_table_hidden.html +1 -0
  53. data/spec/data/helpers/report_table_hidden.html.tmp +1 -0
  54. data/spec/data/lib/chart_columns.json +1 -0
  55. data/spec/data/lib/chart_columns.json.tmp +1 -0
  56. data/spec/data/lib/chart_data.json +1 -0
  57. data/spec/data/lib/chart_data.json.tmp +1 -0
  58. data/spec/data/lib/date_range_report_where.sql +6 -0
  59. data/spec/data/lib/date_range_report_where.sql.tmp +6 -0
  60. data/spec/data/lib/report.csv +3 -0
  61. data/spec/data/lib/report.csv.tmp +3 -0
  62. data/spec/data/lib/report.sql +1 -0
  63. data/spec/data/lib/report.sql.tmp +1 -0
  64. data/spec/data/models/sql_intersect.sql +5 -0
  65. data/spec/data/models/sql_intersect.sql.tmp +5 -0
  66. data/spec/dummy/README.rdoc +28 -0
  67. data/spec/dummy/Rakefile +6 -0
  68. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  69. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  70. data/spec/dummy/app/controllers/application_controller.rb +21 -0
  71. data/spec/dummy/app/controllers/root_controller.rb +20 -0
  72. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  73. data/spec/dummy/app/models/user.rb +13 -0
  74. data/spec/dummy/app/models/visit.rb +16 -0
  75. data/spec/dummy/app/reports/retention_cohort_report.rb +19 -0
  76. data/spec/dummy/app/reports/retention_report.rb +30 -0
  77. data/spec/dummy/app/reports/user_report.rb +23 -0
  78. data/spec/dummy/app/views/layouts/admin.html.erb +19 -0
  79. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  80. data/spec/dummy/app/views/root/index.html.erb +8 -0
  81. data/spec/dummy/bin/bundle +3 -0
  82. data/spec/dummy/bin/rails +4 -0
  83. data/spec/dummy/bin/rake +4 -0
  84. data/spec/dummy/config/application.rb +30 -0
  85. data/spec/dummy/config/boot.rb +5 -0
  86. data/spec/dummy/config/database.yml +25 -0
  87. data/spec/dummy/config/environment.rb +5 -0
  88. data/spec/dummy/config/environments/development.rb +31 -0
  89. data/spec/dummy/config/environments/production.rb +80 -0
  90. data/spec/dummy/config/environments/test.rb +36 -0
  91. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  92. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  93. data/spec/dummy/config/initializers/inflections.rb +16 -0
  94. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  95. data/spec/dummy/config/initializers/report_cat.rb +15 -0
  96. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  97. data/spec/dummy/config/initializers/session_store.rb +3 -0
  98. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  99. data/spec/dummy/config/locales/en.yml +38 -0
  100. data/spec/dummy/config/routes.rb +13 -0
  101. data/spec/dummy/config.ru +4 -0
  102. data/spec/dummy/db/development.sqlite3 +0 -0
  103. data/spec/dummy/db/schema.rb +26 -0
  104. data/spec/dummy/db/test.sqlite3 +0 -0
  105. data/spec/dummy/log/development.log +61 -0
  106. data/spec/dummy/log/test.log +26478 -0
  107. data/spec/dummy/public/404.html +58 -0
  108. data/spec/dummy/public/422.html +58 -0
  109. data/spec/dummy/public/500.html +57 -0
  110. data/spec/dummy/public/favicon.ico +0 -0
  111. data/spec/helpers/report_cat/reports_helper_spec.rb +224 -0
  112. data/spec/lib/report_cat/config_spec.rb +96 -0
  113. data/spec/lib/report_cat/core/chart_spec.rb +67 -0
  114. data/spec/lib/report_cat/core/column_spec.rb +156 -0
  115. data/spec/lib/report_cat/core/param_spec.rb +95 -0
  116. data/spec/lib/report_cat/core/report_spec.rb +342 -0
  117. data/spec/lib/report_cat/engine_spec.rb +9 -0
  118. data/spec/lib/report_cat/matchers/have_chart_spec.rb +36 -0
  119. data/spec/lib/report_cat/matchers/have_column_spec.rb +30 -0
  120. data/spec/lib/report_cat/matchers/have_param_spec.rb +33 -0
  121. data/spec/lib/report_cat/reports/cohort_report_spec.rb +215 -0
  122. data/spec/lib/report_cat/reports/date_range_report_spec.rb +125 -0
  123. data/spec/lib/report_cat/version_spec.rb +11 -0
  124. data/spec/lib/report_cat_spec.rb +62 -0
  125. data/spec/lib/tasks/report_cat.rake_spec.rb +13 -0
  126. data/spec/models/report_cat/date_range_spec.rb +144 -0
  127. data/spec/rails_helper.rb +49 -0
  128. data/spec/spec_helper.rb +23 -0
  129. data/spec/support/setup_reports.rb +28 -0
  130. data/spec/views/report_cat/reports/index.html.erb_spec.rb +16 -0
  131. data/spec/views/report_cat/reports/show.html.erb_spec.rb +19 -0
  132. metadata +489 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,224 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReportCat::ReportsHelper do
4
+
5
+ include SetupReports
6
+
7
+ before( :each ) do
8
+ setup_reports
9
+ end
10
+
11
+ #############################################################################
12
+ # report_back
13
+
14
+ describe '#report_back' do
15
+
16
+ context 'when back is set' do
17
+
18
+ it 'returns a link to the back report' do
19
+ @report.back = { :name => :user_report }
20
+ expected = "<a href=\"/report_cat/reports/user_report\">User Report</a>"
21
+ expect( helper.report_back( @report ) ).to eql( expected )
22
+ end
23
+
24
+ end
25
+
26
+ context 'when back is not set' do
27
+
28
+ it 'returns a link to the report root path' do
29
+ @report.back = nil
30
+ expected = "<a href=\"/\">Reports</a>"
31
+ expect( helper.report_back( @report ) ).to eql( expected )
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ #############################################################################
39
+ # report_chart_partial
40
+
41
+ describe '#report_chart_partial' do
42
+
43
+ it 'renders the google charts partial' do
44
+ expect( helper ).to receive( :render ).with( :partial => 'report_cat/reports/google_charts' )
45
+ helper.report_chart_partial
46
+ end
47
+
48
+ end
49
+
50
+ #############################################################################
51
+ # report_charts
52
+
53
+ describe '#report_charts' do
54
+
55
+ it 'renders the configured charts' do
56
+ expect( helper.report_charts( @report ) ).to eql_file( 'spec/data/helpers/report_charts.html' )
57
+ end
58
+
59
+ end
60
+
61
+ #############################################################################
62
+ # report_count
63
+
64
+ describe '#report_count' do
65
+
66
+ it 'returns a translated count string' do
67
+ expected = I18n.t( :count, :scope => :report_cat, :count => @report.rows.count )
68
+ expect( helper.report_count( @report ) ).to eql( expected )
69
+ end
70
+
71
+ end
72
+
73
+ #############################################################################
74
+ # report_csv_link
75
+
76
+ describe '#report_csv_link' do
77
+
78
+ it 'renders a CSV link' do
79
+ url = '/foo/bar?format=csv'
80
+ expect( helper ).to receive( :url_for ).with( { :params => { :format => :csv } } ).and_return( url )
81
+ expected = "<a href=\"#{url}\">Export as CSV</a>"
82
+ expect( helper.report_csv_link( @report ) ).to eql( expected )
83
+ end
84
+
85
+ end
86
+
87
+ #############################################################################
88
+ # report_description
89
+
90
+ describe '#report_description' do
91
+
92
+ it 'renders the localized description for the report' do
93
+ expected = t( :description, :scope => [ :report_cat, :instances, @report.name.to_sym ] )
94
+ expect( helper.report_description( @report ) ).to eql( expected )
95
+ end
96
+
97
+ end
98
+
99
+ #############################################################################
100
+ # report_form
101
+
102
+ describe '#report_form' do
103
+
104
+ it 'renders a form for the report params' do
105
+ pending 'broken on Travis in a non-obvious way. need build artifact. http://blog.travis-ci.com/2012-12-18-travis-artifacts/ '
106
+ expect( helper ).to receive( :report_path ).and_return( '' )
107
+ expect( helper.report_form( @report ) ).to eql_file( 'spec/data/helpers/report_form.html' )
108
+ end
109
+
110
+ end
111
+
112
+ #############################################################################
113
+ # report_form_param
114
+
115
+ describe '#report_form_param' do
116
+
117
+ it 'returns a div with the form element' do
118
+ param = @report.param( :check_box_test )
119
+ expect( helper.report_form_param( param ) ).to eql_file( 'spec/data/helpers/report_form_param.html' )
120
+ end
121
+
122
+ it 'returns hidden params' do
123
+ param = @report.param( :hidden_test )
124
+ expected = "<input id=\"hidden_test\" name=\"hidden_test\" type=\"hidden\" value=\"true\" />"
125
+ expect( helper.report_form_param( param ) ).to eql( expected )
126
+ end
127
+
128
+ end
129
+
130
+ #############################################################################
131
+ # report_link
132
+
133
+ describe '#report_link' do
134
+
135
+ it 'generates a link to a report' do
136
+ attributes = { :name => :cohort_report, :is_cohort => '1' }
137
+ expected = "<a href=\"/report_cat/reports/cohort_report?is_cohort=1\">Cohort Report</a>"
138
+ expect( helper.report_link( attributes ) ).to eql( expected )
139
+ end
140
+
141
+ end
142
+
143
+ #############################################################################
144
+ # report_list
145
+
146
+ describe '#report_list' do
147
+
148
+ it 'renders a list of reports in HTML' do
149
+ expect( helper.report_list( @reports ) ).to eql_file( 'spec/data/helpers/report_list.html' )
150
+ end
151
+
152
+ end
153
+
154
+ #############################################################################
155
+ # report_name
156
+
157
+ describe '#report_name' do
158
+
159
+ it 'renders the localized description for the report' do
160
+ expected = t( :name, :scope => [ :report_cat, :instances, @report.name.to_sym ] )
161
+ expect( helper.report_name( @report ) ).to eql( expected )
162
+ end
163
+
164
+ end
165
+
166
+ #############################################################################
167
+ # report_param
168
+
169
+ describe '#report_param' do
170
+
171
+ it 'returns a checkbox' do
172
+ param = @report.param( :check_box_test )
173
+ path = 'spec/data/helpers/report_param_checkbox.html'
174
+ expect( report_param( param ) ).to eql_file( path )
175
+ end
176
+
177
+ it 'returns a date' do
178
+ param = @report.param( :date_test )
179
+ path = 'spec/data/helpers/report_param_date.html'
180
+ expect( report_param( param ) ).to eql_file( path )
181
+ end
182
+
183
+ it 'returns a hidden' do
184
+ param = @report.param( :hidden_test )
185
+ path = 'spec/data/helpers/report_param_hidden.html'
186
+ expect( report_param( param ) ).to eql_file( path )
187
+ end
188
+
189
+ it 'returns a select' do
190
+ param = @report.param( :select_test )
191
+ path = 'spec/data/helpers/report_param_select.html'
192
+ expect( report_param( param ) ).to eql_file( path )
193
+ end
194
+
195
+ it 'returns a text_field' do
196
+ param = @report.param( :text_field_test )
197
+ path = 'spec/data/helpers/report_param_text_field.html'
198
+ expect( report_param( param ) ).to eql_file( path )
199
+ end
200
+
201
+ it 'raises an exception for unknown types' do
202
+ param = Param.new( :name => :foo, :type => :bar )
203
+ expect { report_param( param ) }.to raise_error
204
+ end
205
+
206
+ #############################################################################
207
+ # report_table
208
+
209
+ describe '#report_table' do
210
+
211
+ it 'renders a table of report rows' do
212
+ expect( report_table( @report ) ).to eql_file( 'spec/data/helpers/report_table.html' )
213
+ end
214
+
215
+ it 'excludes hidden columns'do
216
+ @report.column( :day ).options[ :hidden ] = true
217
+ @report.column( :total ).options[ :hidden ] = true
218
+ expect( report_table( @report ) ).to eql_file( 'spec/data/helpers/report_table_hidden.html' )
219
+ end
220
+
221
+ end
222
+
223
+ end
224
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe ReportCat::Config do
4
+
5
+ let( :config ) { ReportCat::Config.instance }
6
+
7
+ it 'is a singleton' do
8
+ expect( config ).to be( ReportCat::Config.instance )
9
+ end
10
+
11
+ describe 'attributes' do
12
+
13
+ it 'has an #authenticate accessor' do
14
+ config.authenticate = ReportCat::Config::NIL_PROC
15
+ config.authenticate = config.authenticate
16
+ expect( config.authenticate ).to eql( config.authenticate )
17
+ end
18
+
19
+ it 'has an #authorize accessor' do
20
+ config.authorize = ReportCat::Config::NIL_PROC
21
+ config.authorize = config.authorize
22
+ expect( config.authorize ).to eql( config.authorize )
23
+ end
24
+
25
+ it 'has an #layout excludes' do
26
+ expect( config.excludes ).to_not be_nil
27
+ config.excludes = config.excludes
28
+ expect( config.excludes ).to eql( config.excludes )
29
+ end
30
+
31
+ it 'has a #layout accessor' do
32
+ expect( config.layout ).to_not be_nil
33
+ config.layout = config.layout
34
+ expect( config.layout ).to eql( config.layout )
35
+ end
36
+
37
+ end
38
+
39
+ describe '#authenticate_with' do
40
+
41
+ it 'accepts a block' do
42
+ config.authenticate = nil
43
+ config.authenticate_with do
44
+ true
45
+ end
46
+
47
+ expect( config.authenticate ).to_not be_nil
48
+ end
49
+
50
+ it 'returns a block' do
51
+ @test = false
52
+ config.authenticate_with do
53
+ @test = true
54
+ end
55
+
56
+ instance_eval( &config.authenticate_with )
57
+ expect( @test ).to be( true )
58
+ end
59
+
60
+ it 'returns a nil proc if none has been set' do
61
+ config.authenticate = nil
62
+ instance_eval( &config.authenticate_with )
63
+ end
64
+
65
+ end
66
+
67
+ describe '#authorize_with' do
68
+
69
+ it 'accepts a block' do
70
+ config.authorize = nil
71
+ config.authorize_with do
72
+ true
73
+ end
74
+
75
+ expect( config.authorize ).to_not be_nil
76
+ end
77
+
78
+ it 'returns a block' do
79
+ @test = false
80
+ config.authorize_with do
81
+ @test = true
82
+ end
83
+
84
+ instance_eval( &config.authorize_with )
85
+ expect( @test ).to be( true )
86
+ end
87
+
88
+ it 'returns a nil proc if none has been set' do
89
+ config.authorize = nil
90
+ instance_eval( &config.authorize_with )
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ include ReportCat::Core
4
+
5
+ module ReportCat::Core
6
+
7
+ describe Chart do
8
+
9
+ include SetupReports
10
+
11
+ before( :each ) do
12
+ setup_reports
13
+
14
+ @name = :test
15
+ @type = :select
16
+ @label = @report.columns.first.name.to_sym
17
+ @values = @report.columns.map { |c| c.name.to_sym }
18
+ @options = {}
19
+
20
+ @chart = Chart.new(
21
+ :name => @name,
22
+ :type => @type,
23
+ :label => @label,
24
+ :values => @values,
25
+ :options => @options )
26
+ end
27
+
28
+ #############################################################################
29
+ # #initialize
30
+
31
+ describe '#initialize' do
32
+
33
+ it 'initializes accessor values' do
34
+ expect( @chart.name ).to eql( @name )
35
+ expect( @chart.type ).to eql( @type )
36
+ expect( @chart.label ).to eql( @label )
37
+ expect( @chart.values ).to eql( @values )
38
+ expect( @chart.options ).to eql( @options )
39
+ end
40
+
41
+ end
42
+
43
+ #############################################################################
44
+ # #columns
45
+
46
+ describe '#columns' do
47
+
48
+ it 'generates json' do
49
+ expect( @chart.columns( @report ) ).to eql_file( 'spec/data/lib/chart_columns.json' )
50
+ end
51
+
52
+ end
53
+
54
+ #############################################################################
55
+ # #initialize
56
+
57
+ describe '#data' do
58
+
59
+ it 'generates json' do
60
+ setup_reports
61
+ expect( @chart.data( @report ) ).to eql_file( 'spec/data/lib/chart_data.json' )
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+ end