@@ -5,13 +5,13 @@ module Pageflow
5
5
describe 'as Enumerable' do
6
6
it 'returns all registered FileTypes and nested FileTypes' do
7
7
config = Configuration . new
8
- nested_file_type = FileType . new ( model : TextTrackFile ,
8
+ nested_file_type = FileType . new ( model : 'Pageflow:: TextTrackFile' ,
9
9
collection_name : 'text_track_files' ,
10
10
editor_partial : 'path' )
11
- file_type1 = FileType . new ( model : ImageFile ,
11
+ file_type1 = FileType . new ( model : 'Pageflow:: ImageFile' ,
12
12
collection_name : 'image_files' ,
13
13
editor_partial : 'path' )
14
- file_type2 = FileType . new ( model : VideoFile ,
14
+ file_type2 = FileType . new ( model : 'Pageflow:: VideoFile' ,
15
15
collection_name : 'video_files' ,
16
16
editor_partial : 'path' ,
17
17
nested_file_types : [ nested_file_type ] )
@@ -22,12 +22,31 @@ module Pageflow
22
22
expect ( config . file_types . to_a ) . to eq ( [ file_type1 , file_type2 , nested_file_type ] )
23
23
end
24
24
25
+ it 'allows lambda registration' do
26
+ config = Configuration . new
27
+ nested_file_type = FileType . new ( model : 'Pageflow::TextTrackFile' ,
28
+ collection_name : 'text_track_files' ,
29
+ editor_partial : 'path' )
30
+ file_type1 = FileType . new ( model : 'Pageflow::ImageFile' ,
31
+ collection_name : 'image_files' ,
32
+ editor_partial : 'path' )
33
+ file_type2 = FileType . new ( model : 'Pageflow::VideoFile' ,
34
+ collection_name : 'video_files' ,
35
+ editor_partial : 'path' ,
36
+ nested_file_types : [ nested_file_type ] )
37
+
38
+ config . file_types . register ( -> { file_type1 } )
39
+ config . file_types . register ( -> { [ file_type2 ] } )
40
+
41
+ expect ( config . file_types . to_a ) . to eq ( [ file_type1 , file_type2 , nested_file_type ] )
42
+ end
43
+
25
44
it 'makes FileTypes unique by model' do
26
45
config = Configuration . new
27
- file_type1 = FileType . new ( model : ImageFile ,
46
+ file_type1 = FileType . new ( model : 'Pageflow:: ImageFile' ,
28
47
collection_name : 'image_files' ,
29
48
editor_partial : 'path' )
30
- file_type2 = FileType . new ( model : VideoFile ,
49
+ file_type2 = FileType . new ( model : 'Pageflow:: VideoFile' ,
31
50
collection_name : 'video_files' ,
32
51
editor_partial : 'path' ,
33
52
nested_file_types : [ file_type1 ] )
@@ -42,7 +61,7 @@ module Pageflow
42
61
describe '#find_by_collection_name!' do
43
62
it 'finds FileType by collection_name' do
44
63
config = Configuration . new
45
- file_type = FileType . new ( model : ImageFile ,
64
+ file_type = FileType . new ( model : 'Pageflow:: ImageFile' ,
46
65
collection_name : 'image_files' ,
47
66
editor_partial : 'path' )
48
67
config . file_types . register ( file_type )
@@ -65,7 +84,7 @@ module Pageflow
65
84
describe '#find_by_model!' do
66
85
it 'finds FileType by model' do
67
86
config = Configuration . new
68
- file_type = FileType . new ( model : ImageFile ,
87
+ file_type = FileType . new ( model : 'Pageflow:: ImageFile' ,
69
88
collection_name : 'image_files' ,
70
89
editor_partial : 'path' )
71
90
config . file_types . register ( file_type )
@@ -88,7 +107,7 @@ module Pageflow
88
107
describe '#with_thumbnail_support' do
89
108
it 'includes file types whose models have thumbnail_url instance method' do
90
109
config = Configuration . new
91
- file_type = FileType . new ( model : ImageFile )
110
+ file_type = FileType . new ( model : 'Pageflow:: ImageFile' )
92
111
config . file_types . register ( file_type )
93
112
file_types = config . file_types
94
113
@@ -99,7 +118,7 @@ module Pageflow
99
118
100
119
it 'does not include file types whose models do not have thumbnail_url instance method' do
101
120
config = Configuration . new
102
- file_type = FileType . new ( model : AudioFile )
121
+ file_type = FileType . new ( model : 'Pageflow:: AudioFile' )
103
122
config . file_types . register ( file_type )
104
123
file_types = config . file_types
105
124
@@ -112,7 +131,7 @@ module Pageflow
112
131
describe '#with_css_background_image_support' do
113
132
it 'includes file types with css_background_image_urls attribute set' do
114
133
config = Configuration . new
115
- file_type = FileType . new ( model : ImageFile ,
134
+ file_type = FileType . new ( model : 'Pageflow:: ImageFile' ,
116
135
css_background_image_urls : -> { } )
117
136
config . file_types . register ( file_type )
118
137
file_types = config . file_types
@@ -124,7 +143,7 @@ module Pageflow
124
143
125
144
it 'does not include file types without css_background_image_urls attribute set' do
126
145
config = Configuration . new
127
- file_type = FileType . new ( model : ImageFile )
146
+ file_type = FileType . new ( model : 'Pageflow:: ImageFile' )
128
147
config . file_types . register ( file_type )
129
148
file_types = config . file_types
130
149
0 commit comments