1 # -*- encoding: utf-8 -*-
\r
2 require 'spec_helper'
\r
5 include ManifestsMacros
\r
10 describe 'ペタナイズに於いて' do
\r
11 it 'スクコマを閉じるためのバインダーである' do
\r
12 expect(@model.ancestors.include?(Peta::Binder)).to eq true
\r
15 expect(@model.my_peta.parent_model_name).to be_blank
\r
17 describe 'ブーストに於いて' do
\r
18 it '特筆すべき注意事項はない' do
\r
19 expect(@model.my_peta.boost.keys).to be_empty
\r
25 describe 'コントローラに於いて' do
\r
27 @controller = @model.my_controller
\r
29 it 'スクロールのためのコントローラである' do
\r
30 expect(@model.item_name).to eq 'scroll'
\r
32 describe 'actionに於いて' do
\r
34 @actions = @controller.actions
\r
35 @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show',
\r
36 'count', 'count_by_author', 'count_by_panel',
\r
37 'new', 'edit', 'create', 'update', 'destroy']
\r
39 it 'これらのアクションが定義されている' do
\r
40 set_actions? @actions, @actions_names
\r
42 describe 'baseに於いて' do
\r
44 describe 'indexに於いて' do
\r
46 @action = @actions['index']
\r
48 it 'listタイプのアクションである' do
\r
49 expect(@action.type).to eq 'list'
\r
51 it 'マニフェストから設定を取り出している' do
\r
52 # スクロールの公開リストを返すように定義している
\r
53 set_list_action? @action, 'scroll', 'public'
\r
56 describe 'by_authorに於いて' do
\r
58 @action = @actions['by_author']
\r
60 it 'listタイプのアクションである' do
\r
61 expect(@action.type).to eq 'list'
\r
63 it 'マニフェストから設定を取り出している' do
\r
64 # スクロールの作家フィルタリストを返すように定義している
\r
65 set_list_action? @action, 'scroll', 'by_author'
\r
68 describe 'by_panelに於いて' do
\r
70 @action = @actions['by_panel']
\r
72 it 'listタイプのアクションである' do
\r
73 expect(@action.type).to eq 'list'
\r
75 it 'マニフェストから設定を取り出している' do
\r
76 #スクロールのコマフィルタリストを返すように定義している
\r
77 set_list_action? @action, 'scroll', 'by_panel'
\r
80 describe 'countに於いて' do
\r
82 @action = @actions['count']
\r
84 it 'countタイプのアクションである' do
\r
85 expect(@action.type).to eq 'count'
\r
87 it 'マニフェストから設定を取り出している' do
\r
88 #スクロールの公開リストのカウントを返すように定義している
\r
89 set_list_action? @action, 'scroll', 'public'
\r
92 describe 'count_by_authorに於いて' do
\r
94 @action = @actions['count_by_author']
\r
96 it 'countタイプのアクションである' do
\r
97 expect(@action.type).to eq 'count'
\r
99 it 'マニフェストから設定を取り出している' do
\r
100 # スクロールの作家フィルタリストのカウントを返すように定義している
\r
101 set_list_action? @action, 'scroll', 'by_author'
\r
104 describe 'count_by_panelに於いて' do
\r
106 @action = @actions['count_by_panel']
\r
108 it 'countタイプのアクションである' do
\r
109 expect(@action.type).to eq 'count'
\r
111 it 'マニフェストから設定を取り出している' do
\r
112 # スクロールのコマフィルタリストのカウントを返すように定義している
\r
113 set_list_action? @action, 'scroll', 'by_panel'
\r
116 describe 'newに於いて' do
\r
118 @action = @actions['new']
\r
120 it 'newタイプのアクションである' do
\r
121 expect(@action.type).to eq 'new'
\r
124 expect(@action.item_name).to eq 'scroll'
\r
127 describe 'editに於いて' do
\r
129 @action = @actions['edit']
\r
131 it 'editタイプのアクションである' do
\r
132 expect(@action.type).to eq 'edit'
\r
135 expect(@action.item_name).to eq 'scroll'
\r
138 describe 'createに於いて' do
\r
140 @action = @actions['create']
\r
142 it 'createタイプのアクションである' do
\r
143 expect(@action.type).to eq 'create'
\r
146 expect(@action.item_name).to eq 'scroll'
\r
149 describe 'updateに於いて' do
\r
151 @action = @actions['update']
\r
153 it 'updateタイプのアクションである' do
\r
154 expect(@action.type).to eq 'update'
\r
157 expect(@action.item_name).to eq 'scroll'
\r
160 describe 'destroyに於いて' do
\r
162 @action = @actions['destroy']
\r
164 it 'destroyタイプのアクションである' do
\r
165 expect(@action.type).to eq 'destroy'
\r
168 expect(@action.item_name).to eq 'scroll'
\r
175 describe 'モデルに於いて' do
\r
177 @my_manifest = @model.my_manifest
\r
179 it 'サポート機能が動作している' do
\r
180 expect(@my_manifest.model_name).to eq 'scroll'
\r
181 expect(@my_manifest.classify).to eq @model
\r
182 expect(@my_manifest.table_name).to eq 'scrolls'
\r
185 describe 'associationsに於いて' do
\r
186 describe 'belongs_toに於いて' do
\r
188 @belongs_to = @my_manifest.associations.belongs_to
\r
189 @names = ['author']
\r
191 it 'これらのモデルに所属している' do
\r
192 set_associations? @belongs_to, @names
\r
194 describe 'authorに於いて' do
\r
196 @mani = @belongs_to['author']
\r
198 it 'マニフェストから設定を取り出している' do
\r
199 # モデル名と外部キーが定義あるいはデフォルト値補充されている
\r
200 expect(@mani.model_name).to eq 'author'
\r
201 expect(@mani.id_column).to eq 'author_id'
\r
203 it 'サポート機能が動作している' do
\r
205 expect(@mani.model).to eq Author
\r
209 describe 'has_manyに於いて' do
\r
211 @has_many = @model.my_manifest.associations.has_many
\r
212 @names = ['scroll_panels', 'panels']
\r
214 it 'これらのモデルを所持している' do
\r
215 set_associations? @has_many, @names
\r
217 describe 'scroll_panelsに於いて' do
\r
219 @mani = @has_many['scroll_panels']
\r
221 it 'マニフェストから設定を取り出している' do
\r
222 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
\r
223 expect(@mani.model_name).to eq 'scroll_panel'
\r
224 expect(@mani.foreign_key).to eq 'scroll_id'
\r
225 expect(@mani.through).to be nil
\r
227 it 'サポート機能が動作している' do
\r
228 # モデルを再現できている, 中間モデルフラグ
\r
229 expect(@mani.through?).to be false
\r
230 expect(@mani.model).to eq ScrollPanel
\r
233 describe 'panelsに於いて' do
\r
235 @mani = @has_many['panels']
\r
237 it 'マニフェストから設定を取り出している' do
\r
238 # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
\r
239 expect(@mani.model_name).to eq 'panel'
\r
240 expect(@mani.foreign_key).to eq 'scroll_id'
\r
241 expect(@mani.through).to eq 'scroll_panels'
\r
243 it 'サポート機能が動作している' do
\r
244 # モデルを再現できている, 中間モデルフラグ
\r
245 expect(@mani.through?).to be true
\r
246 expect(@mani.model).to eq Panel
\r
252 describe 'attributesに於いて' do
\r
254 @attributes = @model.my_manifest.attributes
\r
256 it 'これらのカラムを定義している' do
\r
257 set_attributes? @attributes,
\r
258 ['id', 'title', 'description', 'visible', 'author_id',
\r
259 'created_at', 'updated_at']
\r
261 describe 'titleに於いて' do
\r
263 @attribute = @attributes['title']
\r
266 expect(@attribute.type).to eq 'text'
\r
269 describe 'descriptionに於いて' do
\r
271 @attribute = @attributes['description']
\r
274 expect(@attribute.type).to eq 'text'
\r
277 describe 'visibleに於いて' do
\r
279 @attribute = @attributes['visible']
\r
281 it 'numberタイプである' do
\r
282 expect(@attribute.type).to eq 'number'
\r
284 it '選択肢を定数から取得できるように定義している' do
\r
285 expect(@attribute.source.type).to eq 'magic_number'
\r
286 expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
\r
289 describe 'author_idに於いて' do
\r
291 @attribute = @attributes['author_id']
\r
293 it 'numberタイプである' do
\r
294 expect(@attribute.type).to eq 'number'
\r