OSDN Git Service

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