OSDN Git Service

fix:error dlg
[pettanr/pettanr.git] / spec / manifests / original_picture_spec.rb
1 # -*- encoding: utf-8 -*-
2 #原画
3 require 'spec_helper'
4
5 describe OriginalPicture do
6   include ManifestsMacros
7   before do
8     @model = OriginalPicture
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       it '特筆すべき注意事項はない' do
20         expect(@model.my_peta.boost.keys).to be_empty
21       end
22     end
23     
24   end
25   
26   describe 'コントローラに於いて' do
27     before do
28       @controller = @model.my_controller
29     end
30     it '原画のためのコントローラである' do
31       expect(@model.item_name).to eq 'original_picture'
32     end
33     describe 'actionに於いて' do
34       before do
35         @actions = @controller.actions
36         @actions_names = ['index', 'history', 'show', 
37           'count', 
38           'new', 'edit', 'create', 'update', 'destroy']
39       end
40       it 'これらのアクションが定義されている' do
41         set_actions? @actions, @actions_names
42       end
43       describe 'baseに於いて' do
44       end
45       describe 'indexに於いて' do
46         before do
47           @action = @actions['index']
48         end
49         it 'listタイプのアクションである' do
50           expect(@action.type).to eq 'list'
51         end
52         it 'マニフェストから設定を取り出している' do
53           # オーナーしか操作できないアイテムなので、
54           # 不特定多数のユーザで共有する必要がない。
55           # よって、 privateリスト(自分の原画リスト)に割り当てる。 
56           set_list_action? @action, 'original_picture', 'private'
57         end
58       end
59       describe 'historyに於いて' do
60         before do
61           @action = @actions['history']
62         end
63         # 投稿履歴を一覧するための機能。
64         # 一覧そのものは実素材の原画フィルタで見られるが、
65         # 過去の実素材を他人が見る事はできないので、
66         # オーナーであることが保証される原画にこの機能を備えてある。 
67         it 'showタイプのアクションである' do
68           expect(@action.type).to eq 'show'
69         end
70       end
71       describe 'showに於いて' do
72         before do
73           @action = @actions['show']
74         end
75         it 'showタイプのアクションである' do
76           expect(@action.type).to eq 'show'
77         end
78       end
79       describe 'countに於いて' do
80         before do
81           @action = @actions['count']
82         end
83         it 'countタイプのアクションである' do
84           expect(@action.type).to eq 'count'
85         end
86         it 'マニフェストから設定を取り出している' do
87           # indexがprivateリストなので、当然件数取得もprivateリストの総数を返す。 
88           set_list_action? @action, 'original_picture', 'private'
89         end
90       end
91       describe 'newに於いて' do
92         before do
93           @action = @actions['new']
94         end
95         it 'newタイプのアクションである' do
96           expect(@action.type).to eq 'new'
97         end
98         it 'type' do
99           expect(@action.item_name).to eq 'original_picture'
100         end
101       end
102       describe 'editに於いて' do
103         before do
104           @action = @actions['edit']
105         end
106         it 'editタイプのアクションである' do
107           expect(@action.type).to eq 'edit'
108         end
109         it 'type' do
110           expect(@action.item_name).to eq 'original_picture'
111         end
112       end
113       describe 'createに於いて' do
114         before do
115           @action = @actions['create']
116         end
117         it 'createタイプのアクションである' do
118           expect(@action.type).to eq 'create'
119         end
120         it 'type' do
121           expect(@action.item_name).to eq 'original_picture'
122         end
123       end
124       describe 'updateに於いて' do
125         before do
126           @action = @actions['update']
127         end
128         it 'updateタイプのアクションである' do
129           expect(@action.type).to eq 'update'
130         end
131         it 'type' do
132           expect(@action.item_name).to eq 'original_picture'
133         end
134       end
135       describe 'destroyに於いて' do
136         before do
137           @action = @actions['destroy']
138         end
139         it 'destroyタイプのアクションである' do
140           expect(@action.type).to eq 'destroy'
141         end
142         it 'type' do
143           expect(@action.item_name).to eq 'original_picture'
144         end
145       end
146     end
147     
148   end
149   
150   describe 'モデルに於いて' do
151     before do
152       @my_manifest = @model.my_manifest
153     end
154     it 'サポート機能が動作している' do
155       expect(@my_manifest.model_name).to eq 'original_picture'
156       expect(@my_manifest.classify).to eq @model
157       expect(@my_manifest.table_name).to eq 'original_pictures'
158     end
159     
160     describe 'associationsに於いて' do
161       describe 'belongs_toに於いて' do
162         before do
163           @belongs_to = @my_manifest.associations.belongs_to
164           @names = ['artist']
165         end
166         it 'これらのモデルに所属している' do
167           set_associations? @belongs_to, @names
168         end
169         describe 'artistに於いて' do
170           before do
171             @mani = @belongs_to['artist']
172           end
173           it 'マニフェストから設定を取り出している' do
174             # モデル名と外部キーが定義あるいはデフォルト値補充されている
175             expect(@mani.model_name).to eq 'artist'
176             expect(@mani.id_column).to eq 'artist_id'
177           end
178           it 'サポート機能が動作している' do
179             # モデルを再現できている
180             expect(@mani.model).to eq Artist
181           end
182         end
183       end
184       describe 'has_manyに於いて' do
185         before do
186           @has_many = @model.my_manifest.associations.has_many
187           @names = ['pictures']
188         end
189         it 'これらのモデルを所持している' do
190           set_associations? @has_many, @names
191         end
192         describe 'picturesに於いて' do
193           before do
194             @mani = @has_many['pictures']
195           end
196           it 'マニフェストから設定を取り出している' do
197             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
198             expect(@mani.model_name).to eq 'picture'
199             expect(@mani.foreign_key).to eq 'original_picture_id'
200             expect(@mani.through).to be nil
201           end
202           it 'サポート機能が動作している' do
203             # モデルを再現できている, 中間モデルフラグ
204             expect(@mani.through?).to be false
205             expect(@mani.model).to eq Picture
206           end
207         end
208       end
209       describe 'has_oneに於いて' do
210         before do
211           @has_one = @model.my_manifest.associations.has_one
212           @names = ['resource_picture']
213         end
214         it 'これらのモデルを所持している' do
215           set_associations? @has_one, @names
216         end
217         describe 'resource_pictureに於いて' do
218           before do
219             @mani = @has_one['resource_picture']
220           end
221           it 'マニフェストから設定を取り出している' do
222             # モデル名, 外部キーが定義あるいはデフォルト値補充されている
223             expect(@mani.model_name).to eq 'resource_picture'
224             expect(@mani.foreign_key).to eq 'original_picture_id'
225           end
226           it 'サポート機能が動作している' do
227             # モデルを再現できている
228             expect(@mani.model).to eq ResourcePicture
229           end
230         end
231       end
232     end
233     
234     describe 'attributesに於いて' do
235       before do
236         @attributes = @model.my_manifest.attributes
237       end
238       it 'これらのカラムを定義している' do
239         set_attributes? @attributes, 
240           ['id', 'ext', 
241           'width', 'height', 'filesize', 'artist_id', 'md5', 
242           'uploaded_at', 'published_at', 'stopped_at', 
243           'created_at', 'updated_at']
244       end
245       describe 'extに於いて' do
246         before do
247           @attribute = @attributes['ext']
248         end
249         it 'textタイプである' do
250           expect(@attribute.type).to eq 'text'
251         end
252       end
253       describe 'widthに於いて' do
254         before do
255           @attribute = @attributes['width']
256         end
257         it 'numberタイプである' do
258           expect(@attribute.type).to eq 'number'
259         end
260       end
261       describe 'heightに於いて' do
262         before do
263           @attribute = @attributes['height']
264         end
265         it 'numberタイプである' do
266           expect(@attribute.type).to eq 'number'
267         end
268       end
269       describe 'filesizeに於いて' do
270         before do
271           @attribute = @attributes['filesize']
272         end
273         it 'numberタイプである' do
274           expect(@attribute.type).to eq 'number'
275         end
276       end
277       describe 'artist_idに於いて' do
278         before do
279           @attribute = @attributes['artist_id']
280         end
281         it 'numberタイプである' do
282           expect(@attribute.type).to eq 'number'
283         end
284       end
285       describe 'md5に於いて' do
286         before do
287           @attribute = @attributes['md5']
288         end
289         it 'textタイプである' do
290           expect(@attribute.type).to eq 'text'
291         end
292       end
293       describe 'uploaded_atに於いて' do
294         before do
295           @attribute = @attributes['uploaded_at']
296         end
297         it 'datetimeタイプである' do
298           expect(@attribute.type).to eq 'datetime'
299         end
300       end
301       describe 'published_atに於いて' do
302         before do
303           @attribute = @attributes['published_at']
304         end
305         it 'datetimeタイプである' do
306           expect(@attribute.type).to eq 'datetime'
307         end
308       end
309       describe 'stopped_atに於いて' do
310         before do
311           @attribute = @attributes['stopped_at']
312         end
313         it 'datetimeタイプである' do
314           expect(@attribute.type).to eq 'datetime'
315         end
316       end
317     end
318     
319   end
320   
321 end