OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / panel_picture_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #コマ絵
4 describe PanelPicture do
5   include ManifestsMacros
6   before do
7     @model = PanelPicture
8   end
9   
10   describe 'ペタナイズに於いて' do
11     it 'パネルの要素として利用されるエレメントである' do
12       expect(@model.ancestors.include?(Peta::Element)).to eq true
13     end
14     it '親モデルはパネルである' do
15       expect(@model.my_peta.parent_model_name).to eq 'panel'
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 'panel_picture'
31     end
32     describe 'actionに於いて' do
33       before do
34         @actions = @controller.actions
35         @actions_names = ['index', 'by_author', 'by_panel', 'show', 
36           'count', 'count_by_author', 'count_by_panel', 
37           'new', 'edit']
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, 'panel_picture', '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, 'panel_picture', '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, 'panel_picture', 'by_panel'
78         end
79       end
80       describe 'showに於いて' do
81         before do
82           @action = @actions['show']
83         end
84         it 'showタイプのアクションである' do
85           expect(@action.type).to eq 'show'
86         end
87       end
88       describe 'countに於いて' do
89         before do
90           @action = @actions['count']
91         end
92         it 'countタイプのアクションである' do
93           expect(@action.type).to eq 'count'
94         end
95         it 'マニフェストから設定を取り出している' do
96           #コマ絵の公開リストのカウントを返すように定義している
97           set_list_action? @action, 'panel_picture', 'public'
98         end
99       end
100       describe 'count_by_authorに於いて' do
101         before do
102           @action = @actions['count_by_author']
103         end
104         it 'countタイプのアクションである' do
105           expect(@action.type).to eq 'count'
106         end
107         it 'マニフェストから設定を取り出している' do
108           # コマ絵の作家フィルタリストのカウントを返すように定義している
109           set_list_action? @action, 'panel_picture', 'by_author'
110         end
111       end
112       describe 'count_by_panelに於いて' do
113         before do
114           @action = @actions['count_by_panel']
115         end
116         it 'countタイプのアクションである' do
117           expect(@action.type).to eq 'count'
118         end
119         it 'マニフェストから設定を取り出している' do
120           # コマ絵のコマフィルタリストのカウントを返すように定義している
121           set_list_action? @action, 'panel_picture', 'by_panel'
122         end
123       end
124       describe 'newに於いて' do
125         before do
126           @action = @actions['new']
127         end
128         it 'newタイプのアクションである' do
129           expect(@action.type).to eq 'new'
130         end
131         it 'type' do
132           expect(@action.item_name).to eq 'panel_picture'
133         end
134       end
135       describe 'editに於いて' do
136         before do
137           @action = @actions['edit']
138         end
139         it 'editタイプのアクションである' do
140           expect(@action.type).to eq 'edit'
141         end
142         it 'type' do
143           expect(@action.item_name).to eq 'panel_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 'panel_picture'
156       expect(@my_manifest.classify).to eq @model
157       expect(@my_manifest.table_name).to eq 'panel_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 = ['panel']
165         end
166         it 'これらのモデルに所属している' do
167           set_associations? @belongs_to, @names
168         end
169         describe 'panelに於いて' do
170           before do
171             @mani = @belongs_to['panel']
172           end
173           it 'マニフェストから設定を取り出している' do
174             # モデル名と外部キーが定義あるいはデフォルト値補充されている
175             expect(@mani.model_name).to eq 'panel'
176             expect(@mani.id_column).to eq 'panel_id'
177           end
178           it 'サポート機能が動作している' do
179             # モデルを再現できている
180             expect(@mani.model).to eq Panel
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 = []
188         end
189         it 'これらのモデルを所持している' do
190           set_associations? @has_many, @names
191         end
192       end
193     end
194     
195     describe 'attributesに於いて' do
196       before do
197         @attributes = @model.my_manifest.attributes
198       end
199       it 'これらのカラムを定義している' do
200         set_attributes? @attributes, 
201           ['id', 'panel_id', 'picture_id', 'caption', 'x', 'y', 'width', 'height', 
202           'link', 'z', 't', 
203           'created_at', 'updated_at']
204       end
205       describe 'panel_idに於いて' do
206         before do
207           @attribute = @attributes['panel_id']
208         end
209         it 'numberタイプである' do
210           expect(@attribute.type).to eq 'number'
211         end
212       end
213       describe 'picture_idに於いて' do
214         before do
215           @attribute = @attributes['picture_id']
216         end
217         it 'numberタイプである' do
218           expect(@attribute.type).to eq 'number'
219         end
220       end
221       describe 'captionに於いて' do
222         before do
223           @attribute = @attributes['caption']
224         end
225         it 'textタイプである' do
226           expect(@attribute.type).to eq 'text'
227         end
228       end
229       describe 'xに於いて' do
230         before do
231           @attribute = @attributes['x']
232         end
233         it 'numberタイプである' do
234           expect(@attribute.type).to eq 'number'
235         end
236       end
237       describe 'yに於いて' do
238         before do
239           @attribute = @attributes['y']
240         end
241         it 'numberタイプである' do
242           expect(@attribute.type).to eq 'number'
243         end
244       end
245       describe 'widthに於いて' do
246         before do
247           @attribute = @attributes['width']
248         end
249         it 'numberタイプである' do
250           expect(@attribute.type).to eq 'number'
251         end
252       end
253       describe 'heightに於いて' do
254         before do
255           @attribute = @attributes['height']
256         end
257         it 'numberタイプである' do
258           expect(@attribute.type).to eq 'number'
259         end
260       end
261       describe 'linkに於いて' do
262         before do
263           @attribute = @attributes['link']
264         end
265         it 'textタイプである' do
266           expect(@attribute.type).to eq 'text'
267         end
268       end
269       describe 'zに於いて' do
270         before do
271           @attribute = @attributes['z']
272         end
273         it 'numberタイプである' do
274           expect(@attribute.type).to eq 'number'
275         end
276       end
277       describe 'tに於いて' do
278         before do
279           @attribute = @attributes['t']
280         end
281         it 'numberタイプである' do
282           expect(@attribute.type).to eq 'number'
283         end
284       end
285     end
286     
287   end
288   
289 end