enju_library 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/enju_library/controller.rb +12 -3
- data/app/controllers/libraries_controller.rb +1 -0
- data/app/controllers/shelves_controller.rb +2 -1
- data/app/models/library.rb +1 -1
- data/app/models/library_group.rb +22 -17
- data/app/models/shelf.rb +1 -1
- data/app/views/libraries/_form.html.erb +1 -0
- data/app/views/library_groups/_color_fields.html.erb +0 -1
- data/app/views/library_groups/_form.html.erb +1 -4
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/config/routes.rb +1 -0
- data/lib/enju_library/version.rb +1 -1
- data/lib/tasks/enju_library_tasks.rake +2 -2
- data/spec/controllers/accepts_controller_spec.rb +96 -96
- data/spec/controllers/baskets_controller_spec.rb +126 -126
- data/spec/controllers/bookstores_controller_spec.rb +152 -152
- data/spec/controllers/budget_types_controller_spec.rb +48 -49
- data/spec/controllers/libraries_controller_spec.rb +183 -183
- data/spec/controllers/library_groups_controller_spec.rb +47 -47
- data/spec/controllers/request_status_types_controller_spec.rb +152 -152
- data/spec/controllers/request_types_controller_spec.rb +152 -152
- data/spec/controllers/search_engines_controller_spec.rb +152 -152
- data/spec/controllers/shelves_controller_spec.rb +152 -152
- data/spec/controllers/subscribes_controller_spec.rb +151 -151
- data/spec/controllers/subscriptions_controller_spec.rb +152 -152
- data/spec/controllers/user_export_files_controller_spec.rb +75 -75
- data/spec/controllers/user_groups_controller_spec.rb +108 -108
- data/spec/controllers/user_import_files_controller_spec.rb +73 -73
- data/spec/controllers/user_import_results_controller_spec.rb +33 -34
- data/spec/controllers/withdraws_controller_spec.rb +42 -45
- data/spec/fixtures/libraries.yml +1 -1
- data/spec/fixtures/library_groups.yml +22 -17
- data/spec/fixtures/shelves.yml +1 -1
- data/spec/models/library_group_spec.rb +22 -17
- data/spec/models/library_spec.rb +1 -1
- data/spec/models/shelf_spec.rb +1 -1
- data/spec/views/library_groups/edit.html.erb_spec.rb +8 -0
- metadata +11 -25
@@ -3,37 +3,37 @@ require 'rails_helper'
|
|
3
3
|
describe UserExportFilesController do
|
4
4
|
fixtures :all
|
5
5
|
|
6
|
-
describe
|
7
|
-
describe
|
6
|
+
describe 'GET index' do
|
7
|
+
describe 'When logged in as Administrator' do
|
8
8
|
login_fixture_admin
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'assigns all user_export_files as @user_export_files' do
|
11
11
|
get :index
|
12
12
|
assigns(:user_export_files).should eq(UserExportFile.order('id DESC').page(1))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe 'When logged in as Librarian' do
|
17
17
|
login_fixture_librarian
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'assigns empty as @user_export_files' do
|
20
20
|
get :index
|
21
21
|
assigns(:user_export_files).should be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe 'When logged in as User' do
|
26
26
|
login_fixture_user
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'assigns empty as @user_export_files' do
|
29
29
|
get :index
|
30
30
|
assigns(:user_export_files).should be_nil
|
31
31
|
expect(response).to be_forbidden
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
36
|
-
it
|
35
|
+
describe 'When not logged in' do
|
36
|
+
it 'assigns empty as @user_export_files' do
|
37
37
|
get :index
|
38
38
|
assigns(:user_export_files).should be_nil
|
39
39
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -41,39 +41,39 @@ describe UserExportFilesController do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
45
|
-
describe
|
44
|
+
describe 'GET show' do
|
45
|
+
describe 'When logged in as Administrator' do
|
46
46
|
login_fixture_admin
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
49
49
|
get :show, id: user_export_files(:user_export_file_00003).id
|
50
50
|
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
|
51
51
|
expect(response).to be_success
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe
|
55
|
+
describe 'When logged in as Librarian' do
|
56
56
|
login_fixture_librarian
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
59
59
|
get :show, id: user_export_files(:user_export_file_00003).id
|
60
60
|
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
|
61
61
|
expect(response).to be_forbidden
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
describe
|
65
|
+
describe 'When logged in as User' do
|
66
66
|
login_fixture_user
|
67
67
|
|
68
|
-
it
|
68
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
69
69
|
get :show, id: user_export_files(:user_export_file_00003).id
|
70
70
|
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
|
71
71
|
expect(response).to be_forbidden
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
75
|
+
describe 'When not logged in' do
|
76
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
77
77
|
get :show, id: user_export_files(:user_export_file_00003).id
|
78
78
|
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
|
79
79
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -81,39 +81,39 @@ describe UserExportFilesController do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
describe
|
85
|
-
describe
|
84
|
+
describe 'GET new' do
|
85
|
+
describe 'When logged in as Administrator' do
|
86
86
|
login_fixture_admin
|
87
87
|
|
88
|
-
it
|
88
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
89
89
|
get :new
|
90
90
|
assigns(:user_export_file).should be_valid
|
91
91
|
expect(response).to be_success
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe
|
95
|
+
describe 'When logged in as Librarian' do
|
96
96
|
login_fixture_librarian
|
97
97
|
|
98
|
-
it
|
98
|
+
it 'should not assign the requested user_export_file as @user_export_file' do
|
99
99
|
get :new
|
100
100
|
assigns(:user_export_file).should be_nil
|
101
101
|
expect(response).to be_forbidden
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe
|
105
|
+
describe 'When logged in as User' do
|
106
106
|
login_fixture_user
|
107
107
|
|
108
|
-
it
|
108
|
+
it 'should not assign the requested user_export_file as @user_export_file' do
|
109
109
|
get :new
|
110
110
|
assigns(:user_export_file).should be_nil
|
111
111
|
expect(response).to be_forbidden
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe
|
116
|
-
it
|
115
|
+
describe 'When not logged in' do
|
116
|
+
it 'should not assign the requested user_export_file as @user_export_file' do
|
117
117
|
get :new
|
118
118
|
assigns(:user_export_file).should be_nil
|
119
119
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -121,80 +121,80 @@ describe UserExportFilesController do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe
|
125
|
-
describe
|
124
|
+
describe 'POST create' do
|
125
|
+
describe 'When logged in as Administrator' do
|
126
126
|
login_fixture_admin
|
127
127
|
|
128
|
-
it
|
129
|
-
post :create, user_export_file: {mode: 'export'}
|
128
|
+
it 'should create agent_export_file' do
|
129
|
+
post :create, user_export_file: { mode: 'export' }
|
130
130
|
assigns(:user_export_file).should be_valid
|
131
131
|
assigns(:user_export_file).user.username.should eq @user.username
|
132
132
|
expect(response).to redirect_to user_export_file_url(assigns(:user_export_file))
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
describe
|
136
|
+
describe 'When logged in as Librarian' do
|
137
137
|
login_fixture_librarian
|
138
138
|
|
139
|
-
it
|
140
|
-
post :create, user_export_file: {mode: 'export'}
|
139
|
+
it 'should create agent_export_file' do
|
140
|
+
post :create, user_export_file: { mode: 'export' }
|
141
141
|
assigns(:user_export_file).should be_nil
|
142
142
|
expect(response).to be_forbidden
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
describe
|
146
|
+
describe 'When logged in as User' do
|
147
147
|
login_fixture_user
|
148
148
|
|
149
|
-
it
|
150
|
-
post :create, user_export_file: {mode: 'export'}
|
149
|
+
it 'should be forbidden' do
|
150
|
+
post :create, user_export_file: { mode: 'export' }
|
151
151
|
assigns(:user_export_file).should be_nil
|
152
152
|
expect(response).to be_forbidden
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
describe
|
157
|
-
it
|
158
|
-
post :create, user_export_file: {mode: 'export'}
|
156
|
+
describe 'When not logged in' do
|
157
|
+
it 'should be redirected to new session url' do
|
158
|
+
post :create, user_export_file: { mode: 'export' }
|
159
159
|
assigns(:user_export_file).should be_nil
|
160
160
|
expect(response).to redirect_to new_user_session_url
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
describe
|
166
|
-
describe
|
165
|
+
describe 'GET edit' do
|
166
|
+
describe 'When logged in as Administrator' do
|
167
167
|
login_fixture_admin
|
168
168
|
|
169
|
-
it
|
169
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
170
170
|
user_export_file = user_export_files(:user_export_file_00001)
|
171
171
|
get :edit, id: user_export_file.id
|
172
172
|
assigns(:user_export_file).should eq(user_export_file)
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
-
describe
|
176
|
+
describe 'When logged in as Librarian' do
|
177
177
|
login_fixture_librarian
|
178
178
|
|
179
|
-
it
|
179
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
180
180
|
user_export_file = user_export_files(:user_export_file_00001)
|
181
181
|
get :edit, id: user_export_file.id
|
182
182
|
expect(response).to be_forbidden
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
describe
|
186
|
+
describe 'When logged in as User' do
|
187
187
|
login_fixture_user
|
188
188
|
|
189
|
-
it
|
189
|
+
it 'assigns the requested user_export_file as @user_export_file' do
|
190
190
|
user_export_file = user_export_files(:user_export_file_00001)
|
191
191
|
get :edit, id: user_export_file.id
|
192
192
|
expect(response).to be_forbidden
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
-
describe
|
197
|
-
it
|
196
|
+
describe 'When not logged in' do
|
197
|
+
it 'should not assign the requested user_export_file as @user_export_file' do
|
198
198
|
user_export_file = user_export_files(:user_export_file_00001)
|
199
199
|
get :edit, id: user_export_file.id
|
200
200
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -202,92 +202,92 @@ describe UserExportFilesController do
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
describe
|
206
|
-
describe
|
205
|
+
describe 'PUT update' do
|
206
|
+
describe 'When logged in as Administrator' do
|
207
207
|
login_fixture_admin
|
208
208
|
|
209
|
-
it
|
210
|
-
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: {mode: 'export'}
|
209
|
+
it 'should update user_export_file' do
|
210
|
+
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' }
|
211
211
|
expect(response).to redirect_to user_export_file_url(assigns(:user_export_file))
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
-
describe
|
215
|
+
describe 'When logged in as Librarian' do
|
216
216
|
login_fixture_librarian
|
217
217
|
|
218
|
-
it
|
219
|
-
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: {mode: 'export'}
|
218
|
+
it 'should update user_export_file' do
|
219
|
+
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' }
|
220
220
|
expect(response).to be_forbidden
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
224
|
-
describe
|
224
|
+
describe 'When logged in as User' do
|
225
225
|
login_fixture_user
|
226
226
|
|
227
|
-
it
|
228
|
-
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: {mode: 'export'}
|
227
|
+
it 'should not update user_export_file' do
|
228
|
+
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' }
|
229
229
|
expect(response).to be_forbidden
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
describe
|
234
|
-
it
|
235
|
-
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: {mode: 'export'}
|
233
|
+
describe 'When not logged in' do
|
234
|
+
it 'should not update user_export_file' do
|
235
|
+
put :update, id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' }
|
236
236
|
expect(response).to redirect_to new_user_session_url
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
|
-
describe
|
241
|
+
describe 'DELETE destroy' do
|
242
242
|
before(:each) do
|
243
243
|
@user_export_file = user_export_files(:user_export_file_00001)
|
244
244
|
end
|
245
245
|
|
246
|
-
describe
|
246
|
+
describe 'When logged in as Administrator' do
|
247
247
|
login_fixture_admin
|
248
248
|
|
249
|
-
it
|
249
|
+
it 'destroys the requested user_export_file' do
|
250
250
|
delete :destroy, id: @user_export_file.id
|
251
251
|
end
|
252
252
|
|
253
|
-
it
|
253
|
+
it 'redirects to the user_export_files list' do
|
254
254
|
delete :destroy, id: @user_export_file.id
|
255
255
|
expect(response).to redirect_to(user_export_files_url)
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
-
describe
|
259
|
+
describe 'When logged in as Librarian' do
|
260
260
|
login_fixture_librarian
|
261
261
|
|
262
|
-
it
|
262
|
+
it 'destroys the requested user_export_file' do
|
263
263
|
delete :destroy, id: @user_export_file.id
|
264
264
|
end
|
265
265
|
|
266
|
-
it
|
266
|
+
it 'should be forbidden' do
|
267
267
|
delete :destroy, id: @user_export_file.id
|
268
268
|
expect(response).to be_forbidden
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
272
|
-
describe
|
272
|
+
describe 'When logged in as User' do
|
273
273
|
login_fixture_user
|
274
274
|
|
275
|
-
it
|
275
|
+
it 'destroys the requested user_export_file' do
|
276
276
|
delete :destroy, id: @user_export_file.id
|
277
277
|
end
|
278
278
|
|
279
|
-
it
|
279
|
+
it 'should be forbidden' do
|
280
280
|
delete :destroy, id: @user_export_file.id
|
281
281
|
expect(response).to be_forbidden
|
282
282
|
end
|
283
283
|
end
|
284
284
|
|
285
|
-
describe
|
286
|
-
it
|
285
|
+
describe 'When not logged in' do
|
286
|
+
it 'destroys the requested user_export_file' do
|
287
287
|
delete :destroy, id: @user_export_file.id
|
288
288
|
end
|
289
289
|
|
290
|
-
it
|
290
|
+
it 'should be forbidden' do
|
291
291
|
delete :destroy, id: @user_export_file.id
|
292
292
|
expect(response).to redirect_to(new_user_session_url)
|
293
293
|
end
|
@@ -7,79 +7,79 @@ describe UserGroupsController do
|
|
7
7
|
FactoryGirl.attributes_for(:user_group)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'GET index' do
|
11
11
|
before(:each) do
|
12
12
|
FactoryGirl.create(:user_group)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
15
|
+
describe 'When logged in as Administrator' do
|
16
16
|
login_fixture_admin
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'assigns all user_groups as @user_groups' do
|
19
19
|
get :index
|
20
20
|
assigns(:user_groups).should eq(UserGroup.order(:position))
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe 'When logged in as Librarian' do
|
25
25
|
login_fixture_librarian
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'assigns all user_groups as @user_groups' do
|
28
28
|
get :index
|
29
29
|
assigns(:user_groups).should eq(UserGroup.order(:position))
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
33
|
+
describe 'When logged in as User' do
|
34
34
|
login_fixture_user
|
35
35
|
|
36
|
-
it
|
36
|
+
it 'assigns all user_groups as @user_groups' do
|
37
37
|
get :index
|
38
38
|
assigns(:user_groups).should eq(UserGroup.order(:position))
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
42
|
+
describe 'When not logged in' do
|
43
|
+
it 'assigns all user_groups as @user_groups' do
|
44
44
|
get :index
|
45
45
|
assigns(:user_groups).should eq(UserGroup.order(:position))
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
describe
|
50
|
+
describe 'GET show' do
|
51
|
+
describe 'When logged in as Administrator' do
|
52
52
|
login_fixture_admin
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'assigns the requested user_group as @user_group' do
|
55
55
|
user_group = FactoryGirl.create(:user_group)
|
56
56
|
get :show, id: user_group.id
|
57
57
|
assigns(:user_group).should eq(user_group)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
describe
|
61
|
+
describe 'When logged in as Librarian' do
|
62
62
|
login_fixture_librarian
|
63
63
|
|
64
|
-
it
|
64
|
+
it 'assigns the requested user_group as @user_group' do
|
65
65
|
user_group = FactoryGirl.create(:user_group)
|
66
66
|
get :show, id: user_group.id
|
67
67
|
assigns(:user_group).should eq(user_group)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
71
|
+
describe 'When logged in as User' do
|
72
72
|
login_fixture_user
|
73
73
|
|
74
|
-
it
|
74
|
+
it 'assigns the requested user_group as @user_group' do
|
75
75
|
user_group = FactoryGirl.create(:user_group)
|
76
76
|
get :show, id: user_group.id
|
77
77
|
assigns(:user_group).should eq(user_group)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
describe
|
82
|
-
it
|
81
|
+
describe 'When not logged in' do
|
82
|
+
it 'assigns the requested user_group as @user_group' do
|
83
83
|
user_group = FactoryGirl.create(:user_group)
|
84
84
|
get :show, id: user_group.id
|
85
85
|
assigns(:user_group).should eq(user_group)
|
@@ -87,39 +87,39 @@ describe UserGroupsController do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
describe
|
91
|
-
describe
|
90
|
+
describe 'GET new' do
|
91
|
+
describe 'When logged in as Administrator' do
|
92
92
|
login_fixture_admin
|
93
93
|
|
94
|
-
it
|
94
|
+
it 'assigns the requested user_group as @user_group' do
|
95
95
|
get :new
|
96
96
|
assigns(:user_group).should_not be_valid
|
97
97
|
expect(response).to be_success
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
describe
|
101
|
+
describe 'When logged in as Librarian' do
|
102
102
|
login_fixture_librarian
|
103
103
|
|
104
|
-
it
|
104
|
+
it 'should not assign the requested user_group as @user_group' do
|
105
105
|
get :new
|
106
106
|
assigns(:user_group).should be_nil
|
107
107
|
expect(response).to be_forbidden
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
describe
|
111
|
+
describe 'When logged in as User' do
|
112
112
|
login_fixture_user
|
113
113
|
|
114
|
-
it
|
114
|
+
it 'should not assign the requested user_group as @user_group' do
|
115
115
|
get :new
|
116
116
|
assigns(:user_group).should be_nil
|
117
117
|
expect(response).to be_forbidden
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
describe
|
122
|
-
it
|
121
|
+
describe 'When not logged in' do
|
122
|
+
it 'should not assign the requested user_group as @user_group' do
|
123
123
|
get :new
|
124
124
|
assigns(:user_group).should be_nil
|
125
125
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -127,39 +127,39 @@ describe UserGroupsController do
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
describe
|
131
|
-
describe
|
130
|
+
describe 'GET edit' do
|
131
|
+
describe 'When logged in as Administrator' do
|
132
132
|
login_fixture_admin
|
133
133
|
|
134
|
-
it
|
134
|
+
it 'assigns the requested user_group as @user_group' do
|
135
135
|
user_group = FactoryGirl.create(:user_group)
|
136
136
|
get :edit, id: user_group.id
|
137
137
|
assigns(:user_group).should eq(user_group)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
describe
|
141
|
+
describe 'When logged in as Librarian' do
|
142
142
|
login_fixture_librarian
|
143
143
|
|
144
|
-
it
|
144
|
+
it 'assigns the requested user_group as @user_group' do
|
145
145
|
user_group = FactoryGirl.create(:user_group)
|
146
146
|
get :edit, id: user_group.id
|
147
147
|
expect(response).to be_forbidden
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
describe
|
151
|
+
describe 'When logged in as User' do
|
152
152
|
login_fixture_user
|
153
153
|
|
154
|
-
it
|
154
|
+
it 'assigns the requested user_group as @user_group' do
|
155
155
|
user_group = FactoryGirl.create(:user_group)
|
156
156
|
get :edit, id: user_group.id
|
157
157
|
expect(response).to be_forbidden
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
describe
|
162
|
-
it
|
161
|
+
describe 'When not logged in' do
|
162
|
+
it 'should not assign the requested user_group as @user_group' do
|
163
163
|
user_group = FactoryGirl.create(:user_group)
|
164
164
|
get :edit, id: user_group.id
|
165
165
|
expect(response).to redirect_to(new_user_session_url)
|
@@ -167,116 +167,116 @@ describe UserGroupsController do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
-
describe
|
170
|
+
describe 'POST create' do
|
171
171
|
before(:each) do
|
172
172
|
@attrs = valid_attributes
|
173
|
-
@invalid_attrs = {name: ''}
|
173
|
+
@invalid_attrs = { name: '' }
|
174
174
|
end
|
175
175
|
|
176
|
-
describe
|
176
|
+
describe 'When logged in as Administrator' do
|
177
177
|
login_fixture_admin
|
178
178
|
|
179
|
-
describe
|
180
|
-
it
|
179
|
+
describe 'with valid params' do
|
180
|
+
it 'assigns a newly created user_group as @user_group' do
|
181
181
|
post :create, user_group: @attrs
|
182
182
|
assigns(:user_group).should be_valid
|
183
183
|
end
|
184
184
|
|
185
|
-
it
|
185
|
+
it 'redirects to the created patron' do
|
186
186
|
post :create, user_group: @attrs
|
187
187
|
expect(response).to redirect_to(assigns(:user_group))
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
describe
|
192
|
-
it
|
191
|
+
describe 'with invalid params' do
|
192
|
+
it 'assigns a newly created but unsaved user_group as @user_group' do
|
193
193
|
post :create, user_group: @invalid_attrs
|
194
194
|
assigns(:user_group).should_not be_valid
|
195
195
|
end
|
196
196
|
|
197
197
|
it "re-renders the 'new' template" do
|
198
198
|
post :create, user_group: @invalid_attrs
|
199
|
-
expect(response).to render_template(
|
199
|
+
expect(response).to render_template('new')
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
describe
|
204
|
+
describe 'When logged in as Librarian' do
|
205
205
|
login_fixture_librarian
|
206
206
|
|
207
|
-
describe
|
208
|
-
it
|
207
|
+
describe 'with valid params' do
|
208
|
+
it 'assigns a newly created user_group as @user_group' do
|
209
209
|
post :create, user_group: @attrs
|
210
210
|
assigns(:user_group).should be_nil
|
211
211
|
end
|
212
212
|
|
213
|
-
it
|
213
|
+
it 'should be forbidden' do
|
214
214
|
post :create, user_group: @attrs
|
215
215
|
expect(response).to be_forbidden
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
describe
|
220
|
-
it
|
219
|
+
describe 'with invalid params' do
|
220
|
+
it 'assigns a newly created but unsaved user_group as @user_group' do
|
221
221
|
post :create, user_group: @invalid_attrs
|
222
222
|
assigns(:user_group).should be_nil
|
223
223
|
end
|
224
224
|
|
225
|
-
it
|
225
|
+
it 'should be forbidden' do
|
226
226
|
post :create, user_group: @invalid_attrs
|
227
227
|
expect(response).to be_forbidden
|
228
228
|
end
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
-
describe
|
232
|
+
describe 'When logged in as User' do
|
233
233
|
login_fixture_user
|
234
234
|
|
235
|
-
describe
|
236
|
-
it
|
235
|
+
describe 'with valid params' do
|
236
|
+
it 'assigns a newly created user_group as @user_group' do
|
237
237
|
post :create, user_group: @attrs
|
238
238
|
assigns(:user_group).should be_nil
|
239
239
|
end
|
240
240
|
|
241
|
-
it
|
241
|
+
it 'should be forbidden' do
|
242
242
|
post :create, user_group: @attrs
|
243
243
|
expect(response).to be_forbidden
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
-
describe
|
248
|
-
it
|
247
|
+
describe 'with invalid params' do
|
248
|
+
it 'assigns a newly created but unsaved user_group as @user_group' do
|
249
249
|
post :create, user_group: @invalid_attrs
|
250
250
|
assigns(:user_group).should be_nil
|
251
251
|
end
|
252
252
|
|
253
|
-
it
|
253
|
+
it 'should be forbidden' do
|
254
254
|
post :create, user_group: @invalid_attrs
|
255
255
|
expect(response).to be_forbidden
|
256
256
|
end
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
260
|
-
describe
|
261
|
-
describe
|
262
|
-
it
|
260
|
+
describe 'When not logged in' do
|
261
|
+
describe 'with valid params' do
|
262
|
+
it 'assigns a newly created user_group as @user_group' do
|
263
263
|
post :create, user_group: @attrs
|
264
264
|
assigns(:user_group).should be_nil
|
265
265
|
end
|
266
266
|
|
267
|
-
it
|
267
|
+
it 'should be forbidden' do
|
268
268
|
post :create, user_group: @attrs
|
269
269
|
expect(response).to redirect_to(new_user_session_url)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
|
273
|
-
describe
|
274
|
-
it
|
273
|
+
describe 'with invalid params' do
|
274
|
+
it 'assigns a newly created but unsaved user_group as @user_group' do
|
275
275
|
post :create, user_group: @invalid_attrs
|
276
276
|
assigns(:user_group).should be_nil
|
277
277
|
end
|
278
278
|
|
279
|
-
it
|
279
|
+
it 'should be forbidden' do
|
280
280
|
post :create, user_group: @invalid_attrs
|
281
281
|
expect(response).to redirect_to(new_user_session_url)
|
282
282
|
end
|
@@ -284,100 +284,100 @@ describe UserGroupsController do
|
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
|
-
describe
|
287
|
+
describe 'PUT update' do
|
288
288
|
before(:each) do
|
289
289
|
@user_group = FactoryGirl.create(:user_group)
|
290
290
|
@attrs = valid_attributes
|
291
|
-
@invalid_attrs = {name: ''}
|
291
|
+
@invalid_attrs = { name: '' }
|
292
292
|
end
|
293
293
|
|
294
|
-
describe
|
294
|
+
describe 'When logged in as Administrator' do
|
295
295
|
login_fixture_admin
|
296
296
|
|
297
|
-
describe
|
298
|
-
it
|
297
|
+
describe 'with valid params' do
|
298
|
+
it 'updates the requested user_group' do
|
299
299
|
put :update, id: @user_group.id, user_group: @attrs
|
300
300
|
end
|
301
301
|
|
302
|
-
it
|
302
|
+
it 'assigns the requested user_group as @user_group' do
|
303
303
|
put :update, id: @user_group.id, user_group: @attrs
|
304
304
|
assigns(:user_group).should eq(@user_group)
|
305
305
|
end
|
306
306
|
|
307
|
-
it
|
308
|
-
put :update, id: @user_group.id, user_group: @attrs, :
|
307
|
+
it 'moves its position when specified' do
|
308
|
+
put :update, id: @user_group.id, user_group: @attrs, move: 'lower'
|
309
309
|
expect(response).to redirect_to(user_groups_url)
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
|
-
describe
|
314
|
-
it
|
313
|
+
describe 'with invalid params' do
|
314
|
+
it 'assigns the requested user_group as @user_group' do
|
315
315
|
put :update, id: @user_group.id, user_group: @invalid_attrs
|
316
|
-
expect(response).to render_template(
|
316
|
+
expect(response).to render_template('edit')
|
317
317
|
end
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
-
describe
|
321
|
+
describe 'When logged in as Librarian' do
|
322
322
|
login_fixture_librarian
|
323
323
|
|
324
|
-
describe
|
325
|
-
it
|
324
|
+
describe 'with valid params' do
|
325
|
+
it 'updates the requested user_group' do
|
326
326
|
put :update, id: @user_group.id, user_group: @attrs
|
327
327
|
end
|
328
328
|
|
329
|
-
it
|
329
|
+
it 'assigns the requested user_group as @user_group' do
|
330
330
|
put :update, id: @user_group.id, user_group: @attrs
|
331
331
|
assigns(:user_group).should eq(@user_group)
|
332
332
|
expect(response).to be_forbidden
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
-
describe
|
337
|
-
it
|
336
|
+
describe 'with invalid params' do
|
337
|
+
it 'assigns the requested user_group as @user_group' do
|
338
338
|
put :update, id: @user_group.id, user_group: @invalid_attrs
|
339
339
|
expect(response).to be_forbidden
|
340
340
|
end
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
describe
|
344
|
+
describe 'When logged in as User' do
|
345
345
|
login_fixture_user
|
346
346
|
|
347
|
-
describe
|
348
|
-
it
|
347
|
+
describe 'with valid params' do
|
348
|
+
it 'updates the requested user_group' do
|
349
349
|
put :update, id: @user_group.id, user_group: @attrs
|
350
350
|
end
|
351
351
|
|
352
|
-
it
|
352
|
+
it 'assigns the requested user_group as @user_group' do
|
353
353
|
put :update, id: @user_group.id, user_group: @attrs
|
354
354
|
assigns(:user_group).should eq(@user_group)
|
355
355
|
expect(response).to be_forbidden
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
-
describe
|
360
|
-
it
|
359
|
+
describe 'with invalid params' do
|
360
|
+
it 'assigns the requested user_group as @user_group' do
|
361
361
|
put :update, id: @user_group.id, user_group: @invalid_attrs
|
362
362
|
expect(response).to be_forbidden
|
363
363
|
end
|
364
364
|
end
|
365
365
|
end
|
366
366
|
|
367
|
-
describe
|
368
|
-
describe
|
369
|
-
it
|
367
|
+
describe 'When not logged in' do
|
368
|
+
describe 'with valid params' do
|
369
|
+
it 'updates the requested user_group' do
|
370
370
|
put :update, id: @user_group.id, user_group: @attrs
|
371
371
|
end
|
372
372
|
|
373
|
-
it
|
373
|
+
it 'should be forbidden' do
|
374
374
|
put :update, id: @user_group.id, user_group: @attrs
|
375
375
|
expect(response).to redirect_to(new_user_session_url)
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
379
|
-
describe
|
380
|
-
it
|
379
|
+
describe 'with invalid params' do
|
380
|
+
it 'assigns the requested user_group as @user_group' do
|
381
381
|
put :update, id: @user_group.id, user_group: @invalid_attrs
|
382
382
|
expect(response).to redirect_to(new_user_session_url)
|
383
383
|
end
|
@@ -385,56 +385,56 @@ describe UserGroupsController do
|
|
385
385
|
end
|
386
386
|
end
|
387
387
|
|
388
|
-
describe
|
388
|
+
describe 'DELETE destroy' do
|
389
389
|
before(:each) do
|
390
390
|
@user_group = FactoryGirl.create(:user_group)
|
391
391
|
end
|
392
392
|
|
393
|
-
describe
|
393
|
+
describe 'When logged in as Administrator' do
|
394
394
|
login_fixture_admin
|
395
395
|
|
396
|
-
it
|
396
|
+
it 'destroys the requested user_group' do
|
397
397
|
delete :destroy, id: @user_group.id
|
398
398
|
end
|
399
399
|
|
400
|
-
it
|
400
|
+
it 'redirects to the user_groups list' do
|
401
401
|
delete :destroy, id: @user_group.id
|
402
402
|
expect(response).to redirect_to(user_groups_url)
|
403
403
|
end
|
404
404
|
end
|
405
405
|
|
406
|
-
describe
|
406
|
+
describe 'When logged in as Librarian' do
|
407
407
|
login_fixture_librarian
|
408
408
|
|
409
|
-
it
|
409
|
+
it 'destroys the requested user_group' do
|
410
410
|
delete :destroy, id: @user_group.id
|
411
411
|
end
|
412
412
|
|
413
|
-
it
|
413
|
+
it 'should be forbidden' do
|
414
414
|
delete :destroy, id: @user_group.id
|
415
415
|
expect(response).to be_forbidden
|
416
416
|
end
|
417
417
|
end
|
418
418
|
|
419
|
-
describe
|
419
|
+
describe 'When logged in as User' do
|
420
420
|
login_fixture_user
|
421
421
|
|
422
|
-
it
|
422
|
+
it 'destroys the requested user_group' do
|
423
423
|
delete :destroy, id: @user_group.id
|
424
424
|
end
|
425
425
|
|
426
|
-
it
|
426
|
+
it 'should be forbidden' do
|
427
427
|
delete :destroy, id: @user_group.id
|
428
428
|
expect(response).to be_forbidden
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
432
|
-
describe
|
433
|
-
it
|
432
|
+
describe 'When not logged in' do
|
433
|
+
it 'destroys the requested user_group' do
|
434
434
|
delete :destroy, id: @user_group.id
|
435
435
|
end
|
436
436
|
|
437
|
-
it
|
437
|
+
it 'should be forbidden' do
|
438
438
|
delete :destroy, id: @user_group.id
|
439
439
|
expect(response).to redirect_to(new_user_session_url)
|
440
440
|
end
|