1 # -*- encoding: utf-8 -*-
5 describe OriginalPicture do
6 include ManifestsMacros
8 @model = OriginalPicture
11 describe 'ペタナイズに於いて' do
12 it '絵師が投稿するコンテンツである' do
13 expect(@model.ancestors.include?(Peta::Content)).to eq true
16 expect(@model.my_peta.parent_model_name).to be_blank
18 describe 'ブーストに於いて' do
20 expect(@model.my_peta.boost.keys).to be_empty
26 describe 'コントローラに於いて' do
28 @controller = @model.my_controller
30 it '原画のためのコントローラである' do
31 expect(@model.item_name).to eq 'original_picture'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'history', 'show',
38 'new', 'edit', 'create', 'update', 'destroy']
40 it 'これらのアクションが定義されている' do
41 set_actions? @actions, @actions_names
43 describe 'baseに於いて' do
45 describe 'indexに於いて' do
47 @action = @actions['index']
49 it 'listタイプのアクションである' do
50 expect(@action.type).to eq 'list'
52 it 'マニフェストから設定を取り出している' do
53 # オーナーしか操作できないアイテムなので、
54 # 不特定多数のユーザで共有する必要がない。
55 # よって、 privateリスト(自分の原画リスト)に割り当てる。
56 set_list_action? @action, 'original_picture', 'private'
59 describe 'historyに於いて' do
61 @action = @actions['history']
64 # 一覧そのものは実素材の原画フィルタで見られるが、
65 # 過去の実素材を他人が見る事はできないので、
66 # オーナーであることが保証される原画にこの機能を備えてある。
67 it 'showタイプのアクションである' do
68 expect(@action.type).to eq 'show'
71 describe 'showに於いて' do
73 @action = @actions['show']
75 it 'showタイプのアクションである' do
76 expect(@action.type).to eq 'show'
79 describe 'countに於いて' do
81 @action = @actions['count']
83 it 'countタイプのアクションである' do
84 expect(@action.type).to eq 'count'
86 it 'マニフェストから設定を取り出している' do
87 # indexがprivateリストなので、当然件数取得もprivateリストの総数を返す。
88 set_list_action? @action, 'original_picture', 'private'
93 @action = @actions['new']
95 it 'newタイプのアクションである' do
96 expect(@action.type).to eq 'new'
99 expect(@action.item_name).to eq 'original_picture'
102 describe 'editに於いて' do
104 @action = @actions['edit']
106 it 'editタイプのアクションである' do
107 expect(@action.type).to eq 'edit'
110 expect(@action.item_name).to eq 'original_picture'
113 describe 'createに於いて' do
115 @action = @actions['create']
117 it 'createタイプのアクションである' do
118 expect(@action.type).to eq 'create'
121 expect(@action.item_name).to eq 'original_picture'
124 describe 'updateに於いて' do
126 @action = @actions['update']
128 it 'updateタイプのアクションである' do
129 expect(@action.type).to eq 'update'
132 expect(@action.item_name).to eq 'original_picture'
135 describe 'destroyに於いて' do
137 @action = @actions['destroy']
139 it 'destroyタイプのアクションである' do
140 expect(@action.type).to eq 'destroy'
143 expect(@action.item_name).to eq 'original_picture'
150 describe 'モデルに於いて' do
152 @my_manifest = @model.my_manifest
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'
160 describe 'associationsに於いて' do
161 describe 'belongs_toに於いて' do
163 @belongs_to = @my_manifest.associations.belongs_to
166 it 'これらのモデルに所属している' do
167 set_associations? @belongs_to, @names
169 describe 'artistに於いて' do
171 @mani = @belongs_to['artist']
173 it 'マニフェストから設定を取り出している' do
174 # モデル名と外部キーが定義あるいはデフォルト値補充されている
175 expect(@mani.model_name).to eq 'artist'
176 expect(@mani.id_column).to eq 'artist_id'
178 it 'サポート機能が動作している' do
180 expect(@mani.model).to eq Artist
184 describe 'has_manyに於いて' do
186 @has_many = @model.my_manifest.associations.has_many
187 @names = ['pictures']
189 it 'これらのモデルを所持している' do
190 set_associations? @has_many, @names
192 describe 'picturesに於いて' do
194 @mani = @has_many['pictures']
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
202 it 'サポート機能が動作している' do
203 # モデルを再現できている, 中間モデルフラグ
204 expect(@mani.through?).to be false
205 expect(@mani.model).to eq Picture
209 describe 'has_oneに於いて' do
211 @has_one = @model.my_manifest.associations.has_one
212 @names = ['resource_picture']
214 it 'これらのモデルを所持している' do
215 set_associations? @has_one, @names
217 describe 'resource_pictureに於いて' do
219 @mani = @has_one['resource_picture']
221 it 'マニフェストから設定を取り出している' do
222 # モデル名, 外部キーが定義あるいはデフォルト値補充されている
223 expect(@mani.model_name).to eq 'resource_picture'
224 expect(@mani.foreign_key).to eq 'original_picture_id'
226 it 'サポート機能が動作している' do
228 expect(@mani.model).to eq ResourcePicture
234 describe 'attributesに於いて' do
236 @attributes = @model.my_manifest.attributes
238 it 'これらのカラムを定義している' do
239 set_attributes? @attributes,
241 'width', 'height', 'filesize', 'artist_id', 'md5',
242 'uploaded_at', 'published_at', 'stopped_at',
243 'created_at', 'updated_at']
245 describe 'extに於いて' do
247 @attribute = @attributes['ext']
250 expect(@attribute.type).to eq 'text'
253 describe 'widthに於いて' do
255 @attribute = @attributes['width']
258 expect(@attribute.type).to eq 'number'
261 describe 'heightに於いて' do
263 @attribute = @attributes['height']
266 expect(@attribute.type).to eq 'number'
269 describe 'filesizeに於いて' do
271 @attribute = @attributes['filesize']
274 expect(@attribute.type).to eq 'number'
277 describe 'artist_idに於いて' do
279 @attribute = @attributes['artist_id']
282 expect(@attribute.type).to eq 'number'
285 describe 'md5に於いて' do
287 @attribute = @attributes['md5']
290 expect(@attribute.type).to eq 'text'
293 describe 'uploaded_atに於いて' do
295 @attribute = @attributes['uploaded_at']
297 it 'datetimeタイプである' do
298 expect(@attribute.type).to eq 'datetime'
301 describe 'published_atに於いて' do
303 @attribute = @attributes['published_at']
305 it 'datetimeタイプである' do
306 expect(@attribute.type).to eq 'datetime'
309 describe 'stopped_atに於いて' do
311 @attribute = @attributes['stopped_at']
313 it 'datetimeタイプである' do
314 expect(@attribute.type).to eq 'datetime'