acts_as_reportable 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/ruport/acts_as_reportable.rb +9 -6
- data/test/acts_as_reportable_test.rb +9 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -167,8 +167,7 @@ module Ruport
|
|
167
167
|
data = data.map {|r| r.reportable_data(:include => includes,
|
168
168
|
:only => only,
|
169
169
|
:except => except,
|
170
|
-
:methods => methods) }.flatten
|
171
|
-
|
170
|
+
:methods => methods) }.flatten
|
172
171
|
|
173
172
|
table = Ruport::Data::Table.new(:data => data,
|
174
173
|
:column_names => aar_columns,
|
@@ -303,12 +302,16 @@ module Ruport
|
|
303
302
|
end
|
304
303
|
|
305
304
|
# Reorder columns to match options[:only]
|
306
|
-
|
307
|
-
|
308
|
-
|
305
|
+
if Array === options[:only]
|
306
|
+
cols = options[:only].map {|c| c.to_s }
|
307
|
+
self.class.aar_columns = cols
|
308
|
+
end
|
309
|
+
|
310
|
+
self.class.aar_columns |= data_records.first.keys
|
309
311
|
|
310
312
|
data_records =
|
311
|
-
add_includes(data_records, options[:include]) if options[:include]
|
313
|
+
add_includes(data_records, options[:include]) if options[:include]
|
314
|
+
|
312
315
|
data_records
|
313
316
|
end
|
314
317
|
|
@@ -139,6 +139,14 @@ if Object.const_defined?(:ActiveRecord) && Object.const_defined?(:Mocha)
|
|
139
139
|
assert_equal expected, actual
|
140
140
|
end
|
141
141
|
|
142
|
+
def test_only_option_allows_symbols
|
143
|
+
column_order = [:name, :personal_trainer_id, :team_id]
|
144
|
+
actual = Player.report_table(:all, :only => column_order)
|
145
|
+
expected = [["Player 1", 1, 1],
|
146
|
+
["Player 2", 2, 1]].to_table(%w[name personal_trainer_id team_id])
|
147
|
+
assert_equal expected, actual
|
148
|
+
end
|
149
|
+
|
142
150
|
def test_except_option
|
143
151
|
actual = Player.report_table(:all, :except => 'personal_trainer_id')
|
144
152
|
expected = [[1, "Player 1"],[1, "Player 2"]].to_table(%w[team_id name])
|
@@ -160,7 +168,7 @@ if Object.const_defined?(:ActiveRecord) && Object.const_defined?(:Mocha)
|
|
160
168
|
assert_equal expected, actual
|
161
169
|
end
|
162
170
|
|
163
|
-
def test_column_sorting_works_with_include_option
|
171
|
+
def test_column_sorting_works_with_include_option
|
164
172
|
actual = Player.report_table(:all,
|
165
173
|
:only => %w[name personal_trainer.name],
|
166
174
|
:include => { :personal_trainer => { :only => %w[name] } })
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: acts_as_reportable
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date:
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2008-01-08 00:00:00 -05:00
|
8
8
|
summary: ActiveRecord support for Ruby Reports
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -31,8 +31,8 @@ authors:
|
|
31
31
|
files:
|
32
32
|
- lib/ruport
|
33
33
|
- lib/ruport/acts_as_reportable.rb
|
34
|
-
- test/helpers.rb
|
35
34
|
- test/acts_as_reportable_test.rb
|
35
|
+
- test/helpers.rb
|
36
36
|
- Rakefile
|
37
37
|
test_files:
|
38
38
|
- test/acts_as_reportable_test.rb
|