1 # -*- encoding: utf-8 -*-
4 describe PanelPicture do
5 include ManifestsMacros
10 describe 'ペタナイズに於いて' do
11 it 'パネルの要素として利用されるエレメントである' do
12 expect(@model.ancestors.include?(Peta::Element)).to eq true
15 expect(@model.my_peta.parent_model_name).to eq 'panel'
17 describe 'ブーストに於いて' do
19 expect(@model.my_peta.boost.keys).to be_empty
25 describe 'コントローラに於いて' do
27 @controller = @model.my_controller
29 it 'コマ絵のためのコントローラである' do
30 expect(@model.item_name).to eq 'panel_picture'
32 describe 'actionに於いて' do
34 @actions = @controller.actions
35 @actions_names = ['index', 'by_author', 'by_panel', 'show',
36 'count', 'count_by_author', 'count_by_panel',
39 it 'これらのアクションが定義されている' do
40 set_actions? @actions, @actions_names
42 describe 'baseに於いて' do
44 describe 'indexに於いて' do
46 @action = @actions['index']
48 it 'listタイプのアクションである' do
49 expect(@action.type).to eq 'list'
51 it 'マニフェストから設定を取り出している' do
52 # コマ絵の公開リストを返すように定義している
53 set_list_action? @action, 'panel_picture', 'public'
56 describe 'by_authorに於いて' do
58 @action = @actions['by_author']
60 it 'listタイプのアクションである' do
61 expect(@action.type).to eq 'list'
63 it 'マニフェストから設定を取り出している' do
64 # コマ絵の作家フィルタリストを返すように定義している
65 set_list_action? @action, 'panel_picture', 'by_author'
68 describe 'by_panelに於いて' do
70 @action = @actions['by_panel']
72 it 'listタイプのアクションである' do
73 expect(@action.type).to eq 'list'
75 it 'マニフェストから設定を取り出している' do
76 #コマ絵のコマフィルタリストを返すように定義している
77 set_list_action? @action, 'panel_picture', 'by_panel'
80 describe 'showに於いて' do
82 @action = @actions['show']
84 it 'showタイプのアクションである' do
85 expect(@action.type).to eq 'show'
88 describe 'countに於いて' do
90 @action = @actions['count']
92 it 'countタイプのアクションである' do
93 expect(@action.type).to eq 'count'
95 it 'マニフェストから設定を取り出している' do
96 #コマ絵の公開リストのカウントを返すように定義している
97 set_list_action? @action, 'panel_picture', 'public'
100 describe 'count_by_authorに於いて' do
102 @action = @actions['count_by_author']
104 it 'countタイプのアクションである' do
105 expect(@action.type).to eq 'count'
107 it 'マニフェストから設定を取り出している' do
108 # コマ絵の作家フィルタリストのカウントを返すように定義している
109 set_list_action? @action, 'panel_picture', 'by_author'
112 describe 'count_by_panelに於いて' do
114 @action = @actions['count_by_panel']
116 it 'countタイプのアクションである' do
117 expect(@action.type).to eq 'count'
119 it 'マニフェストから設定を取り出している' do
120 # コマ絵のコマフィルタリストのカウントを返すように定義している
121 set_list_action? @action, 'panel_picture', 'by_panel'
124 describe 'newに於いて' do
126 @action = @actions['new']
128 it 'newタイプのアクションである' do
129 expect(@action.type).to eq 'new'
132 expect(@action.item_name).to eq 'panel_picture'
135 describe 'editに於いて' do
137 @action = @actions['edit']
139 it 'editタイプのアクションである' do
140 expect(@action.type).to eq 'edit'
143 expect(@action.item_name).to eq 'panel_picture'
150 describe 'モデルに於いて' do
152 @my_manifest = @model.my_manifest
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'
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 'panelに於いて' do
171 @mani = @belongs_to['panel']
173 it 'マニフェストから設定を取り出している' do
174 # モデル名と外部キーが定義あるいはデフォルト値補充されている
175 expect(@mani.model_name).to eq 'panel'
176 expect(@mani.id_column).to eq 'panel_id'
178 it 'サポート機能が動作している' do
180 expect(@mani.model).to eq Panel
184 describe 'has_manyに於いて' do
186 @has_many = @model.my_manifest.associations.has_many
189 it 'これらのモデルを所持している' do
190 set_associations? @has_many, @names
195 describe 'attributesに於いて' do
197 @attributes = @model.my_manifest.attributes
199 it 'これらのカラムを定義している' do
200 set_attributes? @attributes,
201 ['id', 'panel_id', 'picture_id', 'caption', 'x', 'y', 'width', 'height',
203 'created_at', 'updated_at']
205 describe 'panel_idに於いて' do
207 @attribute = @attributes['panel_id']
210 expect(@attribute.type).to eq 'number'
213 describe 'picture_idに於いて' do
215 @attribute = @attributes['picture_id']
218 expect(@attribute.type).to eq 'number'
221 describe 'captionに於いて' do
223 @attribute = @attributes['caption']
226 expect(@attribute.type).to eq 'text'
231 @attribute = @attributes['x']
234 expect(@attribute.type).to eq 'number'
239 @attribute = @attributes['y']
242 expect(@attribute.type).to eq 'number'
245 describe 'widthに於いて' do
247 @attribute = @attributes['width']
250 expect(@attribute.type).to eq 'number'
253 describe 'heightに於いて' do
255 @attribute = @attributes['height']
258 expect(@attribute.type).to eq 'number'
261 describe 'linkに於いて' do
263 @attribute = @attributes['link']
266 expect(@attribute.type).to eq 'text'
271 @attribute = @attributes['z']
274 expect(@attribute.type).to eq 'number'
279 @attribute = @attributes['t']
282 expect(@attribute.type).to eq 'number'