OSDN Git Service

fix:error dlg
[pettanr/pettanr.git] / spec / manifests / resource_picture_spec.rb
1 # -*- encoding: utf-8 -*-\r
2 #素材\r
3 require 'spec_helper'\r
4 \r
5 describe ResourcePicture do\r
6   include ManifestsMacros\r
7   before do\r
8     @model = ResourcePicture\r
9   end\r
10   \r
11   describe 'ペタナイズに於いて' do\r
12     it '絵師が投稿するコンテンツである' do\r
13       expect(@model.ancestors.include?(Peta::Content)).to eq true\r
14     end\r
15     it '親モデルは持たない' do\r
16       expect(@model.my_peta.parent_model_name).to be_blank\r
17     end\r
18     describe 'ブーストに於いて' do\r
19       before do\r
20         @boosts = @model.my_peta.boost\r
21         @boosts_names = ['license_group', 'license', 'credit_picture']\r
22       end\r
23       it 'これらのブーストが定義されている' do\r
24         set_boosts? @boosts, @boosts_names\r
25       end\r
26       describe 'ライセンスグループに於いて' do\r
27         before do\r
28           @mani = @boosts['license_group']\r
29         end\r
30         it 'フキダシテンプレート' do\r
31           expect(@mani.level).to eq 'post'\r
32           expect(@mani.template_name).to eq 'license_group'\r
33           expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
34           expect(@mani.settings_column_name).to eq 'license_group_settings'\r
35           expect(@mani.foreign_key).to eq 'license_group_id'\r
36         end\r
37         it 'フキダシテンプレート' do\r
38           expect(@mani.item_name_for_extend_model).to eq 'license'\r
39           expect(@mani.setter_method_name).to eq 'license_extend='\r
40           expect(@mani.getter_method_name).to eq 'license_extend'\r
41           expect(@mani.extend_model_class_name).to eq 'License'\r
42           expect(@mani.extend_module_name).to eq 'LicenseModule'\r
43         end\r
44       end\r
45       describe 'ライセンスに於いて' do\r
46         before do\r
47           @mani = @boosts['license']\r
48         end\r
49         it 'フキダシテンプレート' do\r
50           expect(@mani.level).to eq 'read'\r
51           expect(@mani.template_name).to eq 'license_group'\r
52           expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
53           expect(@mani.settings_column_name).to eq 'license_settings'\r
54           expect(@mani.foreign_key).to eq 'license_group_id'\r
55         end\r
56         it 'フキダシテンプレート' do\r
57           expect(@mani.item_name_for_extend_model).to eq 'attribute'\r
58           expect(@mani.setter_method_name).to eq 'attribute_extend='\r
59           expect(@mani.getter_method_name).to eq 'attribute_extend'\r
60           expect(@mani.extend_model_class_name).to eq 'Attribute'\r
61           expect(@mani.extend_module_name).to eq 'AttributeModule'\r
62         end\r
63       end\r
64       describe 'クレジットに於いて' do\r
65         before do\r
66           @mani = @boosts['credit_picture']\r
67         end\r
68         it 'フキダシテンプレート' do\r
69           expect(@mani.level).to eq 'read'\r
70           expect(@mani.template_name).to eq 'license_group'\r
71           expect(@mani.column_name_for_template_module).to eq 'license_group_module_name'\r
72           expect(@mani.settings_column_name).to eq 'credit_picture_settings'\r
73           expect(@mani.foreign_key).to eq 'license_group_id'\r
74         end\r
75         it 'フキダシテンプレート' do\r
76           expect(@mani.item_name_for_extend_model).to eq 'credit_picture'\r
77           expect(@mani.setter_method_name).to eq 'credit_picture_extend='\r
78           expect(@mani.getter_method_name).to eq 'credit_picture_extend'\r
79           expect(@mani.extend_model_class_name).to eq 'CreditPicture'\r
80           expect(@mani.extend_module_name).to eq 'CreditPictureModule'\r
81         end\r
82       end\r
83     end\r
84     \r
85   end\r
86   \r
87   describe 'コントローラに於いて' do\r
88     before do\r
89       @controller = @model.my_controller\r
90     end\r
91     it '実素材のためのコントローラである' do\r
92       expect(@model.item_name).to eq 'resource_picture'\r
93     end\r
94     describe 'actionに於いて' do\r
95       before do\r
96         @actions = @controller.actions\r
97         @actions_names = ['index', 'by_license_group', 'by_license', 'by_artist', 'show', \r
98           'count', 'count_by_license_group', 'count_by_license', 'count_by_artist']\r
99       end\r
100       it 'これらのアクションが定義されている' do\r
101         set_actions? @actions, @actions_names\r
102       end\r
103       describe 'baseに於いて' do\r
104       end\r
105       describe 'indexに於いて' do\r
106         before do\r
107           @action = @actions['index']\r
108         end\r
109         it 'listタイプのアクションである' do\r
110           expect(@action.type).to eq 'list'\r
111         end\r
112         it 'マニフェストから設定を取り出している' do\r
113           # 素材の公開リストを返すように定義している\r
114           set_list_action? @action, 'resource_picture', 'public'\r
115         end\r
116       end\r
117       describe 'by_license_groupに於いて' do\r
118         before do\r
119           @action = @actions['by_license_group']\r
120         end\r
121         it 'listタイプのアクションである' do\r
122           expect(@action.type).to eq 'list'\r
123         end\r
124         it 'マニフェストから設定を取り出している' do\r
125           # 素材のライセンスグループフィルタリストを返すように定義している\r
126           set_list_action? @action, 'resource_picture', 'by_license_group'\r
127         end\r
128       end\r
129       describe 'by_licenseに於いて' do\r
130         before do\r
131           @action = @actions['by_license']\r
132         end\r
133         it 'listタイプのアクションである' do\r
134           expect(@action.type).to eq 'list'\r
135         end\r
136         it 'マニフェストから設定を取り出している' do\r
137           # 実素材のライセンスフィルタリストを返すように定義している\r
138           set_list_action? @action, 'resource_picture', 'by_license'\r
139         end\r
140       end\r
141       describe 'by_artistに於いて' do\r
142         before do\r
143           @action = @actions['by_artist']\r
144         end\r
145         it 'listタイプのアクションである' do\r
146           expect(@action.type).to eq 'list'\r
147         end\r
148         it 'マニフェストから設定を取り出している' do\r
149           # 素材の絵師フィルタリストを返すように定義している\r
150           set_list_action? @action, 'resource_picture', 'by_artist'\r
151         end\r
152       end\r
153       describe 'showに於いて' do\r
154         before do\r
155           @action = @actions['show']\r
156         end\r
157         it 'showタイプのアクションである' do\r
158           expect(@action.type).to eq 'show'\r
159         end\r
160       end\r
161       describe 'countに於いて' do\r
162         before do\r
163           @action = @actions['count']\r
164         end\r
165         it 'countタイプのアクションである' do\r
166           expect(@action.type).to eq 'count'\r
167         end\r
168         it 'マニフェストから設定を取り出している' do\r
169           # 素材の公開リストのカウントを返すように定義している\r
170           set_list_action? @action, 'resource_picture', 'public'\r
171         end\r
172       end\r
173       describe 'count_by_license_groupに於いて' do\r
174         before do\r
175           @action = @actions['count_by_license_group']\r
176         end\r
177         it 'countタイプのアクションである' do\r
178           expect(@action.type).to eq 'count'\r
179         end\r
180         it 'マニフェストから設定を取り出している' do\r
181           # 素材のライセンスグループフィルタリストのカウントを返すように定義している\r
182           set_list_action? @action, 'resource_picture', 'by_license_group'\r
183         end\r
184       end\r
185       describe 'count_by_licenseに於いて' do\r
186         before do\r
187           @action = @actions['count_by_license']\r
188         end\r
189         it 'countタイプのアクションである' do\r
190           expect(@action.type).to eq 'count'\r
191         end\r
192         it 'マニフェストから設定を取り出している' do\r
193           # 素材のライセンスフィルタリストのカウントを返すように定義している\r
194           set_list_action? @action, 'resource_picture', 'by_license'\r
195         end\r
196       end\r
197       describe 'count_by_artistに於いて' do\r
198         before do\r
199           @action = @actions['count_by_artist']\r
200         end\r
201         it 'countタイプのアクションである' do\r
202           expect(@action.type).to eq 'count'\r
203         end\r
204         it 'マニフェストから設定を取り出している' do\r
205           # 素材の絵師フィルタリストのカウントを返すように定義している\r
206           set_list_action? @action, 'resource_picture', 'by_artist'\r
207         end\r
208       end\r
209     end\r
210     \r
211   end\r
212   \r
213   describe 'モデルに於いて' do\r
214     before do\r
215       @my_manifest = @model.my_manifest\r
216     end\r
217     it 'サポート機能が動作している' do\r
218       expect(@my_manifest.model_name).to eq 'resource_picture'\r
219       expect(@my_manifest.classify).to eq @model\r
220       expect(@my_manifest.table_name).to eq 'resource_pictures'\r
221     end\r
222     \r
223     describe 'associationsに於いて' do\r
224       describe 'belongs_toに於いて' do\r
225         before do\r
226           @belongs_to = @my_manifest.associations.belongs_to\r
227           @names = ['original_picture', 'license_group', 'license', 'artist', 'system_picture']\r
228         end\r
229         it 'これらのモデルに所属している' do\r
230           set_associations? @belongs_to, @names\r
231         end\r
232         describe 'original_pictureに於いて' do\r
233           before do\r
234             @mani = @belongs_to['original_picture']\r
235           end\r
236           it 'マニフェストから設定を取り出している' do\r
237             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
238             expect(@mani.model_name).to eq 'original_picture'\r
239             expect(@mani.id_column).to eq 'original_picture_id'\r
240           end\r
241           it 'サポート機能が動作している' do\r
242             # モデルを再現できている\r
243             expect(@mani.model).to eq OriginalPicture\r
244           end\r
245         end\r
246         describe 'license_groupに於いて' do\r
247           before do\r
248             @mani = @belongs_to['license_group']\r
249           end\r
250           it 'マニフェストから設定を取り出している' do\r
251             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
252             expect(@mani.model_name).to eq 'license_group'\r
253             expect(@mani.id_column).to eq 'license_group_id'\r
254           end\r
255           it 'サポート機能が動作している' do\r
256             # モデルを再現できている\r
257             expect(@mani.model).to eq LicenseGroup\r
258           end\r
259         end\r
260         describe 'artistに於いて' do\r
261           before do\r
262             @mani = @belongs_to['artist']\r
263           end\r
264           it 'マニフェストから設定を取り出している' do\r
265             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
266             expect(@mani.model_name).to eq 'artist'\r
267             expect(@mani.id_column).to eq 'artist_id'\r
268           end\r
269           it 'サポート機能が動作している' do\r
270             # モデルを再現できている\r
271             expect(@mani.model).to eq Artist\r
272           end\r
273         end\r
274         describe 'licenseに於いて' do\r
275           before do\r
276             @mani = @belongs_to['license']\r
277           end\r
278           it 'マニフェストから設定を取り出している' do\r
279             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
280             expect(@mani.model_name).to eq 'license'\r
281             expect(@mani.id_column).to eq 'license_id'\r
282           end\r
283           it 'サポート機能が動作している' do\r
284             # モデルを再現できている\r
285             expect(@mani.model).to eq License\r
286           end\r
287         end\r
288         describe 'system_pictureに於いて' do\r
289           before do\r
290             @mani = @belongs_to['system_picture']\r
291           end\r
292           it 'マニフェストから設定を取り出している' do\r
293             # モデル名と外部キーが定義あるいはデフォルト値補充されている\r
294             expect(@mani.model_name).to eq 'system_picture'\r
295             expect(@mani.id_column).to eq 'system_picture_id'\r
296           end\r
297           it 'サポート機能が動作している' do\r
298             # モデルを再現できている\r
299             expect(@mani.model).to eq SystemPicture\r
300           end\r
301         end\r
302       end\r
303       describe 'has_manyに於いて' do\r
304         before do\r
305           @has_many = @model.my_manifest.associations.has_many\r
306           @names = []\r
307         end\r
308         it 'これらのモデルを所持している' do\r
309           set_associations? @has_many, @names\r
310         end\r
311       end\r
312     end\r
313     \r
314     describe 'attributesに於いて' do\r
315       before do\r
316         @attributes = @model.my_manifest.attributes\r
317       end\r
318       it 'これらのカラムを定義している' do\r
319         set_attributes? @attributes, \r
320           ['id', 'original_picture_id', 'ext', \r
321           'width', 'height', 'filesize', 'artist_id', 'license_group_id', 'license_id', \r
322           'md5', 'system_picture_id', \r
323           'license_group_settings', 'credit_picture_settings', \r
324           'license_settings', 'picture_id', 'license_group_module_name', \r
325           'created_at', 'updated_at']\r
326       end\r
327       describe 'original_picture_idに於いて' do\r
328         before do\r
329           @attribute = @attributes['original_picture_id']\r
330         end\r
331         it 'numberタイプである' do\r
332           expect(@attribute.type).to eq 'number'\r
333         end\r
334       end\r
335       describe 'extに於いて' do\r
336         before do\r
337           @attribute = @attributes['ext']\r
338         end\r
339         it 'textタイプである' do\r
340           expect(@attribute.type).to eq 'text'\r
341         end\r
342       end\r
343       describe 'widthに於いて' do\r
344         before do\r
345           @attribute = @attributes['width']\r
346         end\r
347         it 'numberタイプである' do\r
348           expect(@attribute.type).to eq 'number'\r
349         end\r
350       end\r
351       describe 'heightに於いて' do\r
352         before do\r
353           @attribute = @attributes['height']\r
354         end\r
355         it 'numberタイプである' do\r
356           expect(@attribute.type).to eq 'number'\r
357         end\r
358       end\r
359       describe 'filesizeに於いて' do\r
360         before do\r
361           @attribute = @attributes['filesize']\r
362         end\r
363         it 'numberタイプである' do\r
364           expect(@attribute.type).to eq 'number'\r
365         end\r
366       end\r
367       describe 'artist_idに於いて' do\r
368         before do\r
369           @attribute = @attributes['artist_id']\r
370         end\r
371         it 'numberタイプである' do\r
372           expect(@attribute.type).to eq 'number'\r
373         end\r
374       end\r
375       describe 'license_group_idに於いて' do\r
376         before do\r
377           @attribute = @attributes['license_group_id']\r
378         end\r
379         it 'numberタイプである' do\r
380           expect(@attribute.type).to eq 'number'\r
381         end\r
382       end\r
383       describe 'license_idに於いて' do\r
384         before do\r
385           @attribute = @attributes['license_id']\r
386         end\r
387         it 'numberタイプである' do\r
388           expect(@attribute.type).to eq 'number'\r
389         end\r
390       end\r
391       describe 'md5に於いて' do\r
392         before do\r
393           @attribute = @attributes['md5']\r
394         end\r
395         it 'textタイプである' do\r
396           expect(@attribute.type).to eq 'text'\r
397         end\r
398       end\r
399       describe 'system_picture_idに於いて' do\r
400         before do\r
401           @attribute = @attributes['system_picture_id']\r
402         end\r
403         it 'numberタイプである' do\r
404           expect(@attribute.type).to eq 'number'\r
405         end\r
406       end\r
407       describe 'license_group_settingsに於いて' do\r
408         before do\r
409           @attribute = @attributes['license_group_settings']\r
410         end\r
411         it 'textタイプである' do\r
412           expect(@attribute.type).to eq 'text'\r
413         end\r
414       end\r
415       describe 'credit_picture_settingsに於いて' do\r
416         before do\r
417           @attribute = @attributes['credit_picture_settings']\r
418         end\r
419         it 'textタイプである' do\r
420           expect(@attribute.type).to eq 'text'\r
421         end\r
422       end\r
423       describe 'license_settingsに於いて' do\r
424         before do\r
425           @attribute = @attributes['license_settings']\r
426         end\r
427         it 'textタイプである' do\r
428           expect(@attribute.type).to eq 'text'\r
429         end\r
430       end\r
431       describe 'picture_idに於いて' do\r
432         before do\r
433           @attribute = @attributes['picture_id']\r
434         end\r
435         it 'numberタイプである' do\r
436           expect(@attribute.type).to eq 'number'\r
437         end\r
438       end\r
439       describe 'license_group_module_nameに於いて' do\r
440         before do\r
441           @attribute = @attributes['license_group_module_name']\r
442         end\r
443         it 'textタイプである' do\r
444           expect(@attribute.type).to eq 'text'\r
445         end\r
446       end\r
447     end\r
448     \r
449   end\r
450   \r
451 end\r