1 # -*- encoding: utf-8 -*-
5 describe GroundColor do
6 include ManifestsMacros
11 describe 'ペタナイズに於いて' do
12 it 'パネルの要素として利用されるエレメントである' do
13 expect(@model.ancestors.include?(Peta::Element)).to eq true
16 expect(@model.my_peta.parent_model_name).to eq 'panel'
18 describe 'ブーストに於いて' do
20 expect(@model.my_peta.boost.keys).to be_empty
26 describe 'コントローラに於いて' do
28 @controller = @model.my_controller
30 it '色地のためのコントローラである' do
31 expect(@model.item_name).to eq 'ground_color'
33 describe 'actionに於いて' do
35 @actions = @controller.actions
36 @actions_names = ['index', 'by_author', 'by_panel', 'show',
37 'count', 'count_by_author', 'count_by_panel',
40 it 'これらのアクションが定義されている' do
41 set_actions? @actions, @actions_names
43 describe 'baseに於いて' do
45 describe 'indexに於いて' do
47 @action = @actions['index']
49 it 'listタイプのアクションである' do
50 expect(@action.type).to eq 'list'
52 it 'マニフェストから設定を取り出している' do
53 # 絵地の公開リストを返すように定義している
54 set_list_action? @action, 'ground_color', 'public'
57 describe 'by_authorに於いて' do
59 @action = @actions['by_author']
61 it 'listタイプのアクションである' do
62 expect(@action.type).to eq 'list'
64 it 'マニフェストから設定を取り出している' do
65 # 絵地の作家フィルタリストを返すように定義している
66 set_list_action? @action, 'ground_color', 'by_author'
69 describe 'by_panelに於いて' do
71 @action = @actions['by_panel']
73 it 'listタイプのアクションである' do
74 expect(@action.type).to eq 'list'
76 it 'マニフェストから設定を取り出している' do
77 #絵地のコマフィルタリストを返すように定義している
78 set_list_action? @action, 'ground_color', 'by_panel'
81 describe 'showに於いて' do
83 @action = @actions['show']
85 it 'showタイプのアクションである' do
86 expect(@action.type).to eq 'show'
89 describe 'countに於いて' do
91 @action = @actions['count']
93 it 'countタイプのアクションである' do
94 expect(@action.type).to eq 'count'
96 it 'マニフェストから設定を取り出している' do
97 #絵地の公開リストのカウントを返すように定義している
98 set_list_action? @action, 'ground_color', 'public'
101 describe 'count_by_authorに於いて' do
103 @action = @actions['count_by_author']
105 it 'countタイプのアクションである' do
106 expect(@action.type).to eq 'count'
108 it 'マニフェストから設定を取り出している' do
109 # 絵地の作家フィルタリストのカウントを返すように定義している
110 set_list_action? @action, 'ground_color', 'by_author'
113 describe 'count_by_panelに於いて' do
115 @action = @actions['count_by_panel']
117 it 'countタイプのアクションである' do
118 expect(@action.type).to eq 'count'
120 it 'マニフェストから設定を取り出している' do
121 # 絵地のコマフィルタリストのカウントを返すように定義している
122 set_list_action? @action, 'ground_color', 'by_panel'
125 describe 'newに於いて' do
127 @action = @actions['new']
129 it 'newタイプのアクションである' do
130 expect(@action.type).to eq 'new'
133 expect(@action.item_name).to eq 'ground_color'
136 describe 'editに於いて' do
138 @action = @actions['edit']
140 it 'editタイプのアクションである' do
141 expect(@action.type).to eq 'edit'
144 expect(@action.item_name).to eq 'ground_color'
151 describe 'モデルに於いて' do
153 @my_manifest = @model.my_manifest
155 it 'サポート機能が動作している' do
156 expect(@my_manifest.model_name).to eq 'ground_color'
157 expect(@my_manifest.classify).to eq @model
158 expect(@my_manifest.table_name).to eq 'ground_colors'
161 describe 'associationsに於いて' do
162 describe 'belongs_toに於いて' do
164 @belongs_to = @my_manifest.associations.belongs_to
167 it 'これらのモデルに所属している' do
168 set_associations? @belongs_to, @names
170 describe 'panelに於いて' do
172 @mani = @belongs_to['panel']
174 it 'マニフェストから設定を取り出している' do
175 # モデル名と外部キーが定義あるいはデフォルト値補充されている
176 expect(@mani.model_name).to eq 'panel'
177 expect(@mani.id_column).to eq 'panel_id'
179 it 'サポート機能が動作している' do
181 expect(@mani.model).to eq Panel
185 describe 'has_manyに於いて' do
187 @has_many = @model.my_manifest.associations.has_many
190 it 'これらのモデルを所持している' do
191 set_associations? @has_many, @names
196 describe 'attributesに於いて' do
198 @attributes = @model.my_manifest.attributes
200 it 'これらのカラムを定義している' do
201 set_attributes? @attributes,
202 ['id', 'panel_id', 'caption', 'code', 'orientation', 'xy', 'wh',
204 'created_at', 'updated_at']
206 describe 'panel_idに於いて' do
208 @attribute = @attributes['panel_id']
211 expect(@attribute.type).to eq 'number'
214 describe 'captionに於いて' do
216 @attribute = @attributes['caption']
219 expect(@attribute.type).to eq 'text'
222 describe 'codeに於いて' do
224 @attribute = @attributes['code']
227 expect(@attribute.type).to eq 'number'
230 describe 'orientationに於いて' do
232 @attribute = @attributes['orientation']
235 expect(@attribute.type).to eq 'number'
237 it '選択肢を定数から取得できるように定義している' do
238 expect(@attribute.source.type).to eq 'magic_number'
239 expect(@attribute.source.select_item_name).to eq 'ground_color_orientation_items'
244 @attribute = @attributes['xy']
247 expect(@attribute.type).to eq 'number'
252 @attribute = @attributes['wh']
255 expect(@attribute.type).to eq 'number'
260 @attribute = @attributes['z']
263 expect(@attribute.type).to eq 'number'
268 @attribute = @attributes['t']
271 expect(@attribute.type).to eq 'number'