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