ruport 1.2.0 → 1.2.1
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.
- data/Rakefile +1 -1
- data/lib/ruport.rb +1 -1
- data/lib/ruport/acts_as_reportable.rb +3 -0
- data/test/acts_as_reportable_test.rb +24 -0
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/ruport.rb
CHANGED
@@ -297,6 +297,9 @@ module Ruport
|
|
297
297
|
data_records.first[method.to_s] = send(method)
|
298
298
|
end
|
299
299
|
|
300
|
+
# Reorder columns to match options[:only]
|
301
|
+
self.class.aar_columns = options[:only] if Array === options[:only]
|
302
|
+
|
300
303
|
self.class.aar_columns |= data_records.first.keys
|
301
304
|
|
302
305
|
data_records =
|
@@ -123,6 +123,14 @@ if Object.const_defined?(:ActiveRecord) && Object.const_defined?(:Mocha)
|
|
123
123
|
expected = [["Player 1"],["Player 2"]].to_table(%w[name])
|
124
124
|
assert_equal expected, actual
|
125
125
|
end
|
126
|
+
|
127
|
+
def test_only_option_preserves_column_sort_order
|
128
|
+
column_order = %w[name personal_trainer_id team_id]
|
129
|
+
actual = Player.report_table(:all, :only => column_order)
|
130
|
+
expected = [["Player 1", 1, 1],
|
131
|
+
["Player 2", 2, 1]].to_table(column_order)
|
132
|
+
assert_equal expected, actual
|
133
|
+
end
|
126
134
|
|
127
135
|
def test_except_option
|
128
136
|
actual = Player.report_table(:all, :except => 'personal_trainer_id')
|
@@ -144,6 +152,22 @@ if Object.const_defined?(:ActiveRecord) && Object.const_defined?(:Mocha)
|
|
144
152
|
["Player 2", "Trainer 2"]].to_table(%w[name personal_trainer.name])
|
145
153
|
assert_equal expected, actual
|
146
154
|
end
|
155
|
+
|
156
|
+
def test_column_sorting_works_with_include_option
|
157
|
+
actual = Player.report_table(:all,
|
158
|
+
:only => %w[name personal_trainer.name],
|
159
|
+
:include => { :personal_trainer => { :only => %w[name] } })
|
160
|
+
expected = [["Player 1", "Trainer 1"],
|
161
|
+
["Player 2", "Trainer 2"]].to_table(%w[name personal_trainer.name])
|
162
|
+
assert_equal expected, actual
|
163
|
+
|
164
|
+
actual = Player.report_table(:all,
|
165
|
+
:only => %w[personal_trainer.name name],
|
166
|
+
:include => { :personal_trainer => { :only => %w[name] } })
|
167
|
+
expected = [["Trainer 1", "Player 1"],
|
168
|
+
["Trainer 2", "Player 2"]].to_table(%w[personal_trainer.name name])
|
169
|
+
assert_equal expected, actual
|
170
|
+
end
|
147
171
|
|
148
172
|
def test_include_has_options
|
149
173
|
actual = Team.report_table(:all, :only => '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: ruport
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.2.1
|
7
|
+
date: 2007-09-23 00:00:00 -04:00
|
8
8
|
summary: A generalized Ruby report generation and templating engine.
|
9
9
|
require_paths:
|
10
10
|
- lib
|