active_model_exporters 0.5.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -18
- data/.travis.yml +9 -6
- data/Appraisals +4 -8
- data/CHANGELOG.md +24 -3
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -7
- data/LICENSE.txt +17 -18
- data/README.md +48 -12
- data/Rakefile +3 -5
- data/active_model_exporters.gemspec +21 -8
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gemfiles/rails_6.1.gemfile +7 -0
- data/gemfiles/rails_6.1.gemfile.lock +174 -0
- data/gemfiles/rails_7.0.gemfile +7 -0
- data/gemfiles/rails_7.0.gemfile.lock +190 -0
- data/lib/active_model/array_exporter.rb +1 -1
- data/lib/active_model/exporter/version.rb +1 -1
- data/lib/active_model/exporter.rb +6 -7
- metadata +107 -38
- data/gemfiles/rails_4.gemfile +0 -11
- data/gemfiles/rails_4.gemfile.lock +0 -142
- data/gemfiles/rails_5.2.gemfile +0 -11
- data/gemfiles/rails_5.2.gemfile.lock +0 -157
- data/gemfiles/rails_5.gemfile +0 -11
- data/gemfiles/rails_5.gemfile.lock +0 -149
- data/test/fixtures/active_record/exporters.rb +0 -3
- data/test/fixtures/active_record/models.rb +0 -18
- data/test/fixtures/exporters.rb +0 -23
- data/test/fixtures/locale.rb +0 -20
- data/test/fixtures/models.rb +0 -6
- data/test/integration/action_controller/exportation/csv_test.rb +0 -162
- data/test/integration/action_controller/exportation/xls_test.rb +0 -162
- data/test/integration/active_record/exportation/csv_test.rb +0 -23
- data/test/test_helper.rb +0 -31
@@ -1,157 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
active_model_exporters (0.5.1)
|
5
|
-
activemodel (>= 4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actioncable (5.2.0)
|
11
|
-
actionpack (= 5.2.0)
|
12
|
-
nio4r (~> 2.0)
|
13
|
-
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailer (5.2.0)
|
15
|
-
actionpack (= 5.2.0)
|
16
|
-
actionview (= 5.2.0)
|
17
|
-
activejob (= 5.2.0)
|
18
|
-
mail (~> 2.5, >= 2.5.4)
|
19
|
-
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.2.0)
|
21
|
-
actionview (= 5.2.0)
|
22
|
-
activesupport (= 5.2.0)
|
23
|
-
rack (~> 2.0)
|
24
|
-
rack-test (>= 0.6.3)
|
25
|
-
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.2.0)
|
28
|
-
activesupport (= 5.2.0)
|
29
|
-
builder (~> 3.1)
|
30
|
-
erubi (~> 1.4)
|
31
|
-
rails-dom-testing (~> 2.0)
|
32
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.2.0)
|
34
|
-
activesupport (= 5.2.0)
|
35
|
-
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.2.0)
|
37
|
-
activesupport (= 5.2.0)
|
38
|
-
activerecord (5.2.0)
|
39
|
-
activemodel (= 5.2.0)
|
40
|
-
activesupport (= 5.2.0)
|
41
|
-
arel (>= 9.0)
|
42
|
-
activestorage (5.2.0)
|
43
|
-
actionpack (= 5.2.0)
|
44
|
-
activerecord (= 5.2.0)
|
45
|
-
marcel (~> 0.3.1)
|
46
|
-
activesupport (5.2.0)
|
47
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
-
i18n (>= 0.7, < 2)
|
49
|
-
minitest (~> 5.1)
|
50
|
-
tzinfo (~> 1.1)
|
51
|
-
appraisal (2.2.0)
|
52
|
-
bundler
|
53
|
-
rake
|
54
|
-
thor (>= 0.14.0)
|
55
|
-
arel (9.0.0)
|
56
|
-
builder (3.2.3)
|
57
|
-
concurrent-ruby (1.0.5)
|
58
|
-
coveralls (0.7.2)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
rest-client (= 1.6.7)
|
61
|
-
simplecov (>= 0.7)
|
62
|
-
term-ansicolor (= 1.2.2)
|
63
|
-
thor (= 0.18.1)
|
64
|
-
crass (1.0.4)
|
65
|
-
docile (1.3.0)
|
66
|
-
erubi (1.7.1)
|
67
|
-
globalid (0.4.1)
|
68
|
-
activesupport (>= 4.2.0)
|
69
|
-
i18n (1.0.1)
|
70
|
-
concurrent-ruby (~> 1.0)
|
71
|
-
json (2.1.0)
|
72
|
-
loofah (2.2.2)
|
73
|
-
crass (~> 1.0.2)
|
74
|
-
nokogiri (>= 1.5.9)
|
75
|
-
mail (2.7.0)
|
76
|
-
mini_mime (>= 0.1.1)
|
77
|
-
marcel (0.3.2)
|
78
|
-
mimemagic (~> 0.3.2)
|
79
|
-
method_source (0.9.0)
|
80
|
-
mime-types (3.1)
|
81
|
-
mime-types-data (~> 3.2015)
|
82
|
-
mime-types-data (3.2016.0521)
|
83
|
-
mimemagic (0.3.2)
|
84
|
-
mini_mime (1.0.0)
|
85
|
-
mini_portile2 (2.3.0)
|
86
|
-
minitest (5.11.3)
|
87
|
-
multi_json (1.13.1)
|
88
|
-
nio4r (2.3.1)
|
89
|
-
nokogiri (1.8.2)
|
90
|
-
mini_portile2 (~> 2.3.0)
|
91
|
-
rack (2.0.5)
|
92
|
-
rack-test (1.0.0)
|
93
|
-
rack (>= 1.0, < 3)
|
94
|
-
rails (5.2.0)
|
95
|
-
actioncable (= 5.2.0)
|
96
|
-
actionmailer (= 5.2.0)
|
97
|
-
actionpack (= 5.2.0)
|
98
|
-
actionview (= 5.2.0)
|
99
|
-
activejob (= 5.2.0)
|
100
|
-
activemodel (= 5.2.0)
|
101
|
-
activerecord (= 5.2.0)
|
102
|
-
activestorage (= 5.2.0)
|
103
|
-
activesupport (= 5.2.0)
|
104
|
-
bundler (>= 1.3.0)
|
105
|
-
railties (= 5.2.0)
|
106
|
-
sprockets-rails (>= 2.0.0)
|
107
|
-
rails-dom-testing (2.0.3)
|
108
|
-
activesupport (>= 4.2.0)
|
109
|
-
nokogiri (>= 1.6)
|
110
|
-
rails-html-sanitizer (1.0.4)
|
111
|
-
loofah (~> 2.2, >= 2.2.2)
|
112
|
-
railties (5.2.0)
|
113
|
-
actionpack (= 5.2.0)
|
114
|
-
activesupport (= 5.2.0)
|
115
|
-
method_source
|
116
|
-
rake (>= 0.8.7)
|
117
|
-
thor (>= 0.18.1, < 2.0)
|
118
|
-
rake (12.3.1)
|
119
|
-
rest-client (1.6.7)
|
120
|
-
mime-types (>= 1.16)
|
121
|
-
simplecov (0.16.1)
|
122
|
-
docile (~> 1.1)
|
123
|
-
json (>= 1.8, < 3)
|
124
|
-
simplecov-html (~> 0.10.0)
|
125
|
-
simplecov-html (0.10.2)
|
126
|
-
sprockets (3.7.1)
|
127
|
-
concurrent-ruby (~> 1.0)
|
128
|
-
rack (> 1, < 3)
|
129
|
-
sprockets-rails (3.2.1)
|
130
|
-
actionpack (>= 4.0)
|
131
|
-
activesupport (>= 4.0)
|
132
|
-
sprockets (>= 3.0.0)
|
133
|
-
sqlite3 (1.3.13)
|
134
|
-
term-ansicolor (1.2.2)
|
135
|
-
tins (~> 0.8)
|
136
|
-
thor (0.18.1)
|
137
|
-
thread_safe (0.3.6)
|
138
|
-
tins (0.13.2)
|
139
|
-
tzinfo (1.2.5)
|
140
|
-
thread_safe (~> 0.1)
|
141
|
-
websocket-driver (0.7.0)
|
142
|
-
websocket-extensions (>= 0.1.0)
|
143
|
-
websocket-extensions (0.1.3)
|
144
|
-
|
145
|
-
PLATFORMS
|
146
|
-
ruby
|
147
|
-
|
148
|
-
DEPENDENCIES
|
149
|
-
active_model_exporters!
|
150
|
-
appraisal
|
151
|
-
coveralls
|
152
|
-
rails (~> 5.2.0)
|
153
|
-
simplecov
|
154
|
-
sqlite3
|
155
|
-
|
156
|
-
BUNDLED WITH
|
157
|
-
1.16.2
|
data/gemfiles/rails_5.gemfile
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
active_model_exporters (0.5.1)
|
5
|
-
activemodel (>= 4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actioncable (5.0.7)
|
11
|
-
actionpack (= 5.0.7)
|
12
|
-
nio4r (>= 1.2, < 3.0)
|
13
|
-
websocket-driver (~> 0.6.1)
|
14
|
-
actionmailer (5.0.7)
|
15
|
-
actionpack (= 5.0.7)
|
16
|
-
actionview (= 5.0.7)
|
17
|
-
activejob (= 5.0.7)
|
18
|
-
mail (~> 2.5, >= 2.5.4)
|
19
|
-
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.0.7)
|
21
|
-
actionview (= 5.0.7)
|
22
|
-
activesupport (= 5.0.7)
|
23
|
-
rack (~> 2.0)
|
24
|
-
rack-test (~> 0.6.3)
|
25
|
-
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.0.7)
|
28
|
-
activesupport (= 5.0.7)
|
29
|
-
builder (~> 3.1)
|
30
|
-
erubis (~> 2.7.0)
|
31
|
-
rails-dom-testing (~> 2.0)
|
32
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.0.7)
|
34
|
-
activesupport (= 5.0.7)
|
35
|
-
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.0.7)
|
37
|
-
activesupport (= 5.0.7)
|
38
|
-
activerecord (5.0.7)
|
39
|
-
activemodel (= 5.0.7)
|
40
|
-
activesupport (= 5.0.7)
|
41
|
-
arel (~> 7.0)
|
42
|
-
activesupport (5.0.7)
|
43
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
|
-
i18n (>= 0.7, < 2)
|
45
|
-
minitest (~> 5.1)
|
46
|
-
tzinfo (~> 1.1)
|
47
|
-
appraisal (2.2.0)
|
48
|
-
bundler
|
49
|
-
rake
|
50
|
-
thor (>= 0.14.0)
|
51
|
-
arel (7.1.4)
|
52
|
-
builder (3.2.3)
|
53
|
-
concurrent-ruby (1.0.5)
|
54
|
-
coveralls (0.7.2)
|
55
|
-
multi_json (~> 1.3)
|
56
|
-
rest-client (= 1.6.7)
|
57
|
-
simplecov (>= 0.7)
|
58
|
-
term-ansicolor (= 1.2.2)
|
59
|
-
thor (= 0.18.1)
|
60
|
-
crass (1.0.4)
|
61
|
-
docile (1.3.0)
|
62
|
-
erubis (2.7.0)
|
63
|
-
globalid (0.4.1)
|
64
|
-
activesupport (>= 4.2.0)
|
65
|
-
i18n (1.0.1)
|
66
|
-
concurrent-ruby (~> 1.0)
|
67
|
-
json (2.1.0)
|
68
|
-
loofah (2.2.2)
|
69
|
-
crass (~> 1.0.2)
|
70
|
-
nokogiri (>= 1.5.9)
|
71
|
-
mail (2.7.0)
|
72
|
-
mini_mime (>= 0.1.1)
|
73
|
-
method_source (0.9.0)
|
74
|
-
mime-types (3.1)
|
75
|
-
mime-types-data (~> 3.2015)
|
76
|
-
mime-types-data (3.2016.0521)
|
77
|
-
mini_mime (1.0.0)
|
78
|
-
mini_portile2 (2.3.0)
|
79
|
-
minitest (5.11.3)
|
80
|
-
multi_json (1.13.1)
|
81
|
-
nio4r (2.3.1)
|
82
|
-
nokogiri (1.8.2)
|
83
|
-
mini_portile2 (~> 2.3.0)
|
84
|
-
rack (2.0.5)
|
85
|
-
rack-test (0.6.3)
|
86
|
-
rack (>= 1.0)
|
87
|
-
rails (5.0.7)
|
88
|
-
actioncable (= 5.0.7)
|
89
|
-
actionmailer (= 5.0.7)
|
90
|
-
actionpack (= 5.0.7)
|
91
|
-
actionview (= 5.0.7)
|
92
|
-
activejob (= 5.0.7)
|
93
|
-
activemodel (= 5.0.7)
|
94
|
-
activerecord (= 5.0.7)
|
95
|
-
activesupport (= 5.0.7)
|
96
|
-
bundler (>= 1.3.0)
|
97
|
-
railties (= 5.0.7)
|
98
|
-
sprockets-rails (>= 2.0.0)
|
99
|
-
rails-dom-testing (2.0.3)
|
100
|
-
activesupport (>= 4.2.0)
|
101
|
-
nokogiri (>= 1.6)
|
102
|
-
rails-html-sanitizer (1.0.4)
|
103
|
-
loofah (~> 2.2, >= 2.2.2)
|
104
|
-
railties (5.0.7)
|
105
|
-
actionpack (= 5.0.7)
|
106
|
-
activesupport (= 5.0.7)
|
107
|
-
method_source
|
108
|
-
rake (>= 0.8.7)
|
109
|
-
thor (>= 0.18.1, < 2.0)
|
110
|
-
rake (12.3.1)
|
111
|
-
rest-client (1.6.7)
|
112
|
-
mime-types (>= 1.16)
|
113
|
-
simplecov (0.16.1)
|
114
|
-
docile (~> 1.1)
|
115
|
-
json (>= 1.8, < 3)
|
116
|
-
simplecov-html (~> 0.10.0)
|
117
|
-
simplecov-html (0.10.2)
|
118
|
-
sprockets (3.7.1)
|
119
|
-
concurrent-ruby (~> 1.0)
|
120
|
-
rack (> 1, < 3)
|
121
|
-
sprockets-rails (3.2.1)
|
122
|
-
actionpack (>= 4.0)
|
123
|
-
activesupport (>= 4.0)
|
124
|
-
sprockets (>= 3.0.0)
|
125
|
-
sqlite3 (1.3.13)
|
126
|
-
term-ansicolor (1.2.2)
|
127
|
-
tins (~> 0.8)
|
128
|
-
thor (0.18.1)
|
129
|
-
thread_safe (0.3.6)
|
130
|
-
tins (0.13.2)
|
131
|
-
tzinfo (1.2.5)
|
132
|
-
thread_safe (~> 0.1)
|
133
|
-
websocket-driver (0.6.5)
|
134
|
-
websocket-extensions (>= 0.1.0)
|
135
|
-
websocket-extensions (0.1.3)
|
136
|
-
|
137
|
-
PLATFORMS
|
138
|
-
ruby
|
139
|
-
|
140
|
-
DEPENDENCIES
|
141
|
-
active_model_exporters!
|
142
|
-
appraisal
|
143
|
-
coveralls
|
144
|
-
rails (~> 5.0.0)
|
145
|
-
simplecov
|
146
|
-
sqlite3
|
147
|
-
|
148
|
-
BUNDLED WITH
|
149
|
-
1.16.2
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
ActiveRecord::Base.establish_connection(
|
4
|
-
adapter: 'sqlite3',
|
5
|
-
database: ':memory:'
|
6
|
-
)
|
7
|
-
|
8
|
-
ActiveRecord::Schema.define do
|
9
|
-
create_table :ar_users, force: true do |t|
|
10
|
-
t.string :first_name
|
11
|
-
t.string :last_name
|
12
|
-
|
13
|
-
t.timestamps null: false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class ARUser < ActiveRecord::Base
|
18
|
-
end
|
data/test/fixtures/exporters.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class UserExporter < ActiveModel::Exporter
|
2
|
-
attributes :first_name, :last_name, :full_name
|
3
|
-
|
4
|
-
def full_name
|
5
|
-
"#{object.first_name}-#{object.last_name}#{scope ? "-#{scope}" : ''}"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class FancyUserExporter < ActiveModel::Exporter
|
10
|
-
attributes :first_name, :last_name
|
11
|
-
end
|
12
|
-
|
13
|
-
class FilterUserExporter < ActiveModel::Exporter
|
14
|
-
attributes :first_name, :last_name, :email
|
15
|
-
|
16
|
-
def filter(attrs)
|
17
|
-
if object.last_name == 'Bar1'
|
18
|
-
attrs - [:last_name]
|
19
|
-
else
|
20
|
-
attrs
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/test/fixtures/locale.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'i18n'
|
2
|
-
|
3
|
-
class I18n::Backend::Simple
|
4
|
-
def translations_store
|
5
|
-
translations
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
I18n.enforce_available_locales = false
|
10
|
-
|
11
|
-
I18n.backend.translations_store[:en] = {
|
12
|
-
activerecord: {
|
13
|
-
attributes: {
|
14
|
-
ar_user: {
|
15
|
-
first_name: 'First',
|
16
|
-
last_name: 'Last'
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
data/test/fixtures/models.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module ActionController
|
4
|
-
module Exportation::CSV
|
5
|
-
class ImplicitExporterTest < ActionController::TestCase
|
6
|
-
class TestsController < ActionController::Base
|
7
|
-
def render_using_implicit_exporter
|
8
|
-
render csv: [
|
9
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1'),
|
10
|
-
User.new(first_name: 'Foo2', last_name: 'Bar2'),
|
11
|
-
User.new(first_name: 'Foo3', last_name: 'Bar3')
|
12
|
-
]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
tests TestsController
|
17
|
-
|
18
|
-
def test_render_using_implicit_exporter
|
19
|
-
get :render_using_implicit_exporter
|
20
|
-
assert_equal 'text/csv', @response.content_type
|
21
|
-
assert_equal "first_name,last_name,full_name\n"\
|
22
|
-
"Foo1,Bar1,Foo1-Bar1\n"\
|
23
|
-
"Foo2,Bar2,Foo2-Bar2\n"\
|
24
|
-
"Foo3,Bar3,Foo3-Bar3\n", @response.body
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class ExplicitExporterTest < ActionController::TestCase
|
29
|
-
class TestsController < ActionController::Base
|
30
|
-
def render_using_explicit_exporter
|
31
|
-
render csv: [
|
32
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1')
|
33
|
-
], exporter: FancyUserExporter
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
tests TestsController
|
38
|
-
|
39
|
-
def test_render_using_explicit_exporter
|
40
|
-
get :render_using_explicit_exporter
|
41
|
-
assert_equal 'text/csv', @response.content_type
|
42
|
-
assert_equal "first_name,last_name\n"\
|
43
|
-
"Foo1,Bar1\n", @response.body
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class ImplicitExportationScopeTest < ActionController::TestCase
|
48
|
-
class TestsController < ActionController::Base
|
49
|
-
def render_using_implicit_exportation_scope
|
50
|
-
render csv: [
|
51
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1')
|
52
|
-
]
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def current_user
|
58
|
-
'current_user'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
tests TestsController
|
63
|
-
|
64
|
-
def test_render_using_implicit_exportation_scope
|
65
|
-
get :render_using_implicit_exportation_scope
|
66
|
-
assert_equal 'text/csv', @response.content_type
|
67
|
-
assert_equal "first_name,last_name,full_name\n"\
|
68
|
-
"Foo1,Bar1,Foo1-Bar1-current_user\n", @response.body
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class ExplicitExportationScopeTest < ActionController::TestCase
|
73
|
-
class TestsController < ActionController::Base
|
74
|
-
def render_using_explicit_exportation_scope
|
75
|
-
render csv: [
|
76
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1')
|
77
|
-
], scope: current_admin
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def current_admin
|
83
|
-
'current_admin'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
tests TestsController
|
88
|
-
|
89
|
-
def test_render_using_explicit_exportation_scope
|
90
|
-
get :render_using_explicit_exportation_scope
|
91
|
-
assert_equal 'text/csv', @response.content_type
|
92
|
-
assert_equal "first_name,last_name,full_name\n"\
|
93
|
-
"Foo1,Bar1,Foo1-Bar1-current_admin\n", @response.body
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class CallingExportationScopeTest < ActionController::TestCase
|
98
|
-
class TestsController < ActionController::Base
|
99
|
-
exportation_scope :current_admin
|
100
|
-
|
101
|
-
def render_calling_exportation_scope
|
102
|
-
render csv: [
|
103
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1')
|
104
|
-
]
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def current_admin
|
110
|
-
'current_admin'
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
tests TestsController
|
115
|
-
|
116
|
-
def test_render_calling_exportation_scope
|
117
|
-
get :render_calling_exportation_scope
|
118
|
-
assert_equal 'text/csv', @response.content_type
|
119
|
-
assert_equal "first_name,last_name,full_name\n"\
|
120
|
-
"Foo1,Bar1,Foo1-Bar1-current_admin\n", @response.body
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
class UsingFilterAttributesTest < ActionController::TestCase
|
125
|
-
class TestsController < ActionController::Base
|
126
|
-
def render_using_filter_attributes
|
127
|
-
render csv: [
|
128
|
-
User.new(first_name: 'Foo1', last_name: 'Bar1', email: 'FooBar1'),
|
129
|
-
User.new(first_name: 'Foo2', last_name: 'Bar2', email: 'FooBar2')
|
130
|
-
], exporter: FilterUserExporter
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
tests TestsController
|
135
|
-
|
136
|
-
def test_render_using_filter_attributes
|
137
|
-
get :render_using_filter_attributes
|
138
|
-
assert_equal 'text/csv', @response.content_type
|
139
|
-
assert_equal "first_name,last_name,email\n"\
|
140
|
-
"Foo1,,FooBar1\n"\
|
141
|
-
"Foo2,Bar2,FooBar2\n", @response.body
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class ExporterSingleResourceTest < ActionController::TestCase
|
146
|
-
class TestsController < ActionController::Base
|
147
|
-
def render_single_resource
|
148
|
-
render csv: User.new(first_name: 'Foo1', last_name: 'Bar1')
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
tests TestsController
|
153
|
-
|
154
|
-
def test_render_single_resource
|
155
|
-
get :render_single_resource
|
156
|
-
assert_equal 'text/csv', @response.content_type
|
157
|
-
assert_equal "first_name,last_name,full_name\n"\
|
158
|
-
"Foo1,Bar1,Foo1-Bar1\n", @response.body
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|