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