active_model_exporters 0.4.0 → 0.6.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.
@@ -1,162 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActionController
4
- module Exportation::XLS
5
- class ImplicitExporterTest < ActionController::TestCase
6
- class TestsController < ActionController::Base
7
- def render_using_implicit_exporter
8
- render xls: [
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 'application/vnd.ms-excel', @response.content_type
21
- assert_equal "first_name\tlast_name\tfull_name\n"\
22
- "Foo1\tBar1\tFoo1-Bar1\n"\
23
- "Foo2\tBar2\tFoo2-Bar2\n"\
24
- "Foo3\tBar3\tFoo3-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 xls: [
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 'application/vnd.ms-excel', @response.content_type
42
- assert_equal "first_name\tlast_name\n"\
43
- "Foo1\tBar1\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 xls: [
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 'application/vnd.ms-excel', @response.content_type
67
- assert_equal "first_name\tlast_name\tfull_name\n"\
68
- "Foo1\tBar1\tFoo1-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 xls: [
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 'application/vnd.ms-excel', @response.content_type
92
- assert_equal "first_name\tlast_name\tfull_name\n"\
93
- "Foo1\tBar1\tFoo1-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 xls: [
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 'application/vnd.ms-excel', @response.content_type
119
- assert_equal "first_name\tlast_name\tfull_name\n"\
120
- "Foo1\tBar1\tFoo1-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 xls: [
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 'application/vnd.ms-excel', @response.content_type
139
- assert_equal "first_name\tlast_name\temail\n"\
140
- "Foo1\t\tFooBar1\n"\
141
- "Foo2\tBar2\tFooBar2\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 xls: 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 'application/vnd.ms-excel', @response.content_type
157
- assert_equal "first_name\tlast_name\tfull_name\n"\
158
- "Foo1\tBar1\tFoo1-Bar1\n", @response.body
159
- end
160
- end
161
- end
162
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActiveModel
4
- class Exporter::CSV
5
- class LocaleHeadersTest < Minitest::Test
6
- def setup
7
- @collection = [
8
- ARUser.new(first_name: 'ARFoo1', last_name: 'ARBar1'),
9
- ARUser.new(first_name: 'ARFoo2', last_name: 'ARBar2'),
10
- ARUser.new(first_name: 'ARFoo3', last_name: 'ARBar3')
11
- ]
12
- end
13
-
14
- def test_locale_headers
15
- exporter = ActiveModel::ArrayExporter.new(@collection)
16
- assert_equal "First,Last\n"\
17
- "ARFoo1,ARBar1\n"\
18
- "ARFoo2,ARBar2\n"\
19
- "ARFoo3,ARBar3\n", exporter.to_csv
20
- end
21
- end
22
- end
23
- end
data/test/test_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'ostruct'
2
- require 'action_controller'
3
- require 'active_model_exporters'
4
- require 'minitest/autorun'
5
- require 'minitest/unit'
6
- require 'minitest/pride'
7
- require 'fixtures/locale'
8
- require 'fixtures/models'
9
- require 'fixtures/exporters'
10
- require 'fixtures/active_record/models'
11
- require 'fixtures/active_record/exporters'
12
-
13
- module TestHelper
14
- Routes = ActionDispatch::Routing::RouteSet.new
15
- Routes.draw do
16
- get ':controller(/:action(/:id))'
17
- get ':controller(/:action)'
18
- end
19
-
20
- ActionController::Base.send(:include, Routes.url_helpers)
21
- end
22
-
23
- class ActionController::TestCase
24
- def setup
25
- @routes = TestHelper::Routes
26
- end
27
- end