OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / sheet_panel_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #紙コマ
4 describe SheetPanel do
5   include ManifestsMacros
6   before do
7     @model = SheetPanel
8   end
9   
10   describe 'ペタナイズに於いて' do
11     it 'スクコマを閉じるためのバインダーである' do
12       expect(@model.ancestors.include?(Peta::Binder)).to eq true
13     end
14     it '親モデルは持たない' do
15       expect(@model.my_peta.parent_model_name).to be_blank
16     end
17     describe 'ブーストに於いて' do
18       it '特筆すべき注意事項はない' do
19         expect(@model.my_peta.boost.keys).to be_empty
20       end
21     end
22     
23   end
24   
25   describe 'コントローラに於いて' do
26     before do
27       @controller = @model.my_controller
28     end
29     it 'スクロールのためのコントローラである' do
30       expect(@model.item_name).to eq 'scroll'
31     end
32     describe 'actionに於いて' do
33       before do
34         @actions = @controller.actions
35         @actions_names = ['index', 'by_author', 'by_panel', 'play', 'show', 
36           'count', 'count_by_author', 'count_by_panel', 
37           'new', 'edit', 'create', 'update', 'destroy']
38       end
39       it 'これらのアクションが定義されている' do
40         set_actions? @actions, @actions_names
41       end
42       describe 'baseに於いて' do
43       end
44       describe 'indexに於いて' do
45         before do
46           @action = @actions['index']
47         end
48         it 'listタイプのアクションである' do
49           expect(@action.type).to eq 'list'
50         end
51         it 'マニフェストから設定を取り出している' do
52           # スクロールの公開リストを返すように定義している
53           set_list_action? @action, 'scroll', 'public'
54         end
55       end
56       describe 'by_authorに於いて' do
57         before do
58           @action = @actions['by_author']
59         end
60         it 'listタイプのアクションである' do
61           expect(@action.type).to eq 'list'
62         end
63         it 'マニフェストから設定を取り出している' do
64           # スクロールの作家フィルタリストを返すように定義している
65           set_list_action? @action, 'scroll', 'by_author'
66         end
67       end
68       describe 'by_panelに於いて' do
69         before do
70           @action = @actions['by_panel']
71         end
72         it 'listタイプのアクションである' do
73           expect(@action.type).to eq 'list'
74         end
75         it 'マニフェストから設定を取り出している' do
76           #スクロールのコマフィルタリストを返すように定義している
77           set_list_action? @action, 'scroll', 'by_panel'
78         end
79       end
80       describe 'countに於いて' do
81         before do
82           @action = @actions['count']
83         end
84         it 'countタイプのアクションである' do
85           expect(@action.type).to eq 'count'
86         end
87         it 'マニフェストから設定を取り出している' do
88           #スクロールの公開リストのカウントを返すように定義している
89           set_list_action? @action, 'scroll', 'public'
90         end
91       end
92       describe 'count_by_authorに於いて' do
93         before do
94           @action = @actions['count_by_author']
95         end
96         it 'countタイプのアクションである' do
97           expect(@action.type).to eq 'count'
98         end
99         it 'マニフェストから設定を取り出している' do
100           # スクロールの作家フィルタリストのカウントを返すように定義している
101           set_list_action? @action, 'scroll', 'by_author'
102         end
103       end
104       describe 'count_by_panelに於いて' do
105         before do
106           @action = @actions['count_by_panel']
107         end
108         it 'countタイプのアクションである' do
109           expect(@action.type).to eq 'count'
110         end
111         it 'マニフェストから設定を取り出している' do
112           # スクロールのコマフィルタリストのカウントを返すように定義している
113           set_list_action? @action, 'scroll', 'by_panel'
114         end
115       end
116       describe 'newに於いて' do
117         before do
118           @action = @actions['new']
119         end
120         it 'newタイプのアクションである' do
121           expect(@action.type).to eq 'new'
122         end
123         it 'type' do
124           expect(@action.item_name).to eq 'scroll'
125         end
126       end
127       describe 'editに於いて' do
128         before do
129           @action = @actions['edit']
130         end
131         it 'editタイプのアクションである' do
132           expect(@action.type).to eq 'edit'
133         end
134         it 'type' do
135           expect(@action.item_name).to eq 'scroll'
136         end
137       end
138       describe 'createに於いて' do
139         before do
140           @action = @actions['create']
141         end
142         it 'createタイプのアクションである' do
143           expect(@action.type).to eq 'create'
144         end
145         it 'type' do
146           expect(@action.item_name).to eq 'scroll'
147         end
148       end
149       describe 'updateに於いて' do
150         before do
151           @action = @actions['update']
152         end
153         it 'updateタイプのアクションである' do
154           expect(@action.type).to eq 'update'
155         end
156         it 'type' do
157           expect(@action.item_name).to eq 'scroll'
158         end
159       end
160       describe 'destroyに於いて' do
161         before do
162           @action = @actions['destroy']
163         end
164         it 'destroyタイプのアクションである' do
165           expect(@action.type).to eq 'destroy'
166         end
167         it 'type' do
168           expect(@action.item_name).to eq 'scroll'
169         end
170       end
171     end
172     
173   end
174   
175   describe 'モデルに於いて' do
176     before do
177       @my_manifest = @model.my_manifest
178     end
179     it 'サポート機能が動作している' do
180       expect(@my_manifest.model_name).to eq 'scroll'
181       expect(@my_manifest.classify).to eq @model
182       expect(@my_manifest.table_name).to eq 'scrolls'
183     end
184     
185     describe 'associationsに於いて' do
186       describe 'belongs_toに於いて' do
187         before do
188           @belongs_to = @my_manifest.associations.belongs_to
189           @names = ['author']
190         end
191         it 'これらのモデルに所属している' do
192           set_associations? @belongs_to, @names
193         end
194         describe 'authorに於いて' do
195           before do
196             @mani = @belongs_to['author']
197           end
198           it 'マニフェストから設定を取り出している' do
199             # モデル名と外部キーが定義あるいはデフォルト値補充されている
200             expect(@mani.model_name).to eq 'author'
201             expect(@mani.id_column).to eq 'author_id'
202           end
203           it 'サポート機能が動作している' do
204             # モデルを再現できている
205             expect(@mani.model).to eq Author
206           end
207         end
208       end
209       describe 'has_manyに於いて' do
210         before do
211           @has_many = @model.my_manifest.associations.has_many
212           @names = ['scroll_panels', 'panels']
213         end
214         it 'これらのモデルを所持している' do
215           set_associations? @has_many, @names
216         end
217         describe 'scroll_panelsに於いて' do
218           before do
219             @mani = @has_many['scroll_panels']
220           end
221           it 'マニフェストから設定を取り出している' do
222             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
223             expect(@mani.model_name).to eq 'scroll_panel'
224             expect(@mani.foreign_key).to eq 'scroll_id'
225             expect(@mani.through).to be nil
226           end
227           it 'サポート機能が動作している' do
228             # モデルを再現できている, 中間モデルフラグ
229             expect(@mani.through?).to be false
230             expect(@mani.model).to eq ScrollPanel
231           end
232         end
233         describe 'panelsに於いて' do
234           before do
235             @mani = @has_many['panels']
236           end
237           it 'マニフェストから設定を取り出している' do
238             # モデル名, 外部キーと中間モデルが定義あるいはデフォルト値補充されている
239             expect(@mani.model_name).to eq 'panel'
240             expect(@mani.foreign_key).to eq 'scroll_id'
241             expect(@mani.through).to eq 'scroll_panels'
242           end
243           it 'サポート機能が動作している' do
244             # モデルを再現できている, 中間モデルフラグ
245             expect(@mani.through?).to be true
246             expect(@mani.model).to eq Panel
247           end
248         end
249       end
250     end
251     
252     describe 'attributesに於いて' do
253       before do
254         @attributes = @model.my_manifest.attributes
255       end
256       it 'これらのカラムを定義している' do
257         set_attributes? @attributes, 
258           ['id', 'title', 'description', 'visible', 'author_id', 
259           'created_at', 'updated_at']
260       end
261       describe 'titleに於いて' do
262         before do
263           @attribute = @attributes['title']
264         end
265         it 'textタイプである' do
266           expect(@attribute.type).to eq 'text'
267         end
268       end
269       describe 'descriptionに於いて' do
270         before do
271           @attribute = @attributes['description']
272         end
273         it 'textタイプである' do
274           expect(@attribute.type).to eq 'text'
275         end
276       end
277       describe 'visibleに於いて' do
278         before do
279           @attribute = @attributes['visible']
280         end
281         it 'numberタイプである' do
282           expect(@attribute.type).to eq 'number'
283         end
284         it '選択肢を定数から取得できるように定義している' do
285           expect(@attribute.source.type).to eq 'magic_number'
286           expect(@attribute.source.select_item_name).to eq 'scroll_visible_items'
287         end
288       end
289       describe 'author_idに於いて' do
290         before do
291           @attribute = @attributes['author_id']
292         end
293         it 'numberタイプである' do
294           expect(@attribute.type).to eq 'number'
295         end
296       end
297     end
298     
299   end
300   
301 end