enju_resource_merge 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +36 -0
  4. data/app/controllers/patron_merge_lists_controller.rb +93 -0
  5. data/app/controllers/patron_merges_controller.rb +89 -0
  6. data/app/controllers/series_statement_merge_lists_controller.rb +93 -0
  7. data/app/controllers/series_statement_merges_controller.rb +94 -0
  8. data/app/models/patron_merge.rb +22 -0
  9. data/app/models/patron_merge_list.rb +31 -0
  10. data/app/models/series_statement_merge.rb +22 -0
  11. data/app/models/series_statement_merge_list.rb +26 -0
  12. data/app/views/patron_merge_lists/_form.html.erb +11 -0
  13. data/app/views/patron_merge_lists/edit.html.erb +13 -0
  14. data/app/views/patron_merge_lists/index.html.erb +33 -0
  15. data/app/views/patron_merge_lists/new.html.erb +12 -0
  16. data/app/views/patron_merge_lists/show.html.erb +31 -0
  17. data/app/views/patron_merges/edit.html.erb +31 -0
  18. data/app/views/patron_merges/index.html.erb +32 -0
  19. data/app/views/patron_merges/new.html.erb +39 -0
  20. data/app/views/patron_merges/show.html.erb +25 -0
  21. data/app/views/series_statement_merge_lists/_form.html.erb +11 -0
  22. data/app/views/series_statement_merge_lists/edit.html.erb +13 -0
  23. data/app/views/series_statement_merge_lists/index.html.erb +33 -0
  24. data/app/views/series_statement_merge_lists/new.html.erb +12 -0
  25. data/app/views/series_statement_merge_lists/show.html.erb +31 -0
  26. data/app/views/series_statement_merges/_form.html.erb +12 -0
  27. data/app/views/series_statement_merges/edit.html.erb +31 -0
  28. data/app/views/series_statement_merges/index.html.erb +32 -0
  29. data/app/views/series_statement_merges/new.html.erb +39 -0
  30. data/app/views/series_statement_merges/show.html.erb +27 -0
  31. data/config/routes.rb +21 -0
  32. data/db/migrate/133_create_patron_merges.rb +15 -0
  33. data/db/migrate/134_create_patron_merge_lists.rb +13 -0
  34. data/db/migrate/20110627034940_create_series_statement_merge_lists.rb +13 -0
  35. data/db/migrate/20110627035057_create_series_statement_merges.rb +16 -0
  36. data/lib/enju_resource_merge.rb +5 -0
  37. data/lib/enju_resource_merge/engine.rb +12 -0
  38. data/lib/enju_resource_merge/version.rb +3 -0
  39. data/lib/tasks/enju_resource_merge_tasks.rake +4 -0
  40. data/spec/controllers/patron_merge_lists_controller_spec.rb +456 -0
  41. data/spec/controllers/patron_merges_controller_spec.rb +437 -0
  42. data/spec/controllers/series_statement_merge_lists_controller_spec.rb +439 -0
  43. data/spec/controllers/series_statement_merges_controller_spec.rb +437 -0
  44. data/spec/dummy/Rakefile +7 -0
  45. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  46. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  47. data/spec/dummy/app/controllers/application_controller.rb +75 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +13 -0
  49. data/spec/dummy/app/models/ability.rb +22 -0
  50. data/spec/dummy/app/models/create.rb +4 -0
  51. data/spec/dummy/app/models/donate.rb +10 -0
  52. data/spec/dummy/app/models/item.rb +20 -0
  53. data/spec/dummy/app/models/manifestation.rb +416 -0
  54. data/spec/dummy/app/models/own.rb +22 -0
  55. data/spec/dummy/app/models/patron.rb +14 -0
  56. data/spec/dummy/app/models/produce.rb +4 -0
  57. data/spec/dummy/app/models/realize.rb +4 -0
  58. data/spec/dummy/app/models/role.rb +5 -0
  59. data/spec/dummy/app/models/series_has_manifestation.rb +35 -0
  60. data/spec/dummy/app/models/series_statement.rb +88 -0
  61. data/spec/dummy/app/models/user.rb +28 -0
  62. data/spec/dummy/app/models/user_has_role.rb +4 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  64. data/spec/dummy/app/views/page/403.html.erb +9 -0
  65. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  66. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  67. data/spec/dummy/app/views/page/404.html.erb +9 -0
  68. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  69. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  70. data/spec/dummy/config.ru +4 -0
  71. data/spec/dummy/config/application.rb +46 -0
  72. data/spec/dummy/config/boot.rb +10 -0
  73. data/spec/dummy/config/database.yml +25 -0
  74. data/spec/dummy/config/environment.rb +5 -0
  75. data/spec/dummy/config/environments/development.rb +30 -0
  76. data/spec/dummy/config/environments/production.rb +60 -0
  77. data/spec/dummy/config/environments/test.rb +39 -0
  78. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/spec/dummy/config/initializers/devise.rb +209 -0
  80. data/spec/dummy/config/initializers/inflections.rb +10 -0
  81. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  82. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  83. data/spec/dummy/config/initializers/session_store.rb +8 -0
  84. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  85. data/spec/dummy/config/locales/en.yml +5 -0
  86. data/spec/dummy/config/routes.rb +60 -0
  87. data/spec/dummy/db/development.sqlite3 +0 -0
  88. data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
  89. data/spec/dummy/db/migrate/005_create_manifestations.rb +68 -0
  90. data/spec/dummy/db/migrate/006_create_items.rb +36 -0
  91. data/spec/dummy/db/migrate/125_create_donates.rb +16 -0
  92. data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +17 -0
  93. data/spec/dummy/db/migrate/20100223121519_rename_sereis_statement_title_to_original_title.rb +13 -0
  94. data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
  95. data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
  96. data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
  97. data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +17 -0
  98. data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
  99. data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
  100. data/spec/dummy/db/migrate/20111201115527_create_creates.rb +10 -0
  101. data/spec/dummy/db/migrate/20111201115540_create_produces.rb +10 -0
  102. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  103. data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
  104. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
  105. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  106. data/spec/dummy/db/migrate/20120106093356_create_realizes.rb +10 -0
  107. data/spec/dummy/db/migrate/20120106093603_create_owns.rb +10 -0
  108. data/spec/dummy/db/schema.rb +300 -0
  109. data/spec/dummy/db/test.sqlite3 +0 -0
  110. data/spec/dummy/lib/url_validator.rb +10 -0
  111. data/spec/dummy/log/development.log +63 -0
  112. data/spec/dummy/log/test.log +67969 -0
  113. data/spec/dummy/public/404.html +26 -0
  114. data/spec/dummy/public/422.html +26 -0
  115. data/spec/dummy/public/500.html +26 -0
  116. data/spec/dummy/public/favicon.ico +0 -0
  117. data/spec/dummy/script/rails +6 -0
  118. data/spec/enju_resource_merge_test.rb +7 -0
  119. data/spec/factories/patron.rb +10 -0
  120. data/spec/factories/patron_merge.rb +6 -0
  121. data/spec/factories/patron_merge_list.rb +5 -0
  122. data/spec/factories/series_statement.rb +5 -0
  123. data/spec/factories/series_statement_merge.rb +6 -0
  124. data/spec/factories/series_statement_merge_list.rb +5 -0
  125. data/spec/factories/user.rb +31 -0
  126. data/spec/fixtures/manifestations.yml +2017 -0
  127. data/spec/fixtures/patron_merge_lists.yml +27 -0
  128. data/spec/fixtures/patron_merges.yml +31 -0
  129. data/spec/fixtures/patrons.yml +338 -0
  130. data/spec/fixtures/roles.yml +21 -0
  131. data/spec/fixtures/series_has_manifestations.yml +35 -0
  132. data/spec/fixtures/series_statement_merge_lists.yml +27 -0
  133. data/spec/fixtures/series_statement_merges.yml +31 -0
  134. data/spec/fixtures/series_statements.yml +35 -0
  135. data/spec/fixtures/user_has_roles.yml +41 -0
  136. data/spec/fixtures/users.yml +69 -0
  137. data/spec/models/patron_merge_list_spec.rb +18 -0
  138. data/spec/models/patron_merge_spec.rb +19 -0
  139. data/spec/models/series_statement_merge_list_spec.rb +21 -0
  140. data/spec/models/series_statement_merge_spec.rb +17 -0
  141. data/spec/requests/series_statement_merge_lists_spec.rb +11 -0
  142. data/spec/requests/series_statement_merges_spec.rb +11 -0
  143. data/spec/spec_helper.rb +33 -0
  144. data/spec/support/controller_macros.rb +48 -0
  145. data/spec/support/devise.rb +4 -0
  146. data/spec/views/series_statement_merge_lists/edit.html.erb_spec.rb +18 -0
  147. data/spec/views/series_statement_merge_lists/index.html.erb_spec.rb +22 -0
  148. data/spec/views/series_statement_merge_lists/new.html.erb_spec.rb +18 -0
  149. data/spec/views/series_statement_merge_lists/show.html.erb_spec.rb +15 -0
  150. data/spec/views/series_statement_merges/edit.html.erb_spec.rb +23 -0
  151. data/spec/views/series_statement_merges/index.html.erb_spec.rb +25 -0
  152. data/spec/views/series_statement_merges/new.html.erb_spec.rb +23 -0
  153. data/spec/views/series_statement_merges/show.html.erb_spec.rb +17 -0
  154. metadata +433 -0
@@ -0,0 +1,437 @@
1
+ require 'spec_helper'
2
+
3
+ describe PatronMergesController do
4
+ fixtures :all
5
+
6
+ describe "GET index" do
7
+ before(:each) do
8
+ FactoryGirl.create(:patron_merge)
9
+ end
10
+
11
+ describe "When logged in as Administrator" do
12
+ login_admin
13
+
14
+ it "assigns all patron_merges as @patron_merges" do
15
+ get :index
16
+ assigns(:patron_merges).should eq(PatronMerge.all)
17
+ end
18
+ end
19
+
20
+ describe "When logged in as Librarian" do
21
+ login_librarian
22
+
23
+ it "assigns all patron_merges as @patron_merges" do
24
+ get :index
25
+ assigns(:patron_merges).should eq(PatronMerge.all)
26
+ end
27
+ end
28
+
29
+ describe "When logged in as User" do
30
+ login_user
31
+
32
+ it "should be forbidden" do
33
+ get :index
34
+ assigns(:patron_merges).should be_empty
35
+ response.should be_forbidden
36
+ end
37
+ end
38
+
39
+ describe "When not logged in" do
40
+ it "should be forbidden" do
41
+ get :index
42
+ assigns(:patron_merges).should be_empty
43
+ response.should redirect_to(new_user_session_url)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "GET show" do
49
+ describe "When logged in as Administrator" do
50
+ login_admin
51
+
52
+ it "assigns the requested patron_merge as @patron_merge" do
53
+ patron_merge = FactoryGirl.create(:patron_merge)
54
+ get :show, :id => patron_merge.id
55
+ assigns(:patron_merge).should eq(patron_merge)
56
+ end
57
+ end
58
+
59
+ describe "When logged in as Librarian" do
60
+ login_librarian
61
+
62
+ it "assigns the requested patron_merge as @patron_merge" do
63
+ patron_merge = FactoryGirl.create(:patron_merge)
64
+ get :show, :id => patron_merge.id
65
+ assigns(:patron_merge).should eq(patron_merge)
66
+ end
67
+ end
68
+
69
+ describe "When logged in as User" do
70
+ login_user
71
+
72
+ it "assigns the requested patron_merge as @patron_merge" do
73
+ patron_merge = FactoryGirl.create(:patron_merge)
74
+ get :show, :id => patron_merge.id
75
+ assigns(:patron_merge).should eq(patron_merge)
76
+ end
77
+ end
78
+
79
+ describe "When not logged in" do
80
+ it "assigns the requested patron_merge as @patron_merge" do
81
+ patron_merge = FactoryGirl.create(:patron_merge)
82
+ get :show, :id => patron_merge.id
83
+ assigns(:patron_merge).should eq(patron_merge)
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "GET new" do
89
+ describe "When logged in as Administrator" do
90
+ login_admin
91
+
92
+ it "assigns the requested patron_merge as @patron_merge" do
93
+ get :new
94
+ assigns(:patron_merge).should_not be_valid
95
+ response.should be_success
96
+ end
97
+ end
98
+
99
+ describe "When logged in as Librarian" do
100
+ login_librarian
101
+
102
+ it "assigns the requested patron_merge as @patron_merge" do
103
+ get :new
104
+ assigns(:patron_merge).should_not be_valid
105
+ response.should be_success
106
+ end
107
+ end
108
+
109
+ describe "When logged in as User" do
110
+ login_user
111
+
112
+ it "should not assign the requested patron_merge as @patron_merge" do
113
+ get :new
114
+ assigns(:patron_merge).should_not be_valid
115
+ response.should be_forbidden
116
+ end
117
+ end
118
+
119
+ describe "When not logged in" do
120
+ it "should not assign the requested patron_merge as @patron_merge" do
121
+ get :new
122
+ assigns(:patron_merge).should_not be_valid
123
+ response.should redirect_to(new_user_session_url)
124
+ end
125
+ end
126
+ end
127
+
128
+ describe "GET edit" do
129
+ describe "When logged in as Administrator" do
130
+ login_admin
131
+
132
+ it "assigns the requested patron_merge as @patron_merge" do
133
+ patron_merge = FactoryGirl.create(:patron_merge)
134
+ get :edit, :id => patron_merge.id
135
+ assigns(:patron_merge).should eq(patron_merge)
136
+ end
137
+ end
138
+
139
+ describe "When logged in as Librarian" do
140
+ login_librarian
141
+
142
+ it "assigns the requested patron_merge as @patron_merge" do
143
+ patron_merge = FactoryGirl.create(:patron_merge)
144
+ get :edit, :id => patron_merge.id
145
+ assigns(:patron_merge).should eq(patron_merge)
146
+ end
147
+ end
148
+
149
+ describe "When logged in as User" do
150
+ login_user
151
+
152
+ it "assigns the requested patron_merge as @patron_merge" do
153
+ patron_merge = FactoryGirl.create(:patron_merge)
154
+ get :edit, :id => patron_merge.id
155
+ response.should be_forbidden
156
+ end
157
+ end
158
+
159
+ describe "When not logged in" do
160
+ it "should not assign the requested patron_merge as @patron_merge" do
161
+ patron_merge = FactoryGirl.create(:patron_merge)
162
+ get :edit, :id => patron_merge.id
163
+ response.should redirect_to(new_user_session_url)
164
+ end
165
+ end
166
+ end
167
+
168
+ describe "POST create" do
169
+ before(:each) do
170
+ @attrs = FactoryGirl.attributes_for(:patron_merge)
171
+ @invalid_attrs = {:patron_merge_list_id => ''}
172
+ end
173
+
174
+ describe "When logged in as Administrator" do
175
+ login_admin
176
+
177
+ describe "with valid params" do
178
+ it "assigns a newly created patron_merge as @patron_merge" do
179
+ post :create, :patron_merge => @attrs
180
+ assigns(:patron_merge).should be_valid
181
+ end
182
+
183
+ it "redirects to the created patron" do
184
+ post :create, :patron_merge => @attrs
185
+ response.should redirect_to(assigns(:patron_merge))
186
+ end
187
+ end
188
+
189
+ describe "with invalid params" do
190
+ it "assigns a newly created but unsaved patron_merge as @patron_merge" do
191
+ post :create, :patron_merge => @invalid_attrs
192
+ assigns(:patron_merge).should_not be_valid
193
+ end
194
+
195
+ it "re-renders the 'new' template" do
196
+ post :create, :patron_merge => @invalid_attrs
197
+ response.should render_template("new")
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "When logged in as Librarian" do
203
+ login_librarian
204
+
205
+ describe "with valid params" do
206
+ it "assigns a newly created patron_merge as @patron_merge" do
207
+ post :create, :patron_merge => @attrs
208
+ assigns(:patron_merge).should be_valid
209
+ end
210
+
211
+ it "redirects to the created patron" do
212
+ post :create, :patron_merge => @attrs
213
+ response.should redirect_to(assigns(:patron_merge))
214
+ end
215
+ end
216
+
217
+ describe "with invalid params" do
218
+ it "assigns a newly created but unsaved patron_merge as @patron_merge" do
219
+ post :create, :patron_merge => @invalid_attrs
220
+ assigns(:patron_merge).should_not be_valid
221
+ end
222
+
223
+ it "re-renders the 'new' template" do
224
+ post :create, :patron_merge => @invalid_attrs
225
+ response.should render_template("new")
226
+ end
227
+ end
228
+ end
229
+
230
+ describe "When logged in as User" do
231
+ login_user
232
+
233
+ describe "with valid params" do
234
+ it "assigns a newly created patron_merge as @patron_merge" do
235
+ post :create, :patron_merge => @attrs
236
+ assigns(:patron_merge).should be_valid
237
+ end
238
+
239
+ it "should be forbidden" do
240
+ post :create, :patron_merge => @attrs
241
+ response.should be_forbidden
242
+ end
243
+ end
244
+
245
+ describe "with invalid params" do
246
+ it "assigns a newly created but unsaved patron_merge as @patron_merge" do
247
+ post :create, :patron_merge => @invalid_attrs
248
+ assigns(:patron_merge).should_not be_valid
249
+ end
250
+
251
+ it "should be forbidden" do
252
+ post :create, :patron_merge => @invalid_attrs
253
+ response.should be_forbidden
254
+ end
255
+ end
256
+ end
257
+
258
+ describe "When not logged in" do
259
+ describe "with valid params" do
260
+ it "assigns a newly created patron_merge as @patron_merge" do
261
+ post :create, :patron_merge => @attrs
262
+ assigns(:patron_merge).should be_valid
263
+ end
264
+
265
+ it "should be forbidden" do
266
+ post :create, :patron_merge => @attrs
267
+ response.should redirect_to(new_user_session_url)
268
+ end
269
+ end
270
+
271
+ describe "with invalid params" do
272
+ it "assigns a newly created but unsaved patron_merge as @patron_merge" do
273
+ post :create, :patron_merge => @invalid_attrs
274
+ assigns(:patron_merge).should_not be_valid
275
+ end
276
+
277
+ it "should be forbidden" do
278
+ post :create, :patron_merge => @invalid_attrs
279
+ response.should redirect_to(new_user_session_url)
280
+ end
281
+ end
282
+ end
283
+ end
284
+
285
+ describe "PUT update" do
286
+ before(:each) do
287
+ @patron_merge = FactoryGirl.create(:patron_merge)
288
+ @attrs = FactoryGirl.attributes_for(:patron_merge)
289
+ @invalid_attrs = {:patron_merge_list_id => ''}
290
+ end
291
+
292
+ describe "When logged in as Administrator" do
293
+ login_admin
294
+
295
+ describe "with valid params" do
296
+ it "updates the requested patron_merge" do
297
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
298
+ end
299
+
300
+ it "assigns the requested patron_merge as @patron_merge" do
301
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
302
+ assigns(:patron_merge).should eq(@patron_merge)
303
+ response.should redirect_to(@patron_merge)
304
+ end
305
+ end
306
+
307
+ describe "with invalid params" do
308
+ it "assigns the requested patron_merge as @patron_merge" do
309
+ put :update, :id => @patron_merge.id, :patron_merge => @invalid_attrs
310
+ response.should render_template("edit")
311
+ end
312
+ end
313
+ end
314
+
315
+ describe "When logged in as Librarian" do
316
+ login_librarian
317
+
318
+ describe "with valid params" do
319
+ it "updates the requested patron_merge" do
320
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
321
+ end
322
+
323
+ it "assigns the requested patron_merge as @patron_merge" do
324
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
325
+ assigns(:patron_merge).should eq(@patron_merge)
326
+ response.should redirect_to(@patron_merge)
327
+ end
328
+ end
329
+
330
+ describe "with invalid params" do
331
+ it "assigns the requested patron_merge as @patron_merge" do
332
+ put :update, :id => @patron_merge.id, :patron_merge => @invalid_attrs
333
+ response.should render_template("edit")
334
+ end
335
+ end
336
+ end
337
+
338
+ describe "When logged in as User" do
339
+ login_user
340
+
341
+ describe "with valid params" do
342
+ it "updates the requested patron_merge" do
343
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
344
+ end
345
+
346
+ it "assigns the requested patron_merge as @patron_merge" do
347
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
348
+ assigns(:patron_merge).should eq(@patron_merge)
349
+ response.should be_forbidden
350
+ end
351
+ end
352
+
353
+ describe "with invalid params" do
354
+ it "assigns the requested patron_merge as @patron_merge" do
355
+ put :update, :id => @patron_merge.id, :patron_merge => @invalid_attrs
356
+ response.should be_forbidden
357
+ end
358
+ end
359
+ end
360
+
361
+ describe "When not logged in" do
362
+ describe "with valid params" do
363
+ it "updates the requested patron_merge" do
364
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
365
+ end
366
+
367
+ it "should be forbidden" do
368
+ put :update, :id => @patron_merge.id, :patron_merge => @attrs
369
+ response.should redirect_to(new_user_session_url)
370
+ end
371
+ end
372
+
373
+ describe "with invalid params" do
374
+ it "assigns the requested patron_merge as @patron_merge" do
375
+ put :update, :id => @patron_merge.id, :patron_merge => @invalid_attrs
376
+ response.should redirect_to(new_user_session_url)
377
+ end
378
+ end
379
+ end
380
+ end
381
+
382
+ describe "DELETE destroy" do
383
+ before(:each) do
384
+ @patron_merge = FactoryGirl.create(:patron_merge)
385
+ end
386
+
387
+ describe "When logged in as Administrator" do
388
+ login_admin
389
+
390
+ it "destroys the requested patron_merge" do
391
+ delete :destroy, :id => @patron_merge.id
392
+ end
393
+
394
+ it "redirects to the patron_merges list" do
395
+ delete :destroy, :id => @patron_merge.id
396
+ response.should redirect_to(patron_merges_url)
397
+ end
398
+ end
399
+
400
+ describe "When logged in as Librarian" do
401
+ login_librarian
402
+
403
+ it "destroys the requested patron_merge" do
404
+ delete :destroy, :id => @patron_merge.id
405
+ end
406
+
407
+ it "redirects to the patron_merges list" do
408
+ delete :destroy, :id => @patron_merge.id
409
+ response.should redirect_to(patron_merges_url)
410
+ end
411
+ end
412
+
413
+ describe "When logged in as User" do
414
+ login_user
415
+
416
+ it "destroys the requested patron_merge" do
417
+ delete :destroy, :id => @patron_merge.id
418
+ end
419
+
420
+ it "should be forbidden" do
421
+ delete :destroy, :id => @patron_merge.id
422
+ response.should be_forbidden
423
+ end
424
+ end
425
+
426
+ describe "When not logged in" do
427
+ it "destroys the requested patron_merge" do
428
+ delete :destroy, :id => @patron_merge.id
429
+ end
430
+
431
+ it "should be forbidden" do
432
+ delete :destroy, :id => @patron_merge.id
433
+ response.should redirect_to(new_user_session_url)
434
+ end
435
+ end
436
+ end
437
+ end
@@ -0,0 +1,439 @@
1
+ require 'spec_helper'
2
+ require 'sunspot/rails/spec_helper'
3
+
4
+ describe SeriesStatementMergeListsController do
5
+ disconnect_sunspot
6
+
7
+ describe "GET index" do
8
+ describe "When logged in as Administrator" do
9
+ login_admin
10
+
11
+ it "assigns all series_statement_merge_lists as @series_statement_merge_lists" do
12
+ get :index
13
+ assigns(:series_statement_merge_lists).should eq(SeriesStatementMergeList.page(1))
14
+ end
15
+ end
16
+
17
+ describe "When logged in as Librarian" do
18
+ login_librarian
19
+
20
+ it "assigns all series_statement_merge_lists as @series_statement_merge_lists" do
21
+ get :index
22
+ assigns(:series_statement_merge_lists).should eq(SeriesStatementMergeList.page(1))
23
+ end
24
+ end
25
+
26
+ describe "When logged in as User" do
27
+ login_user
28
+
29
+ it "assigns empty as @series_statement_merge_lists" do
30
+ get :index
31
+ assigns(:series_statement_merge_lists).should be_empty
32
+ end
33
+ end
34
+
35
+ describe "When not logged in" do
36
+ it "assigns empty as @series_statement_merge_lists" do
37
+ get :index
38
+ assigns(:series_statement_merge_lists).should be_empty
39
+ end
40
+ end
41
+ end
42
+
43
+ describe "GET show" do
44
+ describe "When logged in as Administrator" do
45
+ login_admin
46
+
47
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
48
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
49
+ get :show, :id => series_statement_merge_list.id
50
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
51
+ end
52
+ end
53
+
54
+ describe "When logged in as Librarian" do
55
+ login_librarian
56
+
57
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
58
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
59
+ get :show, :id => series_statement_merge_list.id
60
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
61
+ end
62
+ end
63
+
64
+ describe "When logged in as User" do
65
+ login_user
66
+
67
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
68
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
69
+ get :show, :id => series_statement_merge_list.id
70
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
71
+ end
72
+ end
73
+
74
+ describe "When not logged in" do
75
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
76
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
77
+ get :show, :id => series_statement_merge_list.id
78
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
79
+ end
80
+ end
81
+ end
82
+
83
+ describe "GET new" do
84
+ describe "When logged in as Administrator" do
85
+ login_admin
86
+
87
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
88
+ get :new
89
+ assigns(:series_statement_merge_list).should_not be_valid
90
+ end
91
+ end
92
+
93
+ describe "When logged in as Librarian" do
94
+ login_librarian
95
+
96
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
97
+ get :new
98
+ assigns(:series_statement_merge_list).should_not be_valid
99
+ end
100
+ end
101
+
102
+ describe "When logged in as User" do
103
+ login_user
104
+
105
+ it "should not assign the requested series_statement_merge_list as @series_statement_merge_list" do
106
+ get :new
107
+ assigns(:series_statement_merge_list).should_not be_valid
108
+ response.should be_forbidden
109
+ end
110
+ end
111
+
112
+ describe "When not logged in" do
113
+ it "should not assign the requested series_statement_merge_list as @series_statement_merge_list" do
114
+ get :new
115
+ assigns(:series_statement_merge_list).should_not be_valid
116
+ response.should redirect_to(new_user_session_url)
117
+ end
118
+ end
119
+ end
120
+
121
+ describe "GET edit" do
122
+ describe "When logged in as Administrator" do
123
+ login_admin
124
+
125
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
126
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
127
+ get :edit, :id => series_statement_merge_list.id
128
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
129
+ end
130
+ end
131
+
132
+ describe "When logged in as Librarian" do
133
+ login_librarian
134
+
135
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
136
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
137
+ get :edit, :id => series_statement_merge_list.id
138
+ assigns(:series_statement_merge_list).should eq(series_statement_merge_list)
139
+ end
140
+ end
141
+
142
+ describe "When logged in as User" do
143
+ login_user
144
+
145
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
146
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
147
+ get :edit, :id => series_statement_merge_list.id
148
+ response.should be_forbidden
149
+ end
150
+ end
151
+
152
+ describe "When not logged in" do
153
+ it "should not assign the requested series_statement_merge_list as @series_statement_merge_list" do
154
+ series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
155
+ get :edit, :id => series_statement_merge_list.id
156
+ response.should redirect_to(new_user_session_url)
157
+ end
158
+ end
159
+ end
160
+
161
+ describe "POST create" do
162
+ before(:each) do
163
+ @attrs = FactoryGirl.attributes_for(:series_statement_merge_list)
164
+ @invalid_attrs = {:title => ''}
165
+ end
166
+
167
+ describe "When logged in as Administrator" do
168
+ login_admin
169
+
170
+ describe "with valid params" do
171
+ it "assigns a newly created series_statement_merge_list as @series_statement_merge_list" do
172
+ post :create, :series_statement_merge_list => @attrs
173
+ assigns(:series_statement_merge_list).should be_valid
174
+ end
175
+
176
+ it "redirects to the created series_statement_merge_list" do
177
+ post :create, :series_statement_merge_list => @attrs
178
+ response.should redirect_to(series_statement_merge_list_url(assigns(:series_statement_merge_list)))
179
+ end
180
+ end
181
+
182
+ describe "with invalid params" do
183
+ it "assigns a newly created but unsaved series_statement_merge_list as @series_statement_merge_list" do
184
+ post :create, :series_statement_merge_list => @invalid_attrs
185
+ assigns(:series_statement_merge_list).should_not be_valid
186
+ end
187
+
188
+ it "re-renders the 'new' template" do
189
+ post :create, :series_statement_merge_list => @invalid_attrs
190
+ response.should render_template("new")
191
+ end
192
+ end
193
+ end
194
+
195
+ describe "When logged in as Librarian" do
196
+ login_librarian
197
+
198
+ describe "with valid params" do
199
+ it "assigns a newly created series_statement_merge_list as @series_statement_merge_list" do
200
+ post :create, :series_statement_merge_list => @attrs
201
+ assigns(:series_statement_merge_list).should be_valid
202
+ end
203
+
204
+ it "redirects to the created series_statement_merge_list" do
205
+ post :create, :series_statement_merge_list => @attrs
206
+ response.should redirect_to(series_statement_merge_list_url(assigns(:series_statement_merge_list)))
207
+ end
208
+ end
209
+
210
+ describe "with invalid params" do
211
+ it "assigns a newly created but unsaved series_statement_merge_list as @series_statement_merge_list" do
212
+ post :create, :series_statement_merge_list => @invalid_attrs
213
+ assigns(:series_statement_merge_list).should_not be_valid
214
+ end
215
+
216
+ it "re-renders the 'new' template" do
217
+ post :create, :series_statement_merge_list => @invalid_attrs
218
+ response.should render_template("new")
219
+ end
220
+ end
221
+ end
222
+
223
+ describe "When logged in as User" do
224
+ login_user
225
+
226
+ describe "with valid params" do
227
+ it "assigns a newly created series_statement_merge_list as @series_statement_merge_list" do
228
+ post :create, :series_statement_merge_list => @attrs
229
+ assigns(:series_statement_merge_list).should be_valid
230
+ end
231
+
232
+ it "should be forbidden" do
233
+ post :create, :series_statement_merge_list => @attrs
234
+ response.should be_forbidden
235
+ end
236
+ end
237
+
238
+ describe "with invalid params" do
239
+ it "assigns a newly created but unsaved series_statement_merge_list as @series_statement_merge_list" do
240
+ post :create, :series_statement_merge_list => @invalid_attrs
241
+ assigns(:series_statement_merge_list).should_not be_valid
242
+ end
243
+
244
+ it "should be forbidden" do
245
+ post :create, :series_statement_merge_list => @invalid_attrs
246
+ response.should be_forbidden
247
+ end
248
+ end
249
+ end
250
+
251
+ describe "When not logged in" do
252
+ describe "with valid params" do
253
+ it "assigns a newly created series_statement_merge_list as @series_statement_merge_list" do
254
+ post :create, :series_statement_merge_list => @attrs
255
+ assigns(:series_statement_merge_list).should be_valid
256
+ end
257
+
258
+ it "should be forbidden" do
259
+ post :create, :series_statement_merge_list => @attrs
260
+ response.should redirect_to(new_user_session_url)
261
+ end
262
+ end
263
+
264
+ describe "with invalid params" do
265
+ it "assigns a newly created but unsaved series_statement_merge_list as @series_statement_merge_list" do
266
+ post :create, :series_statement_merge_list => @invalid_attrs
267
+ assigns(:series_statement_merge_list).should_not be_valid
268
+ end
269
+
270
+ it "should be forbidden" do
271
+ post :create, :series_statement_merge_list => @invalid_attrs
272
+ response.should redirect_to(new_user_session_url)
273
+ end
274
+ end
275
+ end
276
+ end
277
+
278
+ describe "PUT update" do
279
+ before(:each) do
280
+ @series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
281
+ @attrs = FactoryGirl.attributes_for(:series_statement_merge_list)
282
+ @invalid_attrs = {:title => ''}
283
+ end
284
+
285
+ describe "When logged in as Administrator" do
286
+ login_admin
287
+
288
+ describe "with valid params" do
289
+ it "updates the requested series_statement_merge_list" do
290
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
291
+ end
292
+
293
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
294
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
295
+ assigns(:series_statement_merge_list).should eq(@series_statement_merge_list)
296
+ response.should redirect_to(@series_statement_merge_list)
297
+ end
298
+ end
299
+
300
+ describe "with invalid params" do
301
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
302
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
303
+ end
304
+
305
+ it "re-renders the 'edit' template" do
306
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
307
+ response.should render_template("edit")
308
+ end
309
+ end
310
+ end
311
+
312
+ describe "When logged in as Librarian" do
313
+ login_librarian
314
+
315
+ describe "with valid params" do
316
+ it "updates the requested series_statement_merge_list" do
317
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
318
+ end
319
+
320
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
321
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
322
+ assigns(:series_statement_merge_list).should eq(@series_statement_merge_list)
323
+ response.should redirect_to(@series_statement_merge_list)
324
+ end
325
+ end
326
+
327
+ describe "with invalid params" do
328
+ it "assigns the series_statement_merge_list as @series_statement_merge_list" do
329
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
330
+ assigns(:series_statement_merge_list).should_not be_valid
331
+ end
332
+
333
+ it "re-renders the 'edit' template" do
334
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
335
+ response.should render_template("edit")
336
+ end
337
+ end
338
+ end
339
+
340
+ describe "When logged in as User" do
341
+ login_user
342
+
343
+ describe "with valid params" do
344
+ it "updates the requested series_statement_merge_list" do
345
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
346
+ end
347
+
348
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
349
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
350
+ assigns(:series_statement_merge_list).should eq(@series_statement_merge_list)
351
+ response.should be_forbidden
352
+ end
353
+ end
354
+
355
+ describe "with invalid params" do
356
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
357
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
358
+ response.should be_forbidden
359
+ end
360
+ end
361
+ end
362
+
363
+ describe "When not logged in" do
364
+ describe "with valid params" do
365
+ it "updates the requested series_statement_merge_list" do
366
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
367
+ end
368
+
369
+ it "should be forbidden" do
370
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @attrs
371
+ response.should redirect_to(new_user_session_url)
372
+ end
373
+ end
374
+
375
+ describe "with invalid params" do
376
+ it "assigns the requested series_statement_merge_list as @series_statement_merge_list" do
377
+ put :update, :id => @series_statement_merge_list.id, :series_statement_merge_list => @invalid_attrs
378
+ response.should redirect_to(new_user_session_url)
379
+ end
380
+ end
381
+ end
382
+ end
383
+
384
+ describe "DELETE destroy" do
385
+ before(:each) do
386
+ @series_statement_merge_list = FactoryGirl.create(:series_statement_merge_list)
387
+ end
388
+
389
+ describe "When logged in as Administrator" do
390
+ login_admin
391
+
392
+ it "destroys the requested series_statement_merge_list" do
393
+ delete :destroy, :id => @series_statement_merge_list.id
394
+ end
395
+
396
+ it "redirects to the series_statement_merge_lists list" do
397
+ delete :destroy, :id => @series_statement_merge_list.id
398
+ response.should redirect_to(series_statement_merge_lists_url)
399
+ end
400
+ end
401
+
402
+ describe "When logged in as Librarian" do
403
+ login_librarian
404
+
405
+ it "destroys the requested series_statement_merge_list" do
406
+ delete :destroy, :id => @series_statement_merge_list.id
407
+ end
408
+
409
+ it "redirects to the series_statement_merge_lists list" do
410
+ delete :destroy, :id => @series_statement_merge_list.id
411
+ response.should redirect_to(series_statement_merge_lists_url)
412
+ end
413
+ end
414
+
415
+ describe "When logged in as User" do
416
+ login_user
417
+
418
+ it "destroys the requested series_statement_merge_list" do
419
+ delete :destroy, :id => @series_statement_merge_list.id
420
+ end
421
+
422
+ it "should be forbidden" do
423
+ delete :destroy, :id => @series_statement_merge_list.id
424
+ response.should be_forbidden
425
+ end
426
+ end
427
+
428
+ describe "When not logged in" do
429
+ it "destroys the requested series_statement_merge_list" do
430
+ delete :destroy, :id => @series_statement_merge_list.id
431
+ end
432
+
433
+ it "should be forbidden" do
434
+ delete :destroy, :id => @series_statement_merge_list.id
435
+ response.should redirect_to(new_user_session_url)
436
+ end
437
+ end
438
+ end
439
+ end