1 # -*- encoding: utf-8 -*-
\r
3 require 'spec_helper'
\r
5 describe ResourcePicture do
\r
6 include ManifestsMacros
\r
8 @model = ResourcePicture
\r
11 describe 'ペタナイズに於いて' do
\r
12 it 'スクコマを閉じるためのバインダーである' do
\r
13 expect(@model.ancestors.include?(Peta::Binder)).to eq true
\r
16 expect(@model.my_peta.parent_model_name).to be_blank
\r
18 describe 'ブーストに於いて' do
\r
19 it '特筆すべき注意事項はない' do
\r
20 expect(@model.my_peta.boost.keys).to be_empty
\r
26 describe 'コントローラに於いて' do
\r
28 @controller = @model.my_controller
\r
30 it 'スクロールのためのコントローラである' do
\r
31 expect(@model.item_name).to eq 'scroll'
\r
33 describe 'actionに於いて' do
\r
35 @actions = @controller.actions
\r
36 @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show',
\r
37 'count', 'count_by_author', 'count_by_panel',
\r
38 'new', 'edit', 'create', 'update', 'destroy']
\r
40 it 'これらのアクションが定義されている' do
\r
41 set_actions? @actions, @actions_names
\r
43 describe 'baseに於いて' do
\r
45 describe 'indexに於いて' do
\r
47 @action = @actions['index']
\r
49 it 'listタイプのアクションである' do
\r
50 expect(@action.type).to eq 'list'
\r
52 it 'マニフェストから設定を取り出している' do
\r
53 # スクロールの公開リストを返すように定義している
\r
54 set_list_action? @action, 'scroll', 'public'
\r
57 describe 'by_authorに於いて' do
\r
59 @action = @actions['by_author']
\r
61 it 'listタイプのアクションである' do
\r
62 expect(@action.type).to eq 'list'
\r
64 it 'マニフェストから設定を取り出している' do
\r
65 # スクロールの作家フィルタリストを返すように定義している
\r
66 set_list_action? @action, 'scroll', 'by_author'
\r
69 describe 'by_panelに於いて' do
\r
71 @action = @actions['by_panel']
\r
73 it 'listタイプのアクションである' do
\r
74 expect(@action.type).to eq 'list'
\r
76 it 'マニフェストから設定を取り出している' do
\r
77 #スクロールのコマフィルタリストを返すように定義している
\r
78 set_list_action? @action, 'scroll', 'by_panel'
\r
81 describe 'countに於いて' do
\r
83 @action = @actions['count']
\r
85 it 'countタイプのアクションである' do
\r
86 expect(@action.type).to eq 'count'
\r
88 it 'マニフェストから設定を取り出している' do
\r
89 #スクロールの公開リストのカウントを返すように定義している
\r
90 set_list_action? @action, 'scroll', 'public'
\r
93 describe 'count_by_authorに於いて' do
\r
95 @action = @actions['count_by_author']
\r
97 it 'countタイプのアクションである' do
\r
98 expect(@action.type).to eq 'count'
\r
100 it 'マニフェストから設定を取り出している' do
\r
101 # スクロールの作家フィルタリストのカウントを返すように定義している
\r
102 set_list_action? @action, 'scroll', 'by_author'
\r
105 describe 'count_by_panelに於いて' do
\r
107 @action = @actions['count_by_panel']
\r
109 it 'countタイプのアクションである' do
\r
110 expect(@action.type).to eq 'count'
\r
112 it 'マニフェストから設定を取り出している' do
\r
113 # スクロールのコマフィルタリストのカウントを返すように定義している
\r
114 set_list_action? @action, 'scroll', 'by_panel'
\r
117 describe 'newに於いて' do
\r
119 @action = @actions['new']
\r
121 it 'newタイプのアクションである' do
\r
122 expect(@action.type).to eq 'new'
\r
125 expect(@action.item_name).to eq 'scroll'
\r
128 describe 'editに於いて' do
\r
130 @action = @actions['edit']
\r
132 it 'editタイプのアクションである' do
\r
133 expect(@action.type).to eq 'edit'
\r
136 expect(@action.item_name).to eq 'scroll'
\r
139 describe 'createに於いて' do
\r
141 @action = @actions['create']
\r
143 it 'createタイプのアクションである' do
\r
144 expect(@action.type).to eq 'create'
\r
147 expect(@action.item_name).to eq 'scroll'
\r
150 describe 'updateに於いて' do
\r
152 @action = @actions['update']
\r
154 it 'updateタイプのアクションである' do
\r
155 expect(@action.type).to eq 'update'
\r
158 expect(@action.item_name).to eq 'scroll'
\r
161 describe 'destroyに於いて' do
\r
163 @action = @actions['destroy']
\r
165 it 'destroyタイプのアクションである' do
\r
166 expect(@action.type).to eq 'destroy'
\r
169 expect(@action.item_name).to eq 'scroll'
\r
176 describe 'モデルに於いて' do
\r
178 @my_manifest = @model.my_manifest
\r
180 it 'サポート機能が動作している' do
\r
181 expect(@my_manifest.model_name).to eq 'scroll'
\r
182 expect(@my_manifest.classify).to eq @model
\r
183 expect(@my_manifest.table_name).to eq 'scrolls'
\r
186 describe 'associationsに於いて' do
\r
187 describe 'belongs_toに於いて' do
\r
189 @belongs_to = @my_manifest.associations.belongs_to
\r
190 @names = ['author']
\r
192 it 'これらのモデルに所属している' do
\r
193 set_associations? @belongs_to, @names
\r
195 describe 'authorに於いて' do
\r
197 @mani = @belongs_to['author']
\r
199 it 'マニフェストから設定を取り出している' do
\r
200 # モデル名と外部キーが定義あるいはデフォルト値補充されている
\r
201 expect(@mani.model_name).to eq 'author'
\r
202 expect(@mani.id_column).to eq 'author_id'
\r
204 it 'サポート機能が動作している' do
\r
206 expect(@mani.model).to eq Author
\r
210 describe 'has_manyに於いて' do
\r
212 @has_many = @model.my_manifest.associations.has_many
\r
213 @names = ['scroll_panels', 'panels']
\r
215 it 'これらのモデルを所持している' do
\r
216 set_associations? @has_many, @names
\r
218 describe 'scroll_panelsに於いて' do
\r
220 @mani = @has_many['scroll_panels']
\r
222 it 'マニフェストから設定を取り出している' do
\r
223 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
\r
224 expect(@mani.model_name).to eq 'scroll_panel'
\r
225 expect(@mani.foreign_key).to eq 'scroll_id'
\r
226 expect(@mani.through).to be nil
\r
228 it 'サポート機能が動作している' do
\r
229 # モデルを再現できている, 中間モデルフラグ
\r
230 expect(@mani.through?).to be false
\r
231 expect(@mani.model).to eq ScrollPanel
\r
234 describe 'panelsに於いて' do
\r
236 @mani = @has_many['panels']
\r
238 it 'マニフェストから設定を取り出している' do
\r
239 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
\r
240 expect(@mani.model_name).to eq 'panel'
\r
241 expect(@mani.foreign_key).to eq 'scroll_id'
\r
242 expect(@mani.through).to eq 'scroll_panels'
\r
244 it 'サポート機能が動作している' do
\r
245 # モデルを再現できている, 中間モデルフラグ
\r
246 expect(@mani.through?).to be true
\r
247 expect(@mani.model).to eq Panel
\r
253 describe 'attributesに於いて' do
\r
255 @attributes = @model.my_manifest.attributes
\r
257 it 'これらのカラムを定義している' do
\r
258 set_attributes? @attributes,
\r
259 ['id', 'title', 'description', 'visible', 'author_id',
\r
260 'created_at', 'updated_at']
\r
262 describe 'titleに於いて' do
\r
264 @attribute = @attributes['title']
\r
267 expect(@attribute.type).to eq 'text'
\r
270 describe 'descriptionに於いて' do
\r
272 @attribute = @attributes['description']
\r
275 expect(@attribute.type).to eq 'text'
\r
278 describe 'visibleに於いて' do
\r
280 @attribute = @attributes['visible']
\r
282 it 'numberタイプである' do
\r
283 expect(@attribute.type).to eq 'number'
\r
285 it '選択肢を定数から取得できるように定義している' do
\r
286 expect(@attribute.source.type).to eq 'magic_number'
\r
287 expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
\r
290 describe 'author_idに於いて' do
\r
292 @attribute = @attributes['author_id']
\r
294 it 'numberタイプである' do
\r
295 expect(@attribute.type).to eq 'number'
\r