enju_biblio 0.1.0.pre49 → 0.1.0.pre50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/agent_types_controller.rb +0 -1
  3. data/app/controllers/countries_controller.rb +0 -1
  4. data/app/controllers/create_types_controller.rb +0 -1
  5. data/app/controllers/extents_controller.rb +0 -1
  6. data/app/controllers/form_of_works_controller.rb +0 -1
  7. data/app/controllers/frequencies_controller.rb +0 -1
  8. data/app/controllers/languages_controller.rb +0 -1
  9. data/app/controllers/licenses_controller.rb +0 -1
  10. data/app/controllers/manifestation_relationship_types_controller.rb +0 -1
  11. data/app/controllers/manifestation_relationships_controller.rb +0 -1
  12. data/app/controllers/medium_of_performances_controller.rb +0 -1
  13. data/app/controllers/produce_types_controller.rb +0 -1
  14. data/app/controllers/realize_types_controller.rb +0 -1
  15. data/app/models/enju_biblio/ability.rb +3 -9
  16. data/app/views/manifestations/_form.html.erb +1 -1
  17. data/app/views/manifestations/_series_form.html.erb +127 -0
  18. data/app/views/manifestations/_show_detail_librarian.html.erb +2 -0
  19. data/app/views/manifestations/_show_detail_user.html.erb +2 -0
  20. data/app/views/manifestations/_show_series_detail.html.erb +6 -20
  21. data/config/locales/translation_en.yml +3 -2
  22. data/config/locales/translation_ja.yml +2 -1
  23. data/config/routes.rb +3 -3
  24. data/lib/enju_biblio/engine.rb +1 -1
  25. data/lib/enju_biblio/version.rb +1 -1
  26. data/spec/cassette_library/ImportRequest/import/should_import_bibliographic_record.yml +512 -501
  27. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_isbn_which_is_already_imported/redirects_to_the_created_import_request.yml +80 -70
  28. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +81 -71
  29. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +81 -71
  30. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +80 -70
  31. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +79 -69
  32. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_has_only_isbn/should_be_imported.yml +470 -460
  33. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_shift_jis/should_be_imported.yml +292 -276
  34. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_be_imported.yml +292 -276
  35. data/spec/controllers/agent_types_controller_spec.rb +107 -388
  36. data/spec/controllers/content_types_controller_spec.rb +106 -385
  37. data/spec/controllers/countries_controller_spec.rb +7 -7
  38. data/spec/controllers/extents_controller_spec.rb +106 -385
  39. data/spec/controllers/form_of_works_controller_spec.rb +107 -385
  40. data/spec/controllers/frequencies_controller_spec.rb +106 -385
  41. data/spec/controllers/languages_controller_spec.rb +6 -6
  42. data/spec/controllers/licenses_controller_spec.rb +106 -385
  43. data/spec/controllers/medium_of_performances_controller_spec.rb +106 -385
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/private/system/agent_import_files/agent_imports/000/000/004/original/agent_delete_file.tsv +8 -0
  46. data/spec/dummy/private/system/agent_import_files/agent_imports/000/000/004/original/agent_import_file_sample3.tsv +5 -0
  47. data/spec/dummy/private/system/agent_import_files/agent_imports/000/000/004/original/agent_update_file.tsv +3 -0
  48. data/spec/dummy/private/system/picture_files/pictures/000/000/005/medium/spinner.gif +0 -0
  49. data/spec/dummy/private/system/picture_files/pictures/000/000/005/original/spinner.gif +0 -0
  50. data/spec/dummy/private/system/picture_files/pictures/000/000/005/thumb/spinner.gif +0 -0
  51. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/isbn_sample.txt +3 -0
  52. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/item_delete_file.tsv +11 -0
  53. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/item_update_file.tsv +4 -0
  54. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/resource_import_file_sample1.tsv +19 -0
  55. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/resource_import_file_sample2.tsv +19 -0
  56. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/update_series_statement.tsv +2 -0
  57. data/spec/dummy/solr/test/data/index/segments.gen +0 -0
  58. data/spec/dummy/solr/test/data/index/segments_1b3 +0 -0
  59. data/spec/dummy/solr/test/data/tlog/{tlog.0000000000000000389 → tlog.0000000000000001688} +0 -0
  60. data/spec/dummy/solr/test/data/tlog/{tlog.0000000000000000390 → tlog.0000000000000001689} +0 -0
  61. data/spec/dummy/solr/test/data/tlog/{tlog.0000000000000000391 → tlog.0000000000000001690} +0 -0
  62. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000001691 +0 -0
  63. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000001692 +0 -0
  64. data/spec/dummy/solr/test/data/tlog/tlog.0000000000000001693 +0 -0
  65. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  66. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  67. data/spec/dummy/tmp/cache/assets/test/sprockets/0830400afa3009686c89dda6258bd75d +0 -0
  68. data/spec/dummy/tmp/cache/assets/test/sprockets/0ee396465e00d17664feec416aacd858 +0 -0
  69. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  70. data/spec/dummy/tmp/cache/assets/test/sprockets/1555daca1ffdb4f1dbea6b81613a6dd0 +0 -0
  71. data/spec/dummy/tmp/cache/assets/test/sprockets/2f332119f883fdd68340b5b3a1079d3f +0 -0
  72. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  73. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  74. data/spec/dummy/tmp/cache/assets/test/sprockets/41967b168e9b1bbeda476591dad80257 +0 -0
  75. data/spec/dummy/tmp/cache/assets/test/sprockets/4b298aca2f28a3547e6865794468d90c +0 -0
  76. data/spec/dummy/tmp/cache/assets/test/sprockets/4facf54d58d89accb1176284157ae74d +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/518a573cb9468335bfe3ebde3696755d +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/5c7fbc78c580dd8592a994e875ae928c +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/c1a4d979d844b4bfa222a268acbdfcac +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/c45932b8beef81cc3ed460679239a0e0 +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  83. data/spec/dummy/tmp/cache/assets/test/sprockets/eac0985173184e3c4a1fdabeca4673a0 +0 -0
  84. data/spec/dummy/tmp/cache/assets/test/sprockets/eaf86421a990484c49be01e9af85c061 +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/f206beea95d427cdde150003c8bd3253 +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/f3ab79106bf7c705cff60f636a7d8b26 +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  88. data/spec/models/resource_import_file_spec.rb +5 -2
  89. metadata +164 -151
  90. data/spec/dummy/solr/test/data/index/_7n.fdt +0 -0
  91. data/spec/dummy/solr/test/data/index/_7n.fdx +0 -0
  92. data/spec/dummy/solr/test/data/index/_7n.fnm +0 -0
  93. data/spec/dummy/solr/test/data/index/_7n.nvd +0 -0
  94. data/spec/dummy/solr/test/data/index/_7n.nvm +0 -0
  95. data/spec/dummy/solr/test/data/index/_7n.si +0 -0
  96. data/spec/dummy/solr/test/data/index/_7n_Lucene41_0.doc +0 -0
  97. data/spec/dummy/solr/test/data/index/_7n_Lucene41_0.pos +0 -0
  98. data/spec/dummy/solr/test/data/index/_7n_Lucene41_0.tim +0 -0
  99. data/spec/dummy/solr/test/data/index/_7n_Lucene41_0.tip +0 -0
  100. data/spec/dummy/solr/test/data/index/_7o.fdt +0 -0
  101. data/spec/dummy/solr/test/data/index/_7o.fdx +0 -0
  102. data/spec/dummy/solr/test/data/index/_7o.fnm +0 -0
  103. data/spec/dummy/solr/test/data/index/_7o.nvd +0 -0
  104. data/spec/dummy/solr/test/data/index/_7o.nvm +0 -0
  105. data/spec/dummy/solr/test/data/index/_7o.si +0 -0
  106. data/spec/dummy/solr/test/data/index/_7o_Lucene41_0.doc +0 -0
  107. data/spec/dummy/solr/test/data/index/_7o_Lucene41_0.pos +0 -0
  108. data/spec/dummy/solr/test/data/index/_7o_Lucene41_0.tim +0 -0
  109. data/spec/dummy/solr/test/data/index/_7o_Lucene41_0.tip +0 -0
  110. data/spec/dummy/solr/test/data/index/_7p.fdt +0 -0
  111. data/spec/dummy/solr/test/data/index/_7p.fdx +0 -0
  112. data/spec/dummy/solr/test/data/index/_7p.fnm +0 -0
  113. data/spec/dummy/solr/test/data/index/_7p.nvd +0 -0
  114. data/spec/dummy/solr/test/data/index/_7p.nvm +0 -0
  115. data/spec/dummy/solr/test/data/index/_7p.si +0 -0
  116. data/spec/dummy/solr/test/data/index/_7p_Lucene41_0.doc +0 -0
  117. data/spec/dummy/solr/test/data/index/_7p_Lucene41_0.pos +0 -0
  118. data/spec/dummy/solr/test/data/index/_7p_Lucene41_0.tim +0 -0
  119. data/spec/dummy/solr/test/data/index/_7p_Lucene41_0.tip +0 -0
  120. data/spec/dummy/solr/test/data/index/segments_ax +0 -0
  121. data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -1
@@ -1,447 +1,166 @@
1
1
  require 'spec_helper'
2
- require 'sunspot/rails/spec_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to specify the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+ #
15
+ # Compared to earlier versions of this generator, there is very limited use of
16
+ # stubs and message expectations in this spec. Stubs are only used when there
17
+ # is no simpler way to get a handle on the object needed for the example.
18
+ # Message expectations are only used when there is no simpler way to specify
19
+ # that an instance is receiving a specific message.
3
20
 
4
21
  describe AgentTypesController do
5
- fixtures :all
6
- disconnect_sunspot
22
+ login_admin
7
23
 
24
+ # This should return the minimal set of attributes required to create a valid
25
+ # AgentType. As you add validations to AgentType, be sure to
26
+ # update the return value of this method accordingly.
8
27
  def valid_attributes
9
- @attrs = FactoryGirl.attributes_for(:agent_type)
28
+ FactoryGirl.attributes_for(:agent_type)
10
29
  end
11
30
 
12
31
  describe "GET index" do
13
- before(:each) do
14
- FactoryGirl.create(:agent_type)
15
- end
16
-
17
- describe "When logged in as Administrator" do
18
- login_admin
19
-
20
- it "assigns all agent_types as @agent_types" do
21
- get :index
22
- assigns(:agent_types).should eq(AgentType.all)
23
- end
24
- end
25
-
26
- describe "When logged in as Librarian" do
27
- login_librarian
28
-
29
- it "assigns all agent_types as @agent_types" do
30
- get :index
31
- assigns(:agent_types).should eq(AgentType.all)
32
- end
33
- end
34
-
35
- describe "When logged in as User" do
36
- login_user
37
-
38
- it "assigns empty as @agent_types" do
39
- get :index
40
- assigns(:agent_types).should be_empty
41
- response.should be_forbidden
42
- end
43
- end
44
-
45
- describe "When not logged in" do
46
- it "assigns emptry as @agent_types" do
47
- get :index
48
- assigns(:agent_types).should be_empty
49
- response.should redirect_to(new_user_session_url)
50
- end
32
+ it "assigns all agent_types as @agent_types" do
33
+ agent_type = AgentType.create! valid_attributes
34
+ get :index
35
+ assigns(:agent_types).should eq(AgentType.all)
51
36
  end
52
37
  end
53
38
 
54
39
  describe "GET show" do
55
- describe "When logged in as Administrator" do
56
- login_admin
57
-
58
- it "assigns the requested agent_type as @agent_type" do
59
- agent_type = FactoryGirl.create(:agent_type)
60
- get :show, :id => agent_type.id
61
- assigns(:agent_type).should eq(agent_type)
62
- end
63
- end
64
-
65
- describe "When logged in as Librarian" do
66
- login_librarian
67
-
68
- it "assigns the requested agent_type as @agent_type" do
69
- agent_type = FactoryGirl.create(:agent_type)
70
- get :show, :id => agent_type.id
71
- assigns(:agent_type).should eq(agent_type)
72
- end
73
- end
74
-
75
- describe "When logged in as User" do
76
- login_user
77
-
78
- it "assigns the requested agent_type as @agent_type" do
79
- agent_type = FactoryGirl.create(:agent_type)
80
- get :show, :id => agent_type.id
81
- assigns(:agent_type).should eq(agent_type)
82
- end
83
- end
84
-
85
- describe "When not logged in" do
86
- it "assigns the requested agent_type as @agent_type" do
87
- agent_type = FactoryGirl.create(:agent_type)
88
- get :show, :id => agent_type.id
89
- assigns(:agent_type).should eq(agent_type)
90
- end
40
+ it "assigns the requested agent_type as @agent_type" do
41
+ agent_type = AgentType.create! valid_attributes
42
+ get :show, :id => agent_type.id
43
+ assigns(:agent_type).should eq(agent_type)
91
44
  end
92
45
  end
93
46
 
94
47
  describe "GET new" do
95
- describe "When logged in as Administrator" do
96
- login_admin
97
-
98
- it "assigns the requested agent_type as @agent_type" do
99
- get :new
100
- assigns(:agent_type).should_not be_valid
101
- response.should be_forbidden
102
- end
103
- end
104
-
105
- describe "When logged in as Librarian" do
106
- login_librarian
107
-
108
- it "should not assign the requested agent_type as @agent_type" do
109
- get :new
110
- assigns(:agent_type).should_not be_valid
111
- response.should be_forbidden
112
- end
113
- end
114
-
115
- describe "When logged in as User" do
116
- login_user
117
-
118
- it "should not assign the requested agent_type as @agent_type" do
119
- get :new
120
- assigns(:agent_type).should_not be_valid
121
- response.should be_forbidden
122
- end
123
- end
124
-
125
- describe "When not logged in" do
126
- it "should not assign the requested agent_type as @agent_type" do
127
- get :new
128
- assigns(:agent_type).should_not be_valid
129
- response.should redirect_to(new_user_session_url)
130
- end
48
+ it "assigns a new agent_type as @agent_type" do
49
+ get :new
50
+ assigns(:agent_type).should be_a_new(AgentType)
131
51
  end
132
52
  end
133
53
 
134
54
  describe "GET edit" do
135
- describe "When logged in as Administrator" do
136
- login_admin
137
-
138
- it "assigns the requested agent_type as @agent_type" do
139
- agent_type = FactoryGirl.create(:agent_type)
140
- get :edit, :id => agent_type.id
141
- assigns(:agent_type).should eq(agent_type)
142
- end
143
- end
144
-
145
- describe "When logged in as Librarian" do
146
- login_librarian
147
-
148
- it "assigns the requested agent_type as @agent_type" do
149
- agent_type = FactoryGirl.create(:agent_type)
150
- get :edit, :id => agent_type.id
151
- response.should be_forbidden
152
- end
153
- end
154
-
155
- describe "When logged in as User" do
156
- login_user
157
-
158
- it "assigns the requested agent_type as @agent_type" do
159
- agent_type = FactoryGirl.create(:agent_type)
160
- get :edit, :id => agent_type.id
161
- response.should be_forbidden
162
- end
163
- end
164
-
165
- describe "When not logged in" do
166
- it "should not assign the requested agent_type as @agent_type" do
167
- agent_type = FactoryGirl.create(:agent_type)
168
- get :edit, :id => agent_type.id
169
- response.should redirect_to(new_user_session_url)
170
- end
55
+ it "assigns the requested agent_type as @agent_type" do
56
+ agent_type = AgentType.create! valid_attributes
57
+ get :edit, :id => agent_type.id
58
+ assigns(:agent_type).should eq(agent_type)
171
59
  end
172
60
  end
173
61
 
174
62
  describe "POST create" do
175
- before(:each) do
176
- @attrs = valid_attributes
177
- @invalid_attrs = {:name => ''}
178
- end
179
-
180
- describe "When logged in as Administrator" do
181
- login_admin
182
-
183
- describe "with valid params" do
184
- it "assigns a newly created agent_type as @agent_type" do
185
- post :create, :agent_type => @attrs
186
- assigns(:agent_type).should be_valid
187
- end
188
-
189
- it "should be forbidden" do
190
- post :create, :agent_type => @attrs
191
- response.should be_forbidden
192
- end
63
+ describe "with valid params" do
64
+ it "creates a new AgentType" do
65
+ expect {
66
+ post :create, :agent_type => valid_attributes
67
+ }.to change(AgentType, :count).by(1)
193
68
  end
194
69
 
195
- describe "with invalid params" do
196
- it "assigns a newly created but unsaved agent_type as @agent_type" do
197
- post :create, :agent_type => @invalid_attrs
198
- assigns(:agent_type).should_not be_valid
199
- end
200
-
201
- it "should be forbidden" do
202
- post :create, :agent_type => @invalid_attrs
203
- response.should be_forbidden
204
- end
70
+ it "assigns a newly created agent_type as @agent_type" do
71
+ post :create, :agent_type => valid_attributes
72
+ assigns(:agent_type).should be_a(AgentType)
73
+ assigns(:agent_type).should be_persisted
205
74
  end
206
- end
207
75
 
208
- describe "When logged in as Librarian" do
209
- login_librarian
210
-
211
- describe "with valid params" do
212
- it "assigns a newly created agent_type as @agent_type" do
213
- post :create, :agent_type => @attrs
214
- assigns(:agent_type).should be_valid
215
- end
216
-
217
- it "should be forbidden" do
218
- post :create, :agent_type => @attrs
219
- response.should be_forbidden
220
- end
221
- end
222
-
223
- describe "with invalid params" do
224
- it "assigns a newly created but unsaved agent_type as @agent_type" do
225
- post :create, :agent_type => @invalid_attrs
226
- assigns(:agent_type).should_not be_valid
227
- end
228
-
229
- it "should be forbidden" do
230
- post :create, :agent_type => @invalid_attrs
231
- response.should be_forbidden
232
- end
76
+ it "redirects to the created agent_type" do
77
+ post :create, :agent_type => valid_attributes
78
+ response.should redirect_to(AgentType.last)
233
79
  end
234
80
  end
235
81
 
236
- describe "When logged in as User" do
237
- login_user
238
-
239
- describe "with valid params" do
240
- it "assigns a newly created agent_type as @agent_type" do
241
- post :create, :agent_type => @attrs
242
- assigns(:agent_type).should be_valid
243
- end
244
-
245
- it "should be forbidden" do
246
- post :create, :agent_type => @attrs
247
- response.should be_forbidden
248
- end
82
+ describe "with invalid params" do
83
+ it "assigns a newly created but unsaved agent_type as @agent_type" do
84
+ # Trigger the behavior that occurs when invalid params are submitted
85
+ AgentType.any_instance.stub(:save).and_return(false)
86
+ post :create, :agent_type => {}
87
+ assigns(:agent_type).should be_a_new(AgentType)
249
88
  end
250
89
 
251
- describe "with invalid params" do
252
- it "assigns a newly created but unsaved agent_type as @agent_type" do
253
- post :create, :agent_type => @invalid_attrs
254
- assigns(:agent_type).should_not be_valid
255
- end
256
-
257
- it "should be forbidden" do
258
- post :create, :agent_type => @invalid_attrs
259
- response.should be_forbidden
260
- end
261
- end
262
- end
263
-
264
- describe "When not logged in" do
265
- describe "with valid params" do
266
- it "assigns a newly created agent_type as @agent_type" do
267
- post :create, :agent_type => @attrs
268
- assigns(:agent_type).should be_valid
269
- end
270
-
271
- it "should be forbidden" do
272
- post :create, :agent_type => @attrs
273
- response.should redirect_to(new_user_session_url)
274
- end
275
- end
276
-
277
- describe "with invalid params" do
278
- it "assigns a newly created but unsaved agent_type as @agent_type" do
279
- post :create, :agent_type => @invalid_attrs
280
- assigns(:agent_type).should_not be_valid
281
- end
282
-
283
- it "should be forbidden" do
284
- post :create, :agent_type => @invalid_attrs
285
- response.should redirect_to(new_user_session_url)
286
- end
90
+ it "re-renders the 'new' template" do
91
+ # Trigger the behavior that occurs when invalid params are submitted
92
+ AgentType.any_instance.stub(:save).and_return(false)
93
+ post :create, :agent_type => {}
94
+ #response.should render_template("new")
287
95
  end
288
96
  end
289
97
  end
290
98
 
291
99
  describe "PUT update" do
292
- before(:each) do
293
- @agent_type = FactoryGirl.create(:agent_type)
294
- @attrs = valid_attributes
295
- @invalid_attrs = {:name => ''}
296
- end
297
-
298
- describe "When logged in as Administrator" do
299
- login_admin
300
-
301
- describe "with valid params" do
302
- it "updates the requested agent_type" do
303
- put :update, :id => @agent_type.id, :agent_type => @attrs
304
- end
305
-
306
- it "assigns the requested agent_type as @agent_type" do
307
- put :update, :id => @agent_type.id, :agent_type => @attrs
308
- assigns(:agent_type).should eq(@agent_type)
309
- end
310
-
311
- it "moves its position when specified" do
312
- put :update, :id => @agent_type.id, :agent_type => @attrs, :move => 'lower'
313
- response.should redirect_to(agent_types_url)
314
- end
100
+ describe "with valid params" do
101
+ it "updates the requested agent_type" do
102
+ agent_type = AgentType.create! valid_attributes
103
+ # Assuming there are no other agent_types in the database, this
104
+ # specifies that the AgentType created on the previous line
105
+ # receives the :update_attributes message with whatever params are
106
+ # submitted in the request.
107
+ AgentType.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
108
+ put :update, :id => agent_type.id, :agent_type => {'these' => 'params'}
315
109
  end
316
110
 
317
- describe "with invalid params" do
318
- it "assigns the requested agent_type as @agent_type" do
319
- put :update, :id => @agent_type.id, :agent_type => @invalid_attrs
320
- response.should render_template("edit")
321
- end
322
- end
323
- end
324
-
325
- describe "When logged in as Librarian" do
326
- login_librarian
327
-
328
- describe "with valid params" do
329
- it "updates the requested agent_type" do
330
- put :update, :id => @agent_type.id, :agent_type => @attrs
331
- end
332
-
333
- it "assigns the requested agent_type as @agent_type" do
334
- put :update, :id => @agent_type.id, :agent_type => @attrs
335
- assigns(:agent_type).should eq(@agent_type)
336
- response.should be_forbidden
337
- end
338
- end
339
-
340
- describe "with invalid params" do
341
- it "assigns the requested agent_type as @agent_type" do
342
- put :update, :id => @agent_type.id, :agent_type => @invalid_attrs
343
- response.should be_forbidden
344
- end
111
+ it "assigns the requested agent_type as @agent_type" do
112
+ agent_type = AgentType.create! valid_attributes
113
+ put :update, :id => agent_type.id, :agent_type => valid_attributes
114
+ assigns(:agent_type).should eq(agent_type)
345
115
  end
346
- end
347
-
348
- describe "When logged in as User" do
349
- login_user
350
-
351
- describe "with valid params" do
352
- it "updates the requested agent_type" do
353
- put :update, :id => @agent_type.id, :agent_type => @attrs
354
- end
355
116
 
356
- it "assigns the requested agent_type as @agent_type" do
357
- put :update, :id => @agent_type.id, :agent_type => @attrs
358
- assigns(:agent_type).should eq(@agent_type)
359
- response.should be_forbidden
360
- end
117
+ it "redirects to the agent_type" do
118
+ agent_type = AgentType.create! valid_attributes
119
+ put :update, :id => agent_type.id, :agent_type => valid_attributes
120
+ response.should redirect_to(agent_type)
361
121
  end
362
122
 
363
- describe "with invalid params" do
364
- it "assigns the requested agent_type as @agent_type" do
365
- put :update, :id => @agent_type.id, :agent_type => @invalid_attrs
366
- response.should be_forbidden
367
- end
123
+ it "moves its position when specified" do
124
+ agent_type = AgentType.create! valid_attributes
125
+ position = agent_type.position
126
+ put :update, :id => agent_type.id, :move => 'higher'
127
+ response.should redirect_to agent_types_url
128
+ assigns(:agent_type).position.should eq position - 1
368
129
  end
369
130
  end
370
131
 
371
- describe "When not logged in" do
372
- describe "with valid params" do
373
- it "updates the requested agent_type" do
374
- put :update, :id => @agent_type.id, :agent_type => @attrs
375
- end
376
-
377
- it "should be forbidden" do
378
- put :update, :id => @agent_type.id, :agent_type => @attrs
379
- response.should redirect_to(new_user_session_url)
380
- end
132
+ describe "with invalid params" do
133
+ it "assigns the agent_type as @agent_type" do
134
+ agent_type = AgentType.create! valid_attributes
135
+ # Trigger the behavior that occurs when invalid params are submitted
136
+ AgentType.any_instance.stub(:save).and_return(false)
137
+ put :update, :id => agent_type.id, :agent_type => {}
138
+ assigns(:agent_type).should eq(agent_type)
381
139
  end
382
140
 
383
- describe "with invalid params" do
384
- it "assigns the requested agent_type as @agent_type" do
385
- put :update, :id => @agent_type.id, :agent_type => @invalid_attrs
386
- response.should redirect_to(new_user_session_url)
387
- end
141
+ it "re-renders the 'edit' template" do
142
+ agent_type = AgentType.create! valid_attributes
143
+ # Trigger the behavior that occurs when invalid params are submitted
144
+ AgentType.any_instance.stub(:save).and_return(false)
145
+ put :update, :id => agent_type.id, :agent_type => {}
146
+ #response.should render_template("edit")
388
147
  end
389
148
  end
390
149
  end
391
150
 
392
151
  describe "DELETE destroy" do
393
- before(:each) do
394
- @agent_type = FactoryGirl.create(:agent_type)
395
- end
396
-
397
- describe "When logged in as Administrator" do
398
- login_admin
399
-
400
- it "destroys the requested agent_type" do
401
- delete :destroy, :id => @agent_type.id
402
- end
403
-
404
- it "should be forbidden" do
405
- delete :destroy, :id => @agent_type.id
406
- response.should be_forbidden
407
- end
152
+ it "destroys the requested agent_type" do
153
+ agent_type = AgentType.create! valid_attributes
154
+ expect {
155
+ delete :destroy, :id => agent_type.id
156
+ }.to change(AgentType, :count).by(-1)
408
157
  end
409
158
 
410
- describe "When logged in as Librarian" do
411
- login_librarian
412
-
413
- it "destroys the requested agent_type" do
414
- delete :destroy, :id => @agent_type.id
415
- end
416
-
417
- it "should be forbidden" do
418
- delete :destroy, :id => @agent_type.id
419
- response.should be_forbidden
420
- end
421
- end
422
-
423
- describe "When logged in as User" do
424
- login_user
425
-
426
- it "destroys the requested agent_type" do
427
- delete :destroy, :id => @agent_type.id
428
- end
429
-
430
- it "should be forbidden" do
431
- delete :destroy, :id => @agent_type.id
432
- response.should be_forbidden
433
- end
434
- end
435
-
436
- describe "When not logged in" do
437
- it "destroys the requested agent_type" do
438
- delete :destroy, :id => @agent_type.id
439
- end
440
-
441
- it "should be forbidden" do
442
- delete :destroy, :id => @agent_type.id
443
- response.should redirect_to(new_user_session_url)
444
- end
159
+ it "redirects to the agent_types list" do
160
+ agent_type = AgentType.create! valid_attributes
161
+ delete :destroy, :id => agent_type.id
162
+ response.should redirect_to(agent_types_url)
445
163
  end
446
164
  end
165
+
447
166
  end