OSDN Git Service

add test
[pettanr/pettanr.git] / spec / manifests / folder_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 # フォルダ
4
5 describe Folder do
6   include ManifestsMacros
7   before do
8     @model = Folder
9   end
10   
11   describe 'ペタナイズに於いて' do
12     it 'アイテムである' do
13       expect(@model.ancestors.include?(Peta::Item)).to eq true
14     end
15     it '親モデルは持たない' do
16       expect(@model.my_peta.parent_model_name).to be_blank
17     end
18     describe 'ブーストに於いて' do
19       it '特筆すべき注意事項はない' do
20         expect(@model.my_peta.boost.keys).to be_empty
21       end
22     end
23     
24   end
25   
26   describe 'コントローラに於いて' do
27     before do
28       @controller = @model.my_controller
29     end
30     it 'フォルダのためのコントローラである' do
31       expect(@model.item_name).to eq 'folder'
32     end
33     describe 'actionに於いて' do
34       before do
35         @actions = @controller.actions
36         @actions_names = ['root', 'index', 'show', 
37           'count', 
38           'new', 'edit', 'destroy']
39       end
40       it 'これらのアクションが定義されている' do
41         set_actions? @actions, @actions_names
42       end
43       describe 'baseに於いて' do
44       end
45       describe 'rootに於いて' do
46         before do
47           @action = @actions['root']
48         end
49         it 'showタイプのアクションである' do
50           expect(@action.type).to eq 'show'
51         end
52       end
53       describe 'indexに於いて' do
54         before do
55           @action = @actions['index']
56         end
57         it 'listタイプのアクションである' do
58           expect(@action.type).to eq 'list'
59         end
60         it 'マニフェストから設定を取り出している' do
61           # フォルダの公開リストを返すように定義している
62           set_list_action? @action, 'folder', 'public'
63         end
64       end
65       describe 'showに於いて' do
66         before do
67           @action = @actions['show']
68         end
69         it 'showタイプのアクションである' do
70           expect(@action.type).to eq 'show'
71         end
72       end
73       describe 'countに於いて' do
74         before do
75           @action = @actions['count']
76         end
77         it 'countタイプのアクションである' do
78           expect(@action.type).to eq 'count'
79         end
80         it 'マニフェストから設定を取り出している' do
81           #フォルダの公開リストのカウントを返すように定義している
82           set_list_action? @action, 'folder', 'public'
83         end
84       end
85       describe 'newに於いて' do
86         before do
87           @action = @actions['new']
88         end
89         it 'newタイプのアクションである' do
90           expect(@action.type).to eq 'new'
91         end
92         it 'type' do
93           expect(@action.item_name).to eq 'folder'
94         end
95       end
96       describe 'editに於いて' do
97         before do
98           @action = @actions['edit']
99         end
100         it 'editタイプのアクションである' do
101           expect(@action.type).to eq 'edit'
102         end
103         it 'type' do
104           expect(@action.item_name).to eq 'folder'
105         end
106       end
107       describe 'destroyに於いて' do
108         before do
109           @action = @actions['destroy']
110         end
111         it 'destroyタイプのアクションである' do
112           expect(@action.type).to eq 'destroy'
113         end
114         it 'type' do
115           expect(@action.item_name).to eq 'folder'
116         end
117       end
118     end
119     
120   end
121   
122   describe 'モデルに於いて' do
123     before do
124       @my_manifest = @model.my_manifest
125     end
126     it 'サポート機能が動作している' do
127       expect(@my_manifest.model_name).to eq 'folder'
128       expect(@my_manifest.classify).to eq @model
129       expect(@my_manifest.table_name).to eq 'folders'
130     end
131     
132     describe 'associationsに於いて' do
133       describe 'belongs_toに於いて' do
134         before do
135           @belongs_to = @my_manifest.associations.belongs_to
136           @names = []
137         end
138         it 'これらのモデルに所属している' do
139           set_associations? @belongs_to, @names
140         end
141       end
142       describe 'has_manyに於いて' do
143         before do
144           @has_many = @model.my_manifest.associations.has_many
145           @names = []
146         end
147         it 'これらのモデルを所持している' do
148           set_associations? @has_many, @names
149         end
150       end
151     end
152     
153     describe 'attributesに於いて' do
154       before do
155         @attributes = @model.my_manifest.attributes
156       end
157       it 'これらのカラムを定義している' do
158         set_attributes? @attributes, 
159           ['id', 'name', 'controller_name', 'action_name', 'category_id', 
160           't', 'parent_id', 'lft', 'rgt', 'depth', 
161           'created_at', 'updated_at']
162       end
163       describe 'nameに於いて' do
164         before do
165           @attribute = @attributes['name']
166         end
167         it 'textタイプである' do
168           expect(@attribute.type).to eq 'text'
169         end
170       end
171       describe 'controller_nameに於いて' do
172         before do
173           @attribute = @attributes['controller_name']
174         end
175         it 'textタイプである' do
176           expect(@attribute.type).to eq 'text'
177         end
178       end
179       describe 'action_nameに於いて' do
180         before do
181           @attribute = @attributes['action_name']
182         end
183         it 'textタイプである' do
184           expect(@attribute.type).to eq 'text'
185         end
186       end
187       describe 'category_idに於いて' do
188         before do
189           @attribute = @attributes['category_id']
190         end
191         it 'numberタイプである' do
192           expect(@attribute.type).to eq 'number'
193         end
194       end
195       describe 'tに於いて' do
196         before do
197           @attribute = @attributes['t']
198         end
199         it 'numberタイプである' do
200           expect(@attribute.type).to eq 'number'
201         end
202       end
203       describe 'parent_idに於いて' do
204         before do
205           @attribute = @attributes['parent_id']
206         end
207         it 'numberタイプである' do
208           expect(@attribute.type).to eq 'number'
209         end
210       end
211       describe 'lftに於いて' do
212         before do
213           @attribute = @attributes['lft']
214         end
215         it 'numberタイプである' do
216           expect(@attribute.type).to eq 'number'
217         end
218       end
219       describe 'rgtに於いて' do
220         before do
221           @attribute = @attributes['rgt']
222         end
223         it 'numberタイプである' do
224           expect(@attribute.type).to eq 'number'
225         end
226       end
227       describe 'depthに於いて' do
228         before do
229           @attribute = @attributes['depth']
230         end
231         it 'numberタイプである' do
232           expect(@attribute.type).to eq 'number'
233         end
234       end
235     end
236     
237   end
238   
239 end